-1

I have a stack of images of an elliptical cylinder. Within the cylinder are a few "dots"/seeds of importance. I've calculated the euclidean distance between them and the nearest neighbour. My next step is to make a voronoi diagram and calculate the volume of each voronoi cell.

I need to define the space/limits of that elliptical cylinder, to take into account when calculating the voronoi diagram.

Any ideas?

Thanks in advance,

Yotam

  • what do you mean by "draw"? do you want to graphically plot a 3D volume? but how would you "run some calculations" on that figure? – m.s. May 12 '15 at 10:09
  • Apologies for the vagueness. Basically, I have a stack of images of an elliptical cylinder. Within the cylinder are a few "dots"/seeds of importance. I've calculated the euclidean distance between them and the nearest neighbour. My next step is to make a voronoi diagram and calculate the volume of each voronoi cell. And now finally to my problem, I need to define the space/limits of that elliptical cylinder, to take into account when calculating the voronoi diagram and I'm not sure how to do that... I should have stated that before. My apologies. – Yotam Levy May 12 '15 at 10:21
  • you might want to post the code you already have – m.s. May 12 '15 at 10:22

2 Answers2

0

First let's start with some context guessing:

Matlab mupad is for symbolic calculations. I don't see why you would think you would need this to draw anything?

I have no clue why you need to draw anything, but I assume it's for visualising the calculation done.. Like cross section area, using a specific plane equation, or cross section circumference, given a plane equation. Or perhaps collision points of a ray, or to highlight the surface you are calculating on?

In those cases numerical rendering is adequate, and you could simply use the built in plot functions...

I recommend surface (plots a mesh) http://nl.mathworks.com/help/matlab/ref/surface.html

but in fact a previous question in here shows how to manually plot a 3d cylinder: Cylinder with filled top and bottom in matlab

notice that the equations for the cylinder is expressed directly in the function, allowing you to modify it!


having read your comment, the question you asked had nothing to do with what you want to do.. Disregard this answer, if you update the question to something concerning limiting voronoi calculations on images

Community
  • 1
  • 1
Henrik
  • 2,180
  • 16
  • 29
0

How hard this will be depends on whether you're able to operate on the slices individually or if you need to act on the volume as a whole.

In the former case it'll be much easier if your cylinder is aligned with any of the axes. Then you could use the equation of the cross-sectional ellipse to define a boundary in the transverse plane which you could apply to all the slices. This would let you do things within the plane such as test the points for inside/outsideness, mask the image. I can't guess at how this might interact with a Voronoi diagram other than by excluding outside points but it sounds like it's representing the ellipse/cylinder that's the main issue.

If your cylinder is not aligned axially then it's harder but in principle the same procedure: project the ellipse onto the image plane and offset it in each slice according to the angle between the cylinder's longitudinal vector and the axis normal to the images.

If you are intending to operate on the volume then you'd do the same things but in a different order (it depends what you're using it for): once you've computed the intersection between a given image and the cylinder then you can apply the mask or boundary to each slice first and then draw the Voronoi diagram.

The main thing is to avoid having to represent the cylinder as a 3d object: it's possible, even without symbolic maths, but it's complex and as your dataset is naturally ordered as slices it would be most consistent to slice your cylinder too, the ellipses are much more compactly defined than the cylinder would be.

And for all these options the first step is to define the problem mathematically. Depending on how comfortable you are with matlab you could then transform it to pseudocode and then finally matlab, or skip the pseudocode.

xenoclast
  • 1,635
  • 15
  • 26
  • Thanks for the reply! As I am quite new to Matlab, I found it easier to get the coordinates of the centroids (in xyz) of the dots manually (using Metamorph). I then calculated the euclidean distance between them and the nearest neighbour in Matlab. My next step is to make a voronoi diagram and calculate the volume of each voronoi cell and this is where I'm stuck basically (I should have been clearer. My apologies). I've had mild success in creating the voronoi diagram (though I'm sure it's not complicated), but I don't know how to define its limits in space. – Yotam Levy May 14 '15 at 15:42
  • I'm just not really sure which coordinates I require for it (axes lengths I guess?). – Yotam Levy May 14 '15 at 15:44
  • There's a function `voronoin` which computes an n-D voronoi diagram and you can use `convhulln` to get the cell volumes, but the trick is to wrangle your data into the right format first. See http://uk.mathworks.com/help/matlab/ref/voronoin.html and see if you can adapt the examples to your needs. Try it without bounding and see what the results are, you might find that you can apply the boundary to the voronoi diagram and/or the relevant cells after you have them. – xenoclast May 14 '15 at 16:07
  • Great, I'll work on it. Hopefully I'll manage to do it right. Thanks a lot for your help! – Yotam Levy May 15 '15 at 15:01