2010-05-06 37 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