开发者

Global image threshold in Matlab

When you use graythresh in Matla开发者_开发技巧b it obtains a value that is a normalized between 0 to 1, so when you use a threshold for something else such as imextendedmax or im2bw how would you use graythresh? I guess you have to probably multiply it by something but what?


You need to normalize your image to [0...1] in order to use 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;


Either normalize your image to range between 0 and 1, or multiply the threshold by the maximum possible value of the image.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜