Ellipsoid Mask based on user input of dimension and euler angle
2 ビュー (過去 30 日間)
古いコメントを表示
Actually I am trying to generate a 3d ellipsoid mask based on the user input of semi axes and euler angles. But in my code to do this I am calculating the distance of each pixel from the centre of the ellipse and then based on the ellipse equation pixels falling inside this ellipse are assigned true values. But the problem is that this operation is very tedious as I am scanning each and every pixel.
Any other way to do this which reduces the time complexity of this problem.
0 件のコメント
採用された回答
Matt J
2024 年 5 月 2 日
編集済み: Matt J
2024 年 5 月 2 日
An ellipsoid obeys the inequality (x-c)'*Q*(x-c)<=1 for some appropriate 3x3 matrix Q and 3x1 vector c (which is also the center of the ellipsoid). If you have it expressed this way, generation of the mask is very simple:
[dx,dy,dz]=ndgrid((1:nx)-c(1), (1:ny)-c(2)), (1:nz)-c(3) );
X=[dx(:),dy(:),dz(:)]';
mask = sum(X.*(Q*X))<=1;
mask=reshape(mask,nx, ny,nz);
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!