I am trying to remove the black spots from a face of this image using the erosion methods.
我已经实现了:
img = skimage.io.imread('blemish.jpeg')
img = skimage.color.rgb2gray(img)
img_inten = skimage.exposure.rescale_intensity(img,in_range=(50,100))
diliation_seed = img_inten.copy()
diliation_seed[1:-1,1:-1] = img_inten.min()
mask = img_inten
eroded_img = skimage.morphology.reconstruction(diliation_seed,mask,method='dilation')
matplotlib.pyplot.imshow(eroded_img,cmap='gray')
在两种情况下,我的输出始终都是黑色图像。这是怎么了?
rgb2gray
is outputting an image as a matrix of floats, with values in [0;1]所以rescale_intensity只是输出一个0矩阵,因为您要求的值在50到100之间,而灰色img中没有。
您可以这样解决: