IPSDK 4.1
IPSDK : Image Processing Software Development Kit
Linear combination
imagelinearCombineImgImg (inImg1,inImg2,inFactor1,inFactor2)

Detailed Description

linear combination of 2 images, pixel by pixel

On output image values are given by:

\[ OutImg[i] = saturatedResultOf(inFactor1*InImg1[i] + inFactor2*InImg2[i]) \]

(with $inFactor1$ and $inFactor2$ the constant scalar parameters of the linear combination; $inFactor1$ and $inFactor2$ are encoded on ipReal32

$saturatedResultOf$ means that, if the result of $inFactor1*InImg1[i] + inFactor2*InImg2[i]$ is out of the range of OutImg buffer data type, then OutImg[i] equals to the limit of this range that is closest to this result.

Input and output images must have same size.

Here is an example of a linear combination applied to two 8-bits grey level images, with inFactor1=1.0f and inFactor2=-0.5f:

linearCombineImgImg.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLArithmetic as arithm

Code Example

# opening input images
geometry = PyIPSDK.geometry2d(PyIPSDK.eImageBufferType.eIBT_Real32, 510, 509)
inImg1 = PyIPSDK.loadRawImageFile(inputImg1Path, geometry)
inImg2 = PyIPSDK.loadRawImageFile(inputImg2Path, geometry)
# linear combination of the two input images
outImg = arithm.linearCombineImgImg(inImg1, inImg2, 0.4, 0.6)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLArithmetic/Processor/LinearCombineImgImg/LinearCombineImgImg.h>

Code Example

// open input images
ImageGeometryPtr pIn1ImageGeometry = geometry2d(bufIn1Type, sizeX, sizeY);
ImageGeometryPtr pIn2ImageGeometry = geometry2d(bufIn2Type, sizeX, sizeY);
ImagePtr pInImg1 = loadRawImageFile(input1ImgPath, *pIn1ImageGeometry);
ImagePtr pInImg2 = loadRawImageFile(input2ImgPath, *pIn2ImageGeometry);
// Sample with a generated output image
// ------------------------------------
// compute addition of input images
ImagePtr pAutoOutImg = linearCombineImgImg(
pInImg1,
pInImg2,
inFactor1,
inFactor2);
// Sample with a provided output image
// ----------------------------------
// create output image
ImageGeometryPtr pOutputImageGeometry =
geometry2d(bufOutType, sizeX, sizeY);
boost::shared_ptr<MemoryImage> pOutImg(boost::make_shared<MemoryImage>());
pOutImg->init(*pOutputImageGeometry);
// compute addition of input images
linearCombineImgImg(pInImg1, pInImg2, inFactor1, inFactor2, pOutImg);