How can i understand the meaning of "colors(rgb_label ~= k) = 0;" code meaning?

2 ビュー (過去 30 日間)
Yusuf Suer Erdem
Yusuf Suer Erdem 2021 年 1 月 3 日
コメント済み: Yusuf Suer Erdem 2021 年 1 月 3 日
In this code, nColor =3;
"I" is a 768x1024x3 matrix.
rgb_label is a 768x1024x3 matrix that containt just "1","2","3" values of k means applied of "I" matrix. But i never understand what does
colors(rgb_label ~= k) = 0; code do?
------------------------------------------------------------
for k = 1:nColors
colors = I;
colors(rgb_label ~= k) = 0; %%%meaning???
segmented_images{k} = colors;
end
------------------------------------------------------------

採用された回答

Mario Malic
Mario Malic 2021 年 1 月 3 日
編集済み: Mario Malic 2021 年 1 月 3 日
Hi,
Line below returns the logical array for the condition: rgb_label is not equal to k
rgb_label ~= k
Line below takes that same logical array and assigns 0 to those elements of colors for which above condition is true.
colors(rgb_label ~= k) = 0;

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 1 月 3 日
If you want to see my kmeans demo for RGB images, see attached.

カテゴリ

Help Center および File ExchangeAgriculture についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by