<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Hello Bill, <br></span></div><div><br><span></span></div><div><span>Thank you very much for your reply. <br></span></div><div><span>Now it worked quite well. <br></span></div><div><br><span></span></div><div><span>Best regards,</span></div><div><span>Abayiz<br></span></div><div><br></div>  <div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"> <div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight: bold;">From:</span></b> Bill Lorensen &lt;bill.lorensen@gmail.com&gt;<br> <b><span style="font-weight: bold;">To:</span></b> Abayiz &lt;abayiz@yahoo.com&gt; <br><b><span style="font-weight: bold;">Cc:</span></b> itk &lt;insight-users@itk.org&gt; <br> <b><span style="font-weight:
 bold;">Sent:</span></b> Monday, November 21, 2011 3:08 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [Insight-users] Image File Writing Error<br> </font> <br>
Place<br>reader-&gt;Update();<br>before<br>size=reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetSize();<br><br>Until the reader is executed, it's output will be empty.<br><br>On Mon, Nov 21, 2011 at 4:04 AM, Abayiz &lt;<a ymailto="mailto:abayiz@yahoo.com" href="mailto:abayiz@yahoo.com">abayiz@yahoo.com</a>&gt; wrote:<br>&gt; Really sorry, there is an error while I was pasting my code, and here it<br>&gt; should be look like:<br>&gt; --------------------------------------------------------<br>&gt; &nbsp;ImageType::SizeType&nbsp; size;<br>&gt; &nbsp; ImageType::RegionType inputRegion;<br>&gt;<br>&gt; &nbsp; size=reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetSize();<br>&gt; &nbsp; inputRegion.SetSize(size);<br>&gt;<br>&gt; inputRegion.SetIndex(someFilter-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetIndex());<br>&gt;<br>&gt; &nbsp; ImageType::Pointer image = ImageType::New();<br>&gt; &nbsp; image-&gt;SetRegions(inputRegion);<br>&gt;
 &nbsp; image-&gt;Allocate();<br>&gt;<br>&gt; &nbsp; VectorIteratorType iterator(someFilter-&gt;GetOutput(),<br>&gt; someFilter-&gt;GetOutput()-&gt;GetRequestedRegion());<br>&gt; &nbsp; IteratorType iterator2(image, image-&gt;GetRequestedRegion());<br>&gt; ...<br>&gt; &nbsp;&nbsp; anotherFilter-&gt;SetInput(image);<br>&gt; ...<br>&gt; &nbsp; writer-&gt;SetInput(anotherFilter-&gt;GetOutput());<br>&gt; &nbsp;try<br>&gt; &nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp; writer-&gt;Update();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt; &nbsp; catch( itk::ExceptionObject &amp; excep )<br>&gt; &nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Exception caught !" &lt;&lt; std::endl;<br>&gt; &nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; excep &lt;&lt; std::endl;<br>&gt; &nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt;<br>&gt;<br>&gt; ________________________________<br>&gt; From: Abayiz &lt;<a ymailto="mailto:abayiz@yahoo.com"
 href="mailto:abayiz@yahoo.com">abayiz@yahoo.com</a>&gt;<br>&gt; To: itk &lt;<a ymailto="mailto:insight-users@itk.org" href="mailto:insight-users@itk.org">insight-users@itk.org</a>&gt;<br>&gt; Sent: Monday, November 21, 2011 10:59 AM<br>&gt; Subject: Image File Writing Error<br>&gt;<br>&gt; Dear all,<br>&gt; I am trying to use region iterator to just copy one image content to<br>&gt; another, and save it. My partial code for this is as follows:<br>&gt; -----------------------<br>&gt; mageType::SizeType&nbsp; size;<br>&gt; &nbsp; ImageType::RegionType inputRegion;<br>&gt;<br>&gt; &nbsp; size=reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetSize();<br>&gt; &nbsp; inputRegion.SetSize(size);<br>&gt;<br>&gt; inputRegion.SetIndex(someFilter-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetIndex());<br>&gt;<br>&gt; &nbsp; ImageType::Pointer image = ImageType::New();<br>&gt; &nbsp; image-&gt;SetRegions(inputRegion);<br>&gt; &nbsp;
 image-&gt;Allocate();<br>&gt;<br>&gt; &nbsp; VectorIteratorType iterator(someFilter-&gt;GetOutput(),<br>&gt; gradientMagnitude-&gt;GetOutput()-&gt;GetRequestedRegion());<br>&gt; &nbsp; IteratorType iterator2(image, image-&gt;GetRequestedRegion());<br>&gt; ...<br>&gt; &nbsp;&nbsp; anotherFilter-&gt;SetInput(image);<br>&gt; ...<br>&gt; &nbsp; writer-&gt;SetInput(anotherFilter-&gt;GetOutput());<br>&gt; &nbsp;try<br>&gt; &nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp; writer-&gt;Update();<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt; &nbsp; catch( itk::ExceptionObject &amp; excep )<br>&gt; &nbsp;&nbsp;&nbsp; {<br>&gt; &nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Exception caught !" &lt;&lt; std::endl;<br>&gt; &nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; excep &lt;&lt; std::endl;<br>&gt; &nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt; -----------------------<br>&gt; And, it gives out the following error:<br>&gt; ----------------------<br>&gt; Description: itk::ERROR:
 ImageFileWriter(0x26d6df0): Largest possible region<br>&gt; does not fully contain requested paste IO regionPaste IO region:<br>&gt; ImageIORegion (0x7fff8ddb7c90)<br>&gt; &nbsp; Dimension: 3<br>&gt; &nbsp; Index: 0 0 0<br>&gt; &nbsp; Size: 0 0 0<br>&gt; Largest possible region: ImageRegion (0x7fff8ddb7d90)<br>&gt; &nbsp; Dimension: 3<br>&gt; &nbsp; Index: [0, 0, 0]<br>&gt; &nbsp; Size: [0, 0, 0]<br>&gt; -----------------------<br>&gt; I've searched the internet, but couldn't solve it yet. Could anyone give any<br>&gt; suggestions?<br>&gt; Thanks in advance.<br>&gt; Abayiz<br>&gt;<br>&gt;<br>&gt;<br>&gt; _____________________________________<br>&gt; Powered by <a target="_blank" href="http://www.kitware.com">www.kitware.com</a><br>&gt;<br>&gt; Visit other Kitware open-source projects at<br>&gt; http://www.kitware.com/opensource/opensource.html<br>&gt;<br>&gt; Kitware offers ITK Training Courses, for more information visit:<br>&gt;
 http://www.kitware.com/products/protraining.html<br>&gt;<br>&gt; Please keep messages on-topic and check the ITK FAQ at:<br>&gt; http://www.itk.org/Wiki/ITK_FAQ<br>&gt;<br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; http://www.itk.org/mailman/listinfo/insight-users<br>&gt;<br>&gt;<br><br><br><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br><br> </div> </div>  </div></body></html>