Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import math
- import numpy as np
- img = cv2.imread('lena.jpg')
- img_gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
- cv2.imshow("input",img_gray)
- h=img_gray.shape[0]
- w=img_gray.shape[1]
- alpha=float(input('Input angle = '))
- xc=int(input('xc co = '))
- yc=int(input('yc co = '))
- rmax=int(input('rmax = '))
- alpha=math.radians(alpha)
- newimg=img_gray.copy()
- # newimg=np.zeros((h,w),img_gray.dtype)
- def distance(dy,dx):
- r=math.sqrt(dx*dx+dy*dy)
- return r
- for i in range (h):
- for j in range(w):
- dx=i-xc
- dy=j-yc
- r=distance(dy,dx)
- beta=math.atan2(dy,dx)
- beta=beta+alpha*(1-(r/rmax))
- if(rmax>=r):
- x=xc+int(r*math.cos(beta))
- y=yc+int(r*math.sin(beta))
- else:
- x=int(i)
- y=int(j)
- newimg[i,j]=img_gray.item(x,y)
- cv2.imshow("output",newimg)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement