TImageEnMView.FindSimilar
Declaration
function FindSimilar(Index: Integer; Threshold: Double = 0.75; Algorithm: TIEVisionImageHashAlgorithm = ievHashPHash): TIEArrayOfInteger; overload;
function FindSimilar(Index: Integer; var Similarities: TIEArrayOfDouble; Threshold: Double = 0.75; Algorithm: TIEVisionImageHashAlgorithm = ievHashPHash): TIEArrayOfInteger; overload;
Description
Returns the indexes of all images that are the same as, or similar to, the image at
Index (requires
IEVision).
Images are compared using a
perceptual hash, so resized, recompressed and slightly edited copies are found.
The result is sorted with the most similar image first.
Index itself is not included.
| Parameter | Description |
| Index | The image to compare with all others |
| Similarities | Returns the similarity (0 to 1) of each returned image, in the same order |
| Threshold | Minimum similarity (0 to 1). 0.75 finds near-duplicates. Use a lower value to find more loosely similar images. See similarity |
| Algorithm | The perceptual hash algorithm. See TIEVisionImageHashAlgorithm |
Works with any
StoreType: images loaded on demand are loaded to be hashed, and thumbnails are hashed as they are (which is faster and gives the same result).
Note: Every image is hashed on each call, so for repeated searches of large collections it is faster to store the hashes (
GetPerceptualHash) and compare them with
IEVisionCompareHashes.
Demo
| Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
Example
// Check all images that are similar to the selected one
var
idx: TIEArrayOfInteger;
i: Integer;
begin
idx := ImageEnMView1.FindSimilar( ImageEnMView1.SelectedImage );
for i := 0 to Length( idx ) - 1 do
ImageEnMView1.Checked[ idx[ i ]] := True;
end;
See Also
◼RemoveDuplicates
◼TIEMultiBitmap.FindSimilar
◼GetPerceptualHash