Matlab图像处理中运用区域二值,输出图像全黑的问题..
发布网友
发布时间:2023-03-05 21:05
我来回答
共1个回答
热心网友
时间:2024-08-22 17:43
原因是: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;
end
end
imshow(input);
按上面语句试试