Reputation: 43
ive got a problem that i cant solve. Im trying to make a temporal median filter using the method sort(), but i simply cant do it. This is the simpliest test i tried:
import cv2
def sortExample():
img = cv2.imread("guitar.jpg")
cv2.sort(img, cv2.SORT_ASCENDING)
sortExample()
And the error:
cv2.sort(img, cv2.SORT_ASCENDING) cv2.error: ......\src\opencv\modules\core\src\matrix.cpp:2367: error: (-215) src.dims <= 2 && src.channels() == 1 && func != 0
What am i doing wrong? Thanks in advance
Upvotes: 1
Views: 945
Reputation: 19241
The error message is telling you that the checks src.dims <= 2 && src.channels() == 1 && func != 0
failed (maybe if it was less cluttered you would have no trouble seeing that ?). In special, it is telling you the number of channels is not 1.
So you can either consider one of the channels or convert the image to, for example, grayscale: x = cv2.cvtColor(x, cv2.COLOR_BGR2GRAY)
.
Upvotes: 1