[Insight-developers] Gaussian filter performance

Paul Yushkevich pauly@cognitica.com
Fri, 09 May 2003 11:33:47 -0400


Thank you, Mark, Josh, Ken, Bill and Luis for your generous answers!

I did miss the fact that the Recursive gaussian is supposed to be 
applied 3 times, so the results that I sent should be tripled for that 
filter. 

I tried playing with the MaxError setting on the Discrete Gaussian 
filter.  Taking it from 0.01 to 0.1 results in about a 2x speedup.  I 
wonder if the MaxError describes the difference between the area under 
the curve of the true Gaussian and the area of the discretized Gaussian 
in one dimension or if the comparison is made in three dimensions. 

I think that the most fair comparison of the different filters would be 
to compute a 'true' Gaussian convolution of an image with a given sigma 
and then to compare results of different filters with different 
error/kernel size settings to the true convolution in terms of max 
error, mean squared error, etc.  Then the times can be compared fairly.  
My apologies for the quick-hack approach.

To give credit to the performance of all three filters, I must say that 
going the FFT-Multiply-RFFT route, which theoretically is an order of 
magnitude faster than brute force convolution seems to be actually 1.5 
orders of magnitude slower for this image.  I tried using a vtkImageFFT 
on a 256x256x256 padded version of the same image, and it took 82,000 
ms.  Again, I used the default settings for that filter.


Luis Ibanez wrote:

>
> Hi Paul,
>
> As Bill pointed out, the RecursiveGaussian applies the blurring only
> in one dimension. When you use it in 3D you need to concatenate three
> of these filters, each blurring along one axis.
>
> Did you do this for your test ?
>
> Otherwise the times may have to be multiplied by 3 (roughtly)...
>
>
> For convenience a filter was recently added for smoothing with the
> recursive gaussians. It just creates a minipipeline with N filters:
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1SmoothingRecursiveGaussianImageFilter.html
> An example is available in Insight/Examples/Filtering.
>
>
> The computing time of the DiscreteGaussian depends on the error
> threshold that you select with SetMaximumError(). This filters adapts
> the kernel size in order to approximate the gaussian to the precision
> required by the user. The lower the threshold, the larger the kernel
> size will be. You can limit how far the kernel can grow by using the
> SetMaximumKernelWidth.
>
> So, the tricky thing here is that there is no "a single" 
> DiscreteGaussian but any number of them, and their performance will
> depend on the precision you select.  The only fair comparision will
> require to figure out the precision of the gaussian approximation in
> the IIR filters of the Recursive gaussian, and then use the same quality
> criterion for the Discrete gaussian. Only then we may be comparing the
> computational burden required for producing a similar output (all this
> with the same sigma, of course).
>
> One factor that you may want to add to the trade-off, is memory
> consumption. The RecursiveGaussians are faster in general, but also
> require N times more memory (N = image dimension) since they concatenate
> N filters.  In the SmoothingRecursiveGaussian filter, the
> ReleaseDataFlag is set ON, so in principle the filters in this case
> will only use one image copy.
>
>
>
>    Luis
>
>
>
> ------------------------
> Paul Yushkevich wrote:
>
>> I have been trying to choose an appropriate Gaussian blurring filter 
>> to use in the SnAP project.  While doing so, I tried to compare the 
>> performance of three candidates from ITK and VTK on a sample image.  
>> The candidates were itk::DiscreteGaussianImageFilter, 
>> itk::RecursiveGaussianImageFilter and vtkImageGaussianSmooth .  I ran 
>> the filters with default parameters, only changing the standard 
>> deviation.
>>
>> Perhaps the result is useful to others, so I post it here.  For one 
>> thing, it shows that the recursive gaussian filter seems to perform 
>> better on even very small sigmas.  What is the error of the recursive 
>> filter w.r.t to the true solution for subpixel values of sigma?
>>
>> The times listed below are for VC6 Release program running on a 
>> two-month old machine.
>>
>> Loaded image     : image01.mha
>> Image size       : 7109137 bytes
>> Image dimensions : 181 x 217 x 181
>> Component count  : 1
>> File type        : Binary
>> File byte order  : Little Endian
>>
>> Standard Deviation: 0.5
>>   ITK Discrete Gaussian   : 3688ms.
>>   ITK Recursive Gaussian  : 515ms.
>>   VTK Gaussian            : 1907ms.
>>
>> Standard Deviation: 1.5
>>   ITK Discrete Gaussian   : 4578ms.
>>   ITK Recursive Gaussian  : 484ms.
>>   VTK Gaussian            : 2281ms.
>>
>> Standard Deviation: 2.5
>>   ITK Discrete Gaussian   : 5672ms.
>>   ITK Recursive Gaussian  : 485ms.
>>   VTK Gaussian            : 2406ms.
>>
>> Standard Deviation: 3.5
>>   ITK Discrete Gaussian   : 7079ms.
>>   ITK Recursive Gaussian  : 500ms.
>>   VTK Gaussian            : 2781ms.
>>
>> Standard Deviation: 4.5
>>   ITK Discrete Gaussian   : 8578ms.
>>   ITK Recursive Gaussian  : 484ms.
>>   VTK Gaussian            : 3078ms.
>>
>> Paul.
>>
>>
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers@public.kitware.com
>> http://public.kitware.com/mailman/listinfo/insight-developers
>>
>
>
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>
>


-- 
--------------------------------
Paul A. Yushkevich, Ph.D.
President, Cognitica Corporation

17 Flemington Rd
Chapel Hill, NC 27517
Tel: 1-919-929-7652
--------------------------------