三次元表示を行いたい(三次元空間内でメダカを棒状で表示したい)のですが、あともう少しのアイデアが出ません。教えていただけないでしょうか?
Show older comments
3次元表示なので、2方向から撮影した画像を画像処理により、対象物である メダカの重心座標・楕円長軸・楕円短軸などは求まりました。 プログラムは以下の通りです。
clear all;
BW = imread('nuri x.jpg');
BW2=rgb2gray(BW)>0;
%%regionprops を使用してイメージ内の連結要素の重心を計算します。
s = regionprops(BW2,'centroid');
%%各重心位置計算されたエリアの面積
Areas = regionprops(BW2,'Area');
%%角度計算
d=regionprops(BW2,'Orientation');
%%楕円長軸計算
l=regionprops(BW2,'MajorAxisLength');
%%楕円短軸計算
m=regionprops(BW2,'MinorAxisLength');
%%重心を格納する構造体配列を単一の行列に連結します。
centroids = cat(1, s.Centroid);
centroids2 = cat(1, Areas.Area);
centroids(:,3) = centroids2;
length(centroids)
format long
disp(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
この結果を用いることで、3次元空間でメダカを棒状で表示できるのではないかと思うのですが、そのやりかたが分かりません。どうかお助けください。
Accepted Answer
More Answers (1)
Jiro Doke
on 2 Feb 2018
ellipsoid 関数を使ってもできそうです。
% 中心点(xc, yc, zc)、半軸の長さ(xr, yr, zy)、解像度(n)
[x,y,z] = ellipsoid(200,200,20,10,4,4,100);
surface(x,y,z,'EdgeColor','none','FaceColor','r')
% 中心点(xc, yc, zc)、半軸の長さ(xr, yr, zy)、解像度(n)
[x,y,z] = ellipsoid(50,50,10,20,4,4,100);
surface(x,y,z,'EdgeColor','none','FaceColor','b')
%座標軸の範囲や縦横比設定など
axis vis3d equal;
view([-30,30]);
camlight;
grid on;
xlim([0,255]);
ylim([0,255]);
zlim([0,100]);

Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
