[Insight-users] error while using rescale and extractImageFilter

john smith mkitkinsightuser at gmail.com
Sat Jun 4 03:00:36 EDT 2011


Hello to all,

I am using itkExtractImageFilter and RescaleImageFilter, but when I make the
pipeline among reader, rescaleimagefilter, extractimageFilter and writer I
get this error.
*error C2664: 'void
itk::ImageToImageFilter<TInputImage,TOutputImage>::SetInput(const
itk::Image<TPixel,VImageDimension> *)' : cannot convert parameter 1 from
'itk::Image<TPixel,VImageDimension> *' to 'const
itk::Image<TPixel,VImageDimension> *'*

Couldsomebody tell me what I am doing wrong?
Thanks in advance


Here is my code (I have highlighted the point of the error)


  typedef unsigned char        InputPixelType;
  typedef unsigned char        OutputPixelType;

  typedef itk::Image< InputPixelType,  3 >    InputImageType;
  typedef itk::Image< OutputPixelType, 2 >    OutputImageType;

  typedef itk::ImageFileReader< InputImageType  >  ReaderType;
  typedef itk::ImageFileWriter< OutputImageType >  WriterType;

     ReaderType::Pointer reader = ReaderType::New();
     reader->SetFileName( fileName.toStdString()  );
     reader->Update();

  WriterType::Pointer writer = WriterType::New();

  writer->SetFileName( "z.png" );

  typedef itk::RescaleIntensityImageFilter< InputImageType, OutputImageType
> RescaleFilterType;
  RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();
  rescaleFilter->SetInput(reader->GetOutput());
  rescaleFilter->SetOutputMinimum(0);
  rescaleFilter->SetOutputMaximum(255);



  typedef itk::ExtractImageFilter< InputImageType, OutputImageType >
FilterType;
  FilterType::Pointer filter = FilterType::New();

  InputImageType::RegionType inputRegion =
           reader->GetOutput()->GetLargestPossibleRegion();

  InputImageType::SizeType size = inputRegion.GetSize();

  // get the size of the hole 3D image
  size_x = size[0];
  size_y = size[1];
  size_z = size[2];

  // get slices of z coordiante
  size[2] = 0;


  InputImageType::IndexType start = inputRegion.GetIndex();
 // const unsigned int sliceNumber = 90;
  ui->verticalScrollBar_z->setRange(1,size_z);
  unsigned int sliceNumber = ui->verticalScrollBar_z->value();
  start[2] = sliceNumber;
 // ui->verticalScrollBar_z->setValue(sliceNumber);


  InputImageType::RegionType desiredRegion;
  desiredRegion.SetSize( size );
  desiredRegion.SetIndex( start );

  filter->SetExtractionRegion( desiredRegion );


  filter->SetInput( rescaleFilter->GetOutput() );
  writer->SetInput( filter->GetOutput() );

      try
    {
    writer->Update();
    }
    catch( itk::ExceptionObject & err )
    {
    std::cerr << "ExceptionObject caught !" << std::endl;
    std::cerr << err << std::endl;
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110604/386ba6a4/attachment.htm>


More information about the Insight-users mailing list