Suppose you thresholded an image at value t1 and thresholded the result at value t2, describe the results if (a) t1>t2 and (b) t2>t1.
1 回表示 (過去 30 日間)
古いコメントを表示
7 件のコメント
採用された回答
DGM
2023 年 5 月 19 日
編集済み: DGM
2023 年 5 月 19 日
Say
%B = A >= t1; % threshold A at t1
%C = B >= t2; % threshold B at t2
The relationship between t1,t2 is irrelevant. What matters is the relationship between t2 and the values used in B. In the context of the example I gave, B is logical, so for numerical purposes, its elements are either 0 or 1. In other contexts, a binarized image may be represented with values of 0 or 255. Depending on where t2 is with respect those two values, the output will either be entirely black, unchanged, or white.
A = linspace(0,1,6)
B = A >= 0.5
C1 = B >= -0.5 % below the interval
C2 = B >= 0.5 % inside the interval
C3 = B >= 1.5 % above the interval
8 件のコメント
DGM
2023 年 5 月 19 日
編集済み: DGM
2023 年 5 月 19 日
Yes. 0<0.4<1, so the image is unchanged. You should also get a warning when you do that.
inpict = imread('peppers.png'); % this is uint8, RGB
mk1 = im2bw(inpict,0.3); % this is logical, single-channel
mk2 = im2bw(mk1,0.4); % this is logical, single-channel
isequal(mk1,mk2)
The threshold parameter given to im2bw() is in unit-scale, regardless of the class (and implied scale) of the input image. In the case of inpict, the scale of the image is [0 255], so it's thresholded at 0.3*255. In the case of mk1, the scale is [0 1], so you're thresholding at 0.4*1.
Since im2bw() doesn't allow the threshold parameter to be less than 0 or greater than 1, logical-class inputs will always be unchanged. If you were to check the internals of im2bw(), it knows that nothing will change, so it doesn't even bother with the comparison. It just dumps the warning and returns the input.
This is different than the example I gave above where thresholds are specified outside of the unit interval. Like I said, there are only three possible outcomes for a binarized input. The only way the output will differ from the input is if the threshold value is outside the interval defined by the values in the input.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!