A method and device for measuring image similarity based on neighborhood difference
Through the neighborhood difference method, it is converted into a grayscale image and Gaussian filtering and tolerance coefficient are used to calculate the neighborhood difference matrix, which solves the instability of the image similarity measurement method under brightness and translation conditions and realizes the accurate judgment of image similarity.
Patent Information
- Application Number
- CN202310285859.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-22
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2043-03-22
AI Technical Summary
Existing image similarity measurement methods such as PSNR and SSIM are unstable when facing image translation and brightness changes, making it difficult to accurately judge image similarity.
An image similarity measurement method based on neighborhood difference is adopted. By converting the image into a grayscale image, Gaussian filtering and tolerance coefficient are used to calculate the maximum evaluation coefficient and neighborhood difference coefficient of the neighborhood difference matrix, eliminating the influence of brightness and contrast, and accurately judging image translation and other situations.
It achieves accurate judgment of image similarity in different application scenarios, solves the instability caused by image translation and brightness changes, and improves the robustness and accuracy of the algorithm.
Smart Images

Figure CN116310420B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an image similarity measurement method, in particular to an image similarity measurement method and device based on neighborhood difference. Background Art
[0002] Image similarity algorithms are of great significance in research fields such as image recognition and image search engines. An increasing number of researchers are using image similarity techniques to improve production efficiency, whether in image registration or image search, demonstrating that image similarity algorithms are gradually influencing the production environment.
[0003] Among them, PSNR is a widely used image similarity measurement method in the past. However, in real production environments, it is shown that the final score coefficient of PSNR cannot be consistent with the image performance observed by the human eye. It is possible that images with higher PSNR coefficients perform worse than images with lower PSNR coefficients. This may be because human vision is not always sensitive to errors, and its perception results will change due to many external factors. The structural similarity SSIM algorithm improves the above defects. Nowadays, the structural similarity index SSIM is widely popular as an image quality assessment measure in current image similarity algorithms. It is considered to be one of the most powerful methods for evaluating the visual proximity of images. However, the structural similarity index SSIM is particularly sensitive to images with problems such as translation and to information such as image brightness, resulting in poor performance on this type of image data.
[0004] The above-mentioned image translation and image brightness problems also need to be solved urgently in the production environment. Summary of the Invention
[0005] The present invention addresses the problems of the existing technology by providing a method and apparatus for measuring image similarity based on neighborhood differences. By converting the images into grayscale images for calculation, the effects of image brightness and contrast are minimized. By subtracting the images and finding the differences between the neighborhood points of each pixel in the difference matrix, the maximum difference is selected as the final result. This allows accurate determination of image translation and avoids misjudgments due to structural similarity.
[0006] Specifically, after the method converts the image into a grayscale image, a tolerance coefficient is set, which allows the user to optimize the performance of the algorithm by adjusting the parameters. If the parameters are not adjusted, the default tolerance coefficient will be calculated according to the size of the image. The image is Gaussian filtered using the tolerance coefficient. The difference matrix is obtained by subtracting the Gaussian filtered image. Using the difference matrix, the maximum distance between each pixel and the surrounding pixels is calculated, and the fluctuation of the difference image is analyzed, which can reflect the image translation and other situations, thereby avoiding the phenomenon of insensitivity to the image caused by the unchanged structure due to image translation. Specifically, the present invention is implemented by the following technical solutions:
[0007] The present invention discloses a method for measuring image similarity based on neighborhood differences, comprising:
[0008] Obtain at least two or more image data of the same size;
[0009] According to the obtained two images of the same size, determine whether the image data is in RGB format or grayscale format, and if it is in RGB format, convert it to obtain two images in grayscale format;
[0010] According to the obtained data, whether the tolerance coefficient is included is determined; if the tolerance coefficient is not included, the tolerance coefficient is calculated according to the sizes of the two grayscale images generated;
[0011] According to the two grayscale images and the tolerance coefficient, two Gaussian blurred grayscale images are obtained by using the Gaussian filtering algorithm;
[0012] Through two Gaussian blurred grayscale images, the maximum evaluation coefficient of the two grayscale images is obtained;
[0013] According to the two Gaussian blurred grayscale images, a difference matrix is obtained by subtracting them;
[0014] According to the difference matrix, the range of the difference matrix is obtained;
[0015] According to the difference matrix, calculate the distance between the value of each coordinate in the difference matrix and the values of its surrounding coordinates, select the one with the largest distance as the value of the current coordinate, and generate a neighborhood matrix;
[0016] According to the neighborhood matrix, the range of the neighborhood matrix is obtained;
[0017] The neighborhood difference coefficient is obtained according to the maximum evaluation coefficient, the range of the difference matrix and the range of the neighborhood matrix.
[0018] As a further improvement, the calculation of the tolerance coefficient described in the present invention is specifically: based on the two grayscale images generated, the number of pixels in the grayscale image is calculated, and based on the number value, the square root of the number is obtained and divided by 100 to obtain the final value as the default tolerance coefficient of the grayscale image.
[0019] As a further improvement, the present invention obtains the maximum evaluation coefficient of the two grayscale images through two Gaussian blurred grayscale images, specifically:
[0020] According to the two Gaussian blurred grayscale images, calculate the maximum value of the first Gaussian blurred grayscale image Image1 max and minimum value Image1 min , calculate the maximum value Image2 of the second grayscale image after Gaussian blur max and minimum value Image2 min , and then calculate the maximum value Image2 of the second Gaussian blurred grayscale image max The maximum value of the grayscale image after the first Gaussian blur Image1 max and minimum value Image1 min The absolute value of the difference, and then calculate the maximum value of the second grayscale image after Gaussian blur Image2 min The maximum value of the grayscale image after the first Gaussian blur Image1 max and minimum value Image1 min The absolute value of the difference between the four differences is used to further calculate the maximum evaluation coefficient according to the maximum evaluation coefficient formula:
[0021] The above maximum evaluation coefficient formula is as follows:
[0022]
[0023] Where e0 represents the maximum evaluation coefficient of the two grayscale images after Gaussian blur processing, ABS represents the absolute value of the difference, Max represents the maximum value, and Min represents the minimum value.
[0024] As a further improvement, the present invention calculates the distance between the value of each coordinate in the difference matrix and the values of its surrounding coordinates based on the difference matrix, selects the value of the current coordinate with the largest distance, and generates a neighborhood matrix, specifically:
[0025] According to the difference matrix, the difference matrix is a two-dimensional array. The values in the two-dimensional array can be expressed as the current value of each coordinate point. The value of each coordinate point is calculated to find the difference between the value of each coordinate point and the value of the nearby neighboring points. The nearby neighboring points of the coordinate points in the two-dimensional array are divided into the following three different situations:
[0026] There are three neighboring points near the four corners of the two-dimensional array: the neighboring points near the upper left corner are right, bottom, and bottom right respectively; the neighboring points near the upper right corner are left, bottom, and bottom left respectively; the neighboring points near the lower left corner are right, top, and top right respectively; the neighboring points near the lower right corner are left, top, and top left respectively;
[0027] There are five neighboring points near the coordinate points on the four edges of the two-dimensional array: the neighboring points near the coordinate point on the left edge are: top, upper right, right, lower right, and bottom; the neighboring points near the coordinate point on the right edge are: top, upper left, left, lower left, and bottom; the neighboring points near the coordinate point on the upper edge are: left, lower left, bottom, lower right, and right; the neighboring points near the coordinate point on the lower edge are: left, upper left, top, upper right, and right;
[0028] There are eight neighboring points in the two-dimensional array for the coordinate point located in the inner area: the neighboring points of the inner coordinate point are: top, bottom, left, right, upper left, lower left, upper right, and lower right;
[0029] For each coordinate point in the two-dimensional matrix, the difference between it and its nearby neighboring points is calculated. Among the differences between it and its neighboring points, the one with the largest difference is selected as the new value of the current coordinate point, and finally a two-dimensional array consisting of new values is obtained, namely the neighborhood matrix.
[0030] As a further improvement, the present invention obtains the neighborhood difference coefficient according to the maximum evaluation coefficient, the range of the difference matrix and the range of the neighborhood matrix, specifically:
[0031] The maximum evaluation coefficient e0 is calculated based on the grayscale images after two Gaussian blur processing, and the range R is calculated based on the difference matrix. d , calculated based on the neighborhood matrix, the range R b , the above three values are substituted into the neighborhood coefficient formula to calculate the final image similarity based on neighborhood difference, and the final value is a coefficient value between 0 and 1;
[0032] The above maximum evaluation coefficient formula is as follows:
[0033]
[0034] Where ndc represents the final image similarity measurement coefficient based on neighborhood difference, e0 represents the maximum evaluation coefficient calculated from the two grayscale images after Gaussian blur processing, R d Represents the range of the difference matrix, R b Represents the range of the neighborhood matrix.
[0035] The present invention also discloses an image similarity measurement device based on neighborhood difference, comprising:
[0036] The first processing module: obtains at least two or more image data of the same size;
[0037] The first judgment module: determines whether the image data is in RGB format or grayscale format based on the two images of the same size obtained. If it is in RGB format, it converts the image data to obtain two grayscale images;
[0038] The second judgment module: judging whether the obtained data contains a tolerance coefficient, and if not, calculating the tolerance coefficient based on the sizes of the two grayscale images generated;
[0039] The first filtering module: obtains two Gaussian blurred grayscale images through the Gaussian filtering algorithm according to the two grayscale images and the tolerance coefficient;
[0040] The first calculation module: obtains the maximum evaluation coefficient of the two grayscale images through two Gaussian blurred grayscale images;
[0041] The second calculation module: based on the two Gaussian blurred grayscale images, a difference matrix is obtained; based on the difference matrix, the range of the difference matrix is obtained;
[0042] The first selection module: According to the difference matrix, calculate the distance between the value of each coordinate in the difference matrix and the values of its surrounding coordinates, select the value with the largest distance as the value of the current coordinate, and generate a neighborhood matrix;
[0043] The third calculation module: according to the neighborhood matrix, obtain the range of the neighborhood matrix;
[0044] The fourth calculation module: obtains the neighborhood difference coefficient according to the maximum evaluation coefficient, the range of the difference matrix and the range of the neighborhood matrix.
[0045] The beneficial effects of the present invention are as follows:
[0046] This paper utilizes the characteristics of distance deviation between adjacent pixels to implement a neighborhood difference image similarity measurement method. By converting the dataset into a grayscale image, the instability problem caused by the overall brightness difference of the image is solved. By increasing the tolerance coefficient and performing Gaussian filtering, the algorithm's precision is adjusted, achieving good performance in different application scenarios. By calculating the maximum distance between each pixel in the difference matrix, the instability caused by image translation and other problems is resolved, achieving the purpose of the image similarity algorithm for accurate image judgment in different application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 It is a data flow diagram of the present invention; DETAILED DESCRIPTION
[0048] The technical solution of the present invention will be further described below with reference to the accompanying drawings and specific embodiments:
[0049] The purpose of this invention is to propose a method for measuring image similarity based on neighborhood differences in order to solve the problem of instability in the existing image similarity measurement index. Figure 1 It is a data flow diagram of the present invention:
[0050] The specific implementation method of the present invention is as follows:
[0051] Step 1: Obtain at least two images of the same size.
[0052] In this example, four types of image data were acquired: pets, flowers, the moon, and chess. The pet image has a pixel size of 700*700 and a cluttered background; the flower image has a pixel size of 2744*4090 and a completely black background; the moon image has a pixel size of 5184*3888 and a completely black background; and the chess image has a pixel size of 5760*3840 and a completely white background.
[0053] Each image has 11 image data, one of which is the original image, and the other 10 are images shifted by different programs. The shift degrees are based on the size of the original image pixels, and the shift amounts are 0.1%, 0.2%, 0.3%, 0.4%, 0.5%, 0.6%, 0.7%, 0.8%, 0.9%, and 1.0%, respectively. By comparing the original image data with the shifted image data, including the comparison between the original image data and itself, each image will have 11 different image combinations, for a total of 44 image combinations.
[0054] Step 2: Based on the two obtained image data of the same size, determine whether the image data is in RGB format or grayscale format. If it is in RGB format, convert it to obtain two images in grayscale format.
[0055] In this embodiment, the original data set is read to obtain three-dimensional image data in RGB format, which needs to be converted into two-dimensional image data in grayscale format.
[0056] After reading the image data, the innermost data of the three-dimensional RGB format image data is RGB. First, the dimension of the image data needs to be converted and the RGB data is divided into three two-dimensional R matrices m R 、G matrix m G 、B matrix m B , and input it into the formula for converting grayscale images to obtain image data in grayscale format.
[0057] The formula for converting the grayscale image above is as follows:
[0058] m Gery =m R ×0.299+m G ×0.587+m B ×0.114
[0059] Convert the two image data in each group of images into grayscale image data.
[0060] Step 3: Based on the obtained data, determine whether the data contains a tolerance coefficient. If the data does not contain a tolerance coefficient, calculate the tolerance coefficient based on the sizes of the two grayscale images generated.
[0061] In this embodiment, in addition to the two images of the same size, a determination is made as to whether a tolerance coefficient value is also obtained from the acquired data. If the tolerance coefficient is not obtained, it is necessary to first calculate the tolerance coefficient. Based on the two generated grayscale images, the number of pixels in the grayscale image is calculated. From this number, the square root of the number is obtained and divided by 100 to obtain the final value, which serves as the default tolerance coefficient for the grayscale image.
[0062] Step 4: Based on the two grayscale images and the tolerance coefficient, two Gaussian blurred grayscale images are obtained through the Gaussian filtering algorithm.
[0063] In this embodiment, the image data in the two grayscale formats and the tolerance coefficient in the above-mentioned set of images are subjected to Gaussian blurring processing on the image data by the Scipy.ndimage.gaussian_filter Gaussian filtering method encapsulated in the Scipy library of the Python programming language, thereby obtaining two grayscale image data after Gaussian blurring processing.
[0064] Step 5: Obtain the maximum evaluation coefficient of the two grayscale images through the two Gaussian blurred grayscale images.
[0065] In this embodiment, the maximum value Image1 of the first Gaussian blurred grayscale image is calculated based on the two Gaussian blurred grayscale images. max and minimum value Image1 min , calculate the maximum value Image2 of the second grayscale image after Gaussian blur max and minimum value Image2 min Then calculate the maximum value Image2 of the second Gaussian blurred grayscale image max The maximum value of the grayscale image after the first Gaussian blur Image1 max and minimum value Image1 min The absolute value of the difference, and then calculate the maximum value of the second grayscale image after Gaussian blur Image2 min The maximum value of the grayscale image after the first Gaussian blur Image1 max and minimum value Image1 min Based on the above four differences, the maximum evaluation coefficient is further calculated according to the maximum evaluation coefficient formula.
[0066] The above maximum evaluation coefficient formula is as follows:
[0067] Where e0 represents the maximum evaluation coefficient of the two grayscale images after Gaussian blur processing, ABS represents the absolute value of the difference, Max represents the maximum value, and Min represents the minimum value.
[0068] Step 6: Subtract the two Gaussian blurred grayscale images to obtain a difference matrix.
[0069] In this embodiment, two grayscale image data after Gaussian blur processing are directly subtracted and the absolute value is taken to obtain a difference matrix Matrix d , each set of image data will generate a difference matrix, so that the neighborhood points can be found through the difference matrix later.
[0070] Step 7: According to the difference matrix, obtain the range of the difference matrix.
[0071] In this embodiment, the difference matrix Matrix obtained above d , analyze the difference matrix Matrix d Substitute the maximum and minimum values in the range formula to obtain the difference matrix Matrix d The range R d .
[0072] The above difference matrix Matrix d The range formula is as follows:
[0073] R d =Max(Matrix d )-Min(Matrix d )
[0074] Step 8: Based on the difference matrix, calculate the distance between the value of each coordinate in the difference matrix and the values of its surrounding coordinates, select the one with the largest distance as the value of the current coordinate, and generate a neighborhood matrix.
[0075] According to the difference matrix Matrix d , difference matrix Matrix d A two-dimensional array represents the current value of each coordinate point. Calculate the difference between each coordinate point and its neighboring points. The neighboring points in the two-dimensional array can be divided into three different categories.
[0076] There are three neighboring points near the coordinate points at the four corners of the two-dimensional array: the neighboring points near the upper left corner are right, bottom, and lower right respectively; the neighboring points near the upper right corner are left, bottom, and lower left respectively; the neighboring points near the lower left corner are right, top, and upper right respectively; the neighboring points near the lower right corner are left, top, and upper left respectively.
[0077] There are five nearby neighboring points for the coordinate points on the four edges in the two-dimensional array: the nearby neighboring points for the coordinate points on the left edge are: top, upper right, right, lower right, and bottom; the nearby neighboring points for the coordinate points on the right edge are: top, upper left, left, lower left, and bottom; the nearby neighboring points for the coordinate points on the upper edge are: left, lower left, bottom, lower right, and right; the nearby neighboring points for the coordinate points on the lower edge are: left, upper left, top, upper right, and right.
[0078] There are eight neighboring points near the coordinate point located in the inner area of the two-dimensional array: the neighboring points near the inner coordinate point are: top, bottom, left, right, upper left, lower left, upper right, and lower right.
[0079] For each coordinate point in the two-dimensional matrix, the difference between it and its neighboring points is calculated. Among the differences between it and its neighboring points, the one with the largest difference is selected as the new value of the current coordinate point, and finally a two-dimensional array consisting of new values is obtained, namely the neighborhood matrix Matrix b .
[0080] In this embodiment, considering that the above method needs to traverse the difference matrix Matrix in a double loop in Python programming d Each pixel on the network needs to be calculated with its neighboring points, which causes the program to run too long.
[0081] To implement it in Python programming code, you can first create the difference matrix Matrix d Add a circle of marginal values around to get the new difference matrix Matrix after expanding the marginal value d2 , set the sliding window size and the original difference matrix Matrix d The size of the sliding window is consistent, and the new difference matrix Matrix is applied d2 9 different temporary matrices of the same size as the original difference matrix are obtained in sequence, among which the fifth temporary matrix will be the same as the original difference matrix Matrix d First initialize a matrix with all values 0 and the same size as the original difference matrix Matrix d Neighborhood matrices of the same size b , subtract the original difference matrix from the temporary matrix each time to get the temporary neighborhood matrix, and then use the temporary neighborhood matrix and the neighborhood matrix Matrix b Compare the sizes and assign the larger value of the temporary neighborhood matrix to the neighborhood matrix Matrix b , each temporary neighborhood matrix will be combined with the neighborhood matrix Matrix b Compared to update, the neighborhood matrix Matrix b It will be updated 9 times to get the final neighborhood matrix Matrix b .
[0082] The above implementation in Python programming is either direct double training to traverse each pixel to calculate the neighborhood matrix Matrix b , or update the neighborhood matrix Matrix in sequence through the sliding window b The two methods are just different in the writing of Python programming code, which improves the time efficiency of program running, and the core ideas are the same.
[0083] Step 9: According to the neighborhood matrix, obtain the range of the neighborhood matrix.
[0084] In this embodiment, the neighborhood matrix Matrix obtained above b , analyze the neighborhood matrix Matrix b Substitute the maximum and minimum values in the range formula to obtain the neighborhood matrix Matrix b The range R b .
[0085] The neighborhood matrix Matrix b The range formula is as follows:
[0086] R b =Max(Matrixb )-Min(Matrix b )
[0087] Step 10: Obtain the neighborhood difference coefficient based on the maximum evaluation coefficient, the range of the difference matrix, and the range of the neighborhood matrix.
[0088] In this embodiment, the maximum evaluation coefficient e0 is calculated based on the grayscale image after two Gaussian blur processing, and the difference matrix Matrix d The calculated range R d , according to the neighborhood matrix Matrix b The calculated range R b Substitute the above three values into the neighborhood coefficient formula to calculate the final image similarity based on neighborhood differences. The final value is a coefficient value between 0 and 1.
[0089] The above maximum evaluation coefficient formula is as follows:
[0090]
[0091] Where ndc represents the final image similarity measurement coefficient based on neighborhood difference, e0 represents the maximum evaluation coefficient calculated from the two grayscale images after Gaussian blur processing, R d Represents the range of the difference matrix, R b Represents the range of the neighborhood matrix.
[0092] There are four different types of image data, with 44 different image combinations. Table 1 shows the results of the SSIM (Structural Similarity) calculation dataset, the most commonly used image structure similarity on the market. The results in the table show that the SSIM algorithm experiences desensitization when the offset of the Dog and Flower images exceeds approximately 5%, and cannot effectively address the problem of image translation. Furthermore, due to the different background colors of the Moon and Chess images, resulting in different overall image brightness, the SSIM algorithm exhibits different coefficient values for data with the same offset, resulting in instability due to image brightness. Table 2 shows the results of the image similarity (ndc) calculation based on neighborhood differences. Neither excessive image offset nor overall image brightness affects the ndc coefficient value, and the algorithm still performs well.
[0093] Table 1 SSIM coefficient values of image structural similarity
[0094]
[0095]
[0096] Table 2 Image similarity NDC coefficient values based on neighborhood difference
[0097]
[0098] The present invention also discloses an image similarity measurement device based on a neighborhood matrix, comprising:
[0099] The first processing module: obtains at least two or more image data of the same size;
[0100] The first judgment module: determines whether the image data is in RGB format or grayscale format based on the two images of the same size obtained. If it is in RGB format, it converts the image data to obtain two grayscale images;
[0101] The second judgment module: judging whether the obtained data contains a tolerance coefficient, and if not, calculating the tolerance coefficient based on the sizes of the two grayscale images generated;
[0102] The first filtering module: obtains two Gaussian blurred grayscale images through the Gaussian filtering algorithm according to the two grayscale images and the tolerance coefficient;
[0103] The first calculation module: obtains the maximum evaluation coefficient of the two grayscale images through two Gaussian blurred grayscale images;
[0104] The second calculation module: based on the two Gaussian blurred grayscale images, a difference matrix is obtained; based on the difference matrix, the range of the difference matrix is obtained;
[0105] The first selection module: According to the difference matrix, calculate the distance between the value of each coordinate in the difference matrix and the values of its surrounding coordinates, select the value with the largest distance as the value of the current coordinate, and generate a neighborhood matrix;
[0106] The third calculation module: according to the neighborhood matrix, obtain the range of the neighborhood matrix;
[0107] The fourth calculation module: obtains the neighborhood difference coefficient according to the maximum evaluation coefficient, the range of the difference matrix and the range of the neighborhood matrix.
[0108] The above description is not intended to limit the present invention. It should be noted that a person skilled in the art may make several changes, modifications, additions or substitutions without departing from the essential scope of the present invention. Such improvements and modifications should also be regarded as within the scope of protection of the present invention.
Claims
1. A method for measuring image similarity based on neighborhood difference, characterized in that: include: Obtain at least two or more image data of the same size; According to the obtained two images of the same size, determine whether the image data is in RGB format or grayscale format, and if it is in RGB format, convert it to obtain two images in grayscale format; According to the obtained data, whether the tolerance coefficient is included is determined; if the tolerance coefficient is not included, the tolerance coefficient is calculated according to the sizes of the two grayscale images generated; According to the two grayscale images and the tolerance coefficient, two Gaussian blurred grayscale images are obtained by using the Gaussian filtering algorithm; Through two Gaussian blurred grayscale images, the maximum evaluation coefficient of the two grayscale images is obtained; According to the two Gaussian blurred grayscale images, a difference matrix is obtained by subtracting them; According to the difference matrix, the range of the difference matrix is obtained; According to the difference matrix, calculate the distance between the value of each coordinate in the difference matrix and the values of its surrounding coordinates, select the one with the largest distance as the value of the current coordinate, and generate a neighborhood matrix; According to the neighborhood matrix, the range of the neighborhood matrix is obtained; The neighborhood difference coefficient is obtained according to the maximum evaluation coefficient, the range of the difference matrix and the range of the neighborhood matrix.
2. The image similarity measurement method based on neighborhood difference according to claim 1, characterized in that: The tolerance coefficient is calculated specifically as follows: based on the two grayscale images generated, the number of pixels in the grayscale image is calculated, and based on the number value, the square root of the number value is obtained and divided by 100 to obtain the final value as the default tolerance coefficient of the grayscale image.
3. The image similarity measurement method based on neighborhood difference according to claim 1, characterized in that: The maximum evaluation coefficient of the two grayscale images obtained by using the two Gaussian blurred grayscale images is specifically: According to the two Gaussian blurred grayscale images, calculate the maximum value of the first Gaussian blurred grayscale image Image1 max and minimum value Image1 min , calculate the maximum value Image2 of the second grayscale image after Gaussian blur max and minimum value Image2 min , and then calculate the maximum value Image2 of the second Gaussian blurred grayscale image max The maximum value of the grayscale image after the first Gaussian blur Image1 max and minimum value Image1 min The absolute value of the difference, and then calculate the maximum value of the second grayscale image after Gaussian blur Image2 min The maximum value of the grayscale image after the first Gaussian blur Image1 max and minimum value Image1 min The absolute value of the difference between the four differences is used to further calculate the maximum evaluation coefficient according to the maximum evaluation coefficient formula: The above maximum evaluation coefficient formula is as follows: Where e0 represents the maximum evaluation coefficient of the two grayscale images after Gaussian blur processing, ABS represents the absolute value of the difference, Max represents the maximum value, and Min represents the minimum value.
4. The image similarity measurement method based on neighborhood difference according to claim 1, characterized in that: According to the difference matrix, calculate the distance between the value of each coordinate in the difference matrix and the values of the surrounding coordinates, select the one with the largest distance as the value of the current coordinate, and generate a neighborhood matrix, specifically: According to the difference matrix, the difference matrix is a two-dimensional array. The values in the two-dimensional array can be expressed as the current value of each coordinate point. The value of each coordinate point is calculated to find the difference between the value of each coordinate point and the value of the nearby neighboring points. The nearby neighboring points of the coordinate points in the two-dimensional array are divided into the following three different situations: There are three neighboring points near the four corners of the two-dimensional array: the neighboring points near the upper left corner are right, bottom, and bottom right respectively; the neighboring points near the upper right corner are left, bottom, and bottom left respectively; the neighboring points near the lower left corner are right, top, and top right respectively; the neighboring points near the lower right corner are left, top, and top left respectively; There are five neighboring points near the coordinate points on the four edges of the two-dimensional array: the neighboring points near the coordinate point on the left edge are: top, upper right, right, lower right, and bottom; the neighboring points near the coordinate point on the right edge are: top, upper left, left, lower left, and bottom; the neighboring points near the coordinate point on the upper edge are: left, lower left, bottom, lower right, and right; the neighboring points near the coordinate point on the lower edge are: left, upper left, top, upper right, and right; There are eight neighboring points in the two-dimensional array for the coordinate point located in the inner area: the neighboring points of the inner coordinate point are: top, bottom, left, right, upper left, lower left, upper right, and lower right; For each coordinate point in the two-dimensional matrix, the difference between it and its nearby neighboring points is calculated. Among the differences between it and its neighboring points, the one with the largest difference is selected as the new value of the current coordinate point, and finally a two-dimensional array consisting of new values is obtained, namely the neighborhood matrix.
5. The image similarity measurement method based on neighborhood difference according to claim 1, characterized in that: The neighborhood difference coefficient is obtained according to the maximum evaluation coefficient, the range of the difference matrix and the range of the neighborhood matrix, which is specifically: The maximum evaluation coefficient e0 is calculated based on the grayscale images after two Gaussian blur processing, and the range R is calculated based on the difference matrix. d , calculated based on the neighborhood matrix, the range R b , the above three values are substituted into the neighborhood coefficient formula to calculate the final image similarity based on neighborhood difference, and the final value is a coefficient value between 0 and 1; The above maximum evaluation coefficient formula is as follows: Where ndc represents the final image similarity measurement coefficient based on neighborhood difference, e0 represents the maximum evaluation coefficient calculated from the two grayscale images after Gaussian blur processing, R d Represents the range of the difference matrix, R b Represents the range of the neighborhood matrix.
6. A device for measuring image similarity based on neighborhood difference, characterized in that: include: The first processing module: obtains at least two or more image data of the same size; The first judgment module: determines whether the image data is in RGB format or grayscale format based on the two images of the same size obtained. If it is in RGB format, it converts the image data to obtain two grayscale images; The second judgment module: judging whether the obtained data contains a tolerance coefficient, and if not, calculating the tolerance coefficient based on the sizes of the two grayscale images generated; The first filtering module: obtains two Gaussian blurred grayscale images through the Gaussian filtering algorithm according to the two grayscale images and the tolerance coefficient; The first calculation module: obtains the maximum evaluation coefficient of the two grayscale images through two Gaussian blurred grayscale images; The second calculation module: based on the two Gaussian blurred grayscale images, a difference matrix is obtained; According to the difference matrix, the range of the difference matrix is obtained; The first selection module: According to the difference matrix, calculate the distance between the value of each coordinate in the difference matrix and the values of its surrounding coordinates, select the value with the largest distance as the value of the current coordinate, and generate a neighborhood matrix; The third calculation module: according to the neighborhood matrix, obtain the range of the neighborhood matrix; The fourth calculation module: obtains the neighborhood difference coefficient according to the maximum evaluation coefficient, the range of the difference matrix and the range of the neighborhood matrix.
Citation Information
Patent Citations
Similar image recognition method and equipment
CN106203242A
Multi-dimensional layered object detection method based on space-spectrum constraint
CN106407975A