[Insight-users] error while using rescale and extractImageFilter

robert tamburo robert.tamburo at gmail.com
Sat Jun 4 07:36:51 EDT 2011


It means that RescaleImageFilter cannot convert the input image from 3D to
2D. Change:
typedef itk::RescaleIntensityImageFilter< InputImageType, OutputImageType>
RescaleFilterType;
to
typedef itk::RescaleIntensityImageFilter< InputImageType, InputImageType>
RescaleFilterType;

On Sat, Jun 4, 2011 at 3:00 AM, john smith <mkitkinsightuser at gmail.com>wrote:

> 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;
>     }
> }
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110604/5035f0fd/attachment.htm>


More information about the Insight-users mailing list