IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Mask filter (one input image)See full documentation
imagemaskImg (inImg,inMaskImg)
imagereverseMaskImg (inImg,inMaskImg)

Detailed Description

Mask filter algorithm, computing an output image for which each pixel equals to either corresponding pixel in input image or 0, depending on whether corresponding input mask image pixel equals 1 or 0.

Compute an output image for which each pixel equals to either corresponding pixel in input image or 0, depending on the corresponding input mask image pixel value.

A call to the maskImg wrappers, the output image values are given by:

\[ OutImg[i] = \begin{cases} InImg[i], & \text{if }InMaskImg[i] \text{ equals } 1 \\ 0, & \text{if } InMaskImg[i] \text{ equals } 0\end{cases} \]

On the contrary, a call to the reverseMaskImg wrappers, the output image values are given by:

\[ OutImg[i] = \begin{cases} 0, & \text{if }InMaskImg[i] \text{ equals } 1 \\ InImg[i], & \text{if } InMaskImg[i] \text{ equals } 0\end{cases} \]

Input, mask and output images must have same size. Input and output image buffers must have same type.

Here is an example of this mask filter applied to one 8-bits grey level image. The upper result is obtained by calling the maskImg wrapper, whereas the lower result corresponds to the reverseMaskImg wrapper :

maskImgExample.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLLogical as logic

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
inMaskImg = PyIPSDK.loadTiffImageFile(inputMaskImgPath)
# mask image computation
outImg = logic.maskImg(inImg, inMaskImg)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLLogical/Processor/MaskImg/MaskImg.h>

Code Example

// open input images
ImageGeometryPtr pImageGeometry = geometry2d(inType, sizeX, sizeY);
ImagePtr pInImg = loadRawImageFile(inPath, *pImageGeometry);
ImageGeometryPtr pMaskImageGeometry = geometry2d(eImageBufferType::eIBT_Binary, sizeX, sizeY);
ImagePtr pInMask = loadRawImageFile(inMaskPath, *pMaskImageGeometry);
// compute mask on input image
ImagePtr pOutImg = maskImg(pInImg, pInMask);