Declarationfunction CompareWith(SecondImage: TIEBitmap; DiffBitmap: TIEBitmap = nil; CheckAlpha: Boolean = False; Coverage: Double = 1.0; CompareMethod: TIECompareMethod = iecwGrayScale): Double; overload;
function CompareWith(Rect: TRect; SecondImage: TIEBitmap; SecondImageRect: TRect; DiffBitmap: TIEBitmap = nil; Coverage: Double = 1.0; CompareMethod: TIECompareMethod = iecwGrayScale): Double; overload;
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.
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 combination with a DiffBitmap, because the resulting image will be incomplete.
The default Comparison Method
is iecwGrayScale, which compares the intensity of the pixels, not the colors (i.e. grey scale and color versions of the same image will be considered identical). Alternatively you can specify iecwColorMetric which compares colors more similarly to the way humans do.
Second overload compares only the specified rectangle of the two images (the rects must be the same size).
- 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 is ie24RGB. If they are different formats, performance will be significantly degraded
| ||Demos\ImageAnalysis\ImagesDiff\ImagesDiff.dpr |
| ||Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
ExampleEq := ImageEnView1.Proc.CompareWith( ImageEnView2.IEBitmap, nil );
// Compare equality if image contains transparency
Eq := ImageEnView1.Proc.CompareWith( ImageEnView2.IEBitmap, nil, True );
// Compare and show difference in ImageEnView3
ImageEnView3.IEBitmap.PixelFormat := ie8g;
Eq := ImageEnView1.Proc.CompareWith( ImageEnView2.IEBitmap, ImageEnView3.IEBitmap );