<DIV>
<DIV>Hi all,</DIV>
<DIV>I want to define a public filter in my function which I will use&nbsp;as a&nbsp;buffer&nbsp;to hold my images,&nbsp;but I am getting an exception error. Actually even before the exception error, I can see that the&nbsp;&nbsp;output of the filter is empty,&nbsp;which makes me think that I am defining the RegionType&nbsp;in a wrong way -- could you please particularly look at that and tell me if it is correct?&nbsp;&nbsp; I am copying parts of the code below from the header file and the c++ file. </DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV>//------------------------------------------------------------------------------</DIV></DIV>
<DIV>//part of the code from my .h file:</DIV>
<DIV>
<DIV>//------------------------------------------------------------------------------</DIV>
<DIV>&nbsp;</DIV></DIV>
<DIV>public:</DIV>
<DIV>&nbsp;</DIV>
<DIV>//&nbsp;........</DIV>
<DIV>&nbsp;</DIV>
<DIV>//===================<BR>//My ITK Object Pointers<BR>//===================<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; typedef int integer;<BR>&nbsp; typedef unsigned short&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PixelType;</DIV>
<DIV>&nbsp; typedef&nbsp; unsigned char&nbsp; InputPixelType;<BR>&nbsp; typedef&nbsp; unsigned char&nbsp; OutputPixelType;<BR>&nbsp; typedef itk::Image&lt; InputPixelType,&nbsp; 2 &gt;&nbsp;&nbsp; InputImageType;<BR>&nbsp; typedef itk::Image&lt; OutputPixelType, 2 &gt;&nbsp;&nbsp; OutputImageType;<BR>&nbsp; typedef itk::RegionOfInterestImageFilter&lt;InputImageType, OutputImageType &gt;&nbsp; FilterType;<BR>&nbsp;&nbsp;typedef itk::ImageFileWriter&lt; OutputImageType&gt; WriterTypeGL;</DIV>
<DIV><BR>&nbsp; FilterType::Pointer filter; <BR>&nbsp; WriterTypeGL::Pointer writergl;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;InputImageType::RegionType regionGL;</DIV>
<DIV>// ........</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>//------------------------------------------------------------------------------</DIV>
<DIV>//-------------------- part of my c++ code --------------------------</DIV>
<DIV>&nbsp;</DIV>
<DIV>int FrontDialog::CropImage(){</DIV>
<DIV>&nbsp;</DIV>
<DIV>//...........................</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;writerMoving-&gt;SetFileName( output.c_str() );<BR>&nbsp;writerMoving-&gt;SetInput( cropMoving-&gt;GetOutput() );<BR>&nbsp;try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writerMoving-&gt;Update();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp; catch (itk::ExceptionObject &amp;err)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout&lt;&lt; "Exception caught:" &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout&lt;&lt; err &lt;&lt;std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>//here I definitely know that cropMoving-&gt;GetOutput()&nbsp; gives correct results</DIV>
<DIV>//because I am able to save it as an image. However, I also want to save it in a</DIV>
<DIV>//public variable to use over and over.</DIV>
<DIV>&nbsp;</DIV>
<DIV>//here comes the part which fails:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;regionGL.SetSize(Width, Height);<BR>&nbsp;regionGL.SetIndex(0,0);</DIV>
<DIV><BR>&nbsp;filter = FilterType::New();<BR>&nbsp;filter-&gt;SetRegionOfInterest(regionGL);<BR>&nbsp;filter-&gt;SetInput( crop-&gt;GetOutput());<BR>&nbsp;try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;filter-&gt;Update();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp; catch (itk::ExceptionObject &amp;err)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout&lt;&lt; "Exception caught:" &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout&lt;&lt; err &lt;&lt;std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV><BR>&nbsp;filter-&gt;GetOutput()-&gt;Print( std::cout );</DIV>
<DIV>&nbsp;</DIV>
<DIV>//.............</DIV>
<DIV>return 0;</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>//-------------------------------------------------------------------</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV>I spent too much time to figure out this problem but I am now clueless on what to do. The output of the exe&nbsp;file is as below.&nbsp;&nbsp;I will really appreciate it a lot if anyone could help me...</DIV>
<DIV>Thanks a lot in advance,</DIV>
<DIV>Seniha</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>This program resizes the input file with the following parameters<BR>x starting value: 300<BR>y starting value: 300<BR>x extension&nbsp;&nbsp;&nbsp;&nbsp; : 200<BR>y extension&nbsp;&nbsp;&nbsp;&nbsp; : 200<BR>===========================</DIV>
<DIV>images are cropped</DIV>
<DIV>Image (02695AA0)<BR>&nbsp; RTTI typeinfo:&nbsp;&nbsp; class itk::Image&lt;unsigned char,2&gt;<BR>&nbsp; Reference Count: 1<BR>&nbsp; Modified Time: 236<BR>&nbsp; Debug: Off<BR>&nbsp; Observers:<BR>&nbsp;&nbsp;&nbsp; none<BR>&nbsp; Source: (02695B90)<BR>&nbsp; Source output index: 0<BR>&nbsp; Release Data: Off<BR>&nbsp; Data Released: False<BR>&nbsp; Global Release Data: Off<BR>&nbsp; PipelineMTime: 222<BR>&nbsp; UpdateMTime: 237<BR>&nbsp; LargestPossibleRegion:<BR>&nbsp;&nbsp;&nbsp; Dimension: 2<BR>&nbsp;&nbsp;&nbsp; Index: [0, 0]<BR>&nbsp;&nbsp;&nbsp; Size: [0, 0]<BR>&nbsp; BufferedRegion:<BR>&nbsp;&nbsp;&nbsp; Dimension: 2<BR>&nbsp;&nbsp;&nbsp; Index: [0, 0]<BR>&nbsp;&nbsp;&nbsp; Size: [0, 0]<BR>&nbsp; RequestedRegion:<BR>&nbsp;&nbsp;&nbsp; Dimension: 2<BR>&nbsp;&nbsp;&nbsp; Index: [0, 0]<BR>&nbsp;&nbsp;&nbsp; Size: [0, 0]<BR>&nbsp; Spacing: [1, 1]<BR>&nbsp; Origin: [300, 300]<BR>&nbsp; PixelContainer:<BR>&nbsp;&nbsp;&nbsp; ImportImageContainer
 (02694BE0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTTI typeinfo:&nbsp;&nbsp; class itk::ImportImageContainer&lt;unsigned long,unsigned ch<BR>ar&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Reference Count: 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Modified Time: 235<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug: Off<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Observers:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; none<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pointer: 02694C10<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Container manages memory: true<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Size: 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Capacity: 0<BR>Exception caught:</DIV>
<DIV>itk::ExceptionObject (0109E4C0)<BR>Location: "Unknown"<BR>File: C:\ITK\InsightToolkit-2.0.0\InsightToolkit-2.0.0\Code\IO\itkPNGImageIO.cxx</DIV>
<DIV>Line: 395<BR>Description: itk::ERROR: PNGImageIO(026955F0): PNG Writer can only write 2-dimen<BR>sional images</DIV>
<DIV><BR>&nbsp;</DIV></DIV></DIV><BR><BR><DIV>Seniha Esen Yuksel <BR>Research Assistant <BR>Computer Vision and Image Processing Lab, <BR>Lutz Hall Rm 414, <BR>University of Louisville, <BR>Louisville, KY <BR>work ph: 502- 8521528 <BR>home ph: 502- 8549856 <BR>email: esen@cvip.uofl.edu // esenyuksel@ieee.org <BR>web: <A href="http://www.cvip.louisville.edu/~esen/">http://www.cvip.louisville.edu/~esen/</A></DIV><p>__________________________________________________<br>Do You Yahoo!?<br>Tired of spam?  Yahoo! Mail has the best spam protection around <br>http://mail.yahoo.com