<div dir="ltr">Thanks guys. In the end, I ended up using the  itkImageSliceConstIteratorWithIndex as I only needed to crop along one dimension and it worked quite well but the solution suggested might be better and I will give it a try.<div>
<br></div><div style>Thanks!</div><div style><br></div><div style>Anja</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 23 September 2013 14:01, Bradley Lowekamp <span dir="ltr">&lt;<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
Another option would be to use the LabelStatisticsImageFilter to get the bounding box:<br>
<a href="http://www.itk.org/Doxygen/html/classitk_1_1LabelStatisticsImageFilter.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1LabelStatisticsImageFilter.html</a><br>
<a href="http://www.itk.org/Doxygen/html/classitk_1_1LabelStatisticsImageFilter.html#a132a7474536f24a7285950353cfe0e3c" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1LabelStatisticsImageFilter.html#a132a7474536f24a7285950353cfe0e3c</a><br>

<br>
Then combine that with the largest possible region to make the itk::ImageRegion you want. And place that into on of these filters:<br>
<br>
<a href="http://www.itk.org/Doxygen/html/classitk_1_1RegionOfInterestImageFilter.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1RegionOfInterestImageFilter.html</a><br>
<a href="http://www.itk.org/Doxygen/html/classitk_1_1CropImageFilter.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1CropImageFilter.html</a><br>
<br>
Brad<br>
<div class="HOEnZb"><div class="h5"><br>
On Sep 22, 2013, at 7:35 PM, Dan Mueller &lt;<a href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>&gt; wrote:<br>
<br>
&gt; Hi Anja,<br>
&gt;<br>
&gt; You might want to try the AutoCropLabelMapImageFilter:<br>
&gt; <a href="http://www.itk.org/Doxygen/html/classitk_1_1AutoCropLabelMapFilter.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1AutoCropLabelMapFilter.html</a><br>
&gt;<br>
&gt; HTH<br>
&gt;<br>
&gt; Cheers, Dan<br>
&gt;<br>
&gt; On 23 September 2013 05:16, Anja Ende &lt;<a href="mailto:anja.ende@googlemail.com">anja.ende@googlemail.com</a>&gt; wrote:<br>
&gt;&gt; Hello,<br>
&gt;&gt;<br>
&gt;&gt; Is there a way to auto crop an image along a particular dimension in ITK.<br>
&gt;&gt; So, basically I want to remove all the zero value background rows in an<br>
&gt;&gt; image and adjust the image origin accordingly according to the removed rows.<br>
&gt;&gt;<br>
&gt;&gt; Is there an easy way to do this in ITK? Sort of like an auto crop filter?<br>
&gt;&gt;<br>
&gt;&gt; Thanks for your help.<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt;<br>
&gt;&gt; Anja<br>
&gt;&gt;<br>
&gt;&gt; _____________________________________<br>
&gt;&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;&gt;<br>
&gt;&gt; Visit other Kitware open-source projects at<br>
&gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;&gt;<br>
&gt;&gt; Kitware offers ITK Training Courses, for more information visit:<br>
&gt;&gt; <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
&gt;&gt;<br>
&gt;&gt; Please keep messages on-topic and check the ITK FAQ at:<br>
&gt;&gt; <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
&gt;&gt;<br>
&gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
&gt;&gt;<br>
&gt; _____________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Kitware offers ITK Training Courses, for more information visit:<br>
&gt; <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the ITK FAQ at:<br>
&gt; <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Cheers,<br><br>Anja
</div>