gpt4 book ai didi

python - OpenCV Python 错误 : Unsupported data type (=4) in function 'cv::opt_AVX2::getMorphologyRowFilter'

转载 作者:行者123 更新时间:2023-12-02 16:33:50 26 4
gpt4 key购买 nike

我正在尝试用形态去除噪音,但内核给了我错误:

import skimage.io as io
import numpy as np
import cv2

c=io.imread('circles.png').astype('bool')*1
x=np.random.random_sample(c.shape)
c[np.nonzero(x>0.95)]= 0
c[np.nonzero(x<=0.05)] = 1

opening = cv2.morphologyEx(c, cv2.MORPH_OPEN, np.ones((2,2),np.uint8))

io.imshow(opening)

错误:
error: OpenCV(4.1.2) C:/projects/opencv-python/opencv/modules/imgproc/src/morph.simd.hpp:756: error: (-213:The function/feature is not implemented) Unsupported data type (=4) in function 'cv::opt_AVX2::getMorphologyRowFilter'

最佳答案

您的数据类型 (=4) 是 CV_32SC1,它是 32 位有符号单 channel - 您需要将数据转换为另一种数据类型,我建议使用 CV_8UC1,因为它具有最小的内存占用和易用性:

c = c.astype('uint8') # or c.astype(np.byte)

关于python - OpenCV Python 错误 : Unsupported data type (=4) in function 'cv::opt_AVX2::getMorphologyRowFilter' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61583991/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com