Open CASCADE Technology
6.9.0
|
This class compares two images pixel-by-pixel. It uses the following methods to ignore the difference between images: More...
#include <Image_Diff.hxx>
Public Member Functions | |
Image_Diff () | |
An empty constructor. Init() should be called for initialization. More... | |
virtual | ~Image_Diff () |
Desctructor. More... | |
Standard_Boolean | Init (const Handle< Image_PixMap > &theImageRef, const Handle< Image_PixMap > &theImageNew, const Standard_Boolean theToBlackWhite=Standard_False) |
Initialize algorithm by two images. More... | |
Standard_Boolean | Init (const TCollection_AsciiString &theImgPathRef, const TCollection_AsciiString &theImgPathNew, const Standard_Boolean theToBlackWhite=Standard_False) |
Initialize algorithm by two images (will be loaded from files). More... | |
void | SetColorTolerance (const Standard_Real theTolerance) |
Color tolerance for equality check. Should be within range 0..1: Corresponds to a difference between white and black colors (maximum difference). By default, the tolerance is equal to 0 thus equality check will return false for any different colors. More... | |
Standard_Real | ColorTolerance () const |
Color tolerance for equality check. More... | |
void | SetBorderFilterOn (const Standard_Boolean theToIgnore) |
Sets taking into account (ignoring) a "border effect" on comparison of images. The border effect is caused by a border of shaded shapes in the viewer 3d. Triangles of this area are located at about 0 or 90 degrees to the user. Therefore, they deflect light differently according to implementation of a video card driver. This flag allows to detect such a "border" area and skip it from comparison of images. Filter turned OFF by default. More... | |
Standard_Boolean | IsBorderFilterOn () const |
Returns a flag of taking into account (ignoring) a border effect in comparison of images. More... | |
Standard_Integer | Compare () |
Compares two images. It returns a number of different pixels (or groups of pixels). It returns -1 if algorithm not initialized before. More... | |
Standard_Boolean | SaveDiffImage (Image_PixMap &theDiffImage) const |
Saves a difference between two images as white pixels on black backgroud. More... | |
Standard_Boolean | SaveDiffImage (const TCollection_AsciiString &theDiffPath) const |
Saves a difference between two images as white pixels on black backgroud. More... | |
Public Member Functions inherited from Standard_Transient | |
Standard_Transient () | |
Empty constructor. More... | |
Standard_Transient (const Standard_Transient &) | |
Copy constructor – does nothing. More... | |
Standard_Transient & | operator= (const Standard_Transient &) |
Assignment operator, needed to avoid copying reference counter. More... | |
virtual | ~Standard_Transient () |
Destructor must be virtual. More... | |
virtual void | Delete () const |
Memory deallocator for transient classes. More... | |
virtual const Handle_Standard_Type & | DynamicType () const |
Returns a type information object about this object. More... | |
Standard_Boolean | IsInstance (const Handle_Standard_Type &theType) const |
Returns a true value if this is an instance of Type. More... | |
Standard_Boolean | IsInstance (const Standard_CString theTypeName) const |
Returns a true value if this is an instance of TypeName. More... | |
Standard_Boolean | IsKind (const Handle_Standard_Type &theType) const |
Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More... | |
Standard_Boolean | IsKind (const Standard_CString theTypeName) const |
Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More... | |
virtual Handle_Standard_Transient | This () const |
Returns a Handle which references this object. Must never be called to objects created in stack. More... | |
Standard_Integer | GetRefCount () const |
Get the reference counter of this object. More... | |
Protected Types | |
typedef NCollection_List < TColStd_MapOfInteger * > | ListOfMapOfInteger |
Protected Member Functions | |
Standard_Integer | ignoreBorderEffect () |
Perform border filter algorithm. More... | |
void | releaseGroupsOfDiffPixels () |
Release dynamically allocated memory. More... | |
Protected Attributes | |
Handle< Image_PixMap > | myImageRef |
reference image to compare (from) More... | |
Handle< Image_PixMap > | myImageNew |
new image to compare (to) More... | |
Standard_Real | myColorTolerance |
tolerance for equality check (0..1, 0 - any not equal, 1 - opposite colors) More... | |
Standard_Boolean | myIsBorderFilterOn |
perform algorithm with border effect filter More... | |
ListOfMapOfInteger | myGroupsOfDiffPixels |
NCollection_Vector< Standard_Size > | myDiffPixels |
different pixels (position packed into integer) More... | |
TColStd_MapOfInteger | myLinearGroups |
This class compares two images pixel-by-pixel. It uses the following methods to ignore the difference between images:
Border filter ignores a difference in implementation of anti-aliasing and other effects on boundary of a shape. The triangles of a boundary zone are usually located so that their normals point aside the user (about 90 degree between the normal and the direction to the user's eye). Deflection of the light for such a triangle depends on implementation of the video driver. In order to skip this difference the following algorithm is used: a) "Different" pixels are groupped and checked on "one-pixel width line". indeed, the pixels may represent not a line, but any curve. But the width of this curve should be not more than a pixel. This group of pixels become a candidate to be ignored because of boundary effect. b) The group of pixels is checked on belonging to a "shape". Neighbour pixels are checked from the reference image. This test confirms a fact that the group of pixels belongs to a shape and represent a boundary of the shape. In this case the whole group of pixels is ignored (considered as same). Otherwise, the group of pixels may represent a geometrical curve in the viewer 3D and should be considered as "different".
References:
|
protected |
Image_Diff::Image_Diff | ( | ) |
An empty constructor. Init() should be called for initialization.
|
virtual |
Desctructor.
Standard_Real Image_Diff::ColorTolerance | ( | ) | const |
Color tolerance for equality check.
Standard_Integer Image_Diff::Compare | ( | ) |
Compares two images. It returns a number of different pixels (or groups of pixels). It returns -1 if algorithm not initialized before.
|
protected |
Perform border filter algorithm.
Standard_Boolean Image_Diff::Init | ( | const Handle< Image_PixMap > & | theImageRef, |
const Handle< Image_PixMap > & | theImageNew, | ||
const Standard_Boolean | theToBlackWhite = Standard_False |
||
) |
Initialize algorithm by two images.
Standard_Boolean Image_Diff::Init | ( | const TCollection_AsciiString & | theImgPathRef, |
const TCollection_AsciiString & | theImgPathNew, | ||
const Standard_Boolean | theToBlackWhite = Standard_False |
||
) |
Initialize algorithm by two images (will be loaded from files).
Standard_Boolean Image_Diff::IsBorderFilterOn | ( | ) | const |
Returns a flag of taking into account (ignoring) a border effect in comparison of images.
|
protected |
Release dynamically allocated memory.
Standard_Boolean Image_Diff::SaveDiffImage | ( | Image_PixMap & | theDiffImage | ) | const |
Saves a difference between two images as white pixels on black backgroud.
Standard_Boolean Image_Diff::SaveDiffImage | ( | const TCollection_AsciiString & | theDiffPath | ) | const |
Saves a difference between two images as white pixels on black backgroud.
void Image_Diff::SetBorderFilterOn | ( | const Standard_Boolean | theToIgnore | ) |
Sets taking into account (ignoring) a "border effect" on comparison of images. The border effect is caused by a border of shaded shapes in the viewer 3d. Triangles of this area are located at about 0 or 90 degrees to the user. Therefore, they deflect light differently according to implementation of a video card driver. This flag allows to detect such a "border" area and skip it from comparison of images. Filter turned OFF by default.
void Image_Diff::SetColorTolerance | ( | const Standard_Real | theTolerance | ) |
Color tolerance for equality check. Should be within range 0..1: Corresponds to a difference between white and black colors (maximum difference). By default, the tolerance is equal to 0 thus equality check will return false for any different colors.
|
protected |
tolerance for equality check (0..1, 0 - any not equal, 1 - opposite colors)
|
protected |
different pixels (position packed into integer)
|
protected |
|
protected |
new image to compare (to)
|
protected |
reference image to compare (from)
|
protected |
perform algorithm with border effect filter
|
protected |