I want to know how to iterate over all the pixels of an image. I tried this:
import cv2 import numpy as np x = np.random.randint(0,5,(500,500)) img = cv2.imread('D:\Project\Capture1.jpg',0) p = img.shape print p rows,cols = img.shape for i in range(rows): for j in range(cols): k = x[i,j] print k
It prints a vertical set of numbers that does not have the shape of an array. I also get an array outside of the exception. Please suggest a method.
python image-processing opencv pixels
Harini subhakar
source share