Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23305

Image processing (resize, rotation) without loops or libs

$
0
0

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.


Viewing all articles
Browse latest Browse all 23305

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>