Thank you for answer :-)<br>If I understand you, I added <b>reader-&gt;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&lt; PixelType,  InputDimension &gt;     ImageType;<br>        typedef  itk::ImageFileReader&lt; ImageType &gt;   ReaderType;<br><br>        ReaderType::Pointer reader = ReaderType::New();<br>

        reader-&gt;SetFileName( this-&gt;settings.getInputPath().c_str() );<br><br></div>  try<br>    {<br>    <b>reader-&gt;Update();</b><br>    }<br>  catch (itk::ExceptionObject &amp;excp)<br>    {<br>    cerr &lt;&lt; &quot;Exception thrown while writing the image&quot; &lt;&lt; endl;<br>

    cerr &lt;&lt; excp &lt;&lt; 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">&lt;<a href="mailto:ella_kadas@yahoo.com" target="_blank">ella_kadas@yahoo.com</a>&gt;</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-&gt;Update(), before u initialize the output image.</div>
<div>Cheers,</div>Ella<br><br>--- G G <i>&lt;<a href="mailto:greenlander1986@gmail.com" target="_blank">greenlander1986@gmail.com</a>&gt;</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 &lt;<a href="mailto:greenlander1986@gmail.com" target="_blank">greenlander1986@gmail.com</a>&gt;<br>Betreff: [Insight-users] watershed segmentation in own function<br>An: &quot;insight-users&quot; &lt;<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>&gt;<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&lt; PixelType,  InputDimension &gt;     ImageType;<br>        typedef  itk::ImageFileReader&lt; ImageType &gt;   ReaderType;<br><br>        ReaderType::Pointer reader = ReaderType::New();<br>


        reader-&gt;SetFileName( this-&gt;settings.getInputPath().c_str() );<br><br>        const   unsigned int                      OutputDimension = 3;<br><br>        typedef itk::RGBPixel&lt;unsigned char&gt;      RGBPixelType;    // ws<br>


        typedef itk::Image&lt; RGBPixelType, OutputDimension &gt;  OutputImageType; // ws<br><br>        WriterType::Pointer writer = WriterType::New();<br>        writer-&gt;SetFileName( this-&gt;settings.getOutputPath().c_str() );<br>


<br>        OutputImageType::Pointer output = OutputImageType::New();<br>            output = this-&gt;segmentationCC&lt;OutputImageType::Pointer, ImageType, OutputImageType, ImageType::Pointer&gt;(reader-&gt;GetOutput());<br>


        writer-&gt;SetInput(output);<br>        try<br>        {<br>            writer-&gt;Update();<br>            //writer-&gt;UpdateLargestPossibleRegion();<br>            //writer-&gt;UpdateOutputData(output);            <br>


        }<br>        catch (itk::ExceptionObject &amp;e)<br>        {<br>            this-&gt;settings.setLogMessage(&quot;Chyba pri zapisu do souboru&quot;);<br>            cerr &lt;&lt; e &lt;&lt; endl;<br>            this-&gt;settings.setIsOK(false);<br>


            return;<br>        }<br><br><br>then I have to show function segmentationCC:<br><br>   
 template&lt;typename TOutputImageTypePointer, typename TImageType, 
typename TRGBImageType, typename TInput&gt; TOutputImageTypePointer 
IOCompute::segmentationCC(TInput input)<br>

    {<br>          typedef   itk::GradientMagnitudeRecursiveGaussianImageFilter&lt; TImageType, TImageType &gt; GradientMagnitudeFilterType;<br>          GradientMagnitudeFilterType::Pointer gradienMagnitudeFilter = GradientMagnitudeFilterType::New();<br>


          gradienMagnitudeFilter-&gt;SetInput( input );<br>          gradienMagnitudeFilter-&gt;SetSigma( 1.0 );<br><br><br>          typedef  itk::WatershedImageFilter&lt; TImageType &gt; WatershedFilterType;<br>          WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();<br>


          watershedFilter-&gt;SetInput( gradienMagnitudeFilter-&gt;GetOutput() );<br>          watershedFilter-&gt;SetThreshold( 0.01 );<br>          watershedFilter-&gt;SetLevel(     0.15 );<br><br>          typedef itk::Functor::ScalarToRGBPixelFunctor&lt; unsigned long &gt; ColorMapFunctorType;<br>


<br>          typedef WatershedFilterType::OutputImageType  LabeledImageType;<br><br>          typedef itk::UnaryFunctorImageFilter&lt;<br>                                        LabeledImageType,<br>                                        TRGBImageType,<br>


                                        ColorMapFunctorType<br>                                                        &gt; ColorMapFilterType;<br><br>          ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();<br>


<br>          colorMapFilter-&gt;SetInput(  watershedFilter-&gt;GetOutput() );<br><br>          TOutputImageTypePointer output = colorMapFilter-&gt;GetOutput();<br>          return output;<br>    }<br><br><br><br>when I use writer-&gt;Update();<br>


I have exception<br><br><br>itk::ExceptionObject (00A3F388)<br>Location:
 &quot;void __thiscall itk::ImageFileWriter&lt;class itk::Image&lt;class 
itk::RGBPixel&lt;unsigned char&gt;,3&gt; &gt;::Write(void)&quot; <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-&gt;UpdateLargestPossibleRegion(); then no exception, but any writter output file :&#39;-(<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>