I'm developing a small software for a college project and I'm having a problem: The code has a way too low performance.
It's an image editing software, and the image is a larg 3d list (the main list is the whole image, each list inside it is an horizontal line and each list inside that one is a pixel, containing three elements).
I need to make pixel-by-pixel adjustments, like multiplying all of them by a constant, so it would go like
for y in range(0,len(image)):
for x in range (0,len(image[0])):
for c in range (0,3):
im[y][x][c] = (im[y][x][c])*a
Where image
is the 3d list
len(image)
is the amount of horizontal lines in the image (vertical size)
len(image[0])
is the amount of pixels in a horizontal line (horizontal size)
and c
is the component of the pixel (going from 0 to 2).
This loop takes several minutes to go through a single 12 MP image and the amount of images I have to process is in the order of the hundreds, so this is just impossible.
What can I do to get a greater performance? Even editing softwares take some seconds because it can be a pretty large operation, but this code is just too slow.
Thank you!