Hi Luis,<br>I tried to write funcion, which return image after image segmentation. I have this code:<br><br> typedef float PixelType;<br> const unsigned int InputDimension = 3;<br>
<br> typedef itk::Image< PixelType, InputDimension > ImageType;<br> typedef itk::ImageFileReader< ImageType > ReaderType;<br><br> ReaderType::Pointer reader = ReaderType::New();<br>
reader->SetFileName( this->settings.getInputPath().c_str() );<br><br> const unsigned int OutputDimension = 3;<br><br> typedef itk::RGBPixel<unsigned char> RGBPixelType; // ws<br>
typedef itk::Image< RGBPixelType, OutputDimension > OutputImageType; // ws<br><br> WriterType::Pointer writer = WriterType::New();<br> writer->SetFileName( this->settings.getOutputPath().c_str() );<br>
<br> OutputImageType::Pointer output = OutputImageType::New();<br> output = this->segmentationCC<OutputImageType::Pointer, ImageType, OutputImageType, ImageType::Pointer>(reader->GetOutput());<br>
writer->SetInput(output);<br> try<br> {<br> writer->Update();<br> //writer->UpdateLargestPossibleRegion();<br> //writer->UpdateOutputData(output); <br>
}<br> catch (itk::ExceptionObject &e)<br> {<br> this->settings.setLogMessage("Chyba pri zapisu do souboru");<br> cerr << e << endl;<br> this->settings.setIsOK(false);<br>
return;<br> }<br><br><br>then I have to show function segmentationCC:<br><br> template<typename TOutputImageTypePointer, typename TImageType, typename TRGBImageType, typename TInput> TOutputImageTypePointer IOCompute::segmentationCC(TInput input)<br>
{<br> typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< TImageType, TImageType > GradientMagnitudeFilterType;<br> GradientMagnitudeFilterType::Pointer gradienMagnitudeFilter = GradientMagnitudeFilterType::New();<br>
gradienMagnitudeFilter->SetInput( input );<br> gradienMagnitudeFilter->SetSigma( 1.0 );<br><br><br> typedef itk::WatershedImageFilter< TImageType > WatershedFilterType;<br> WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();<br>
watershedFilter->SetInput( gradienMagnitudeFilter->GetOutput() );<br> watershedFilter->SetThreshold( 0.01 );<br> watershedFilter->SetLevel( 0.15 );<br><br> typedef itk::Functor::ScalarToRGBPixelFunctor< unsigned long > ColorMapFunctorType;<br>
<br> typedef WatershedFilterType::OutputImageType LabeledImageType;<br><br> typedef itk::UnaryFunctorImageFilter<<br> LabeledImageType,<br> TRGBImageType,<br>
ColorMapFunctorType<br> > ColorMapFilterType;<br><br> ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();<br>
<br> colorMapFilter->SetInput( watershedFilter->GetOutput() );<br><br> TOutputImageTypePointer output = colorMapFilter->GetOutput();<br> return output;<br> }<br><br><br><br>when I use writer->Update();<br>
I have exception<br><br><br>itk::ExceptionObject (00A3F388)<br>Location: "void __thiscall itk::ImageFileWriter<class itk::Image<class itk::RGBPixel<unsigned char>,3> >::Write(void)" <br>File: c:\itkrel\src\insight\code\io\itkImageFileWriter.txx<br>
Line: 271<br>Description: itk::ERROR: ImageFileWriter(00B513B8): Largest possible region does not fully contain requested paste IO regionPaste IO region: ImageIORegion (00A3F3F8)<br> Dimension: 3<br> Index: 0 0 0 <br> Size: 0 0 0 <br>
Largest possible region: ImageRegion (00A3F3DC)<br> Dimension: 3<br> Index: [0, 0, 0]<br> Size: [0, 0, 0]<br><br><br>or when I have writer->UpdateLargestPossibleRegion(); then no exception, but any writter output file :'-(<br>
<br>Please help me or give some advice, I am desperate...<br>Thanks a lot<br>