IPSDK 0.2
IPSDK : Image Processing Software Development Kit
CompareResultcompareImg (inImg1,inImg2)
CompareResultcompareImg (inImg1,inImg2,tolerance)

Detailed Description

Algorithm allowing to compare two images.

This algorithm allows to compare two images. Images must have same size and buffer type for comparison.

Through the input parameter InOptImgComparisonTolerance::ToleranceType, the user can choose among several tolerance policies:

The result of the comparison is a data item containing the following attributes:

On output a CompareResult structure is filled.

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLUtility as util

Code Example

# opening of input images
inputGeometry = PyIPSDK.geometry2d(PyIPSDK.eImageBufferType.eIBT_UInt8, 510, 509)
image1 = PyIPSDK.loadRawImageFile(inputImgPath1, inputGeometry)
image2 = PyIPSDK.loadRawImageFile(inputImgPath2, inputGeometry)
# images comparison
compareResult = util.compareImg(image1, image2)
# retrieve comparison results
bEqual = compareResult.bEqual
nbDiff = compareResult.nbDiff
pixCount = compareResult.pixCount

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLUtility/Processor/CompareImg/CompareImg.h>

Code Example

// opening input images
ImageGeometryPtr pImageGeometry = geometry2d(imageBufferType, sizeX, sizeY);
ImagePtr pInImg1 = loadRawImageFile(inputImg1Path, *pImageGeometry);
ImagePtr pInImg2 = loadRawImageFile(inputImg2Path, *pImageGeometry);
// comparison of images
CompareResultPtr pCompareResult = compareImg(pInImg1, pInImg2);
// retrieve comparison results
const bool bEqual = pCompareResult->getValue<CompareResult::BEqual>();
const ipUInt64 nbDiff = pCompareResult->getValue<CompareResult::NbDiff>();
const ipUInt64 pixCount = pCompareResult->getValue<CompareResult::PixCount>();