[Insight-users] Computing statistics on a region of an image

Bradley Lowekamp blowekamp at mail.nih.gov
Tue Jun 5 09:39:28 EDT 2012


Hello,

Writing streaming filters is rather complicated and having section 13.3 of the software guide open is quite useful.

On Jun 5, 2012, at 5:15 AM, Cyrille Faucheux wrote:

> Hum, too heavy for me.
> 
> So, in my filter that computes the statistics on a region of an image, I've declared a function to specify the region to process. This filter extends ProcessObject. It works.
> 
> To do things right, do I need to override GenerateInputRequestedRegion() (which by default, set the requested region to the largest possible region). Logically, I do.

This is a very common thing to do, and there are example all over the tool-kit, it's still can be tricky to get just right.


> 
> But...
> 
> This filter may later also be used in a composite filter, whose purpose is to compute for each pixel on an image statistics on a region centered on this pixel. This filter will generate a VectorImage, so it will extend ImageToImageFilter, and will automatically take advantage of the streaming mecanism (through the output of the filter, which is an image, and has a requested region). But since my filter that is inside the composite one will specify for each processed pixel a new requested region, I have the impression that something is wrong (since the region processed by the composite filter is still the region specified by the output image).

Composite filter are surprisingly tricky to implement. It sounds like you are proposing that for each file you are setting a requested region, and updating a mini-pipeline. This is not advise able and very in efficient. 

I don't think I will be able to figure out the problem from your description.

I have implemented something similar to what it sounds like you are trying to do. I have been hoping to get time polish up the code and to write an Insight Journal article on it, but been too busy. Please look at the ImageFilters here, to get ideas for alternative is how to write a filter to compute local neighborhood statistics:

https://github.com/blowekamp/itkTextureAnalysis/tree/master/include


> 
> Do I still need to have the first filter propagating the requested region ?
> 
> Thanks
> 
> Cyrille
> 
> Le 29/05/2012 02:11, Luis Ibanez a écrit :
> Hi Cyrille,
> 
> 
> mm, not quite the way to you describe it,...
> 
> but,... 
> 
> I'm wondering if you may find useful the
> Label Statistics image filter, 
> 
> 
> that will compute statistics from an image 
> by segregating them according to the labels
> of another image.
> 
> You could then do this in parallel, if you
> happen to mark your regions with lablels
> in advance.
> 
> 
> You have this one:
> http://www.itk.org/Doxygen/html/classitk_1_1LabelStatisticsImageFilter_1_1LabelStatistics.html
> 
> 
> and this one:
> http://www.itk.org/Doxygen/html/itkLabelImageToStatisticsLabelMapFilter_8h_source.html
> 
> 
> 
>       Luis
> 
> 
> ----------------------------------
> On Mon, May 21, 2012 at 6:59 AM, Cyrille Faucheux <cyrille.faucheux at etu.univ-tours.fr> wrote:
> Hi,
> 
> I want to compute statistics (lets say for example, an histogram) on a region of an image.
> 
> With an ImageToImageFilter, I know I have to specify the requested region at the end of my pipeline, and everything gets magically propagated upstream through the pipeline.
> 
> Is there a generic way of doing this with a filter that do not produce an image, or should the filter handle the region of interest "manually" (with internal region iterators) ?
> 
> Note: I dont want to use a RegionOfInterestImageFilter nor an ExtractImageFilter because it's too heavy (because later I will need to compute lots of statistics on lots of tiny region of my image).
> 
> Thanks in advance.
> 
> Cyrille
> _____________________________________
> 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://www.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-users
> 
> _____________________________________
> 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://www.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-users

========================================================
Bradley Lowekamp  
Medical Science and Computing for
Office of High Performance Computing and Communications
National Library of Medicine 
blowekamp at mail.nih.gov



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120605/5b674b0e/attachment.htm>


More information about the Insight-users mailing list