How to Use the IPP Image Filter Function

IPP image processing domain covers many kinds of operation that are widely used in image processing, video edition, human-computer interface and so on. Chief among these functions are filter function. The article show some tips about how to use ipp image filter function.

1.  Choose a Filter function for your application.
     All IPP filter funtions are listed in ipp manual ippi.pdf => chapter 9 Filtering Function.

2.  Call the Filter function in your code. 
    there is some example provided in manual. For example, 
    The Example 9-1 illustrates the use of the ippiFilterMin function
    The Example 9-3 illustrates median filtering.
    The Example 9-4 Using the Function ippiFilterColumn.
    Please Note: there is code error in the Example 9-4 in current manual. 
    The code should be modified as 
    Ipp8u src[4*5] = {
                              1, 2, 3, 4,
                              1, 2, 3, 4,
                              1, 2, 3, 4,
                              1, 2, 3, 4,
                              1, 2, 3, 4
    and the result are 0.

    Use the Filter function, we may need take care of two things, 
    First,  Image Border:  all IPP filter functions assume that each pixel being processed, including the all referred 
    neighborhood pixels necessary for the operation are available. So either trim the input buffer or add border to input  
    buffer is required. 

    There is one article talking about it, 

    Secondly, stepBytes: it is the distance in bytes of image row. It depends on your array memory layout and data
    type.  In most of case, it is equal to the image Width*sizeof(datatype)*Channel.  But sometimes, it is not, especially for
    bmp image, which required 4 bytes aligns, may pad zero at the end of row. So it may be
    Here is a small C++ code for call ippiFilterColumn

#include <stdio.h>
#include <stdlib.h>
#include <ipp.h>

int main()

     int nRow = 200;
     int nCol = 655;
     int nCount = nRow * nCol;

     Ipp16s *temp = (Ipp16s *)malloc(nCount * sizeof(Ipp16s));
     Ipp16s *temp2 = (Ipp16s *)malloc(nCount * sizeof(Ipp16s));

     Ipp32s fKernel[] = {1, 2, -3};
     int nAnchor = 1;  // please notes, if it is 1 , then it required border at the top of image.
     int nKernelSize = 3;
     int divisor = 2;

     IppiSize dstRoiSize2 = {nCol, nRow - 2};

     // please note, the step is width*sizeof(Ipp16s)    
     IppStatus b = ippiFilterColumn_16s_C1R((Ipp16s*)temp + nCol, nCol*sizeof(Ipp16s), (Ipp16s*)temp2 + nCol, 
     dstRoiSize2, (Ipp32s*)fKernel, nKernelSize, nAnchor,divisor );

     printf ("%d: %s\n", b, ippGetStatusString(b));
     printf ("the step is %d\n", nCol*sizeof(Ipp16s));
     return 0;

3.  Compile and link ipp library
     please refer to How to Build an Intel IPP Application

For more complete information about compiler optimizations, see our Optimization Notice.