Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Hi All, I have serial cross sections of some long bones, which I would like to calculate centroids and mass moments of inertia for each slice. The steps I have managed to do so far: 1.) Read the stack as a three dimensional volume: 2.) Calculate a threshold for segmenting the data 3.) Get the internal and external contours with contours function. The problem, when I look at the values of PATH_XY with PATH_DATA_COORDS option, those are combined points of two contours. So sorting them out becomes quite tricky. The reason I need those points, I have somebody else's fortran routine to calculate moments based on individual points and it needs two separate inputs... So the first question what else I can use other than contour procedure to get the coordinates of external and internal contours? And what may be a better way to approach this problem? Thanks for your time, Murat
Murat Maga (maga@mail.utexas.edu) writes: > I have serial cross sections of some long bones, which I would like to > calculate centroids and mass moments of inertia for each slice. > The steps I have managed to do so far: > 1.) Read the stack as a three dimensional volume: > 2.) Calculate a threshold for segmenting the data > 3.) Get the internal and external contours with contours function. > > The problem, when I look at the values of PATH_XY with PATH_DATA_COORDS > option, those are combined points of two contours. So sorting them out > becomes quite tricky. Tricky, maybe, but certainly not impossible. You will probably need the information in PATH_INFO to do it correctly. > The reason I need those points, I have somebody else's fortran routine > to calculate moments based on individual points and it needs two > separate inputs... Say what!? How do you expect the contours to help here? > So the first question what else I can use other than contour procedure > to get the coordinates of external and internal contours? And what may > be a better way to approach this problem? You could try using ISOCONTOUR, but I think this approach is probably fine. Cheers, David -- David W. Fanning, Ph.D. Fanning Software Consulting, Inc. Phone: 970-221-0438, E-mail: david@dfanning.com Coyote's Guide to IDL Programming: http://www.dfanning.com/ Toll-Free IDL Book Orders: 1-888-461-0155
Murat Maga wrote: > Hi All, > I have serial cross sections of some long bones, which I would like to > calculate centroids and mass moments of inertia for each slice. > The steps I have managed to do so far: > 1.) Read the stack as a three dimensional volume: > 2.) Calculate a threshold for segmenting the data > 3.) Get the internal and external contours with contours function. > > The problem, when I look at the values of PATH_XY with PATH_DATA_COORDS > option, those are combined points of two contours. So sorting them out > becomes quite tricky. > The reason I need those points, I have somebody else's fortran routine > to calculate moments based on individual points and it needs two > separate inputs... > > So the first question what else I can use other than contour procedure > to get the coordinates of external and internal contours? And what may > be a better way to approach this problem? > Thanks for your time, > Murat When anatomical information becomes important, I find that manual landmarking is the fastest and easiest way to get the job done. You'd probably have to locate the center of the bone marrow on each slide manually anyway; so you may store these center points in an array. Then have your IDL code crawl the CT data - first from the marked bone marrow center to each point along the image border, on each line until it hits your bone threshold level then store those coordinates as part of your inner contour data; then from the outside, crawl from each point along the image border back to the marked bone marrow center landmark until you hit bone threshold level, and record those coordinates as well as part of the outer contours. This probably does not take as long as it sounds; worked fine for me when I tried to measure the skin thickness on a CT head scan and evaluate tissue swelling due to an injury, correcting it for any local anatomical 'normal value' by subtracting the contralateral measurement. Don't forget that you can always alter your data to suit your needs. There is no reason to leave your 3d-array untouched as long as you have the original data stored somewhere to return back to it. So if you want your result to not just contain the vortex list, but also the polygons, you could use the 'center bone marrow to perimeter of image crawl' approach in order to fill the bone marrow with a very high data value, say, twice your bone threshold of, say, 1300 Hounsfield units. Then you'd be able to generate surface meshes for your outside surface (bone threshold), and then your inside surface (the higher threshold value you stuffed your bone marrow with), using something like SHADE_VOLUME. Wolf Schweitzer
> Murat Maga wrote: >> Hi All, >> I have serial cross sections of some long bones, which I would like to >> calculate centroids and mass moments of inertia for each slice. >> The steps I have managed to do so far: >> 1.) Read the stack as a three dimensional volume: >> 2.) Calculate a threshold for segmenting the data >> 3.) Get the internal and external contours with contours function. >> I'm not sure you need to use contours for this. You can calculate the centre of mass of an image using the following routine (it's not very pretty but it does the job): ; PURPOSE: ; returns intensity weighted centre of image ; ; CATEGORY: ; image processing ; ; CALLING SEQUENCE: ; cog_pos=cog(image) ; ; INPUTS: ; image ; OUPUT: ; returns position as a structure {x:xpos,y:ypos} ; EXAMPLE: ; cpos=cog(image) ; Function cog,image s = size(image) tot = total(image) if(tot gt 0) then begin xtotal=0 ytotal=0 xmax = s(1)-1.0 ymax = s(2)-1.0 for i = 0.0 , xmax do xtotal = xtotal + total(image(i,*)*i) for i = 0.0 , ymax do ytotal = ytotal + total(image(*,i)*i) cog_pos = {x: xtotal/tot, $ y: ytotal/tot} endif else cog_pos={x:0,y:0} return,cog_pos end Why not just threshold the image and apply CoG to each thresholded slice? You could used a single seed point together with search_3d to make sure that you just had a single connected bone region. If you needed information about the pixels around the inner and outer edges of the bone then you could use morphology - just dilate the bone region once then subtract off the undilated image. Anne
Thank you very much for the kind and detailed responses. I wanted the contours, because PATH_XY gives me the coordinates of each point that make up the contour. And I have a small routine which takes two arrays, one for internal and one of external, of x-y coordinates of polygons. Then it calculates the centroid, second moments of area, polar moments and such... Wolf: Manual landmarking is not really quite feasible as I want to look at couple of ten thousands of slice (combined sample). Anne: Thanks for th subroutine, I will definitely try that. Best, Murat