IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Smooth an input 2d image computing local mean of pixels. More...

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::meanSmoothing2dImg (const image::ImageConstPtr &pInImg, const ipUInt32 inHalfKnlSizeX, const ipUInt32 inHalfKnlSizeY)
 wrapper function for Mean filter used to blur a 2d image More...
 
IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::meanSmoothing2dImg (const image::ImageConstPtr &pInImg, const ipUInt32 inHalfKnlSizeX, const ipUInt32 inHalfKnlSizeY, const image::ImagePtr &pOutImg)
 wrapper function for Mean filter used to blur a 2d image More...
 

Detailed Description

Smooth an input 2d image computing local mean of pixels.

This low-pass 2d filter, also known as "box blur filter" or "box linear filter", computes for each pixel the average value of its neighboring pixels.

On output image values are given by:

\[ OutImg[x, y] = \dfrac{\sum_{o_y=-n_y}^{n_y}{\sum_{o_x=-n_x}^{n_x}{InImg[x+o_x, y+o_y]}}}{(2n_x+1)(2n_y+1)} \]

where :

Input and output images must have same size.

Here is an example of a Mean smoothing operation applied to an 8-bits grey levels input image (with $InHalfKnlSizeX=InHalfKnlSizeY=7$) :

meanSmoothing2d.png
See also
http://en.wikipedia.org/wiki/Box_blur

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InHalfKnlSizeX [Input] half kernel size along X axis for operation X
ipsdk::imaproc::attr::InHalfKnlSizeY [Input] half kernel size along Y axis for operation X
ipsdk::imaproc::attr::OutOptWk1RealGpuImg [Output Optional] Temporary working image for GPU processes (data contained in image buffer are reals) X
ipsdk::imaproc::attr::OutImg [Output] image for processing operation ipsdk::imaproc::duplicateInOut (_pOutImg, _pInImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSize (_pInImg,_pOutImg)

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLFiltering as filter

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# mean smoothing filter 2d computation
outImg = filter.meanSmoothing2dImg(inImg, 3, 3)

Example of C++ code :

Example informations

Associated library

IPSDKIPLFiltering

Header file

Code Example

// opening input image
ImageGeometryPtr pImageGeometry = geometry2d(imageBufferType, sizeX, sizeY);
boost::shared_ptr<MemoryImage> pInImg(boost::make_shared<MemoryImage>());
pInImg->init(*pImageGeometry);
randomImg(createRange(0, 150), pInImg);
// compute gaussian smoothing on input image
ImagePtr pOutImg = meanSmoothing2dImg(pInImg, inHalfKnlSizeX, inHalfKnlSizeY);
See also
MeanSmoothing2dImgLvl1
MeanSmoothing2dImgLvl2
MeanSmoothing2dImgLvl3

Function Documentation

◆ meanSmoothing2dImg() [1/2]

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::meanSmoothing2dImg ( const image::ImageConstPtr pInImg,
const ipUInt32  inHalfKnlSizeX,
const ipUInt32  inHalfKnlSizeY 
)

wrapper function for Mean filter used to blur a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ meanSmoothing2dImg() [2/2]

IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::meanSmoothing2dImg ( const image::ImageConstPtr pInImg,
const ipUInt32  inHalfKnlSizeX,
const ipUInt32  inHalfKnlSizeY,
const image::ImagePtr pOutImg 
)

wrapper function for Mean filter used to blur a 2d image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure