[Insight-users] watershed with MRI

lydia coin lydia_coin3d@yahoo.fr
Thu, 9 Jan 2003 20:31:49 +0100 (CET)


--0-1956191663-1042140709=:6838
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


Hi Josh
Did the watershed work on the MRI, could you read the image?
Sorry for being impatient :)
 Joshua Cates <cates@sci.utah.edu> wrote:Sure. I'll see what I can do.

Josh.

______________________________
Josh Cates 
School of Computer Science 
University of Utah
Email: cates@sci.utah.edu
Phone: (801) 587-7697
URL: http://www.sci.utah.edu/~cates


On Wed, 8 Jan 2003, lydia coin wrote:

> would you mind if I send you one raw MRI image with all the information of dimensions to perform the filter on it? this will be very helpful as I'm stuck with this problem.
> 
> Joshua Cates wrote:Hi,
> 
> Yes, the test is perhaps misleading as it doesn't really produce any
> meaningful output, just excercises the code. The filters are fine, the
> data is just not interesting and only segments to one region at most level
> values. At some point I will replace the test with one using actual image
> data that will produce more meaningful results for true regression
> testing.
> 
> I suggest looking at the example in the Applications directory instead
> (Applications/WatershedSegmentation). This example is more instructive as
> it shows how to preprocess the data and produce output at different
> levels. It will read images in ASCII pgm format.
> 
> Also, the extremely high value you are seeing looks like the result 
> of the wrong endianness.
> 
> Josh.
> 
> ______________________________
> Josh Cates 
> School of Computer Science 
> University of Utah
> Email: cates@sci.utah.edu
> Phone: (801) 587-7697
> URL: http://www.sci.utah.edu/~cates
> 
> 
> On Wed, 8 Jan 2003, lydia coin wrote:
> 
> > 
> > Hi Josh,
> > I changed the value of the level paramter from 1 to 0.1 and to 0.01, but still the same intensity value of 3452816845 for the whole image. it's really strange, I wonder if this example in the testing folder gives the same result for you
> > Joshua Cates wrote:Hi Lydia,
> > 
> > For your MRI image, make sure that you cast to float (or double) before 
> > passing to the GradientMagnitudeImageFilter. You might also want to do 
> > some smoothing on the image first (i.e. 
> > Gradient/CurvatureAnisotropicDiffusionImageFilter or 
> > BilateralImageFilter). 
> > 
> > In your example code below, you set the Level parameter to 1.0. This 
> > should result in an output of exactly one region because it is telling the 
> > filter to merge all of the potential watershed basins up to 100% of the 
> > possible image height. Try a Level parameter much lower than this, say 
> > 0.10 (i.e. 10% of the height).
> > 
> > Josh.
> > 
> > ______________________________
> > Josh Cates 
> > School of Computer Science 
> > University of Utah
> > Email: cates@sci.utah.edu
> > Phone: (801) 587-7697
> > URL: http://www.sci.utah.edu/~cates
> > 
> > 
> > On Wed, 8 Jan 2003, lydia coin wrote:
> > 
> > > 
> > > thank you for your hints.
> > > 
> > > That what I did, I used an MRI image, with the GradientMagnitudeImageFilter and pass it to the watershed filter. the result is an image with the same intensity value.
> > > 
> > > In addition to using MRI image, I took the image of the testing example as follows (source code below). The result is an image with the same intensity value everywhere in the image ( like for the MRI). In this case the pixel type is float but still doesn't work. I'll cast the MR image to float but in the meanwhile, could you have a look to my code, maybe something is wrong. 
> > > 
> > > 
> > > 
> > > typedef itk::Image ImageType2D;
> > > itk::ImageRegion<2> Region2D;
> > > itk::Size<2> size2D;
> > > size2D[0] = 256;
> > > size2D[1] = 256;
> > > itk::Index<2> orig2D;
> > > orig2D[0] = 0;
> > > orig2D[1] = 0;
> > > 
> > > Region2D.SetSize(size2D);
> > > Region2D.SetIndex(orig2D);
> > > 
> > > ImageType2D::Pointer image2D = ImageType2D::New();
> > > image2D->SetLargestPossibleRegion(Region2D);
> > > image2D->SetBufferedRegion(Region2D);
> > > image2D->SetRequestedRegion(Region2D);
> > > image2D->Allocate();
> > > 
> > > 
> > > itk::ImageRegionIterator
> > > it2D(image2D, image2D->GetRequestedRegion()); 
> > > 
> > > float q = 0.00f;
> > > for (; !it2D.IsAtEnd(); ++it2D)
> > > {
> > > it2D.Value() = ::sin(q);
> > > q = q + 0.10f;
> > > }
> > > 
> > > float lower_threshold=.05f;
> > > itk::WatershedImageFilter::Pointer watershed
> > > = itk::WatershedImageFilter::New();
> > > watershed->SetThreshold(lower_threshold);
> > > watershed->SetLevel(1.0f);
> > > watershed->SetInput(image2D);
> > > typedef unsigned long PixelType1;
> > > PixelType1 *data = new PixelType1[size[0]*size[1]];
> > > typedef itk::ImageRegionIteratorImageIterator1;
> > > ImageIterator1 it1(watershed->GetOutput(),watershed->GetOutput()->GetBufferedRegion());
> > > it1.GoToBegin();
> > > int i=0;
> > > while( !it1.IsAtEnd() )
> > > {
> > > data[i]=it1.Get( );
> > > ++it1;
> > > i++;
> > > }
> > > 
> > > 
> > > 
> > > ---------------------------------
> > > Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
> > > Testez le nouveau Yahoo! Mail
> > 
> > 
> > 
> > ---------------------------------
> > Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
> > Testez le nouveau Yahoo! Mail
> 
> 
> 
> 
> ---------------------------------
> Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
> Testez le nouveau Yahoo! Mail



---------------------------------
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Testez le nouveau Yahoo! Mail
--0-1956191663-1042140709=:6838
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<P>Hi Josh
<P>Did the watershed work on the MRI, could you read the image?
<P>Sorry for being impatient :)
<P>&nbsp;<B><I>Joshua Cates &lt;cates@sci.utah.edu&gt;</I></B> wrote:
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Sure. I'll see what I can do.<BR><BR>Josh.<BR><BR>______________________________<BR>Josh Cates <BR>School of Computer Science <BR>University of Utah<BR>Email: cates@sci.utah.edu<BR>Phone: (801) 587-7697<BR>URL: http://www.sci.utah.edu/~cates<BR><BR><BR>On Wed, 8 Jan 2003, lydia coin wrote:<BR><BR>&gt; would you mind if I send you one raw MRI image with all the information of dimensions to perform the filter on it? this will be very helpful as I'm stuck with this problem.<BR>&gt; <BR>&gt; Joshua Cates <CATES@SCI.UTAH.EDU>wrote:Hi,<BR>&gt; <BR>&gt; Yes, the test is perhaps misleading as it doesn't really produce any<BR>&gt; meaningful output, just excercises the code. The filters are fine, the<BR>&gt; data is just not interesting and only segments to one region at most level<BR>&gt; values. At some point I will replace the test with one using actual image<BR>&gt; data that will produce more meaningful results for true regression<BR>&gt; testing.<BR>&gt; <BR>&gt; I suggest looking at the example in the Applications directory instead<BR>&gt; (Applications/WatershedSegmentation). This example is more instructive as<BR>&gt; it shows how to preprocess the data and produce output at different<BR>&gt; levels. It will read images in ASCII pgm format.<BR>&gt; <BR>&gt; Also, the extremely high value you are seeing looks like the result <BR>&gt; of the wrong endianness.<BR>&gt; <BR>&gt; Josh.<BR>&gt; <BR>&gt; ______________________________<BR>&gt; Josh Cates <BR>&gt; School of Computer Science <BR>&gt; University of Utah<BR>&gt; Email: cates@sci.utah.edu<BR>&gt; Phone: (801) 587-7697<BR>&gt; URL: http://www.sci.utah.edu/~cates<BR>&gt; <BR>&gt; <BR>&gt; On Wed, 8 Jan 2003, lydia coin wrote:<BR>&gt; <BR>&gt; &gt; <BR>&gt; &gt; Hi Josh,<BR>&gt; &gt; I changed the value of the level paramter from 1 to 0.1 and to 0.01, but still the same intensity value of 3452816845 for the whole image. it's really strange, I wonder if this example in the testing folder gives the same result for you<BR>&gt; &gt; Joshua Cates wrote:Hi Lydia,<BR>&gt; &gt; <BR>&gt; &gt; For your MRI image, make sure that you cast to float (or double) before <BR>&gt; &gt; passing to the GradientMagnitudeImageFilter. You might also want to do <BR>&gt; &gt; some smoothing on the image first (i.e. <BR>&gt; &gt; Gradient/CurvatureAnisotropicDiffusionImageFilter or <BR>&gt; &gt; BilateralImageFilter). <BR>&gt; &gt; <BR>&gt; &gt; In your example code below, you set the Level parameter to 1.0. This <BR>&gt; &gt; should result in an output of exactly one region because it is telling the <BR>&gt; &gt; filter to merge all of the potential watershed basins up to 100% of the <BR>&gt; &gt; possible image height. Try a Level parameter much lower than this, say <BR>&gt; &gt; 0.10 (i.e. 10% of the height).<BR>&gt; &gt; <BR>&gt; &gt; Josh.<BR>&gt; &gt; <BR>&gt; &gt; ______________________________<BR>&gt; &gt; Josh Cates <BR>&gt; &gt; School of Computer Science <BR>&gt; &gt; University of Utah<BR>&gt; &gt; Email: cates@sci.utah.edu<BR>&gt; &gt; Phone: (801) 587-7697<BR>&gt; &gt; URL: http://www.sci.utah.edu/~cates<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; On Wed, 8 Jan 2003, lydia coin wrote:<BR>&gt; &gt; <BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; thank you for your hints.<BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; That what I did, I used an MRI image, with the GradientMagnitudeImageFilter and pass it to the watershed filter. the result is an image with the same intensity value.<BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; In addition to using MRI image, I took the image of the testing example as follows (source code below). The result is an image with the same intensity value everywhere in the image ( like for the MRI). In this case the pixel type is float but still doesn't work. I'll cast the MR image to float but in the meanwhile, could you have a look to my code, maybe something is wrong. <BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; typedef itk::Image ImageType2D;<BR>&gt; &gt; &gt; itk::ImageRegion&lt;2&gt; Region2D;<BR>&gt; &gt; &gt; itk::Size&lt;2&gt; size2D;<BR>&gt; &gt; &gt; size2D[0] = 256;<BR>&gt; &gt; &gt; size2D[1] = 256;<BR>&gt; &gt; &gt; itk::Index&lt;2&gt; orig2D;<BR>&gt; &gt; &gt; orig2D[0] = 0;<BR>&gt; &gt; &gt; orig2D[1] = 0;<BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; Region2D.SetSize(size2D);<BR>&gt; &gt; &gt; Region2D.SetIndex(orig2D);<BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; ImageType2D::Pointer image2D = ImageType2D::New();<BR>&gt; &gt; &gt; image2D-&gt;SetLargestPossibleRegion(Region2D);<BR>&gt; &gt; &gt; image2D-&gt;SetBufferedRegion(Region2D);<BR>&gt; &gt; &gt; image2D-&gt;SetRequestedRegion(Region2D);<BR>&gt; &gt; &gt; image2D-&gt;Allocate();<BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; itk::ImageRegionIterator<BR>&gt; &gt; &gt; it2D(image2D, image2D-&gt;GetRequestedRegion()); <BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; float q = 0.00f;<BR>&gt; &gt; &gt; for (; !it2D.IsAtEnd(); ++it2D)<BR>&gt; &gt; &gt; {<BR>&gt; &gt; &gt; it2D.Value() = ::sin(q);<BR>&gt; &gt; &gt; q = q + 0.10f;<BR>&gt; &gt; &gt; }<BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; float lower_threshold=.05f;<BR>&gt; &gt; &gt; itk::WatershedImageFilter::Pointer watershed<BR>&gt; &gt; &gt; = itk::WatershedImageFilter::New();<BR>&gt; &gt; &gt; watershed-&gt;SetThreshold(lower_threshold);<BR>&gt; &gt; &gt; watershed-&gt;SetLevel(1.0f);<BR>&gt; &gt; &gt; watershed-&gt;SetInput(image2D);<BR>&gt; &gt; &gt; typedef unsigned long PixelType1;<BR>&gt; &gt; &gt; PixelType1 *data = new PixelType1[size[0]*size[1]];<BR>&gt; &gt; &gt; typedef itk::ImageRegionIteratorImageIterator1;<BR>&gt; &gt; &gt; ImageIterator1 it1(watershed-&gt;GetOutput(),watershed-&gt;GetOutput()-&gt;GetBufferedRegion());<BR>&gt; &gt; &gt; it1.GoToBegin();<BR>&gt; &gt; &gt; int i=0;<BR>&gt; &gt; &gt; while( !it1.IsAtEnd() )<BR>&gt; &gt; &gt; {<BR>&gt; &gt; &gt; data[i]=it1.Get( );<BR>&gt; &gt; &gt; ++it1;<BR>&gt; &gt; &gt; i++;<BR>&gt; &gt; &gt; }<BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; <BR>&gt; &gt; &gt; ---------------------------------<BR>&gt; &gt; &gt; Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !<BR>&gt; &gt; &gt; Testez le nouveau Yahoo! Mail<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; ---------------------------------<BR>&gt; &gt; Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !<BR>&gt; &gt; Testez le nouveau Yahoo! Mail<BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; ---------------------------------<BR>&gt; Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !<BR>&gt; Testez le nouveau Yahoo! Mail<BR></BLOCKQUOTE><p><br><hr size=1>Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !<br>
<a href=http://fr.mail.yahoo.com>Testez le nouveau Yahoo! Mail</a>
--0-1956191663-1042140709=:6838--