<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"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></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 <<a href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>> wrote:<br>
<br>
> Hi Anja,<br>
><br>
> You might want to try the AutoCropLabelMapImageFilter:<br>
> <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>
><br>
> HTH<br>
><br>
> Cheers, Dan<br>
><br>
> On 23 September 2013 05:16, Anja Ende <<a href="mailto:anja.ende@googlemail.com">anja.ende@googlemail.com</a>> wrote:<br>
>> Hello,<br>
>><br>
>> Is there a way to auto crop an image along a particular dimension in ITK.<br>
>> So, basically I want to remove all the zero value background rows in an<br>
>> image and adjust the image origin accordingly according to the removed rows.<br>
>><br>
>> Is there an easy way to do this in ITK? Sort of like an auto crop filter?<br>
>><br>
>> Thanks for your help.<br>
>><br>
>> Cheers,<br>
>><br>
>> Anja<br>
>><br>
>> _____________________________________<br>
>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><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><br>
>><br>
>> Kitware offers ITK Training Courses, for more information visit:<br>
>> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><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><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><br>
>><br>
> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><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><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><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><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><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Cheers,<br><br>Anja
</div>