Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def rotateImage(self):
- ForwardMap = np.zeros((self.width,self.height),dtype="uint8")
- BackwardMap = np.zeros((self.width,self.height),dtype="uint8")
- for i in range(self.width):
- for j in range(self.height):
- # forward mapping
- for_x = (i - self.x) * math.cos(self.angle*(math.pi/180)) - (j - self.y) * math.sin(self.angle*(math.pi/180)) + self.x
- for_y = (i - self.x) * math.sin(self.angle*(math.pi/180)) + (j - self.y) * math.cos(self.angle*(math.pi/180)) + self.x
- for_x = int(for_x)
- for_y = int(for_y)
- # backward mapping
- back_x = (i - self.x) * math.cos(self.angle*(math.pi/180)) + (j - self.y) * math.sin(self.angle*(math.pi/180)) + self.x
- back_y = -(i - self.x) * math.sin(self.angle*(math.pi/180)) + (j - self.y) * math.cos(self.angle*(math.pi/180)) + self.x
- back_x = int(back_x)
- back_y = int(back_y)
- if for_x in range(self.width) and for_y in range(self.height):
- ForwardMap[i, j] = self.img[for_x, for_y]
- else:
- pass
- if back_x in range(self.width) and back_y in range(self.height):
- BackwardMap[i, j] = self.img[back_x, back_y]
- else:
- pass
- cv2.imshow('Forward Mapping', ForwardMap)
- cv2.imshow('Backward Mapping', BackwardMap)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement