czwartek, 14 czerwca 2018

obrazki

from PIL import Image
from PIL import ImageChops
from PIL import ImageDraw

file1 = 'raw.jpg'
file2 = 'modified.png'

im1 = Image.open(file1)
im2 = Image.open(file2)

diff = ImageChops.difference(im1, im2).getbbox()
draw = ImageDraw.Draw(im2)
diff_list = list(diff) if diff else []
draw.rectangle(diff_list)
im2.convert('RGB').save('file3.jpg')

środa, 13 czerwca 2018

hiperbola

import  matplotlib.pyplot as plt

print("Witaj w programie, ktory wykresla krzywe")
a1=int(input ("Podaj wartosc amin: "))
a2=int(input ("Podaj wartosc amin: "))
b=int(input ("Podaj wartosc b: "))
c=int(input ("Podaj wartosc c: "))
d=int(input ("Podaj wartosc d: "))

for a in range (a1, a2, 1):
    X=[]
    Y=[]
    print("ax3 + bx2 +cd +d")
    for x in range (-10, 10, 1):
        X.append(x)
        y = a*x*x*x+b*x*x+c*x+d
        Y.append(y)
        print(X)
        print(Y)
        plt.plot(X,Y)
    a=a+1
   

   
plt.xlabel("X")
plt.ylabel("Y")
plt.title("Wykres")
plt.grid(True)
plt.legend([a], loc='upper left')
plt.show()

kolo2 marek

#Program do rysowania okręgu o okreslonym promieniu oraz wspolrzednych srodka

import matplotlib.pyplot as plt
import numpy as np

x0 = float(input('podaj x srodka okregu: '))
y0 = float(input('podaj y srodka okregu: '))
r = float(input('podaj promien okregu: '))

dokladnosc = 0.01
kat = np.arange(0, 2 * np.pi, dokladnosc)

x = []
y = []

for a in kat:
    x.append(x0 + r * np.cos(a))
    y.append(y0 + r * np.sin(a))

# print x, y

plt.plot(x, y,'b')  #(opisanie osi x, opisanie osi y, kolor)
plt.show()

kolo marek

#Program do rysowania okreslonej liczby okregow

import matplotlib.pyplot as plt
import numpy as np

rmin = float(input('podaj min promień: '))
rmax = float(input('podaj max promień: '))
ilosc = float(input('podaj ile okręgów: '))

dokladnosc = 0.01
kat = np.arange(0, 2*np.pi, dokladnosc)


for rmin in np.linspace(rmin, rmax, ilosc):
      
    x = rmin * np.cos(kat)
    y = rmin *np.sin(kat)
    plt.plot(x, y, 'b')
    plt.title("Rysowanie okręgów")  #tytul wykresu
    plt.xlabel("x") #tytul osi x
    plt.ylabel("y") #tytul osi y

plt.show() #wyswietlenie wykresu

kwadratowa marek

import math
import matplotlib.pyplot as plt
import numpy as np

print ("Witaj w programie rysujacym funkcje kwadratowa y = Ax2 + Bx + C")

A=float(input("Podaj parametr A: "))
B=float(input("Podaj parametr B: "))
C=float(input("Podaj parametr C: "))



delta = (B*B) - (4*A*C)
print("Delta wynosi: ", delta)
if delta==0:
    x0 = (-B)/(2*A)
    print("Funkcja ma jedno miejsce zerowe: ", x0)
elif delta >0:
    x1 = (-B-math.sqrt(delta))/(2*A)
    x2 = (-B+math.sqrt(delta))/(2*A)
    print("Funkcja ma dwa miejsca zerowe: " ,round(x1,2) ,"i" ,round(x2,2))
else:
    print("Delta mniesza od zera - brak rozwiazan")

x = -B/(2*A)
y = A*x*x + B*x + C
print("Ekstremum wynosi: " ,y ,"dla x rownego: " ,x)

r=[]
l=[]
for x in range (-5,5,1):
        y=A*(x**2)+B*x+C
        r.append(x)
        l.append(y)
       
fig = plt.figure()
axes = fig.add_subplot(111)
axes.plot(r,l)
axes.plot
plt.title("Wykres funkcji kwadratowej", fontsize=22)
plt.xlabel('Os X')
plt.ylabel('Os Y')
plt.show()

bernuli marek

import numpy as np
import matplotlib.pyplot as plt

alpha = int (input("Podaj wartość alpha: "))
num = int (input("Podaj wysokość min. 100: "))
t = np.linspace(0, 2*np.pi, num)

if num < 100:
    print ("Error, hasło nieprawidłowe, Podaj warość więcej niż 100")
else:
    x = alpha * np.sqrt(2) * np.cos(t) / (np.sin(t)**2 + 1)
    y = alpha * np.sqrt(2) * np.cos(t) * np.sin(t) / (np.sin(t)**2 + 1)

    plt.plot(x, y)
    plt.show()

kołko

import matplotlib.pyplot as plt

circle1 = plt.Circle((0, 0), 0.2, color='r')
circle2 = plt.Circle((0.5, 0.5), 0.2, color='blue')
circle3 = plt.Circle((1, 1), 0.2, color='g', clip_on=False)

fig, ax = plt.subplots() # note we must use plt.subplots, not plt.subplot
# (or if you have an existing figure)
# fig = plt.gcf()
# ax = fig.gca()

ax.add_artist(circle1)
ax.add_artist(circle2)
ax.add_artist(circle3)

fig.savefig('plotcircles.png')