機械学習のためにバイナリー画像から任意の座標を100個選択し、画像内に指定した座標を種類ごとにプロットしたい
Afficher commentaires plus anciens

Isabun,Ibyohen,BWの3つの画像を用いて、上記の画像のように3種類の色に分けて座標として可視化できるようにプロットをしたいです。
プロットしたい画像はIsabunという画像です
100個のランダムで選んだx、y座標と
上記の画像の赤色の部分を1、黄色の部分を0、青色の部分を2とした
100行3列の画像を作成したのですがうまくプロットできません。
ープログラムー
imread(Isabun.png)
imread(Isabun.png)
imread(BW.png)
figure;imshow(Isabun)
%ランダムな配列の作成
y = random('uniform',1,236,10);
Y = y(:);
YY = round(Y)
x = random('uniform',1,392,10);
X = x(:);
XX = round(X)
z = zeros(100,1)
%座標の作成
zahyou = zeros(100,3)
n = 1;
for i = 1:100
%黄色部分の座標を指定
if Isabun(YY(i),XX(i)) == 1
zahyou(n,:) = [XX(i),YY(i),0];
hold on
scatter(XX,YY,"yellow")
hold off
n = n+1;
%赤色部分の座標を指定
else if (0 < Ibyohen(YY(i),XX(i)) )
zahyou(n,:) = [XX(i),YY(i),1]
hold on
scatter(XX,YY,"red")
hold off
n = n+1;
%青色部分の座標を指定
else if BW(YY(i),XX(i)) == 0
zahyou(n,:) = [XX(i),YY(i),2];
hold on
scatter(XX,YY,"blue")
hold off
n = n+1;
end
end
end
end
ー結果ー

上記のようにすべて青色のプロットになってしまいます
長文で大変失礼ですがぜひよろしくお願いします。
Réponse acceptée
Plus de réponses (1)
大誠
le 14 Juil 2023
0 votes
Catégories
En savoir plus sur Image Processing and Computer Vision dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

