IPSDK 4.1
IPSDK : Image Processing Software Development Kit
Bitwise Subtraction
imagebitwiseSubImgImg (inIntImg1,inIntImg2)

Detailed Description

Subtract two binary image to remove pixels in the image 2 from the image 1.

This algorithm computes a bitwise butraction between two images. The bitwise subtraction is given by the formula :

\[ OutImg[i] = InIntImg1[i] {\land} (\lnot InIntImg2[i]) \]

A Bitwise sub operator applied to 2 integers performs the logical and operation on each pair of corresponding bits of the binary representation of these 2 integers. As shown in the truth table below, the result in each position is 1 if the first bit is 1 and the second bit is 1; otherwise, the result is 0.

Input bit #1 Input bit #2 Output bit :
0 0 0
0 1 0
1 0 1
1 1 0

Here is an example of a Bitwise sub operation applied to two 2D binary images (black pixels have value 0, white pixels have value 1):

bitwiseSubExample.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLLogical as logic

Code Example

# bitwize 'sub' computation
outImg = logic.bitwiseSubImgImg(inImg1, inImg2)

Example of C++ code :

Example informations

Header file

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

Code Example

// Sample with a generated output image
// ------------------------------------
// compute addition of input images
ImagePtr pAutoOutImg = bitwiseSubImgImg(pInImg1, pInImg2);
// Sample with a provided output image
// -----------------------------------
// create output image
ImageGeometryPtr pOutputImageGeometry = geometry2d(eImageBufferType::eIBT_Binary, sizeX, sizeY);
boost::shared_ptr<MemoryImage> pOutImg(boost::make_shared<MemoryImage>());
pOutImg->init(*pOutputImageGeometry);
// compute addition of input images
bitwiseSubImgImg(pInImg1, pInImg2, pOutImg);