Re: contouring the CT slice [message #34994 is a reply to message #34921] |
Tue, 06 May 2003 09:09   |
anne.martel
Messages: 6 Registered: April 2002
|
Junior Member |
|
|
> 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
|
|
|