Declaration
function CompareWith(SecondImage: TIEBitmap; DiffBitmap: TIEBitmap = nil; CheckAlpha: Boolean = False; Coverage: Double = 1.0): Double; overload;
function CompareWith(Rect: TRect; SecondImage: TIEBitmap; SecondImageRect: TRect; DiffBitmap: TIEBitmap = nil; Coverage: Double = 1.0): Double; overload;
Description
Compare the current image with
SecondImage and returns a floating point value (0 to 1) specifying the percentage of equality. 1 means that two images are equal.
The algorithm compares only the intensity of the pixels, not the colors (i.e. grey scale and color versions of the same image will be considered identical).
If CheckAlpha is False it does not take the alpha value of each pixel into account. If CheckAlpha is True it conisders the level of alpha to compare values. A fully transparent pixel will be treated the same as a white pixel.
The DiffBitmap can be nil, otherwise it must be an 8 bit bitmap (ie8g or ie8p PixelFormat) which will contain a bitmap with the differences.
Coverage specifies the percentage of rows that are checked. This is used to speed up processing of very large images at the cost of accuracy. For example, 1.0 checks every row, 0.5 checks every second row, 0.1 every 10th row, 0.01 every 100th row, etc. Generally this options should not be used in combintation with a DiffBitmap, because the resulting image will be incomplete.
Second overload compares only the specified rectangle of the two images (the rects must be the same size).
Notes:
- The images (or image rects if using the second overload) must be the same size (if they are different sizes any pixels outside the common area are ignored)
- It is best if the
PixelFormat of both images are ie24RGB. If they are a different format, performance will be significantly degraded
Demo
| Demos\ImageAnalysis\ImagesDiff\ImagesDiff.dpr |
| Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
Example
Eq := ImageEnView1.CompareWith( ImageEnView2.IEBitmap, nil );
// Compare equality if image contains transparency
Eq := ImageEnView1.CompareWith( ImageEnView2.IEBitmap, nil, True );
See Also
-
CompareHistogramWith-
ComputeImageEquality