IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

linear combination of 2 images, pixel by pixel More...

IPSDKIPLARITHMETIC_API image::ImagePtr ipsdk::imaproc::arithm::linearCombineImgImg (const image::ImageConstPtr &pInImg1, const image::ImageConstPtr &pInImg2, const ipReal32 inFactor1, const ipReal32 inFactor2)
 wrapper function for linear combination of 2 images, pixel by pixel More...
 
IPSDKIPLARITHMETIC_API void ipsdk::imaproc::arithm::linearCombineImgImg (const image::ImageConstPtr &pInImg1, const image::ImageConstPtr &pInImg2, const ipReal32 inFactor1, const ipReal32 inFactor2, const image::ImagePtr &pOutImg)
 wrapper function for linear combination of 2 images, pixel by pixel More...
 

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

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg1 [Input] First image for processing operation X
ipsdk::imaproc::attr::InImg2 [Input] Second image for processing operation X
ipsdk::imaproc::attr::InFactor1 [Input] first factor, used in particular by linear combination algorithm X
ipsdk::imaproc::attr::InFactor2 [Input] second factor, used in particular by linear combination algorithm X
ipsdk::imaproc::attr::OutImg [Output] image for processing operation promoteBinary (_pOutImg, _pInImg1, _pInImg2, ipsdk::imaproc::ePromoteBinaryType::ePBT_UpperSigned)

Global Rule description

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

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

Associated library

IPSDKIPLArithmetic

Header file

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
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);
See also
LinearCombineImgImgLvl1
LinearCombineImgImgLvl2
LinearCombineImgImgLvl3

Function Documentation

◆ linearCombineImgImg() [1/2]

IPSDKIPLARITHMETIC_API image::ImagePtr ipsdk::imaproc::arithm::linearCombineImgImg ( const image::ImageConstPtr pInImg1,
const image::ImageConstPtr pInImg2,
const ipReal32  inFactor1,
const ipReal32  inFactor2 
)

wrapper function for linear combination of 2 images, pixel by pixel

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ linearCombineImgImg() [2/2]

IPSDKIPLARITHMETIC_API void ipsdk::imaproc::arithm::linearCombineImgImg ( const image::ImageConstPtr pInImg1,
const image::ImageConstPtr pInImg2,
const ipReal32  inFactor1,
const ipReal32  inFactor2,
const image::ImagePtr pOutImg 
)

wrapper function for linear combination of 2 images, pixel by pixel

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure