Matlab图像处理中运用区域二值,输出图像全黑的问题?matlab数字图像处理
Matlab图像处理中运用区域二值,输出图像全黑的问题?
原因是:operatingRegion = im2bw (operatingRegion, thresh);得的数据是0和1,所以,input (32*(i-1)+1:32*i,32*(j-1)+1:32*j)也是0和1,而imshow(input)展示的领域是[0,255],1/255近似于0,所以,全展示为黑色。我给你改下:[a,b] = size(input);for i = 1:a/32 for j = 1:b/32 operatingRegion = input (32*(i-1)+1:32*i,32*(j-1)+1:32*j); thresh = graythresh(operatingRegion); operatingRegion = im2bw (operatingRegion, thresh); input (32*(i-1)+1:32*i,32*(j-1)+1:32*j) = operatingRegion*255; endendimshow(input);按上面语句试试
0