重心位置の座標を表示したいのですが、どうやって組み合わせればいいのかわかりません
조회 수: 18 (최근 30일)
이전 댓글 표시
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167435/image.jpeg)
BW = imread('k.jpg');
BW2=rgb2gray(BW)>0;
%regionprops を使用してイメージ内の連結要素の重心を計算します。
s = regionprops(BW2,'centroid');
%各重心位置計算されたエリアの面積
Areas = regionprops(BW2,'Area');
%重心を格納する構造体配列を単一の行列に連結します。
centroids = cat(1, s.Centroid);
centroids2 = cat(1, Areas.Area);
centroids(:,3) = centroids2;
length(centroids)
j=1;
for i=1:length(centroids)
if (centroids(i,3)>1000 && centroids(i,3)<10000)
medaka_index = i;
end
end
% 重心の位置を重ね合わせたバイナリ イメージを表示します。
imshow(BW)
hold on
plot(centroids(medaka_index,1),centroids(medaka_index,2), 'b*')
hold off
ソースコードはこれです。どうすればよいのでしょうか?
댓글 수: 2
Takuji Fukumoto
2017년 12월 8일
重心にプロットまではできているようですが、 「座標を表示したい」とは何を指していますかね?
1.座標を数値で画像上に表示させたい
2.Plotでの表示でなく、画像データの中にマークを入れ込みたい
などいくつか考えられるかと思いますが、 具体的に何ができていないのかを教えていただけますか?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 イメージのセグメンテーションと解析에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!