2010-05-06 114 views
0

当您在Matlab中使用graythresh时,它会获得一个标准化值介于0到1之间的值,因此,当您使用某个其他值的阈值时,如imextendedmax或im2bw,您将如何使用graythresh?我想你可能需要乘以一些东西,但是什么?Matlab中的全局图像阈值

回答

0

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

1

为了使用graythresh,您需要将图像标准化为[0 ... 1]。

%# 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; 
+0

可以使用'IMG =(IMG中只有一行正常化 - 分钟(IMG(:)))/(最大(IMG(:)) - 分钟(IMG(:))' – 2016-02-01 15:31:59

+0

@BlackAdder) :的确可以。捕获偏移量和乘数可帮助您将阈值恢复为原始单位,如果要使用相同阈值分割多个图像,这一点非常重要。 – Jonas 2016-02-03 07:53:25