A method and device for identifying infringing images based on an improved perceptual hashing algorithm
By improving the perceptual hash algorithm, high-frequency components are retained for solid-color background images. Combined with image histogram partitioning and hash value processing, the problem of inaccurate recognition of solid-color background images in existing technologies is solved, and more efficient infringement image recognition is achieved.
Patent Information
- Application Number
- CN202310719594.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-16
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2043-06-16
AI Technical Summary
Existing perceptual hashing algorithms are not ideal for identifying images with solid color backgrounds, making it difficult to effectively identify infringing images, and they lack sufficient robustness to image processing operations.
By improving the perceptual hashing algorithm, the frequency coefficient matrix of the high-frequency part of the solid color background image is retained. The image type is divided by combining the image histogram, the image fingerprint is calculated and the hash value is normalized. The similarity is calculated by Hamming distance to identify infringing images.
It improves the accuracy and robustness of infringement identification for solid color background images, enhances the universality and security of the algorithm, and can effectively resist common image attacks.
Smart Images

Figure CN116721269B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to a method and device for infringing image recognition based on an improved perceptual hashing algorithm, and belongs to the technical field of image copyright protection. BACKGROUND
[0002] In recent years, the development of mobile Internet has promoted the generation and dissemination of various images, and a large number of image copyright infringement problems have followed. A pure color background image is a special image with a small proportion of main patterns and a large proportion of single color backgrounds, and is often applied to the fields of wallpaper and advertisement. Since a pure color background image can be easily obtained by embedding an existing copyrighted image into a single color background, and has high commercial value, there are a large number of infringing images in the pure color background image, which causes great interest loss to the image copyright holder. How to identify infringing images, especially pure color background images, is a key research content in the field of image copyright protection.
[0003] Traditional image authentication schemes mainly rely on digital watermarking and content-based image copy detection technology. Among them, the digital watermarking technology pre-embeds watermark information into the image to be protected, and when the image copyright infringement problem occurs, the image copyright can be verified by extracting the watermark. The digital watermarking can be divided into spatial domain watermarking and transform domain watermarking. The spatial domain watermarking algorithm has poor robustness and is almost unable to resist common image processing operations, and it is more difficult to identify whether a pure color background image is infringing. The transform domain watermarking algorithm needs the designer to consider where to embed information and how much information to embed, and also needs to consider the influence of the modification of each transform coefficient on the entire image, and the operation is relatively complex, and the effect of infringing identification on the pure color background image is also general. The content-based image copy detection technology extracts features from the image itself, finds the copy image, and then verifies whether it is illegally disseminated, so as to achieve the purpose of copyright protection. However, only a geometric transformation of the image can affect the extraction of features, so the content-based image copy detection technology is difficult to effectively process the various copy images existing in reality.
[0004] Image perceptual hashing is a technology for comparing the similarity between images, and is often used for image verification, search and copy detection due to its change insensitivity. In recent years, the image perceptual hashing technology has also been applied to the field of image copyright protection, and good image authentication results have been achieved. However, the existing perceptual hashing algorithm only retains the low-frequency part of the image matrix which concentrates most of the energy, resulting in that the algorithm cannot obtain the details of the image, and the effect of using the perceptual hashing algorithm to detect the similarity of the pure color background image is not very ideal. SUMMARY
[0005] In order to solve the problems in the prior art, the application provides an infringement image identification method and device based on an improved perceptual hashing algorithm, the existing perceptual hashing algorithm is optimized, the problem that the existing perceptual hashing algorithm is not applicable to pure color background images is solved by retaining the high frequency part of the image matrix, the robustness of the algorithm is enhanced, and the universality of infringement image identification is improved.
[0006] To solve the above technical problems, the application adopts the following technical means:
[0007] In a first aspect, the application provides an infringement image identification method based on an improved perceptual hashing algorithm, comprising the following steps:
[0008] According to the image histogram, the obtained to-be-verified images are divided into pure color background images and non-pure color background images;
[0009] The image fingerprint of the non-pure color background image is calculated by using the perceptual hashing algorithm;
[0010] The image fingerprint of the pure color background image is calculated by using the improved perceptual hashing algorithm;
[0011] According to the image fingerprint of each to-be-verified image, the hash value of each to-be-verified image is obtained;
[0012] According to the hash values of all to-be-verified images, the similarity of any two to-be-verified images is calculated;
[0013] The similarity of the any two to-be-verified images is compared with a preset similarity threshold value, and an infringement image identification result is obtained.
[0014] In combination with the first aspect, further, according to the image histogram, all to-be-verified images are divided into pure color background images and non-pure color background images, comprising:
[0015] The image histogram of each to-be-verified image is obtained by calling the calcHist function;
[0016] According to the image histogram, the image pixel matrix corresponding to each to-be-verified image is obtained;
[0017] The values in the image pixel matrix are sorted in descending order, and the ratio P of the sum of the maximum value and the second largest value in the image pixel matrix to the total sum of image pixels is calculated:
[0018] P=(e1+e2) / E
[0019] Wherein, e1 is the maximum value in the image pixel matrix, e2 is the second largest value in the image pixel matrix, and E is the sum of all values in the image pixel matrix.
[0020] The ratio P corresponding to each to-be-verified image is compared with a preset ratio threshold value, and when P is greater than or equal to the ratio threshold value, the current to-be-verified image is divided into a solid color background image, otherwise, the current to-be-verified image is divided into a non-solid color background image.
[0021] In combination with the first aspect, further, the image fingerprint of the solid color background image is calculated by using an improved perceptual hash algorithm, including:
[0022] The size of the solid color background image is reduced to N*N;
[0023] The reduced solid color background image is converted into a gray-scale image to obtain a gray-scale matrix of the reduced solid color background image;
[0024] The gray-scale matrix of the reduced solid color background image is subjected to a discrete cosine transform to obtain a frequency coefficient matrix of the reduced solid color background image, and the calculation formula is as follows:
[0025]
[0026]
[0027]
[0028] A2 ( u,v) is the DCT value of the u-th row and the v-th column in the frequency coefficient matrix A2 of the reduced solid color background image, c(u), c(v) are compensation coefficients, f2(i,j) is the gray-scale value of the pixel point with pixel coordinates (i,j) in the reduced solid color background image, u∈[0,N-1], v∈[0,N-1];
[0029] Elements in the right lower corner 8*8 part of the frequency coefficient matrix are extracted as the image fingerprint of the solid color background image.
[0030] In combination with the first aspect, further, the hash value of each to-be-verified image is obtained according to the image fingerprint of each to-be-verified image, including:
[0031] The DCT mean value of the to-be-verified image is calculated according to the image fingerprint of the to-be-verified image;
[0032] The image fingerprint of the to-be-verified image is normalized according to the DCT mean value to obtain the hash value of the to-be-verified image, and the normalization formula is as follows:
[0033]
[0034] h={h1,…,h k ,…,h 64}
[0035] wherein, h k denotes the hash value corresponding to the kth element in the image fingerprint of the image to be verified, denotes the DCT value of the pth row and qth column in the image fingerprint of the image to be verified, m is the DCT mean value of the image to be verified, h is the hash value of the image to be verified, k∈[1, 64], p, q∈[0, 7].
[0036] In combination with the first aspect, further, the calculation formula of the similarity of any two images to be verified is as follows:
[0037]
[0038]
[0039] wherein, H d is the Hamming distance between any two images to be verified, is the kth hash value of the first image to be verified, is the kth hash value of the second image to be verified, similarity is the similarity of any two images to be verified, HBC is the number of bits of the hash value, HBC=64.
[0040] In combination with the first aspect, further, the similarity of the two images to be verified is compared with a preset similarity threshold, when the similarity is greater than or equal to the similarity threshold, it is determined that the two images to be verified are similar, and there is an infringing image, otherwise, it is determined that the two images to be verified are not similar, and there is no infringing image.
[0041] The second aspect, the present application proposes an infringing image recognition device based on an improved perceptual hash algorithm, comprising:
[0042] An image classification module is used to divide the obtained images to be verified into pure color background images and non-pure color background images according to an image histogram;
[0043] An image fingerprint extraction module is used to calculate the image fingerprint of the non-pure color background image by using a perceptual hash algorithm, and calculate the image fingerprint of the pure color background image by using an improved perceptual hash algorithm;
[0044] A hash value extraction module is used to obtain the hash value of each image to be verified according to the image fingerprint of each image to be verified;
[0045] A similarity calculation module is used to calculate the similarity of any two images to be verified according to the hash values of all images to be verified;
[0046] An infringing image recognition module is used to compare the similarity of the two images to be verified with a preset similarity threshold to obtain an infringing image recognition result.
[0047] With reference to the second aspect, further, the image classification module is specifically configured to:
[0048] obtain an image histogram of each to-be-verified image by calling a calcHist function;
[0049] obtain an image pixel matrix corresponding to each to-be-verified image according to the image histogram;
[0050] sort values in the image pixel matrix in descending order, and calculate a proportion P of a sum of a maximum value and a second maximum value in the image pixel matrix in the total sum of image pixels:
[0051] P = (e1+e2) / E
[0052] wherein e1 is the maximum value in the image pixel matrix, e2 is the second maximum value in the image pixel matrix, and E is the sum of all values in the image pixel matrix;
[0053] compare the proportion P corresponding to each to-be-verified image with a preset proportion threshold value, when the P is greater than or equal to the proportion threshold value, the current to-be-verified image is classified as a solid color background image, otherwise, the current to-be-verified image is classified as a non-solid color background image.
[0054] With reference to the second aspect, further, the image fingerprint extraction module calculates the image fingerprint of the solid color background image by using an improved perceptual hashing algorithm, comprising:
[0055] reduce the size of the solid color background image to N×N;
[0056] convert the reduced solid color background image into a gray-scale image to obtain a gray-scale matrix of the reduced solid color background image;
[0057] perform a discrete cosine transform on the gray-scale matrix of the reduced solid color background image to obtain a frequency coefficient matrix of the reduced solid color background image, and the calculation formula is as follows:
[0058]
[0059]
[0060]
[0061] wherein A2(u,v) is the DCT value of the u-th row and the v-th column in the frequency coefficient matrix A2 of the reduced solid color background image, c(u), c(v) are compensation coefficients, f2(i,j) is the gray-scale value of the pixel point with pixel coordinates (i,j) in the reduced solid color background image, u∈[0,N-1], v∈[0,N-1];
[0062] Extract the elements of the lower right corner 8*8 part of the frequency coefficient matrix as the image fingerprint of the solid color background image.
[0063] In combination with the second aspect, further, in the similarity calculation module, the calculation formula of the similarity of any two images to be verified is as follows:
[0064]
[0065]
[0066] Wherein, H d is the Hamming distance between any two images to be verified, is the kth hash value of the first image to be verified, is the kth hash value of the second image to be verified, similarity is the similarity of any two images to be verified, HBC is the number of bits of the hash value, HBC=64.
[0067] The following advantages can be obtained after using the above technical means:
[0068] The application proposes a kind of infringement image identification method and device based on improved perceptual hash algorithm, to be detected image is divided into non-solid color background image and solid color background image, for non-solid color background image using the existing perceptual hash algorithm of reserving low frequency DCT, for solid color background image using the improved perceptual hash algorithm of reserving high frequency DCT, obtain the image fingerprint containing the key features of two kinds of images, then image similarity is measured, finally obtain infringement image identification result.The application can accurately identify whether solid color background image infringes, so that the image type supported by infringement image identification is more comprehensive, improve the universality of infringement image identification method, simultaneously, the method of the application enhances the robustness of algorithm, has resistance to common image attack authorization, improves the security and accuracy of infringement image identification. BRIEF DESCRIPTION OF DRAWINGS
[0069] Figure 1 for the steps of the application a kind of based on improved perceptual hash algorithm infringement image identification method schematic diagram;
[0070] Figure 2 for the flowchart of infringement image identification process in the embodiment of the application;
[0071] Figure 3 for the schematic diagram of solid color background image in the embodiment of the application;
[0072] Figure 4 for the schematic diagram of non-solid color background image in the embodiment of the application;
[0073] Figure 5A pure color background image schematic diagram with the same background color and different content in the embodiment of the present application;
[0074] Figure 6 A similarity detection result comparison chart of the wave hash algorithm, zero watermark algorithm, existing perceptual hash algorithm and the method of the present application. DETAILED DESCRIPTION
[0075] It should be noted that the present application proposes a new infringement image recognition method, first, the image is divided into non-pure color background image and pure color background image by calculating the proportion of the maximum value and the second maximum value in the pixel matrix of the image;For non-pure color background image, the existing perceptual hash algorithm is used to obtain its image fingerprint;For pure color background image, first unify the image size and gray scale, and then use the improved perceptual hash algorithm to retain the high frequency part of the image frequency matrix, compare the value of the high frequency part with the average value, if less than the average value, take 0, otherwise take 1, obtain the image fingerprint of the pure color background image;Finally, the similarity of the image fingerprints of non-pure color background image and pure color background image is calculated using hamming distance, when the similarity is greater than the threshold value, it is determined that the pure color background image infringes.
[0076] The technical scheme of the present application will be described in detail below by means of the accompanying drawings and specific embodiments, it should be understood that the embodiments of the present application and the specific features in the embodiments are detailed description of the technical scheme of the present application, rather than limitation of the technical scheme of the present application, in the case of no conflict, the technical features in the embodiments of the present application and the embodiments can be combined with each other.
[0077] Embodiment 1:
[0078] This embodiment introduces an infringement image recognition method based on improved perceptual hash algorithm, as shown in Figure 1 , 2 , mainly includes the following steps:
[0079] S1, obtaining a plurality of to-be-verified images, wherein the to-be-verified images include non-pure color background images and pure color background images, as shown in Figure 3 , 4 .
[0080] S2, since the pixel characteristics of non-pure color background image and pure color background image are different, in order to improve the accuracy of infringement image recognition, the present application divides all to-be-verified images into pure color background images and non-pure color background images according to the image histogram, and different processing is done on the two types of images in the subsequent infringement image recognition process.
[0081] The specific operation of step S2 is as follows:
[0082] S21, according to the preset pixel value range (0~255), the calcHist function is called to calculate the image histogram of each to-be-verified image, and then the image pixel matrix of each to-be-verified image is obtained according to the image histogram.
[0083] S22, for each image pixel matrix, the maximum value e1, the second maximum value e2 in the image pixel matrix are obtained, and the sum E (the total sum of image pixels) of all values in the image pixel matrix is calculated, to obtain the proportion P = (e1+e2) / E of the maximum value and the second maximum value in the total sum of image pixels.
[0084] S23, the proportion P in step S22 is compared with the proportion threshold value, if P is greater than or equal to the proportion threshold value, the corresponding to-be-verified image is divided into a pure color background image, otherwise, the corresponding to-be-verified image is divided into a non-pure color background image.
[0085] The pure color background in the common pure color background image on the market mostly occupies more than half of the whole image, therefore, the proportion threshold value is set to 51% in the embodiment of the application.
[0086] S3, the image fingerprint of the non-pure color background image is calculated by using the existing perceptual hash.
[0087] Step S31, in order to simplify the subsequent DCT calculation and reduce the error caused by different sizes or proportions of images, all non-pure color background images are reduced to N*N size, and in the embodiment of the application, N=32.
[0088] Step S32, the reduced non-pure color background image is converted into a gray-scale image to obtain a gray-scale matrix f1 of the reduced non-pure color background image. In the gray-scale matrix f1, f1(i,j) is the gray-scale value of the pixel point with pixel coordinates (i,j) in the reduced non-pure color background image, i∈[1,32], j∈[1,32]. Through step 32, the color information amount of the RGB image can be simplified to black and white gray-scale values, and the subsequent calculation is further simplified.
[0089] Step S33, the discrete cosine transform (DCT) is performed on the gray-scale matrix f1 of the reduced non-pure color background image to obtain a frequency coefficient matrix of the reduced non-pure color background image, so as to realize the purpose of converting the image from the spatial domain to the frequency domain.
[0090] Let A1 be the frequency coefficient matrix, and the formula of DCT calculation is as follows:
[0091]
[0092] Wherein, A1(u, v) is the DCT value of the u-th row and the v-th column in the frequency coefficient matrix A1, c(u) and c(v) are compensation coefficients, u∈[0, 31], v∈[0, 31].
[0093] The calculation formula of c(u) and c(v) is as follows:
[0094]
[0095] Step S34, the upper left 8x8 part of the frequency coefficient matrix A1 of the non-pure color background image is reserved (i.e. the low frequency part is reserved), and the remaining part is deleted, as the image fingerprint of the non-pure color background image.
[0096] S4, the image fingerprint of the pure color background image is calculated by using the improved perceptual hash.
[0097] Step S41, all the pure color background images are reduced to 32x32 size.
[0098] Step S42, the reduced pure color background image is converted into a gray image, and the gray matrix f2 of the reduced pure color background image is obtained.
[0099] Step S43, discrete cosine transform (DCT) is performed on the gray matrix f2 of the reduced pure color background image, and the frequency coefficient matrix A2 of the reduced pure color background image is obtained. The specific calculation process of step S43 is consistent with step S33.
[0100] Step S34, the right lower 8x8 part of the frequency coefficient matrix A2 of the pure color background image is reserved (i.e. the high frequency part is reserved), and the remaining part is deleted, as the image fingerprint of the pure color background image.
[0101] S5, according to the image fingerprint of each to-be-verified image, the hash value of each to-be-verified image is obtained.
[0102] Step S51, the image fingerprints of the non-pure color background image and the pure color background image are both 8x8 matrices, each element in the image fingerprint corresponds to a DCT value, and the DCT mean values of the non-pure color background image and the pure color background image are calculated according to the image fingerprints.
[0103] In the embodiment of the application, the DCT mean value of the non-pure color background image is calculated by the following formula:
[0104]
[0105] The DCT mean value of the pure color background image is calculated by the following formula:
[0106]
[0107] Step S52, according to the DCT mean values of the non-solid color background image and the solid color background image, normalizing the image fingerprints of the non-solid color background image and the solid color background image to obtain the hash values of the non-solid color background image and the solid color background image. Specifically, compare each DCT value in the image fingerprint with the DCT mean value corresponding to the image fingerprint, if the current DCT value is less than the DCT mean value, normalize the current DCT value to 0, otherwise normalize the current DCT value to 1, thereby generating a binary string representing the final hash value of the image.
[0108] In the embodiment of the application, the normalization formula of the non-solid color background image is as follows:
[0109]
[0110] wherein, h k represents the hash value corresponding to the kth element in the image fingerprint of the non-solid color background image, k∈[1, 64]. 1k
[0111] The hash value of the non-solid color background image is h1={h1, h2, …, h63, h64}. 11 1k 164 .
[0112] In the embodiment of the application, k is obtained by sorting from left to right and from top to bottom in the image fingerprint.
[0113] The normalization formula of the solid color background image is as follows:
[0114]
[0115] wherein, h k represents the hash value corresponding to the kth element in the image fingerprint of the solid color background image. 2k
[0116] The hash value of the solid color background image is h2={h1, h2, …, h63, h64}. 21 2k 264 .
[0117] S6, according to the hash values, calculating the similarity between any two images to be verified.
[0118] Two images to be verified are randomly selected, and the hash values of the two images to be verified are obtained, the characters at the same positions in the hash values of the two images to be verified are compared in order, the proportion of different characters in the two images to be verified is calculated using the Hamming distance, and then the similarity between the images to be verified is obtained, and the specific calculation formula is as follows:
[0119]
[0120]
[0121] wherein H d is the Hamming distance between any two images to be verified, is the hash value of the first image to be verified, is the hash value of the second image to be verified, similarity is the similarity between any two images to be verified, and HBC is the number of bits of the hash value, HBC = 64.
[0122] S7, comparing the similarity between the two images to be verified obtained in step S6 with a preset similarity threshold to obtain an infringement image identification result. If the similarity is greater than or equal to the similarity threshold, it is determined that the two images to be verified are similar, and there is infringement, otherwise, it is not determined as infringement. In the embodiment of the present application, the similarity threshold is set to 0.4.
[0123] In order to verify the effect of the method of the present application, the present application gives the following experiment:
[0124] In the experiment, 200 experimental images are used to form an experimental image set, wherein the proportion of pure color background images and non-pure color background images is 1:1. The experimental images of the experimental image set are processed by conventional image processing means to obtain infringement images corresponding to the experimental images, and then the wavelet hash algorithm, the zero watermark algorithm, the existing perceptual hash algorithm and the method of the present application are used to identify the infringement images to obtain the similarity between the experimental images and the infringement images under different algorithms.
[0125] In order to facilitate display, the embodiment of the present application lists 8 pure color background images and 6 non-pure color background images in the experiment, as shown in Figure 3 , 4 The experiment mainly includes two parts: common image attack experiment and replacement of background color experiment. The image attack experiment includes noise attack, filter attack, geometric attack, etc., and the purpose is to verify the robustness of the method of the present application. The purpose of the replacement of background color experiment is to change the background color of the images in the same group to the same color, in order to verify the accuracy of the method of the present application.
[0126] The specific operation of the image attack experiment is as follows:
[0127] a. Gaussian noise, salt and pepper noise, Wiener filter, median filter, jpeg compression, rotation, scaling, translation are applied to each experimental image respectively to obtain the attacked experimental image, i.e. the infringement image.
[0128] b. The experimental images and the infringement are classified by the method of the present application, and the existing perceptual hash algorithm and the improved perceptual hash algorithm are used to process the non-pure color background images and the pure color background images respectively to calculate the similarity between the experimental images and the infringement images.
[0129] The similarity of the experimental images and the infringing images under different attacks for the solid color background images is shown in Table 1, wherein the first row of "house, apple, cat, elephant, cooking, Christmas, coffee, hat" is Figure 3 The abbreviations of the eight experimental images from left to right and from top to bottom.
[0130] Table 1
[0131]
[0132] The similarity of the experimental images and the infringing images under different attacks for the non-solid color background images is shown in Table 2, wherein the first row of "Lena, airplane, Golden Hill, Barbara, ship, baboon" is Figure 4 The abbreviations of the six experimental images from left to right and from top to bottom.
[0133] Table 2
[0134]
[0135] As shown in Table 1, for the solid color background images, the present application has good robustness to common attacks, and the overall average is greater than 0.9, wherein the geometric transformation such as rotation, scaling and translation has less influence on the robustness of the present application method, and the overall robustness generally fluctuates little and is stable at more than 0.94; as shown in Table 2, for the non-solid color background images, the present application also has the effect of copyright protection.
[0136] Change of base color experiment:
[0137] a. Group the solid color background images with different base colors two by two.
[0138] b. Change each group of solid color background images to the same base color, as shown in Figure 5 .
[0139] c. Use the wavelet hash algorithm, zero watermark algorithm, existing perceptual hash algorithm and the present application method to respectively detect the similarity of each group of solid color background images, and compare the detection performance of different algorithms.
[0140] The experimental results are shown in Figure 6 . As shown in the figure, when detecting different solid color background images with the same base color, the similarity value of the present application method is kept below 0.4, and the similarity is less than the preset similarity threshold 0.4, so the present application method can identify two solid color background images with the same base color but actually different as non-infringing original images. On the contrary, the similarity of the remaining algorithms is generally higher than 0.5, which will mistakenly regard one solid color background image as the infringing version of another solid color background image, which is inconsistent with the actual situation.
[0141] In summary, the method has strong robustness and better accuracy, can accurately identify whether the pure color background image infringes the right, and is beneficial to the copyright protection of the pure color background image.
[0142] Embodiment 2:
[0143] Based on the same inventive concept as embodiment 1, this embodiment introduces an infringing image identification device based on an improved perceptual hash algorithm, mainly including an image classification module, an image fingerprint extraction module, a hash value extraction module, a similarity calculation module and an infringing image identification module.
[0144] The image classification module is mainly used for dividing the obtained to-be-verified image into a pure color background image and a non-pure color background image according to an image histogram. In the embodiment of the application, the specific operation of the image classification module is as follows:
[0145] (1) The image histogram of each to-be-verified image is obtained by calling the calcHist function.
[0146] (2) The image pixel matrix corresponding to each to-be-verified image is obtained according to the image histogram.
[0147] (3) The values in the image pixel matrix are sorted in descending order, and the proportion P of the sum of the maximum value and the second largest value in the image pixel matrix to the total sum of the image pixels is calculated:
[0148] P= (e1+ e2) / E (9)
[0149] Wherein, e1 is the maximum value in the image pixel matrix, e2 is the second largest value in the image pixel matrix, and E is the sum of all values in the image pixel matrix.
[0150] (4) The proportion P corresponding to each to-be-verified image is compared with the preset proportion threshold value, when P is greater than or equal to the proportion threshold value, the current to-be-verified image is divided into a pure color background image, otherwise, the current to-be-verified image is divided into a non-pure color background image.
[0151] The image fingerprint extraction module is mainly used for calculating the image fingerprint of the non-pure color background image by using the perceptual hash algorithm, and calculating the image fingerprint of the pure color background image by using the improved perceptual hash algorithm. The existing perceptual hash algorithm retains the low frequency part of the image matrix which concentrates most of the ability, and the improved perceptual hash algorithm retains the high frequency part of the image matrix which contains more details.
[0152] In the image fingerprint extraction module, the specific operation of calculating the image fingerprint of the non-pure color background image by using the existing perceptual hash is as follows:
[0153] (1) The non-pure color background image is reduced to 32*32 size.
[0154] (2) The reduced non-solid color background image is converted into a gray image to obtain a gray matrix f1 of the reduced non-solid color background image.
[0155] (3) Discrete cosine transform (DCT) is performed on the gray matrix f1 of the reduced non-solid color background image to obtain a frequency coefficient matrix of the reduced non-solid color background image.
[0156] Let A1 be the frequency coefficient matrix of the non-solid color background image, and the formula for DCT calculation is as follows:
[0157]
[0158] where A1(u, v) is the DCT value of the u-th row and v-th column in the frequency coefficient matrix A1, c(u) and c(v) are compensation coefficients, N = 32, u ∈ [0, 31], and v ∈ [0, 31].
[0159] The calculation formula of c(u) and c(v) is as follows:
[0160]
[0161] (4) The upper left 8x8 part of the frequency coefficient matrix A1 of the non-solid color background image is retained (i.e., the low-frequency part is retained), and the remaining part is deleted, serving as the image fingerprint of the non-solid color background image.
[0162] In the image fingerprint extraction module, the specific operation of calculating the image fingerprint of the solid color background image by using the improved perceptual hash is as follows:
[0163] (1) The solid color background image is reduced to 32x32 size.
[0164] (2) The reduced solid color background image is converted into a gray image to obtain a gray matrix f2 of the reduced solid color background image.
[0165] (3) Discrete cosine transform (DCT) is performed on the gray matrix f2 of the reduced solid color background image to obtain a frequency coefficient matrix A2 of the reduced solid color background image.
[0166]
[0167] (4) The lower right 8x8 part of the frequency coefficient matrix A2 of the solid color background image is retained (i.e., the high-frequency part is retained), and the remaining part is deleted, serving as the image fingerprint of the solid color background image.
[0168] The hash value extraction module is mainly used to obtain the hash value of each to-be-verified image according to the image fingerprint of each to-be-verified image. The operation of the hash value extraction module is consistent with the operation of step S5 in Embodiment 1.
[0169] The similarity calculation module is mainly used for calculating the similarity of any two to-be-verified images according to the hash values of all to-be-verified images, and the calculation formula of the similarity is as follows:
[0170]
[0171]
[0172] wherein H d is the Hamming distance between any two to-be-verified images, is the kth hash value of the first to-be-verified image, is the kth hash value of the second to-be-verified image, similarity is the similarity of any two to-be-verified images, and HBC is the number of bits of the hash value, HBC=64.
[0173] The infringement image identification module is mainly used for comparing the similarity of the any two to-be-verified images with a preset similarity threshold to obtain an infringement image identification result. Specifically, if the similarity is greater than or equal to the similarity threshold, it is determined that the two to-be-verified images are similar, and there is infringement, otherwise, it is not determined as infringement. In the embodiment of the present application, the similarity threshold is set to 0.4.
[0174] The method and device of the present application perform different processing on pure color background images and non-pure color background images, solve the problem that the prior art is difficult to identify the infringement of pure color background images, achieve more secure and accurate infringement image identification effect, enhance the universality of the algorithm, and make the entire image copyright protection technology more comprehensive in supporting image types. The present application can be used as a kind of authorization of image copyright proof, and can provide better copyright protection for pure color background images and better solve the copyright dispute problem of different images.
[0175] The above description is only the preferred embodiment of the present application, and it should be pointed out that for ordinary skilled persons in the technical field, several improvements and modifications can be made without departing from the technical principles of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.
Claims
1. A method for infringing image recognition based on an improved perceptual hashing algorithm, characterized in that, The method comprises the following steps: According to the image histogram, the obtained to-be-verified images are divided into pure color background images and non-pure color background images; The image fingerprint of the non-pure color background image is calculated by using a perceptual hash algorithm; The image fingerprint of the pure color background image is calculated by using an improved perceptual hash algorithm; According to the image fingerprint of each to-be-verified image, the hash value of each to-be-verified image is obtained; According to the hash values of all to-be-verified images, the similarity between any two to-be-verified images is calculated; The similarity between the two to-be-verified images is compared with a preset similarity threshold value, and an infringement image identification result is obtained; The image fingerprint of the pure color background image is calculated by using an improved perceptual hash algorithm, comprising: The size of the pure color background image is reduced to N×N; The reduced pure color background image is converted into a gray image, and a gray matrix of the reduced pure color background image is obtained; The gray matrix of the reduced pure color background image is subjected to discrete cosine transformation, and a frequency coefficient matrix of the reduced pure color background image is obtained, and the calculation formula is as follows: ; ; wherein, is the DCT value of the u-th row and v-th column in the frequency coefficient matrix A2 of the reduced pure color background image, , is the compensation coefficient, is the gray value of the pixel point with pixel coordinates (i, j) in the reduced pure color background image, u∊[0, N-1], v∊[0, N-1]. The elements in the lower right corner 8×8 part of the frequency coefficient matrix are extracted as the image fingerprint of the pure color background image. 2.The improved perceptual hashing algorithm based infringement image identification method according to claim 1, characterized in that, According to the image histogram, all to-be-verified images are divided into pure color background images and non-pure color background images, comprising: The image histogram of each to-be-verified image is obtained by calling the calcHist function; According to the image histogram, the image pixel matrix corresponding to each to-be-verified image is obtained; The values in the image pixel matrix are sorted in descending order, and the proportion P of the sum of the maximum value and the second largest value in the image pixel matrix to the total sum of the image pixels is calculated: P=(e1+e2) / E Wherein, e1 is the maximum value in the image pixel matrix, e2 is the second largest value in the image pixel matrix, and E is the sum of all values in the image pixel matrix; The proportion P corresponding to each to-be-verified image is compared with a preset proportion threshold value, and when P is greater than or equal to the proportion threshold value, the current to-be-verified image is divided into a pure color background image, otherwise, the current to-be-verified image is divided into a non-pure color background image. 3.The improved perceptual hashing algorithm based infringement image identification method according to claim 1, characterized in that, According to the image fingerprint of each to-be-verified image, the hash value of each to-be-verified image is obtained, comprising: The DCT mean value of the to-be-verified image is calculated according to the image fingerprint of the to-be-verified image; The image fingerprint of the to-be-verified image is normalized according to the DCT mean value, and the hash value of the to-be-verified image is obtained, wherein the normalization formula is as follows: ; ; wherein, denotes the hash value corresponding to the kth element in the image fingerprint of the image to be verified, denotes the DCT value in the pth row and qth column of the image fingerprint of the image to be verified, is the DCT mean value of the image to be verified, h is the hash value of the image to be verified, . 4.The method of claim 1, wherein, The calculation formula of the similarity between any two to-be-verified images is as follows: ; ; wherein, is the Hamming distance between any two images to be verified, is the kth hash value of the first image to be verified, is the kth hash value of the second image to be verified, is the similarity between any two images to be verified, HBC is the number of bits of the hash value, HBC = 64. 5.The improved perceptual hashing algorithm based infringement image identification method according to claim 1, wherein, The similarity between the two to-be-verified images is compared with a preset similarity threshold value, and when the similarity is greater than or equal to the similarity threshold value, it is determined that the two to-be-verified images are similar, and there is an infringement image, otherwise, it is determined that the two to-be-verified images are not similar, and there is no infringement image.
6. An apparatus for infringing image recognition based on an improved perceptual hashing algorithm, characterized by, Comprising: The image classification module is used for dividing the obtained to-be-verified images into pure color background images and non-pure color background images according to the image histogram; The image fingerprint extraction module is used for calculating the image fingerprint of the non-pure color background image by using a perceptual hash algorithm, and calculating the image fingerprint of the pure color background image by using an improved perceptual hash algorithm; The hash value extraction module is configured to obtain a hash value of each to-be-verified image according to an image fingerprint of each to-be-verified image; The similarity calculation module is configured to calculate a similarity between any two to-be-verified images according to the hash values of all to-be-verified images; The infringement image identification module is configured to compare the similarity between the any two to-be-verified images with a preset similarity threshold, and obtain an infringement image identification result. The image fingerprint extraction module calculates the image fingerprint of the solid color background image by using an improved perceptual hashing algorithm, and the calculation includes: reducing the size of the solid color background image to N*N; converting the reduced solid color background image into a gray-scale image to obtain a gray-scale matrix of the reduced solid color background image; performing discrete cosine transform on the gray-scale matrix of the reduced solid color background image to obtain a frequency coefficient matrix of the reduced solid color background image, and the calculation formula is as follows: ; ; wherein, is the DCT value of the u-th row and v-th column in the frequency coefficient matrix A2 of the reduced pure color background image, , is the compensation coefficient, is the gray value of the pixel point with pixel coordinates (i, j) in the reduced pure color background image, u∊[0, N-1], v∊[0, N-1]. extracting elements in the lower right corner of 8*8 of the frequency coefficient matrix as the image fingerprint of the solid color background image.
7. The apparatus for infringement image recognition based on improved perceptual hashing algorithm according to claim 6, characterized in that, The image classification module is specifically configured to: obtain an image histogram of each to-be-verified image by calling a calcHist function; obtain an image pixel matrix corresponding to each to-be-verified image according to the image histogram; sort values in the image pixel matrix in descending order, calculate a proportion P of a sum of a maximum value and a second maximum value in the image pixel matrix in a total sum of image pixels, and the calculation formula is as follows: P=(e1+e2) / E; wherein e1 is the maximum value in the image pixel matrix, e2 is the second maximum value in the image pixel matrix, and E is a sum of all values in the image pixel matrix; compare the proportion P corresponding to each to-be-verified image with a preset proportion threshold, and when P is greater than or equal to the proportion threshold, classify the current to-be-verified image as a solid color background image, otherwise, classify the current to-be-verified image as a non-solid color background image. 8.The device for infringement image recognition based on improved perceptual hashing algorithm according to claim 6, wherein, In the similarity calculation module, the calculation formula of the similarity between any two to-be-verified images is as follows: ; ; wherein, is the Hamming distance between any two images to be verified, is the kth hash value of the first image to be verified, is the kth hash value of the second image to be verified, is the similarity between any two images to be verified, HBC is the number of bits of the hash value, HBC = 64.
Citation Information
Patent Citations
Fast image recognition system and method based on perceptual hashing
CN108897775A
Medical image digital watermarking method based on perceptual hash and data enhancement
WO2022205853A1