Reputation: 1
This error occurs at the line m,n = A.shape
:
ValueError: not enough values to unpack (expected 3, got 2)
I got this message and I don´t know why. It seems that everything is right. Could anyone help me?
image = cv2.resize(image, dsize=(224, 224), interpolation=cv2.INTER_CUBIC)
A = image.copy()/255
m,n = A.shape # HERE IS THE PROBLEM
B = np.zeros((m,n));
i = 2
j = 2
for i in range(m-1):
for j in range(n-1):
B[i, j] = (A[i-1, j-1] +A[i-1, j] +A[i-1, j+1]
+ A[i, j-1] +A[i, j] +A[i, j+1]
+ A[i+1, j+1] +A[i+1, j] +A[i+1, j+1])
B[i, j] = B[i, j]/9;
Upvotes: 0
Views: 731
Reputation: 60444
It appears that your matrix A
has three dimensions, not two. This happens, for example, when image
is a color image. You might want to use the IMREAD_GRAYSCALE
flag to cv.imread
to ensure that the image is always read as a grayscale image, and therefore will always have only two dimensions.
Upvotes: 1