Thank you for answer :-)<br>If I understand you, I added <b>reader->Update()</b> to this part<div class="im"><br><br><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></div> try<br> {<br> <b>reader->Update();</b><br> }<br> catch (itk::ExceptionObject &excp)<br> {<br> cerr << "Exception thrown while writing the image" << endl;<br>
cerr << excp << endl;<br> return;<div class="im"><br> }<br><br> const unsigned int OutputDimension = 3;<br></div>// other is same in my main post...<br><br>When I tried this, my problem is same, any changes....<br>
<br><br>2011/3/1 Ella Maria Kadas <span dir="ltr"><<a href="mailto:ella_kadas@yahoo.com" target="_blank">ella_kadas@yahoo.com</a>></span><div><span id="q_12e71cd8d44d632c_5" class="h4">- Skręt citovanę text -</span></div>
<br>
Hi,<div> I
had a similar problem and that was in my case because the input i was
giving the writer was an empty image. I would suggest that u make an
reader->Update(), before u initialize the output image.</div>
<div>Cheers,</div>Ella<br><br>--- G G <i><<a href="mailto:greenlander1986@gmail.com" target="_blank">greenlander1986@gmail.com</a>></i> schrieb am <b>Di, 1.3.2011:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">
<br>Von: G G <<a href="mailto:greenlander1986@gmail.com" target="_blank">greenlander1986@gmail.com</a>><br>Betreff: [Insight-users] watershed segmentation in own function<br>An: "insight-users" <<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>><br>
Datum: Dienstag, 1. März, 2011 12:17 Uhr<div><div><br><br><div>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>
</div><br></div></div>-----Integrierter Anhang folgt-----<br><br><div>_____________________________________<br>Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><div style="display: inline; cursor: pointer; padding-right: 16px; width: 16px; height: 16px;">
</div><br><br>Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><div style="display: inline; cursor: pointer; padding-right: 16px; width: 16px; height: 16px;">
</div><br><br>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><div style="display: inline; cursor: pointer; padding-right: 16px; width: 16px; height: 16px;">
</div><br>
<br>Please keep messages on-topic and check the ITK FAQ at:<br><a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><div style="display: inline; cursor: pointer; padding-right: 16px; width: 16px; height: 16px;">
</div><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><div style="display: inline; cursor: pointer; padding-right: 16px; width: 16px; height: 16px;">
</div></div></blockquote></b>