Reputation: 165
I am trying to use the cv2.medianBlur on an image but it does not work unless I import the image using the cv2.read. As I don't want to change the rest of my code can anyone explain to me why this happens or any other method to accomplish the same result?
def medianFilterData(data, w):
fdata = []
for i in range(0, len(data)):
img = data[i].astype('d')
median = cv2.medianBlur(img, w)
fdata.append(median)
return fdata
The error:
cv2.error: OpenCV(4.5.1) C:/Users/appveyor/AppData/Local/Temp/1/pip-req-build-kh7iq4w7/opencv/modules/imgproc/src/median_blur.simd.hpp:975: error: (-210:Unsupported format or combination of formats) in function 'cv::opt_AVX2::medianBlur'
Upvotes: 4
Views: 4402
Reputation: 2233
try .astype('int8')
or .astype('float32')
def medianFilterData(data, w):
fdata = []
for i in range(0, len(data)):
img = data[i].astype('int8')
median = cv2.medianBlur(img, w)
fdata.append(median)
return fdata
Upvotes: 4