<DIV>
<DIV>Hi all,</DIV>
<DIV>I had asked this question before unfortunately, and now I am&nbsp;extending it with minor changes, but the problem is&nbsp;still the same. Please give me some clues, ideas, just anything that comes to your mind... </DIV>
<DIV>&nbsp;</DIV>
<DIV>What does it mean</DIV>
<DIV>&nbsp;</DIV>
<DIV>Description: itk::ERROR: PNGImageIO(026955F0): PNG Writer can only write 2-dimen<BR>sional images</DIV>
<DIV>&nbsp;</DIV>
<DIV>And yes&nbsp;I am asking for a 2D image as well ....??</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here is the question: I&nbsp;am trying to use Qt+ITK to test some functions, so&nbsp;I&nbsp;want to define a public filter in Qt's main&nbsp;function which I will use&nbsp;as a&nbsp;buffer&nbsp;to hold my images,&nbsp;but I am getting an exception error (as above).&nbsp;I don't understand if my declerations are wrong, or if only the image writing stage is wrong or else...</DIV>
<DIV>&nbsp;</DIV>
<DIV>The output of my code is:</DIV>
<DIV>&nbsp;</DIV>
<DIV>This program resizes the input file with the following parameters<BR>x starting value: 300<BR>y starting value: 200<BR>x extension&nbsp;&nbsp;&nbsp;&nbsp; : 400<BR>y extension&nbsp;&nbsp;&nbsp;&nbsp; : 400<BR>===========================</DIV>
<DIV>images are cropped</DIV>
<DIV>Image (02685C30)<BR>&nbsp; RTTI typeinfo:&nbsp;&nbsp; class itk::Image&lt;unsigned char,2&gt;<BR>&nbsp; Reference Count: 1<BR>&nbsp; Modified Time: 231<BR>&nbsp; Debug: Off<BR>&nbsp; Observers:<BR>&nbsp;&nbsp;&nbsp; none<BR>&nbsp; Source: (02685D20)<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: 218<BR>&nbsp; UpdateMTime: 232<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, 200]<BR>&nbsp; PixelContainer:<BR>&nbsp;&nbsp;&nbsp; ImportImageContainer
 (02684BE0)<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: 230<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: 02684C10<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 (0109E460)<BR>Location: "Unknown"<BR>File: D:\Esen\C++ STUFF\C++ LIBRARIES\ITK\InsightToolkit-2.0.0\Code\IO\itkPNGIma<BR>geIO.cxx<BR>Line: 395<BR>Description: itk::ERROR: PNGImageIO(026857F0): PNG Writer can only write 2-dimen<BR>sional images</DIV>
<DIV><BR>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>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; </DIV>
<DIV>&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; typedef itk::ImageFileWriter&lt; OutputImageType&gt; WriterTypeGL;</DIV>
<DIV>&nbsp;&nbsp;<BR>&nbsp; FilterType::Pointer filter ;</DIV>
<DIV>&nbsp; WriterTypeGL::Pointer writergl;</DIV>
<DIV>&nbsp;<BR>&nbsp;&nbsp;typedef InputImageType::RegionType RegionType;</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp; // ........</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>writerMoving-&gt;SetInput( cropMoving-&gt;GetOutput() );<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&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 in writing the moving image:" &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; }<BR>&nbsp; </DIV>
<DIV>&nbsp;cout &lt;&lt; "images are cropped \n" &lt;&lt; endl;</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;RegionType regionGL;<BR>&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( cropMoving-&gt;GetOutput());</DIV>
<DIV>&nbsp;</DIV>
<DIV>&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;&nbsp; return -1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;<BR>&nbsp; filter-&gt;GetOutput()-&gt;Print( std::cout );</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;writergl = WriterTypeGL::New();<BR>&nbsp;writergl-&gt;SetFileName( "test.png" );<BR>&nbsp;writergl-&gt;SetInput(filter-&gt;GetOutput());</DIV>
<DIV>&nbsp; try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writergl-&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>return 0;</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>//-------------------------------------------------------------------</DIV>
<DIV>&nbsp;</DIV>
<DIV>If I couldn't express my problem clearly, I am very sorry. I would be glad to send the whole project though...&nbsp;I will really appreciate it a lot if anyone could help me...</DIV>
<DIV>
<DIV>Thanks a lot !</DIV>
<DIV>Seniha</DIV>
<DIV>&nbsp;</DIV>
<DIV>PS: I have an idea that even if I got&nbsp;the previous code working, it will not do the thing I want, or will it? What should I do?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></DIV></DIV><p>
                <hr size=1>Yahoo! Mail for Mobile<br> 
<a href="http://us.rd.yahoo.com/evt=31132/*http://mobile.yahoo.com/learn/mail">Take Yahoo! Mail with you!</a> Check email on your mobile phone.