[Insight-developers] new shrink filter with average value

Bradley Lowekamp blowekamp at mail.nih.gov
Wed Jul 10 08:21:43 EDT 2013


Hi,

I am glad my filter worked for you.

Regarding performance, BinShrinkImageFilter2 was my initial implementation which was derived from the ShrinkImageFilter and usde neighborhood iterators to average a neighborhood. I then created the current BinShrink, where I process the image by accumulated and averaging a row at a time. If I recall this was about ~5X faster, when I was done.  I just changed to the scanline iterator, but I don't recall the speedup, it wasn't as good as some to unary/binary filters, but it was something like 1.5X speedup. I spent a bit of time comparing a variety of options over time since I first implemented the filter, so if it only has a 2X speed up over you initial implementation thats quite a bit better than my first.

The scanline iterator was added to ITK here[1], and has up to a 2-3X speed up over the regular ImageRegionIterator for single threaded unary/binary filters, where the output was pre-allocated. Also note that this changed from reporting progress every pixel to just every scanline also.

The other point to be made about the filter is how the origin is computed as it is deferent than the shrink image filter. Basically, the extent of the first output pixel is aligned with the zero-index input's extent in the origin corner, in such a way that the physical location of the output is preserved and streaming works. This make the filter more suited to certain location based multi-scale analysis and less suited to generating image pyramids when the size of the image isn't evenly divisible by the shrink factor. But this is a detail that would benefit from some figure in a paper.


I would like to move the filter into ITK, but I am suppose to write an InsightJournal article first. I really need to make time for it. At least is very easy to add the filter as  an external or remote module.

Brad

[1] https://github.com/Kitware/ITK/commit/ab29cc59095d7448a1dbf1e09f96947036d2b118

On Jul 10, 2013, at 6:07 AM, Carsten Kendziorra <carsten.kendziorra at charite.de> wrote:

> Hello Brad,
> 
> Thanks for your answer and sorry for the delay!
> 
> Now I've tested your code and the itkBinShrinkImageFilter (not itkBinShrinkImageFilter2) seems to be 2 times faster than mine. And the results are the same.
> So I think I will switch to your filter.
> 
> Do you have an idea how much the impact of the itk::ImageScanlineIterator is, compared to the old iterators?
> 
> And are there plans to implement your filter in ITK? Would be good, since we're probably not the only one who needs this type of filter.
> 
> Thanks again!
> Carsten
> 
> 
> 
> On 06/20/2013 11:31 AM, Bradley Lowekamp wrote:
>> Hello,
>> 
>> Thanks for sharing your work.
>> 
>> The standard way to contribute a new class to ITK it to write an Insight Journal[1] article which describes the algorithm.
>> 
>> Generally these can be started locally as an External module in ITK[2], which can include testing and other needed cmake configuration information. Your code appear to have external dependencies that are not in ITK, and not up to ITK style guidelines[3].
>> 
>> Also, I have also implement a very similar algorithm[2]. I have have extensively tested it to ensure that the physical location of the pixels is maintained and that it's is computationally efficient. I have upgraded to the latest iterators only available in ITK 4.4. Please give the filter a try and let me know how it works for you.
>> 
>> Brad
>> 
>> [1] http://www.insight-journal.org
>> [2] http://www.itk.org/Wiki/ITK/Release_4/New_Code_Contribution_Process#External_Modules
>> [3] http://www.itk.org/Wiki/ITK/Coding_Style_Guide
>> [4] https://github.com/blowekamp/itkBinShrink
>> 
>> 
>> On Jun 20, 2013, at 4:23 AM, Carsten Kendziorra <carsten.kendziorra at charite.de> wrote:
>> 
>>> Sorry, forgot the files.
>>> 
>>> Here they are!
>>> 
>>> On 06/20/2013 09:20 AM, Carsten Kendziorra wrote:
>>>> Hello,
>>>> 
>>>> we've produced a shrink filter, that calculates the output pixel value
>>>> as the average of all corresponding input pixels.
>>>> 
>>>> This is basically a copy of the itkShrinkImageFilter (ITK 4.2.0), with
>>>> modifications in the ThreadedGenerateData() method, where the output
>>>> pixel values are calculated.
>>>> 
>>>> Author: Carsten Kendziorra, Henning Meyer, Marc Dewey. Charite Berlin,
>>>> Germany.
>>>> 
>>>> Maybe you want to include it in ITK.
>>>> 
>>>> Cheers,
>>>> Carsten
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>> 
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>> 
>>>> Kitware offers ITK Training Courses, for more information visit:
>>>> http://kitware.com/products/protraining.php
>>>> 
>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>> 
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.itk.org/mailman/listinfo/insight-developers
>>> <itkShrinkAverageFilter.h><itkShrinkAverageFilter.txx>_______________________________________________
>>> Powered by www.kitware.com
>>> 
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>> 
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://kitware.com/products/protraining.php
>>> 
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>> 
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-developers
> 



More information about the Insight-developers mailing list