Hello to all,<br><br>I am using itkExtractImageFilter and RescaleImageFilter, but when I make the pipeline among reader, rescaleimagefilter, extractimageFilter and writer I get this error.<br><i>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> *'</i><br>
<br>Couldsomebody tell me what I am doing wrong?<br>Thanks in advance<br><br><br>Here is my code (I have highlighted the point of the error)<br><br><br> typedef unsigned char InputPixelType;<br> typedef unsigned char OutputPixelType;<br>
<br> typedef itk::Image< InputPixelType, 3 > InputImageType;<br> typedef itk::Image< OutputPixelType, 2 > OutputImageType;<br><br> typedef itk::ImageFileReader< InputImageType > ReaderType;<br>
typedef itk::ImageFileWriter< OutputImageType > WriterType;<br><br> ReaderType::Pointer reader = ReaderType::New();<br> reader->SetFileName( fileName.toStdString() );<br> reader->Update();<br><br>
WriterType::Pointer writer = WriterType::New();<br><br> writer->SetFileName( "z.png" );<br><br> typedef itk::RescaleIntensityImageFilter< InputImageType, OutputImageType > RescaleFilterType;<br> RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();<br>
rescaleFilter->SetInput(reader->GetOutput());<br> rescaleFilter->SetOutputMinimum(0);<br> rescaleFilter->SetOutputMaximum(255);<br><br> <br><br> typedef itk::ExtractImageFilter< InputImageType, OutputImageType > FilterType;<br>
FilterType::Pointer filter = FilterType::New();<br><br> InputImageType::RegionType inputRegion =<br> reader->GetOutput()->GetLargestPossibleRegion();<br><br> InputImageType::SizeType size = inputRegion.GetSize();<br>
<br> // get the size of the hole 3D image<br> size_x = size[0];<br> size_y = size[1];<br> size_z = size[2];<br> <br> // get slices of z coordiante<br> size[2] = 0; <br> <br> <br> InputImageType::IndexType start = inputRegion.GetIndex();<br>
// const unsigned int sliceNumber = 90;<br> ui->verticalScrollBar_z->setRange(1,size_z);<br> unsigned int sliceNumber = ui->verticalScrollBar_z->value();<br> start[2] = sliceNumber;<br> // ui->verticalScrollBar_z->setValue(sliceNumber);<br>
<br><br> InputImageType::RegionType desiredRegion;<br> desiredRegion.SetSize( size );<br> desiredRegion.SetIndex( start );<br><br> filter->SetExtractionRegion( desiredRegion );<br><br><br> <span style="background-color: rgb(255, 255, 102);">filter->SetInput( rescaleFilter->GetOutput() );</span><br style="background-color: rgb(255, 255, 102);">
writer->SetInput( filter->GetOutput() );<br><br> try<br> {<br> writer->Update(); <br> }<br> catch( itk::ExceptionObject & err )<br> {<br> std::cerr << "ExceptionObject caught !" << std::endl;<br>
std::cerr << err << std::endl;<br> }<br>}<br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>