[Insight-users] problem of segmentation gray image using watershed
Luis Ibanez
luis.ibanez at kitware.com
Tue Jul 6 21:31:36 EDT 2004
Hi Anis,
The output of the Watershed filter is an image of labels.
These labels are encoded in 32 bits (unsigned long).
You are instantiating a writer for images of 8 bits
(unsigned char) and trying to use it for saving the
output of the watershed.
The problem is that you are trying the share the
ImageType type for both the input and the output.
You can maintain the ImageType to be unsigned char
but need to create another type OutputImageType
and use for instantiating the writer.
Something like:
typedef itk::Image< unsingned long, 2> OutputImageType;
typedef itk::ImageFileWriter<
OutputImageType > WriterType;
Regards,
Luis
----------------------
sd d wrote:
> i need to use watershed algorithm for gray scale png image, i tried to
> modify the watershed example for RVB images, but i had a problem of
> image converting : error C2664: 'SetInput' : cannot convert parameter 1
> from 'class itk::Image<unsigned long,2> *' to 'const class
> itk::Image<unsigned char,2> *'
> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
> Error executing cl.exe.
> at this line:
> writer->SetInput( watershed->GetOutput() );
>
> my code is attached.
>
> please help
>
>
> ------------------------------------------------------------------------
> Créez gratuitement votre Yahoo! Mail avec *100 Mo de stockage !*
> Créez votre Yahoo! Mail
> <http://fr.rd.yahoo.com/mail/taglines/*http://fr.rd.yahoo.com/mail/mail_taglines_100/default/*http://fr.benefits.yahoo.com/>
>
>
> Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !
> <http://fr.rd.yahoo.com/mail/taglines/*http://fr.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.messenger.yahoo.com/>
>
>
>
> ------------------------------------------------------------------------
>
> #include <iostream>
>
> #include "itkGradientAnisotropicDiffusionImageFilter.h"
> #include "itkGradientMagnitudeImageFilter.h"
> #include "itkWatershedImageFilter.h"
>
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkUnaryFunctorImageFilter.h"
>
> int main( int argc, char *argv[] )
> {
> if (argc < 3 )
> {
> std::cerr << "Missing Parameters " << std::endl;
> std::cerr << "Usage: " << argv[0];
> std::cerr << " inputImage outputImage " << std::endl;
> return 1;
> }
>
> typedef unsigned char PixelType;
> typedef itk::Image<PixelType, 2> ImageType;
> typedef itk::Image<unsigned long, 2> LabeledImageType;
> typedef itk::Image<float, 2> ScalarImageType;
>
> typedef itk::ImageFileReader<ScalarImageType> FileReaderType;
> typedef itk::GradientAnisotropicDiffusionImageFilter<ScalarImageType,
> ScalarImageType> DiffusionFilterType;
>
> typedef itk::GradientMagnitudeImageFilter<ScalarImageType,ScalarImageType> GradientMagnitudeFilterType;
> typedef itk::WatershedImageFilter<ScalarImageType> WatershedFilterType;
> // Software Guide : EndCodeSnippet
>
> typedef itk::ImageFileWriter<ImageType> FileWriterType;
>
> FileReaderType::Pointer reader = FileReaderType::New();
> reader->SetFileName( argv[1] );
>
> DiffusionFilterType::Pointer diffusion = DiffusionFilterType::New();
> diffusion->SetInput(reader->GetOutput());
> diffusion->SetTimeStep(0.0625);
> diffusion->SetConductanceParameter(9.0);
> diffusion->SetNumberOfIterations( 5 );
>
> GradientMagnitudeFilterType:: Pointer gradient =GradientMagnitudeFilterType::New();
> gradient->SetInput(diffusion->GetOutput());
>
> WatershedFilterType::Pointer watershed = WatershedFilterType::New();
> watershed->SetInput(gradient->GetOutput());
> watershed->SetThreshold(0.1);
> watershed->SetLevel(0.6);
>
> FileWriterType::Pointer writer = FileWriterType::New();
> writer->SetFileName( argv[2] );
> writer->SetInput( watershed->GetOutput() );
> writer->Update();
> return 0;}
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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