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 件のコメント
John D'Errico
John D'Errico 2023 年 5 月 19 日
Stop posting your homework assignments.
Luis Pardella
Luis Pardella 2023 年 5 月 19 日
Do you have evidence that I'm posting an assignment?

サインインしてコメントする。

採用された回答

DGM
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)
A = 1×6
0 0.2000 0.4000 0.6000 0.8000 1.0000
B = A >= 0.5
B = 1×6 logical array
0 0 0 1 1 1
C1 = B >= -0.5 % below the interval
C1 = 1×6 logical array
1 1 1 1 1 1
C2 = B >= 0.5 % inside the interval
C2 = 1×6 logical array
0 0 0 1 1 1
C3 = B >= 1.5 % above the interval
C3 = 1×6 logical array
0 0 0 0 0 0
  8 件のコメント
Luis Pardella
Luis Pardella 2023 年 5 月 19 日
I ran this code and the result from T1 and T2 is the same.
DGM
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
Warning: The input image is already binary.
isequal(mk1,mk2)
ans = logical
1
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!

Translated by