Touché. Revising LinearFilter implementation (pcl/LinearFilter.h from line # 183 to line # 196) it is clear that LinearFilter cannot generate a circular filter:
void Initialize( float v0, float v1 )
{
centralValue = v0;
outerValue = v1;
float* h = *coefficients;
if ( h != 0 )
{
int n2 = Size() >> 1;
float dvn2 = (v1 - v0)/n2;
for ( int y = -n2; y <= n2; ++y )
for ( int x = -n2; x <= n2; ++x )
*h++ = v0 + Sqrt( float( x*x + y*y ) ) * dvn2;
}
}
(which, by the way, is a naive, shamelessly unoptimized implementation).
It generates a 2D distribution with central radial symmetry, but in the degenerate case centralValue = outerValue it yields a box average filter, as you correctly understood.
So the bug is actually in my assertion, not in the code that generates a LinearFilter instance. Next time I better read my own documentation before judging your use of PCL classes
![smile :)](http://pixinsight.com/forum/Smileys/default/smile.gif)
Now the problem with separability, or more precisely, with evaluation of separability. I guess the problem here is with the default tolerance value (1e-6). Instead of calling KernelFilter::IsSeparable() and/or KernelFilter::AsSeparableFilter(), try specifying a moderate tolerance value; for example:
LinearFilter filter( 3, 1.0/9, 1.0/9 );
SeparableFilter separable = filter.AsSeparableFilter( 5.0e-06 ); // explicit tolerance value
if ( separable.IsEmpty() )
throw Error( "A box average filter should be identified as separable!" );
Let me know if it works. Anyway, this is now of 'academic' interest only since you can build and use separable filters directly, as I explained in the thread in question (and implemented in your code).
In the next PCL version I'll try to fix these problems by computing an automatic tolerance, based on the singular value decomposition performed to compute separable filter coefficients. Thanks for looking deeply into this.