[Insight-users] itkVTKImageToImageFilter

Luis Ibanez luis.ibanez at kitware.com
Fri Feb 18 01:40:08 EST 2005


Hi Tubak,

You are reading a PNG image using vtkPNGReader,
your image is likely in color, so it is returning
3 components.

The VTKImageToImageFilter is expecting an image of
a single component.

Please use the method

      pngReader->SetNumberOfScalarComponents (1);

to prevent the reader from passing a 3 components image.

for details, simply look at the VTK doxygen documentation:

http://www.vtk.org/doc/nightly/html/classvtkImageReader2.html


    Regards,


      Luis


--------------------------------------
Tubak.Zoltan at stud.u-szeged.hu wrote:

> Hi all,
> 
>   I would like to ask your help!
> 
> I always get the following exception, when I try to update my vtk->itk 
> pipeline:
> 
> 
> Exception caught !
> 
> itk::ExceptionObject (0x8295830)
> Location: "Unknown"
> File: /home/.../BasicFilters/itkVTKImageImport.txx
> Line: 237
> Description: itk::ERROR: VTKImageImport(0x8292db0): Input number of components 
> is 3 but should be 1
> 
> 
> My primitive code is the following:
> 
> #include "vtkPNGReader.h"
> 
> #include "itkImage.h"
> #include "itkImageFileWriter.h"
> #include "itkVTKImageToImageFilter.h"
> 
> int main( int argc, char **argv ) {
> 
>   vtkPNGReader * reader = vtkPNGReader::New();
>   reader->SetFileName(argv[1]);
> 
>   typedef itk::Image<unsigned short, 2> ImageType;
>   typedef itk::ImageFileWriter<ImageType> WriterType;
>   typedef itk::VTKImageToImageFilter<ImageType> ConnectorType;
> 
>   WriterType::Pointer writer = WriterType::New();
>   ConnectorType::Pointer connector = ConnectorType::New();
> 
>   connector->SetInput(reader->GetOutput() );
>   writer->SetInput( connector->GetOutput() );
>   writer->SetFileName(argv[2]);
> 
>   try{ writer->Update(); } 
>   catch(itk::ExceptionObject & excep)
>      {
>       std::cerr << "Exception caught !" << std::endl;
>       std::cerr << excep << std::endl;
>      }
> 
>   return 0;
> }
> 
> 
> Thanks for your help!
> 
> Zoltan
> 
> 
> 
> 
> -------------------------------------------------
> This mail sent through IMP: http://horde.org/imp/
> _______________________________________________
> 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