Drawing an ellipsoid within an image stack
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a stack of 27 images (each 453x501) in the form of a 453x501x27 3D uint8 matrix. I would like to draw in an ellipsoid (for example, with principle axes 10x10x10 pixels) into this matrix. i.e., every voxel within that ellipsoid should now be a specific value (say, 7), as opposed to what it was earlier.
Is there a command that allows me to do this? I have run into the sphere command but I am not quite sure how to implement it into this. Any help on this topic would be appreciated!
Thank you in advance
댓글 수: 1
Joshua
2017년 6월 26일
Pratik,
I do not know of a command that would let you do this. One possible solution is to start with the equation of you sphere/ellipsoid. I am going to use a sphere of the form x^2+y^2+z^2=R^2. x and y are the coordinates of the specific image, and z would correspond to the image. You could then loop through each coordinate in the stack by
s=size(stack);
width=s(1);
leng=s(2);
depth=s(3);
R=3;
tolerance=0.01;
for x=1:width
for y=1:leng
for z=1:depth
if(x^2+y^2+z^2-R^2<tolerance)
stack(x,y,z)=7;
end
end
end
end
You would put a 7 or whatever value whenever x^2+y^2+z^2-R^2=0, but since that will almost never happen, define some tolerance for it to be true under. Won't give you a perfect sphere or ellipsoid and is rather ineffecient, but could work.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!