Filters an image using the Wiener algorithm.
Case 1: Operation on one-channel images
IppStatus ippiFilterWiener_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize dstRoiSize, IppiSize maskSize, IppiPoint anchor, Ipp32f noise[1], Ipp8u* pBuffer);
Supported values for mod:
8u_C1R | 16s_C1R | 32f_C1R |
Case 2: Operation on multi-channel images
IppStatus ippiFilterWiener_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize dstRoiSize, IppiSize maskSize, IppiPoint anchor, Ipp32f noise[3], Ipp8u* pBuffer);
Supported values for mod:
8u_C3R | 16s_C3R | 32f_C3R |
8u_AC4R | 16s_AC4R | 32f_AC4R |
IppStatus ippiFilterWiener_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize dstRoiSize, IppiSize maskSize, IppiPoint anchor, Ipp32f noise[4], Ipp8u* pBuffer);
Supported values for mod:
8u_C4R | 16s_C4R | 32f_C4R |
pSrc |
Pointer to the source image ROI. |
srcStep |
Distance in bytes between starts of consecutive lines in the source image. |
pDst |
Pointer to the destination image ROI. |
dstStep |
Distance in bytes between starts of consecutive lines in the destination image. |
dstRoiSize |
Size of the source and destination ROI in pixels. |
maskSize |
Size of the mask in pixels. |
anchor |
Anchor cell specifying the mask alignment with respect to the position of the input pixel. |
noise |
Noise level value or array of the noise level values in case of multi-channel image. This value must be in the range [0,1]. |
pBuffer |
Pointer to the external work buffer. |
The function ippiFilterWiener is declared in the ippi.h file. It operates with ROI (see Regions of Interest in Intel IPP). This function performs adaptive filtering of the image degraded by constant power additive noise. For each pixel of the input image pSrc, the function estimates the local image mean μ and variance σ in the rectangular neighborhood (mask) of size maskSize with the anchor cell anchor centered on the pixel. The anchor cell is specified by its coordinates anchor.x and anchor.y in the coordinate system associated with the bottom right corner of the mask.
The following formulas are used in computations:
Here μi,j and σi,j stand for local mean and variance for pixel Xi,j, respectively, and H, W are the vertical and horizontal sizes of the mask, respectively.
The corresponding value for the output pixel Yi,j is computed as:
and stored in the pDst. Here ν2 is the noise variance, specified for each channel by the noise level parameter noise. If this parameter is not defined (noise = 0), then the function estimates the noise level by averaging through the image of all local variances σi,j, and stores the corresponding values in the noise for further use.
The function ippiFilterWiener uses the external work buffer pBuffer, which must be allocated before the function call. To determine the required buffer size, the function ippiFilterWienerGetBufferSize can be used.
Example “Using the Wiener Filter function” shows how to use the function ippiFilterWiener_32f_C1R, result is presentes on Figure “Applying the function ippiFilterWiener”.
ippStsNoErr |
Indicates no error. Any other value indicates an error. |
ippStsNullPtrErr |
Indicates an error condition if one of the specified pointers is NULL. |
ippStsSizeErr |
Indicates an error condition if one of the fields of dstRoiSize has a zero or negative value. |
ippStsMaskSizeErr |
Indicates an error condition if one of the fields of maskSize has a value less than or equal to 1. |
ippStsNoiseRangeErr |
Indicates an error condition if one of the noise values is less than 0 or greater than 1. |
#include "stdio.h" #include "ipp.h" int main() { IppStatus stat = ippStsNoErr; int length = 256*256; Ipp32f pSrc[256*256]; Ipp32f *pSrcW; Ipp32f pDst[256*256]; int srcStep = 256*sizeof(Ipp32f); int dstStep = 256*sizeof(Ipp32f); IppiSize roiSize = {256, 256}; IppiSize maskSize = {3, 3}; IppiSize dstRoiSize = {256-maskSize.width, 256-maskSize.height}; int pBufferSize; int channels = 1; unsigned int pSeed = 3; IppiPoint anchor = {1, 1}; Ipp32f noise[1] = {0.0}; Ipp8u* pBuffer; stat = ippiImageJaehne_32f_C1R(pSrc, srcStep, roiSize); if( stat != ippStsNoErr){ printf (" ERROR !!! \n"); return 1; } stat = ippiFilterWienerGetBufferSize( dstRoiSize, maskSize, channels, &pBufferSize); if( stat != ippStsNoErr ){ printf (" ERROR !!! \n"); return 1; } stat = ippsSet_32f( 1.0, pDst, length ); pBuffer = ippsMalloc_8u(pBufferSize); pSrcW = (Ipp32f*)((Ipp8u*)pSrc + (maskSize.height - 1 - anchor.y ) * srcStep + (maskSize.width - 1 - anchor.x ) * sizeof(Ipp32f) ); stat = ippiFilterWiener_32f_C1R( pSrcW, srcStep, pDst, dstStep, dstRoiSize, maskSize, anchor, noise, pBuffer); if( stat != ippStsNoErr ){ printf (" ERROR !!! \n"); return 1; } ippsFree(pBuffer); return 0; }// __main__
Copyright © 2000 - 2010, Intel Corporation. All rights reserved.