[Insight-users] Strange thing in itkWatershedImageFilter
Lemeur Yann
Yann.Lemeur at stage.cnes.fr
Tue Aug 3 05:34:31 EDT 2004
Thanks for your answer Luis.
I've partially solved my problem: indeed the more disturbing was that there still was zeros in the buffered image (and not in the image written). The solution was to force call update on watershed filter because the GetBasicSegmentation() daesn't produce a real output of WatershedImageFilter. Then it can be used in a pipeline without calling update:
watershed->SetInput(toto.png);
filterX->SetInput(watershed->GetBasicSegmentation() );
filterX->Update(); // doesn't work!
Instead, I have to do:
watershed->SetInput(toto.png);
filterX->SetInput(watershed->GetBasicSegmentation() );
watershed->Update();
filterX->Update();
This is not very nice, but it works...
But I still have the problem to write the image produced by watershed->GetBasicSegmentation() . If I write:
typedef itk::Image<unsigned long,2> LabeledImageType;
typedef itk::ImageFileWriterType<LabeledImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(toto.mhd);
watershed->SetInput(toto.png);
writer->SetInput( watershed->GetBasicSegmentation() );
watershed->Update();
writer->Update();
The result is as described in my first mail: an image with unwanted zeros (on the first line and on diagonals). The use of .mhd file format hasn't changed anything...
Yann
> ----------
> De : Luis Ibanez[SMTP:luis.ibanez at kitware.com]
> Date : mardi 3 ao> ût 2004 05:53
> A : Lemeur Yann
> Cc : insight-users at itk.org
> Objet : Re: [Insight-users] Strange thing in itkWatershedImageFilter
>
>
> Hi Yann,
>
>
> Please don't use the RawImgaeIO class.
>
> You can simply use the MetaImage file format by
> passing an image filename with extension .mhd.
>
>
> The ImageFileReader will then create files
>
> toto.mhd
> toto.raw
>
>
> the .mhd file contains the meta information
> about the image, while the .raw file contains
> the pixel data in binary format.
>
> You will find details about this in the Data
> page of ITK
>
> http://www.itk.org/HTML/Data.htm
>
>
> Regards,
>
>
> Luis
>
>
> --------------------
> Lemeur Yann wrote:
>
> > Hi all!
> >
> > I'm confronted with a big problem in the GetBasicSegmentation method of the itkWatershedImageFilter.
> > I tried with the example provided in the Itk package and it seems to be the same problem.
> > Here is: I want to get the image of the basic segmentation (i.e. the image built with the local minima of the gradient). So in the WatershedSegmentation1.cxx (folder Examples/Segmentation/), I've added the following stuff:
> >
> > typedef itk::ImageFileWriter<LabeledImageType> LabeledFileWriterType; // the Labeled Image Type is previosly defined as // a 2D image of unsigned long
> > typedef itk::RawImageIO<unsigned long,2> RawImageType;
> >
> > LabeledFileWriterType::Pointer writerLab=LabeledFileWriterType::New();
> > RawImageType::Pointer io=RawImageType::New();
> >
> > writerLab->SetFileName("toto.raw");
> > writerLab->SetImageIO(io);
> > ...............
> > .............
> > ..............
> >
> > writerLab->SetInput(watershed->GetBasicSegmentation() );
> > watershed->Update();
> >
> >
> > When I read the image toto.raw, it has the right size in bytes but there is a strange thing: it's like the first row and the first column are wrong (see attached image labels.raw which is 181col x 217lines of unsigned long). As you can see, there are a lot of zero-valued pixels (diagonals, first column, first line) which is unusual for a labeled image of the itkWatershedImageFilter...
> > If I connect this image to a color mapper filter (as made in the example), the .png file written is ok! But in the buffer, there are always zeros (you can check it with iterators on this image).
> > Strange isn't it?
> >
> > Yann <<labels.raw>>
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
>
>
>
>
More information about the Insight-users
mailing list