Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %jasnosc i kontrast
- %
- %
- %
- %
- import numpy as np
- import matplotlib.pyplot as plt
- from scipy import misc as mc
- def warstwa(img):
- r=img[:,:,0]
- g=img[:,:,1]
- b=img[:,:,2]
- s1 = 0.2126*r + 0.7152*g + 0.0722 *b
- return s1
- #
- def jik():
- img2= warstwa(img)
- jasnosc=(np.sum(img2))/(M*N)
- iloraz= 1.0/(M*N)
- kontrast= np.power(iloraz* np.sum(np.power(img2-jasnosc,2)) ,0.5)
- return jasnosc, kontrast
- #
- img = mc.imread('kierowca.png')
- print img.dtype
- print img.shape
- N= img.shape[1]
- M= img.shape[0]
- print jik()
- #dla zwyklego unit8
- img2= img.copy()
- img2 = img2 +150
- img3= img.copy()
- img3= img3 * 2
- img4 = img.copy()
- img4=np.power(img4,0.2)
- img5 = img.copy()
- img4=np.power(img4,2)
- #dla float64
- imgfloat = img.astype('float64')
- img2float= imgfloat.copy()
- img2float = img2float +150
- img3float= imgfloat.copy()
- img3float= img3float * 2
- img4float = imgfloat.copy()
- img4float=np.power(img4float,0.2)
- img5float = imgfloat.copy()
- img5float =np.power(img5float,2)
- #M= img.shape[0];
- #N= img.shape[1];
- #print jik()
- plt.subplot(2,5,1)
- plt.imshow(img)
- plt.subplot(2,5,6)
- plt.imshow(imgfloat)
- plt.subplot(2,5,2)
- plt.imshow(img2)
- plt.subplot(2,5,7)
- plt.imshow(img2float)
- plt.subplot(2,5,3)
- plt.imshow(img3)
- plt.subplot(2,5,8)
- plt.imshow(img3float)
- plt.subplot(2,5,4)
- plt.imshow(img4)
- plt.subplot(2,5,9)
- plt.imshow(img4float)
- plt.subplot(2,5,5)
- plt.imshow(img5)
- plt.subplot(2,5,10)
- plt.imshow(img5float)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement