Using python for images


#1

hello,
I had excercise in python which I’m new in it, for job of image processing,
my question is given 6 images and I have to pass over them and find the median of each pixel,
I wrote something but I get a wrong syntax:

import cv2

imgs=['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg'] 
np_images = []

for img in imgs:
    np_images.append(cv2.imread(img,1))
# assuming the dimensions of all images are the same
median_image  = np.zeros((np_images[0].shape))
shape = np_images[0].shape
for row in range(shape[0]):
    for col in range(shape[1]):
        for c in range(shape[2]):
            p_values = []
            for image in np_images:
                p_values.append(image[row][col][c]
                   median_image[row][col][c] = np.median(p_values)

the problem is with the median_image.
can anyone help me?
thanks!


#2

never mind, I solve it!


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.