原因是: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);按上面語句試試
原因是: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);按上面語句試試