【发布时间】:2021-01-07 13:04:18
【问题描述】:
好吧,我对应用此过滤器应使用的文件格式以及保存图像应使用的文件格式有点困惑。
这是我的代码
img1 = cv2.imread('I1_fil2D.png',1)
skdemo.imshow_with_histogram(img1);
from skimage.filters import threshold_otsu
thresh = threshold_otsu(rgb2gray(img1))
bw_img1 = rgb2gray(img1) > thresh
plt.imshow(bw_img1)
我使用了rgb2gray() 命令,因为threshold_otsu() 需要灰度图像作为输入。我尝试使用cv2.imwrite('bw1.jpg',bw_img1),但它显示:TypeError: Expected Ptr<cv::UMat> for argument 'img'(我也在此命令之前尝试了bw_img1 = np.array(bw_img1),但没有任何改变)。此外,我尝试了imsave,但它也不起作用,因为我使用了cv2 进行阈值处理。
【问题讨论】:
标签: python python-3.x image image-processing