[Insight-users] 3D Segmentation Mask

Cameron Burnett w_e_b_m_a_s_t_e_r_6_9 at hotmail.com
Mon May 12 11:01:27 EDT 2008


After going over my current problem I think I've found a bug in TransformPhysicalPointToIndex.

Below is a simple diagram of the Z axis, ranging from 0 to 342 pixels. If I put my box widget around the yyy section (and put my seed point in this section also), the result will be a segmentation of the opposite side.... the xxx section. 

0|-------xxx----|----yyy-------|342

It doesn't make any sense as to why this happens. I'm simply taking the bounds of the box widget, creating points with them, and then turning them into indices.....

  startPt[0] = (int)bounds[0]; //xmin    
  startPt[1] = (int)bounds[2]; //ymin
  startPt[2] = (int)bounds[4]; //zmin

    InternalImageType::PointType endPt;
  endPt[0] = (int)bounds[1]; //xmin    
  endPt[1] = (int)bounds[3]; //ymin
  endPt[2] = (int)bounds[5]; //zmin

  InternalImageType::IndexType start;
    InternalImageType::IndexType end;

InternalImageType::Pointer image = reader->GetOutput();

  InternalImageType::PointType origin;
  origin[0] = 0.0;
  origin[1] = 0.0;
  origin[2] = 0.0;
  image->SetOrigin(origin);

    image->TransformPhysicalPointToIndex(startPt, start);
    image->TransformPhysicalPointToIndex(endPt, end);

  InternalImageType::SizeType size;
  size[0] = end[0]-start[0];
  size[1] = end[1]-start[1]; 
  size[2] = end[2]-start[2];

--------------------------------------

Does this look like a bug?

Thanks,
Cameron.





From: w_e_b_m_a_s_t_e_r_6_9 at hotmail.com
To: luis.ibanez at kitware.com
Date: Fri, 9 May 2008 21:59:33 +1000
CC: insight-users at itk.org
Subject: Re: [Insight-users] 3D Segmentation Mask








Thanks Luis, that almost worked. I was concentrating so much on the box widget I didn't really think to change the seed point.

The problem now is seen in the following 2 pictures.

This is the dicom object I get from the box widget mask. IE: the area that I want to segment..... http://img169.imageshack.us/img169/1506/femurunsegmentedjx1.jpg
And this is the result.... http://img254.imageshack.us/img254/2503/femursegmenteden8.jpg

You can see that the result is actually not quite the area that we were after. Its moved up in the +Z direction so that most of the femur is actually cut off. I'm almost certain that this is because the Z axis is flipped or something similar. But why? One would presume that the TransformPhysicalPointToIndex function would give the correct index even if the Z axis was somehow the wrong way around, right?

Naturally, I just changed the Z starting point to start on the other side.....

 start[2] = 512 - start[2];   // hardcoded 512 as a test     
 size[2] = start[2]-end[2];  //changed from size[2] = end[2]-start[2];

.... however the program just crashed when I did that.


I'm wondering if this problem is a bug, because it seems really strange to me that the points don't translate properly. Do you think it might be, or is it just another simple fix that I'm overlooking??

Thanks.



> Date: Wed, 7 May 2008 12:01:49 -0400
> From: luis.ibanez at kitware.com
> To: w_e_b_m_a_s_t_e_r_6_9 at hotmail.com
> CC: insight-users at itk.org
> Subject: Re: [Insight-users] 3D Segmentation Mask
> 
> 
> 
> Hi Cameron,
> 
> 
> Your suspicion is probably right,
> 
> 
> If you have the following pipeline:
> 
> 
>     reader-->ROIFilter-->RegionGrow
> 
> 
> and you feed the RegionGrowing filter
> with seed points whose index coordinates
> have been taken from the input image of
> the ROIFilter, then those indices can
> easily be outside of the extent of the
> image used in the RegionGrow filter.
> 
> 
> For example,
> 
> if the input image has a region:
> 
>     Index Start:   0,   0,   0
>     Size:        512, 512, 200
> 
> and you extract the ROI;
> 
>     Index Start: 200, 200, 50
>     Size       : 100, 100, 100
> 
> you will end up with an image whose
> region is given by:
> 
>     Index Start:   0,   0,   0
>     Size:        100, 100, 100
> 
> the Origin coordinates will be computed in
> order to match the physical position of the
> index (200,200,50) in the input image.
> 
> 
> So... if you are picking the seed points
> from the input image you have to convert
> these indices to the range of the output
> image.
> 
> For example:
> 
>   Index picked in the input image:
> 
>          257, 234, 65
> 
>   should be converted to the ROI extracted
>   image by subtracting the origin of the
>   ROI
> 
>      257-200, 234-200, 65-50
> 
> to produce
> 
>          57, 34, 15
> 
> 
> You could also prevent crashes by testing
> the index before running the algorithm.
> 
> 
> For example:
> 
> roi->Update();
> if( roi->GetOutput()->GetBufferedRegion().IsInside( seed ) )
> {
>    regionGrowth->AddSeed( seed );
>    regionGrowth->Update();
> }
> else
> {
>   // error message
> }
> 
> 
> Note tha you must call Update() in the roi filter
> before you attempt to query its output image.
> 
> 
> Please let us know if you find any other problems,
> 
> 
>     Thanks
> 
> 
>       Luis
> 
> -----------------------
> Cameron Burnett wrote:
> > 
> > I've done a bit of testing to see where my problem is.
> > 
> > 1) The region that I've set up (to define the 
> > RegionOfInterestImageFilter) is definately within the input image range.
> > 2) The Confidence Connected seed point is definately within the defined 
> > region.
> > 
> > So in that regard everything seems perfect. Now I'm also getting another 
> > result where the program crashes, presumably because of a bad pixel 
> > index given to the Confidence Connected Filter....
> > 
> >  const InputRealType seedIntensity =
> >       static_cast<InputRealType>(inputImage->GetPixel( *si ));      
> > //crashes here in itkConfidenceConnectedImageFilter.txx
> > 
> > 
> > .... and so now I'm thinking that maybe the RegionOfInterestImageFilter 
> > has set up a whole new pixel index system, but my program is still using 
> > the old one perhaps?
> > 
> > Does this filter use the same pixel indices as the original image or 
> > does it create new ones within the new region?? Thats honestly the ONLY 
> > thing I can think of.
> > 
> > Thanks.
> > 
> > 
> > 
> > 
> > 
> >     ------------------------------------------------------------------------
> >     From: w_e_b_m_a_s_t_e_r_6_9 at hotmail.com
> >     To: w_e_b_m_a_s_t_e_r_6_9 at hotmail.com
> >     CC: insight-users at itk.org
> >     Subject: RE: [Insight-users] 3D Segmentation Mask
> >     Date: Tue, 6 May 2008 22:27:42 +1000
> > 
> >     Hi all,
> > 
> >     I've been working on my problem, and I fixed a few things but it
> >     still does nothing.
> > 
> >     The part that I changed is as follows. I had forgotten to change the
> >     physical coordinates to indices, so thats what I've done here. Its
> >     output is shown below the code.
> > 
> >     -------
> > 
> >     InternalImageType::Pointer image = reader->GetOutput();
> > 
> >       InternalImageType::PointType origin;
> >       origin[0] = 0.0;
> >       origin[1] = 0.0;
> >       origin[2] = 0.0;
> >       image->SetOrigin(origin);
> > 
> >         image->TransformPhysicalPointToIndex(startPt, start);
> >         image->TransformPhysicalPointToIndex(endPt, end);
> > 
> >       InternalImageType::SizeType size;
> >       size[0] = (int)end[0]-(int)start[0];
> >       size[1] = (int)end[1]-(int)start[1];
> >       size[2] = (int)end[2]-(int)start[2];
> > 
> >             CString v;
> >         v.Format("%i %i %i %i %i
> >     %i",start[0],start[1],start[2],size[0],size[1],size[2]);
> >         AfxMessageBox(v);
> > 
> >     ------
> > 
> >     The output of that last message box shows the start coords and the
> >     size coords. That outputs "239 179 229 134 68 51". Now to me that
> >     sounds fine. My image is 512 x 512 x 342 so its within that, and
> >     also the size is quite small, which is exactly what I did with my
> >     box widget.
> > 
> >     I'm not forgetting to refresh the screen or anything. All I have
> >     done is add this filter into the pipeline, and the rest is the same
> >     as when it worked previously with no masking.
> > 
> >     Anything obviously wrong with my code??
> > 
> >     Thanks,
> >     Cameron.
> > 
> > 
> > 
> >         ------------------------------------------------------------------------
> >         From: w_e_b_m_a_s_t_e_r_6_9 at hotmail.com
> >         To: luis.ibanez at kitware.com
> >         Date: Tue, 6 May 2008 00:24:10 +1000
> >         CC: insight-users at itk.org
> >         Subject: Re: [Insight-users] 3D Segmentation Mask
> > 
> >         Thanks for that info Luis.
> > 
> > 
> >         I implemented the box widget approach today and it seems to mask
> >         quite well, because the time it takes to run is drastically
> >         reduced. However I'm not actually getting anything to display on
> >         the screen.
> > 
> >         I'm using the ImageReadRegionOfInterestWrite example, and the
> >         key section of code is as follows.
> > 
> >         -------------------------------------------------------------------------
> > 
> >           vtkPolyData *poly = vtkPolyData::New();
> > 
> >           double bounds[6];
> >           for(int i=0; i<6; i++){bounds[i] = NULL;}
> > 
> >           boxWidget->GetPolyData(poly);
> >           poly->GetBounds(bounds);
> > 
> >         //then i set up the filter
> > 
> >           InternalImageType::IndexType start;
> >           start[0] = (int)bounds[0]; //xmin  
> >           start[1] = (int)bounds[2]; //ymin
> >           start[2] = (int)bounds[4]; //zmin
> > 
> >           InternalImageType::SizeType size;
> >           size[0] = (int)(bounds[1]-bounds[0]);   //xmax-xmin
> >           size[1] = (int)(bounds[3]-bounds[2]);  //etc...
> >           size[2] = (int)(bounds[5]-bounds[4]);
> > 
> >         //then i attach it all together, add it to the pipeline etc.
> > 
> >         --------------------------------------------------------------------------------
> > 
> >         I think my problem has something to do with the Start and Size
> >         indices. I'm not sure what i'm doing wrong though.
> > 
> > 
> >         Thanks for any further help,
> >         Cameron.
> > 
> > 
> > 
> > 
> >         ------------------------------------------------------------------------
> >          > Date: Wed, 30 Apr 2008 16:56:25 -0400
> >          > From: luis.ibanez at kitware.com
> >          > To: w_e_b_m_a_s_t_e_r_6_9 at hotmail.com
> >          > CC: insight-users at itk.org
> >          > Subject: Re: [Insight-users] 3D Segmentation Mask
> >          >
> >          > Hi Cameron,
> >          >
> >          > It seems that what you are looking for is a VTK interactive
> >          > method for selecting a region of interest of your 3D image,
> >          > that will be later passed to an ITK segmentation pipeline.
> >          >
> >          > Is that correct ?
> >          >
> >          > If so, one thing you could easily use is the
> >          >
> >          > vtkAffineWidget
> >          > http://www.vtk.org/doc/nightly/html/classvtkAffineWidget.html
> >          >
> >          > or the
> >          >
> >          > vtkBoxWidget
> >          > http://www.vtk.org/doc/nightly/html/classvtkBoxWidget.html
> >          >
> >          > or a combination of 3 ImagePlaneWidgets:
> >          > http://www.vtk.org/doc/nightly/html/classvtkImagePlaneWidget.html
> >          >
> >          >
> >          > That you will find the widgets under
> >          >
> >          >
> >          > VTK/Widgets/
> >          >
> >          >
> >          > You could interactively manipulate their handles until you have
> >          > captured the region of interest and then (programatically)
> >          > you could query the current state of the widget in order to
> >          > deduce the coordinates of its corners.
> >          >
> >          > The coordinate of the region of interest could then be passed
> >          > as a Region to the itkRegionOfInterestImageFilter.
> >          >
> >          >
> >          >
> >          >
> >          > Regards,
> >          >
> >          >
> >          > Luis
> >          >
> >          >
> >          >
> >          > ----------------------
> >          > Cameron Burnett wrote:
> >          > > Hi,
> >          > >
> >          > > Currently I'm trying to figure out how to create a mask for
> >          > > segmentation. The way i'm thinking of doing it is using a
> >          > > MaskImageFilter to mask my DICOM object with a vtkActor
> >         cube object that
> >          > > I generated just from points. To do that I need to figure
> >         out 1 of 2
> >          > > things (due to the fact that you can't plug an actor
> >         straight into the
> >          > > mask filter). Either I replace that vtkActor with some sort
> >         of ITK box
> >          > > primitive that can go straight into the filter, OR I
> >         somehow convert the
> >          > > object into the correct itk image form.
> >          > >
> >          > > Does that make sense?? Generally I just want to segment
> >         only the stuff
> >          > > inside a box that I can move around. That's the simple way
> >         of putting it.
> >          > >
> >          > > I was looking at this example in the Insight Applications
> >          > > "vtkPolyDataToITKMesh.cxx" , but I'm not sure thats what
> >         I'm after. Also
> >          > > I found a bit on the mailing list about
> >          > > "TriangleMeshToBinaryImageFilter" but that has just left me
> >         even more
> >          > > confused.
> >          > >
> >          > > Is there an easier way to create an
> >         interactive/movable/scaleable 3D
> >          > > mask, other than a cube represented by a vtkActor? What
> >         sort of stuff
> >          > > should I be looking to use for this approach (or a similar
> >         one) ??
> >          > >
> >          > > Thanks in advance,
> >          > > Cameron.
> >          > >
> >          > >
> >          > >
> >          > >
> >          > >
> >          > >
> >         ------------------------------------------------------------------------
> >          > > Click here Search for local singles online @ Lavalife.
> >          > >
> >         <http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D30290&_t=764581033&_r=email_taglines_Search_OCT07&_m=EXT>
> >          > >
> >          > >
> >          > >
> >         ------------------------------------------------------------------------
> >          > >
> >          > > _______________________________________________
> >          > > Insight-users mailing list
> >          > > Insight-users at itk.org
> >          > > http://www.itk.org/mailman/listinfo/insight-users
> > 
> >         ------------------------------------------------------------------------
> >         Find out: SEEK Salary Centre Are you paid what you're worth?
> >         <http://a.ninemsn.com.au/b.aspx?URL=http://ninemsn.seek.com.au/career-resources/salary-centre/?tracking%3Dsk:het:sc:nine:0:hot:text&_t=764565661&_r=OCT07_endtext_salary&_m=EXT>
> > 
> > 
> > 
> >     ------------------------------------------------------------------------
> >     Hotmail on your mobile. Never miss another e-mail with
> >     <http://www.livelife.ninemsn.com.au/article.aspx?id=343869> 
> > 
> > 
> > ------------------------------------------------------------------------
> > at CarPoint.com.au It's simple! Sell your car for just $30 
> > <http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT>
> > 
> > 
> > ------------------------------------------------------------------------
> > 
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users

Find out: SEEK Salary Centre Are you paid what you're worth?

_________________________________________________________________
Are you paid what you're worth? Find out: SEEK Salary Centre
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau%2Fcareer%2Dresources%2Fsalary%2Dcentre%2F%3Ftracking%3Dsk%3Ahet%3Asc%3Anine%3A0%3Ahot%3Atext&_t=764565661&_r=OCT07_endtext_salary&_m=EXT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080513/732de03b/attachment-0001.htm>


More information about the Insight-users mailing list