Matlab中的全局图像阈值

时间:2010-05-06 19:18:49

标签: matlab image-processing

当您在Matlab中使用graythresh时,它会获得一个在0到1之间归一化的值,因此当您使用其他内容的阈值时,例如imextendedmax或im2bw,您将如何使用graythresh?我想你可能会把它增加一些东西而不是什么?

2 个答案:

答案 0 :(得分:1)

您需要将图片标准化为[0 ... 1]才能使用graythresh

%# test image
img = randn(512);
img(200:end,100:end) = img(200:end,100:end) + 5;

%# normalize. Subtract minimum to make lowest intensity equal to 0, then divide by the maximum
offset = min(img(:));
img = img - offset;
mult = max(img(:));
img = img./mult;

%# apply graythresh
th = graythresh(img);

%# if you want to know the threshold relative to the original intensities, use mult and offset like this
oriThresh = th*mult+offset;

答案 1 :(得分:0)

将图像标准化为0到1之间的范围,或者将阈值乘以图像的最大可能值。