This is a topic that has been asked in 5000 images to find 30 images that are the same as the sample but have been enlarged or zoomed out, highlighted or dimmed.
The whole idea is to hash the picture into a piece of fingerprint, this fingerprint and image size, format, light and shade are irrelevant, only and the contents of the picture itself.
1. Turn the color image into a grayscale image first
If the RGB value of the original pixel is (R1,G1,B1), a relatively simple method is converted into a grayscale image,
is gray1= (r1*299+g1*587+b1*114+500)/1000
Then the RGB color of the pixel point becomes (gray1,gray1,gray1).
And I use Matlab in the function Imgray = Rgb2gray (Imdata);
2. Convert grayscale images to black and white
The average gray level of the graph is calculated first, and a relatively simple approach is to sum the grayscale of all pixels. Then for each pixel point, if it is less than the average grayscale, the RGB value is (0,0,0), otherwise (255,255,255).
After this step, the picture becomes black and white. I use Matlab in the function Lev = Graythresh (imdata); Average grayscale, then bwimg = IM2BW (Imdata, Lev); To find a binary graph.
However, such a function is not particularly good for some of the highlighted or dimmed images, which makes the whole picture appear white or All black.
My handling of these images is to set the Lev on my own, and to set the value of Lev to 0~1 as needed, rather than averaging the image. (Find a better way to update again).
4 encoding
Enlarges or shrinks the previous two value graph to a matrix of 8*8 Imdata = Imresize (Imdata, [8,8]);
White is 0, black is 1 integrated into 1 64-bit binary, converted to 16 binary is the fingerprint of this image.
Here, I did not convert to 16 binary to compare, but directly to the binary string to do the comparison, exactly the same is not much, so the different characters within 10 I will be counted as similar, and further comparison.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Two value processing of images by Matlab