IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

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. More...

IPSDKIPLLOGICAL_API void ipsdk::imaproc::logic::maskImg (const image::ImageConstPtr &pInImg, const image::ImageConstPtr &pInMaskImg, const image::ImagePtr &pOutImg)
 wrapper function for Mask filter, 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. These wrappers allow to set an output pixel with the input image value if the mask pixel equals 1 and 0 otherwise. More...
 
IPSDKIPLLOGICAL_API image::ImagePtr ipsdk::imaproc::logic::maskImg (const image::ImageConstPtr &pInImg, const image::ImageConstPtr &pInMaskImg)
 wrapper function for Mask filter, 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. These wrappers allow to set an output pixel with the input image value if the mask pixel equals 1 and 0 otherwise. More...
 
IPSDKIPLLOGICAL_API void ipsdk::imaproc::logic::reverseMaskImg (const image::ImageConstPtr &pInImg, const image::ImageConstPtr &pInMaskImg, const image::ImagePtr &pOutImg)
 wrapper function for Mask filter, 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. Unlike the maskImg wrapper, the reverseMaskImg wrappers allow to set an output pixel to 0 if the mask pixel equals 1 and with the input image value otherwise. More...
 
IPSDKIPLLOGICAL_API image::ImagePtr ipsdk::imaproc::logic::reverseMaskImg (const image::ImageConstPtr &pInImg, const image::ImageConstPtr &pInMaskImg)
 wrapper function for Mask filter, 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. Unlike the maskImg wrapper, the reverseMaskImg wrappers allow to set an output pixel to 0 if the mask pixel equals 1 and with the input image value otherwise. More...
 

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

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InMaskImg [Input] Binary image for masking operation X
ipsdk::imaproc::attr::InOptMaskMode [Input Optional] Inform about the use of a binary mask X
ipsdk::imaproc::attr::OutImg [Output] image for processing operation ipsdk::imaproc::duplicateInOut (_pOutImg, _pInImg)

Global Rule description

Global rule description for algorithm :
(ipsdk::processor::If (
  ipsdk::imaproc::is2d (_pInMaskImg),
  ipsdk::imaproc::matchSize (eMatchImageSizeType::eMIST_2d,_pInImg,_pInMaskImg),
  ipsdk::imaproc::matchSize (eMatchImageSizeType::eMIST_3d,_pInImg,_pInMaskImg))) && 
ipsdk::imaproc::matchSize (_pInImg,_pOutImg) && 
ipsdk::imaproc::matchBufferType (_pInImg,_pOutImg)

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

Associated library

IPSDKIPLLogical

Header file

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);
See also
MaskImgLvl1
MaskImgLvl3

Function Documentation

◆ maskImg() [1/2]

IPSDKIPLLOGICAL_API void ipsdk::imaproc::logic::maskImg ( const image::ImageConstPtr pInImg,
const image::ImageConstPtr pInMaskImg,
const image::ImagePtr pOutImg 
)

wrapper function for Mask filter, 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. These wrappers allow to set an output pixel with the input image value if the mask pixel equals 1 and 0 otherwise.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ reverseMaskImg() [1/2]

IPSDKIPLLOGICAL_API void ipsdk::imaproc::logic::reverseMaskImg ( const image::ImageConstPtr pInImg,
const image::ImageConstPtr pInMaskImg,
const image::ImagePtr pOutImg 
)

wrapper function for Mask filter, 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. Unlike the maskImg wrapper, the reverseMaskImg wrappers allow to set an output pixel to 0 if the mask pixel equals 1 and with the input image value otherwise.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ maskImg() [2/2]

IPSDKIPLLOGICAL_API image::ImagePtr ipsdk::imaproc::logic::maskImg ( const image::ImageConstPtr pInImg,
const image::ImageConstPtr pInMaskImg 
)

wrapper function for Mask filter, 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. These wrappers allow to set an output pixel with the input image value if the mask pixel equals 1 and 0 otherwise.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ reverseMaskImg() [2/2]

IPSDKIPLLOGICAL_API image::ImagePtr ipsdk::imaproc::logic::reverseMaskImg ( const image::ImageConstPtr pInImg,
const image::ImageConstPtr pInMaskImg 
)

wrapper function for Mask filter, 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. Unlike the maskImg wrapper, the reverseMaskImg wrappers allow to set an output pixel to 0 if the mask pixel equals 1 and with the input image value otherwise.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure