Drawing an ellipsoid within an image stack

1 vue (au cours des 30 derniers jours)
Pratik Samant
Pratik Samant le 26 Juin 2017
Commenté : Joshua le 26 Juin 2017
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 commentaire
Joshua
Joshua le 26 Juin 2017
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.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by