Search code examples
javapythonopencvmat

Which values of numpy array in Python correspond to Mat from OpenCV in Java?


I'm very new to Python, and I'm converting Python code into Java, and I've been having trouble trying identifying which array corresponds to what value in Python. For example, for Mat in Java (correct me if I'm wrong), I know that in

Mat matrix = new Mat();
matrix.Get(a, b)[c];

a = channel, b = row/x, c = column/y

But in Python if I have

img = cv2.imread("picture.jpeg")
img[d][e][f]

What values do the arrays of d, e, f correspond to? For example d = row/x, e = column/y


Solution

  • The array has the shape (row, col, channel). Of course it depends on the mode you are loading, grayscale will yield a 2D array.