Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import imageio as io
- import PIL.Image as im
- def blur(arr, n):
- ret = np.copy(arr)
- height=arr.shape[0]
- width =arr.shape[1]
- for y in range(0,height):
- for x in range(0,width):
- rect = arr[max(0,y-n):min(y+n+1,height) , max(0,x-n):min(x+n+1,width) , :]
- ret[y,x,:]=np.mean(rect,(0,1))
- return ret
- def edge (arr):
- ret = np.copy(arr)
- ret[0,0,:]=0
- width = arr.shape[1]
- height=arr.shape[0]
- for y in range(0,height):
- print(y*100/height,'%')
- for x in range(0,width):
- if(x==0 and y==0):
- continue
- rect = arr[max(0,y-1):y+1, max(0,x-1): x+1, :]
- rect = rect.ravel()
- rect=rect.reshape((rect.size//3,3))
- right=rect[-1].ravel()
- left=rect[:-1]
- ed=abs(right-left)
- #print(ed)
- '''if(x==1 and y==0):
- print('ed: ' ,ed)
- print('left: ',left)
- print('right: ',right)
- print('left-right: ',left-right)
- print('mean: ',np.mean(ed,0))'''
- ret[y,x]=np.mean(ed,0)
- return np.round(ret)
- def blackwhite(arr):
- return np.mean(arr,2)
- def blur1(arr,n):
- ret=np.copy(arr)
- width = arr.shape[1]
- height=arr.shape[0]
- weight=0
- for y in range(0,height):
- for x in range(0,width):
- if(x==0 and y==0):
- rect = arr[0:min(height,y+n+1),0:min(width,x+n+1),:]
- weight= rect.size//3
- lizt =np.array([ [[233,23,28],[123,234,67],[43,178,209]],
- [[21,90,123] , [12,65,86] , [3,87,176]] ,
- [[23,34,17] , [23,46,19] , [129,36,29]] ],dtype=np.float32)
- img=np.asarray(io.imread("chess.jpg"))
- img =img[:,:,:3];
- img[:,:,(1)]=0
- #img = img[200:205,200:205,:3]
- #print(img)
- io.imwrite('r.png',img)
- #print(np.mean(lizt,2))
- #print(img)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement