Question

I would like to apply "std filter" with a fixed patch size to a single channel image.
That is I want out[i,j] to equal the std of the pixels values at a neighborhood around img[i,j].

For those of you who are familiar with Matlab, I'm looking for the equivalent of

>> out = nlfilter( img, [P P], @std );

Is there a way to do this using ippi functions?

I came across ippiMean_StdDev but it seems to work for a single window, and not a sliding window (returning a scalar value rather than an array).
I also saw ippiRectStdDev but the manual states this function is for integral images - and I don't see how this applies in my case.

Does anyone has a working example or a more detailed manual for this?

Was it helpful?

Solution

Finally I figured it out.

  1. input image must be in uint8 format
  2. need to allocate 2 buffers (32bit float and 64bit float in my case)
  3. sizes of arrays:
    input size HxW
    filter size, PxP
    result size H-P+1xW-P+1
    intermidate buffers (32f and 64f) sizes H+1xW+1 (note the plus one for integral image boundary!)

    // first, compute integral and sqIntegral image 
    IppiSize sz; sz.width = W; sz.height = H;
    ippiSqrIntegral_8u32f64f_C1R( uint8ImgPtr, W*sizeof(unsigned char), 
        d32ImgPtr, (W+1)*sizeof(float), 
        d64ImgPtr, (W+1)*sizeof(double), 
        sz, 0, 0 );
    // using the integral images compute the std filter result
    IppiRect rect = { 0, 0, P, P };
    IppiSize dsz; dsz.width = W-P+1; dsz.height = H-P+1;
    ippiRectStdDev_32f_C1R( d32ImgPtr, (W+1)*sizeof(float), 
        d64ImgPtr, (W+1)*sizeof(double), 
        dstPtr, (W-P+1)*sizeof(float), dsz, rect );
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top