So, I have a university Python project in development where I need to manipulate an image and apply filters, such as black & white, sepia, etc. Some of the filter options are resize, rotation and translation, and I have to do these without using stuff like cv2.resize(). I did some tests with for loops, but it’s not the fastest thing and I need a way to optmize this part. Is there a way to avoid all those loops?
Last code used for scale:
`def set_scale(img,h,w):
size = [h,w]
image = [[[
img[int(len(img) * i / size[0])][int(len(img[0]) * j / size[1])][k]
for k in range(3)
] for j in range(size[1])] for i in range(size[0])]
new_img = np.array(image)
return new_img`
I don’t have a code for rotation yet. I have tried some stuff I found here but it was just too complicated and I wasn’t able to change the code.
Gabriel Pastore is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.