Similar picture detection method and device, equipment and storage medium
By using a multidimensional hashing algorithm in APK, combining the transparency, color and content information of the picture, the problem of a single hashing algorithm in the prior art ignores other dimension information, and improves the accuracy of similar picture detection.
Patent Information
- Application Number
- CN202411880930.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-05-09
AI Technical Summary
When detecting similar pictures in the APK, the single hashing algorithm only focuses on the similarity of the pictures in a certain dimension, ignoring the information of other dimensions of the picture, resulting in a low accuracy of similarity judgment.
Using the multidimensional hashing algorithm, a multidimensional hashing array is constructed by obtaining the transparency hashing, color hashing and content hashing of the picture, and the distance between the hashing values of each dimension in the hashing array is compared to determine the similarity of the picture.
Through the multidimensional hashing algorithm, comprehensively considering the content, transparency and color information of the picture, the accuracy of image similarity calculation is improved, and the problem of a single hashing algorithm ignoring other dimension information is solved.
Smart Images

Figure CN119963857A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a similar image detection method, apparatus, device and storage medium. Background Art
[0002] With the development of mobile Internet, the functions of mobile applications are constantly increasing, and the size of Android application packages (APK) is also increasing. Among them, with the iteration of products, the image resources are constantly increasing, and it is inevitable that some identical or similar images are repeatedly added to the APK. How to find these identical or similar images in the resource files of APK has become an urgent problem to be solved.
[0003] In the related art, there are usually two solutions to determine the same or similar pictures in APK. One is to use a cryptographic hash algorithm such as the message digest algorithm (MD5). This method can determine whether two pictures are the same file, but it cannot determine the similarity between the two pictures. The other is to use various picture similarity comparison algorithms. Commonly used picture similarity comparison algorithms include the mean square error algorithm, the structural similarity algorithm and the hash algorithm. Since the mean square error algorithm is computationally complex when performing picture similarity comparison, and the structural similarity algorithm abstracts the picture as feature points and stores it, the amount of data is large. Therefore, a hash algorithm is used to compress the picture into a string for easy comparison and storage. Commonly used picture hash algorithms include the average hash algorithm aHash, the perceptual hash algorithm pHash, the gradient hash algorithm dHash, the wavelet hash algorithm wHash, etc.
[0004] Then, a single hash algorithm only focuses on the similarity of images in a certain dimension, thereby ignoring the impact of other dimensional information of the image on the image similarity, which leads to a low accuracy rate of the image similarity judgment results. Summary of the invention
[0005] In order to solve the above technical problems, the present application provides a similar image detection method, device, equipment and storage medium, which adopts a multi-dimensional hash algorithm to calculate the similarity of images and improve the accuracy of image similarity calculation.
[0006] In a first aspect, the present application provides a similar image detection method, the method comprising: obtaining multiple images to be processed; obtaining a hash array of each image to be processed, the hash array comprising at least one of a transparency hash value and a color hash value of the image to be processed, and a content hash value of the image to be processed, the content hash value being obtained by hashing the image content of the image to be processed, the transparency hash value being obtained by hashing the transparency information of the image to be processed, and the color hash value being obtained by hashing the color information of the image to be processed; performing similarity detection based on the hash arrays of each image to be processed to obtain detection results of each hash array, the detection results of the hash array comprising: at least one of a similarity detection result of a transparency hash value and a color hash value detection result, and a similarity detection result of a content hash value; determining similarity detection results of multiple images to be processed based on the detection results of each hash array.
[0007] In a second aspect, the present application provides a similar image detection device, which includes: an image acquisition module, used to acquire multiple images to be processed; a hash array acquisition module, used to acquire a hash array of each of the images to be processed, the hash array including at least one of a transparency hash value and a color hash value of the image to be processed, and a content hash value of the image to be processed, the content hash value is obtained by hashing the image content of the image to be processed, the transparency hash value is obtained by hashing the transparency information of the image to be processed, and the color hash value is obtained by hashing the color information of the image to be processed; a hash array detection module, used to perform similarity detection based on the hash arrays of each of the images to be processed, and obtain detection results of each of the hash arrays, the detection results of the hash arrays including: at least one of a similarity detection result of the transparency hash value and a color hash value detection result, and a similarity detection result of the content hash value; a picture similarity detection module, used to determine the similarity detection results of multiple images to be processed based on the detection results of each of the hash arrays.
[0008] In a third aspect, the present application provides a similar image detection device, which includes: one or more processors; a storage device for storing one or more programs; when the one or more programs are executed by one or more processors, the one or more processors implement the similar image detection method as described in the first aspect above.
[0009] In a fourth aspect, the present application provides a storage medium, which may be a computer-readable storage medium, storing a computer program thereon, which, when executed by a processor, implements the similar image detection method in the first aspect described above.
[0010] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the similar image detection method as described in any one of the first aspects above is implemented.
[0011] Compared with the prior art, the technical solution provided by the embodiments of the present application has the following advantages:
[0012] The embodiment of the present application provides a similar picture detection method, device, equipment and storage medium, the method comprising: obtaining multiple pictures to be processed; obtaining a hash array of each picture to be processed, the hash array comprising at least one of a transparency hash value and a color hash value of the picture to be processed, and a content hash value of the picture to be processed, the content hash value being obtained by hashing the picture content of the picture to be processed, the transparency hash value being obtained by hashing the transparency information of the picture to be processed, and the color hash value being obtained by hashing the color information of the picture to be processed; performing similarity detection based on the hash arrays of each picture to be processed to obtain detection results of each hash array, the detection results of the hash array comprising: at least one of a similarity detection result of the transparency hash value and a color hash value detection result, and a similarity detection result of the content hash value; determining similarity detection results of multiple pictures to be processed based on the detection results of each hash array. The present application compresses the picture to be processed into a multi-dimensional hash array, and judges the similarity of the pictures by comparing the distances between the hash values of each dimension in the hash array, the multi-dimensional hash array comprising a content hash value representing the picture content, a transparency hash value representing the transparency information, and a color hash value representing the color information. By comparing the distances between the hash values of each dimension in the hash array, the similarity between images is determined. This solves the problem that a single hash algorithm only focuses on the similarity of images in a certain dimension, thereby ignoring the impact of other dimensional information on image similarity, thereby improving the accuracy of image similarity calculation. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0014] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0015] Figure 1 A schematic diagram of a process for detecting similar images provided in an embodiment of the present application;
[0016] Figure 2 A schematic diagram of a process for calculating image similarity provided in an embodiment of the present application;
[0017] Figure 3 A schematic diagram of the process flow of the optimized similar image detection method provided in the embodiment of the present application;
[0018] Figure 4 A schematic diagram of the structure of a similar image detection device provided in an embodiment of the present application;
[0019] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0020] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0021] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.
[0022] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0023] It should be noted that the concepts such as "first" and "second" mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0024] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0025] The following is a detailed description of the similar image detection method provided by the present application in conjunction with the accompanying drawings and specific implementation methods.
[0026] Figure 1This is a flow chart of a similar picture detection method in an embodiment of the present application. This embodiment can be applied to detecting similar or identical pictures. The method can be executed by a similar picture detection device. The similar picture detection device can be implemented in software and / or hardware. The similar picture detection device can be configured in an electronic device.
[0027] like Figure 1 As shown, the similar image detection method provided in the embodiment of the present application mainly includes steps S101-S104.
[0028] S101, obtaining a plurality of images to be processed.
[0029] The to-be-processed images refer to images that need to be compared with each other to determine their similarity. That is, the multiple to-be-processed images refer to a combination of images that need to be compared for similarity between each other to screen out similar images.
[0030] The similar image detection method provided in the embodiment of the present application can be applied to any scenario where the similarity of images needs to be detected. For example, in a large image database or personal album, similar images can be screened out, and these duplicate images can be found and deleted to save storage space. Another example: images that violate community guidelines need to be filtered out on a social platform. Using similarity matching can help identify different versions of illegal images. Another example: based on the images that users often like or share, similar images can be screened out for push, which can provide more accurate advertising push.
[0031] In a possible implementation, obtaining a plurality of to-be-processed images includes: decompressing an application package, and using the decompressed images as the to-be-processed images.
[0032] In a possible implementation, obtaining a plurality of to-be-processed pictures includes: periodically obtaining a plurality of to-be-processed pictures. For example, for a large image database or a personal photo album, periodically obtaining pictures therein as to-be-processed pictures to implement periodic similar picture detection.
[0033] S102, obtaining a hash array of each image to be processed, the hash array including at least one of a transparency hash value and a color hash value of the image to be processed, and a content hash value of the image to be processed, the content hash value being obtained by hashing the image content of the image to be processed, the transparency hash value being obtained by hashing the transparency information of the image to be processed, and the color hash value being obtained by hashing the color information of the image to be processed.
[0034] Among them, Hash is an algorithm that converts data of any length into a fixed-length output through a specific algorithm. Image Hash is an algorithm that converts an image into a fixed-length digital sequence (hash value). Image hashing usually involves a series of processing on the original image, such as size reduction, color simplification, feature extraction, etc., and finally obtains a unique identifier that can represent the characteristics of the image.
[0035] Since the image hash algorithm is used to compress the image into a hash value, the obtained hash value is used to detect whether the images are the same or very similar, which is more efficient. The hash value is used to compare the similarity between images. Even if the image has been rotated, scaled, color adjusted, or watermarked, the hash algorithm can still effectively identify these images, thereby improving the accuracy of image similarity detection.
[0036] The hash array is a multidimensional array consisting of at least one of the transparency hash value and the color hash value of the image to be processed, and the content hash value of the image to be processed. Each hash value represents a dimension in the hash array, and the hash array is a two-dimensional array or three-dimensional data. For example: the hash array is a two-dimensional array consisting of a transparency hash value and a content hash value, or the hash array is a two-dimensional array consisting of a color hash value and a content hash value, or the hash array is a three-dimensional array consisting of a transparency hash value, a color hash value, and a content hash value.
[0037] For each image to be processed, the image content of the image to be processed is hashed to obtain a content hash value, the transparency information of the image to be processed is hashed to obtain a transparency hash value, the color information of the image to be processed is hashed to obtain a color hash value, and a hash array of the image to be processed is constructed using at least one of the transparency hash value or the color hash value and the content hash value. In other words, each image to be processed has its corresponding hash array.
[0038] When the hash array is a three-dimensional array, the hash array can represent a picture from three dimensions, namely, a content hash value representing the content of the picture, a transparency hash value representing the transparency information of the picture, and a color value representing the color of the picture.
[0039] The calculation method of the hash array of the image to be processed uses the ImageHash library implemented in python. The imageHash library is a Python library that supports multiple types of hash algorithms, including but not limited to: Average Hash (aHash), Difference Hash (dHash), Perceptual Hash (pHash), Wavelet Hash (wHash), and Color Hash.
[0040] Among them, the average hash algorithm: calculates the grayscale average of the image. Compare each pixel with the average value, set it to 1 if it is higher than the average value, and set it to 0 if it is lower. Get a binary string as the hash value. The difference hash algorithm: compares the brightness difference of adjacent pixels. Compare pixels row by row from left to right. If the pixel on the right is brighter than the pixel on the left, set it to 1, otherwise set it to 0. The perceptual hash algorithm: first perform a discrete cosine transform (DCT) on the image, take the low-frequency part after DCT, and quantize it to a fixed size. Compare the quantized value with the average value to get the hash value. Wavelet hash algorithm: Use wavelet transform to extract image features and generate hash values by analyzing wavelet coefficients. Color hash algorithm: Calculate the color histogram or other color statistics of the image, and use these statistics to create hash values.
[0041] Use the color hash algorithm to hash the image to get the color hash value to be processed. The color hash algorithm uses the Color hash algorithm provided by the mageHash library. You can use any of the aHash algorithm, dHash algorithm, pHash algorithm, and wHash algorithm to hash the image to get the content hash value and transparency hash value.
[0042] Furthermore, since the pHash algorithm and the wHash algorithm use discrete cosine transform and discrete wavelet transform respectively, the calculation is complex, and the aHash algorithm compares each pixel with the average value of the pixels in the row, which is not as accurate as the dHash algorithm that compares the difference between the front and back pixels of each row. Therefore, the dHash algorithm is selected in the embodiment of the present application to calculate the content hash value and transparency hash value of the image to be processed.
[0043] The specific process of using the dHash algorithm to calculate the content hash value includes: converting the image to be processed from a color image to a grayscale image, reducing the grayscale image to a fixed size, and traversing the reduced image from left to right and from top to bottom. For each pixel in each row (except the last column), calculate the brightness difference between the current pixel and the adjacent pixel on the right. If the current pixel is brighter than the adjacent pixel on the right, it is recorded as 1; if it is darker or equal, it is recorded as 0. Stringing all these binary numbers together forms the final content hash value.
[0044] The specific process of using the dHash algorithm to calculate the transparency hash value includes: loading the image to be processed containing the transparency (Alpha) channel, and separating the Alpha channel from the image to be processed. The Alpha channel usually represents the transparency of each pixel, ranging from 0 (completely transparent) to 255 (completely opaque). Reduce the Alpha channel to a fixed size, traverse the reduced Alpha channel, and for each pixel in each row (except the last column), compare the transparency value between the current pixel and the adjacent pixel on the right. If the current pixel is more opaque than the adjacent pixel on the right (that is, the Alpha value is larger), it is recorded as 1; if it is more transparent or equal, it is recorded as 0. Stringing all these binary numbers together forms the final transparency hash value.
[0045] The specific process of using the Color hash algorithm to calculate the color hash value includes: scaling the image to be processed to a fixed size. If the image to be processed is not stored in RGB format, it needs to be converted to RGB color space. For the entire thumbnail, the color distribution in the thumbnail is counted, that is, the average color of the three color channels, and the result is a triplet representing the average color of the entire image. Create a color histogram for each color channel, count the frequency of each color, and then construct a color hash value based on the histogram data.
[0046] For each image to be processed, the transparency hash value, content hash value and color hash value are calculated respectively in the above manner, and at least one of the transparency hash value and content hash value, as well as the color hash value, are combined according to a set rule to obtain a hash array of the image to be processed. The set rule refers to the position of the transparency hash value, content hash value and color hash value in the hash array. For example: the content hash value is the first dimension of the hash array, the transparency hash value is the second dimension of the hash array, and the color hash value is the third dimension of the hash array.
[0047] S103, performing similarity detection based on the hash arrays of each to-be-processed image to obtain detection results of each hash array, wherein the detection results of the hash arrays include: at least one of a similarity detection result of a transparency hash value and a similarity detection result of a color hash value, and a similarity detection result of a content hash value.
[0048] The similarity detection of hash arrays refers to calculating the similarity between the hash arrays of any two images to be processed, and then determining the similarity between the two images to be processed.
[0049] The similarity detection result of the transparency hash value refers to whether the transparency dimension in the hash array is similar, that is, the size relationship between the similarity value of the transparency hash value and the first similarity threshold, mainly including: the transparency dimension in the hash array is similar, and the transparency dimension in the hash array is not similar. If the similarity value of the transparency hash value is greater than the first similarity threshold, the transparency dimension is similar, and if the similarity of the transparency hash value is less than or equal to the first similarity threshold, the transparency dimension is not similar.
[0050] The similarity detection result of the content hash value refers to whether the content dimension in the hash array is similar, and the size relationship between the similarity value of the content hash value and the first similarity threshold, mainly including: the content dimension in the hash array is similar, and the content dimension in the hash array is not similar. If the similarity value of the content hash value is greater than the third similarity threshold, the content dimension is similar, and if the similarity of the content hash value is less than or equal to the third similarity threshold, the content dimension is not similar.
[0051] The similarity detection result of the color hash value refers to whether the color dimension in the hash array is similar, and the size relationship between the similarity value of the color hash value and the first similarity threshold, mainly including: the color dimension in the hash array is similar, and the color dimension in the hash array is not similar. If the similarity value of the color hash value is greater than the second similarity threshold, the color dimension is similar, and if the similarity of the color hash value is less than or equal to the second similarity threshold, the color dimension is not similar.
[0052] The similarity detection result of two hash values can be represented by the relationship between the Hamming distance between the two hash values and the similarity threshold. When the Hamming distance between the two hash values is less than the similarity threshold, it indicates that the two hash values are not similar, and when the Hamming distance between the two hash values is greater than or equal to the similarity threshold, it indicates that the two hash values are similar.
[0053] Specifically, for hash arrays of any two images to be processed, the Hamming distance between the transparency hash values is calculated respectively, and based on the relationship between the Hamming distance between the transparency hash values and the first distance threshold, the similarity detection result of the transparency hash values is determined; the Hamming distance between the color hash values is calculated, and based on the relationship between the Hamming distance between the color hash values and the second distance threshold, the similarity detection result of the color hash values is determined; the Hamming distance between the content hash values is calculated, and based on the relationship between the Hamming distance between the content hash values and the third distance threshold, the similarity detection result of the content hash values is determined, and the similarity detection result of the hash array is determined based on at least one of the similarity detection result of the transparency hash value and the similarity detection result of the color hash value, and the similarity detection result of the content hash value.
[0054] Specifically, if the similarity detection results of hash values of different dimensions included in the hash array are all similar, the detection result of the hash array is similar; if the similarity detection result of the hash value of any dimension included in the hash array is dissimilar, the detection result of the hash array is dissimilar.
[0055] Take the hash array as a three-dimensional array including a transparency hash value, a color hash value, and a content hash value as an example for explanation. If the similarity detection results of the transparency hash value, the color hash value, and the content hash value included in the hash array are all similar, then the detection result of the hash array is similar. If the similarity detection result of the hash value of any dimension among the transparency hash value, the color hash value, and the content hash value included in the hash array is dissimilar, then the detection result of the hash array is dissimilar.
[0056] S104: Determine similarity detection results of multiple images to be processed based on the detection results of each hash array.
[0057] The similarity detection results of the images to be processed include two results. The first detection result means that there are no similar images among the multiple images to be processed. In this case, the similarity detection result is a prompt message, which is used to prompt the designer that there are no similar or identical images among the multiple images to be processed. The second detection result means that there is at least one group of similar images among the multiple images to be processed. In this case, the similarity detection result includes at least one similar image set, and the similar image set includes at least two images whose similarity is greater than the set similarity threshold.
[0058] In a possible implementation, a hash array that meets a set condition is screened out from the detection results of each hash array, wherein meeting the set condition includes: a similarity value of a transparency hash value is greater than at least one of a first similarity threshold and a color hash value is greater than a second similarity threshold, and a similarity value of a content hash value is greater than a third similarity threshold; and at least two to-be-processed images corresponding to the hash array that meets the set condition are determined as a similar image set.
[0059] In order to compare the similarity between two images to be processed, the images to be processed are numbered in order from 1 to N, and an N×N matrix is created, where N is the number of images to be processed, and each element (i, j) of the matrix stores the detection result between the hash array of the i-th image to be processed and the hash array of the j-th image to be processed. For the elements (i, i) on the diagonal, because they are the comparison of the same image to be processed, they are usually set to 0 or the maximum similarity.
[0060] Specifically, the matrix element (i, j) stores the relationship between the similarity value of the transparency hash value of the i-th image to be processed and the first similarity threshold, the relationship between the similarity value of the color hash value and the second similarity threshold, and the relationship between the similarity value of the content hash value and the third similarity threshold.
[0061] In the process of determining the similarity detection results of multiple pictures to be processed based on the detection results of each of the hash arrays, the storage content of each element in the above N×N matrix is read in turn. If the similarity value of the transparency hash value is greater than the first similarity threshold, the similarity value of the color hash value is greater than the second similarity threshold, and the similarity value of the content hash value is greater than the third similarity threshold, it indicates that the two pictures to be processed corresponding to the element are similar.
[0062] If the similarity value of the transparency hash value is less than or equal to the first similarity threshold, or the similarity value of the color hash value is less than or equal to the second similarity threshold, or the similarity value of the content hash value is less than or equal to the third similarity threshold, it indicates that the two to-be-processed images corresponding to the element are not similar.
[0063] In a possible implementation, the similarity values between hash values can be represented by the Hamming distance between the hash values. Specifically, the similarity values between transparency hash values can be represented by the Hamming distance between transparency hash values, the similarity values between color hash values can be represented by the Hamming distance between color hash values, and the similarity values between content hash values can be represented by the Hamming distance between content hash values.
[0064] Specifically, the similarity value of the transparency hash value is greater than the first similarity threshold, including: the Hamming distance of the transparency hash value is less than the first distance threshold; the similarity value of the color hash value is greater than the second similarity threshold, including: the Hamming distance of the color hash value is less than the second distance threshold; the similarity value of the content hash value is greater than the third similarity threshold, including: the Hamming distance of the content hash value is less than the third distance threshold.
[0065] Specifically, the matrix element (i, j) stores the relationship between the Hamming distance of the transparency hash value of the i-th image to be processed and the first distance threshold, the relationship between the Hamming distance of the color hash value and the second distance threshold, and the relationship between the Hamming distance of the content hash value and the third distance threshold.
[0066] In the process of determining the similarity detection results of the plurality of images to be processed based on the detection results of the hash arrays, the storage content of each element in the N×N matrix is read in turn. If the Hamming distance of the transparency hash value is greater than the first distance threshold, the Hamming distance of the color hash value is greater than the second distance threshold, and the Hamming distance of the content hash value is greater than the third distance threshold, it indicates that the two images to be processed corresponding to the element are similar.
[0067] If the Hamming distance of the transparency hash value is less than or equal to the first distance threshold, or the Hamming distance of the color hash value is less than or equal to the second distance threshold, or the Hamming distance of the content hash value is less than or equal to the third distance threshold, it indicates that the two to-be-processed images corresponding to the element are not similar.
[0068] Further, after determining that the two to-be-processed pictures are similar, the two to-be-processed pictures are similar and are added to the corresponding similar picture set. Specifically, it is queried whether one of the two similar to-be-processed pictures already belongs to a similar picture set. If so, the other to-be-processed picture is added to the similar picture set. If neither of the two similar to-be-processed pictures belongs to the existing similar picture set, a new similar picture set is created for the two similar to-be-processed pictures, and the two similar to-be-processed pictures are stored in the new similar picture set.
[0069] For example: through the above steps, it is determined that the i-th picture to be processed and the j-th picture to be processed are similar, then query whether the i-th picture to be processed belongs to an existing similar picture set. If so, add the j-th picture to be processed to the existing similar picture set. If not, query whether the j-th picture to be processed belongs to an existing similar picture set. If so, add the i-th picture to be processed to the existing similar picture set. If the i-th picture to be processed and the j-th picture to be processed do not belong to an existing similar picture set, create a new similar picture set for the i-th picture to be processed and the j-th picture to be processed. Add the i-th picture to be processed and the j-th picture to be processed to the similar picture set.
[0070] In a possible implementation, obtaining a plurality of pictures to be processed includes: when a new picture is detected, obtaining a plurality of pictures to be processed, wherein the pictures to be processed include the new picture.
[0071] When a new picture is detected, it is necessary to determine the similarity between the new picture and the existing pictures. Specifically, according to the calculation method of the hash array provided in the above embodiment, the hash array of the new picture is determined, and the similarity detection is performed based on the hash array of the new picture and the hash array of the determined similar pictures to obtain the detection results of each hash array. According to the detection results of each hash array, it is determined whether the new picture is similar to the screened similar pictures.
[0072] The embodiment of the present application provides a similar picture detection method, the method comprising: obtaining a plurality of pictures to be processed; obtaining a hash array of each picture to be processed, the hash array comprising at least one of a transparency hash value and a color hash value of the picture to be processed, and a content hash value of the picture to be processed, the content hash value being obtained by hashing the picture content of the picture to be processed, the transparency hash value being obtained by hashing the transparency information of the picture to be processed, and the color hash value being obtained by hashing the color information of the picture to be processed; performing similarity detection based on the hash arrays of each picture to be processed, and obtaining detection results of each hash array, the detection results of the hash array comprising: at least one of a similarity detection result of the transparency hash value and a color hash value detection result, and a similarity detection result of the content hash value; determining similarity detection results of a plurality of pictures to be processed based on the detection results of each hash array. The present application compresses the picture to be processed into a multi-dimensional hash array, and judges the similarity of the pictures by comparing the distances between the hash values of each dimension in the hash array, the multi-dimensional hash array comprising a content hash value representing the picture content, a transparency hash value representing the transparency information, and a color hash value representing the color information. By comparing the distances between the hash values of each dimension in the hash array, the similarity between images is determined. This solves the problem that a single hash algorithm only focuses on the similarity of images in a certain dimension, thereby ignoring the impact of other dimensional information on image similarity, thereby improving the accuracy of image similarity calculation.
[0073] In another possible implementation, a method for determining image similarity is provided, such as Figure 2 As shown, the method for determining the similarity of pictures mainly includes steps S201 to S207.
[0074] S201. For any two images to be processed, calculate the Hamming distance between the transparency hash values of the two images to be processed.
[0075] Traverse multiple pictures to be processed, obtain the i-th picture to be processed and the j-th picture to be processed, and calculate the Hamming distance between the transparency hash value of the i-th picture to be processed and the transparency hash value of the j-th picture to be processed.
[0076] S202, determining whether the Hamming distance of the transparency hash values of the two images to be processed is less than a first distance threshold, if not, returning to execute S201, if yes, executing S203.
[0077] The first distance threshold can be understood as a value that measures whether the images are similar in the transparency dimension. If the Hamming distance between the transparency hash value of the i-th image to be processed and the transparency hash value of the j-th image to be processed is less than the first distance threshold, it indicates that the i-th image to be processed and the j-th image to be processed are similar in the transparency dimension.
[0078] If the Hamming distance between the transparency hash value of the i-th image to be processed and the transparency hash value of the j-th image to be processed is greater than or equal to the first distance threshold, it indicates that the i-th image to be processed and the j-th image to be processed are not similar in the transparency dimension. At this time, it is no longer necessary to determine whether they are similar in the content dimension and the color dimension. The execution returns to S201 to obtain the i-th image to be processed and the j+1-th image to be processed from the multiple images to be processed, and calculate the Hamming distance between the transparency hash value of the i-th image to be processed and the transparency hash value of the j+1-th image to be processed. If j+1 is equal to N, obtain the i+1-th image to be processed and the 1st image to be processed from the multiple images to be processed, and calculate the Hamming distance between the transparency hash value of the i+1-th image to be processed and the transparency hash value of the 1st image to be processed.
[0079] S203: Calculate the Hamming distance between the color hash values of two images to be processed.
[0080] If the Hamming distance of the transparency hash values of the two images to be processed is less than the first distance threshold, it indicates that the i-th image to be processed and the j-th image to be processed are similar in color dimension. Further, the Hamming distance between the color hash value of the i-th image to be processed and the color hash value of the j-th image to be processed is calculated.
[0081] S204, determining whether the Hamming distance between the color hash values of the two images to be processed is less than a second distance threshold, if not, returning to execute S201, if yes, executing S205.
[0082] The second distance threshold can be understood as a value that measures whether the images are similar in color dimension. If the Hamming distance between the color hash value of the i-th image to be processed and the color hash value of the j-th image to be processed is less than the second distance threshold, it indicates that the i-th image to be processed and the j-th image to be processed are similar in color dimension.
[0083] If the Hamming distance between the color hash value of the i-th image to be processed and the color hash value of the j-th image to be processed is greater than or equal to the second distance threshold, it indicates that the i-th image to be processed and the j-th image to be processed are not similar in color dimension. At this time, it is no longer necessary to determine whether they are similar in content dimension. The execution returns to S201 to obtain the i-th image to be processed and the j+1-th image to be processed from multiple images to be processed, and calculate the Hamming distance between the transparency hash value of the i-th image to be processed and the transparency hash value of the j+1-th image to be processed. If j+1 is equal to N, obtain the i+1-th image to be processed and the 1st image to be processed from multiple images to be processed, and calculate the Hamming distance between the transparency hash value of the i+1-th image to be processed and the transparency hash value of the 1st image to be processed.
[0084] S205: If the Hamming distance between the color hash values of the two pictures to be processed is less than the second distance threshold, calculate the Hamming distance between the content hash values of the two pictures to be processed.
[0085] If the Hamming distance between the color hash value of the i-th image to be processed and the color hash value of the j-th image to be processed is less than the second distance threshold, it indicates that the i-th image to be processed and the j-th image to be processed are similar in color dimension. Further, the Hamming distance between the color hash value of the first image and the color hash value of the second image is calculated as the third distance.
[0086] S206, determining whether the Hamming distance between the content hash values of the two images to be processed is less than a third distance threshold, if not, returning to execute S201, if yes, executing S207.
[0087] The third distance threshold can be understood as a value that measures whether the images are similar in content dimension. If the Hamming distance between the content hash value of the i-th image to be processed and the content hash value of the j-th image to be processed is less than the third distance threshold, it indicates that the i-th image to be processed and the j-th image to be processed are similar in content dimension.
[0088] If the Hamming distance between the content hash value of the i-th image to be processed and the content hash value of the j-th image to be processed is greater than or equal to the third distance threshold, it indicates that the i-th image to be processed and the j-th image to be processed are not similar in content dimension. At this time, it is no longer necessary to determine whether they are similar in content dimension, and the execution returns to S201 to obtain the i-th image to be processed and the j+1-th image to be processed from multiple images to be processed, and calculate the Hamming distance between the transparency hash value of the i-th image to be processed and the transparency hash value of the j+1-th image to be processed. If j+1 is equal to N, obtain the i+1-th image to be processed and the 1st image to be processed from multiple images to be processed, and calculate the Hamming distance between the transparency hash value of the i+1-th image to be processed and the transparency hash value of the 1st image to be processed.
[0089] S207: Determine that the two to-be-processed pictures are similar pictures.
[0090] If the Hamming distance between the content hash value of the i-th image to be processed and the content hash value of the j-th image to be processed is less than the third distance threshold, it indicates that the i-th image to be processed and the j-th image to be processed are similar in content dimension. At this time, the i-th image to be processed and the j-th image to be processed are regarded as similar images, and the execution returns to S201 to obtain the i-th image to be processed and the j+1-th image to be processed from multiple images to be processed, and calculate the Hamming distance between the transparency hash value of the i-th image to be processed and the transparency hash value of the j+1-th image to be processed. If j+1 is equal to N, obtain the i+1-th image to be processed and the 1st image to be processed from multiple images to be processed, and calculate the Hamming distance between the transparency hash value of the i+1-th image to be processed and the transparency hash value of the 1st image to be processed.
[0091] It should be noted that in the embodiment of the present application, the transparency hash value is determined first, then the color hash value is determined, and finally the content hash value is determined for explanation, but the order of determining the hash values of the three dimensions is not limited.
[0092] In an embodiment of the present application, after calculating the hash values of two images to be processed in any dimension, it is directly determined whether the hashes are similar in this dimension. If not, it is directly determined that the two images to be processed are not similar, which can reduce the amount of calculation of the hash array.
[0093] Based on the above embodiments, the embodiments of the present application further optimize the similar image detection method, such as Figure 3 As shown, the optimized similar image detection method provided in the embodiment of the present application mainly includes steps S301 to S310.
[0094] The similar image detection method provided in the embodiment of the present application is used to detect whether there are identical or similar images in an application package.
[0095] In the process of designing or optimizing an application package, it is usually necessary to add a large number of image files to the application package, such as icons in the application, etc., and inevitably a large number of identical or similar images appear in the application package. The embodiment of the present application is mainly used to find these identical or similar images from the image files of the application package during the process of designing or optimizing the application package by the designer, and delete some or all similar images to reduce the size of the application package.
[0096] S301, decompressing the application package to be detected to obtain multiple decompressed files and file paths of the decompressed files.
[0097] An application package is a collection of all files and resources of an application, which enables the application to be installed, distributed and run on a specific operating system or platform. Different operating systems have different application package formats. The application package to be detected can be understood as the application package that needs to be detected to see if there are similar images in the application package.
[0098] The above-mentioned application package to be detected can be an application package in any format. In other words, the above-mentioned application package to be detected can be an application package applied to any operating system. Specifically, the application package to be detected can include any of the following: an Android application package, an IOS application package, a Windows application package, a macOS application package, and a Linux application package. In the embodiment of the present application, the application package to be tested is an Android application package APK as an example for explanation.
[0099] The decompressed files refer to multiple files obtained after decompressing the application package to be detected. The file path of the decompressed files refers to the specific storage location or storage directory of the decompressed files locally.
[0100] According to the format of the application package to be detected, an appropriate decompression tool or decompression software is selected to decompress the application package to be detected, and multiple decompressed files and the file path of each decompressed file are obtained.
[0101] Specifically, when the application package to be detected is an APK, the APK is actually a ZIP file. The application package to be detected is decompressed using ZIP file decompression software or a command line tool to obtain a decompressed file and a file path of the decompressed file.
[0102] Specifically, when the application package to be detected is an iOS IPA file, a tool or command line tool specifically for iOS application analysis is used to decompress the application package to be detected to obtain a decompressed file and a file path of the decompressed file.
[0103] S302. Filter out multiple image file paths from multiple file paths, where the image path is a file path with at least one suffix being a first data element, where the first data element is used to indicate that the file path indicates an image file.
[0104] The first data element is used to indicate a file path indicating a picture file.
[0105] Among them, the suffix in the file path usually refers to the file extension. The file extension is a string that follows the file name and is used to indicate the file type. It usually starts with a dot (.). The first data element may refer to a string that the file type is a picture type. For example: the first data element may be any one of .jpg, .png, and .gif. In the embodiment of the present application, the first data element is .png as an example for explanation.
[0106] Traverse the file paths of all decompressed files and record the file paths with the suffix .png as the image file paths. In other words, the image file paths refer to the file paths with the suffix .png.
[0107] S303: Delete the file paths that meet the filtering condition from the multiple image file paths to obtain a new image file path.
[0108] Among them, satisfying the filtering conditions includes: the suffix of the file path is the second data element, or pictures with the same name are stored in different resource qualifier files; the second data element includes the first character and the first data element, and the first character is used to indicate that the picture file corresponding to the file path is a picture file with a set purpose in the operating system.
[0109] The second data element includes a first character and a first data element, wherein the first character is used to indicate that the image file corresponding to the file path is an image file with a set purpose in the operating system.
[0110] Exemplarily, the first character may be .9. Further, the second data element may be .9.png. A .9.png file is a special png image format, mainly used in Android applications. Files in the .png image format contain not only image data, but also additional information to define which parts can be stretched (scalable area) and where the content should be placed (content area). The main purpose of a .9.png file is to create UI elements such as buttons, backgrounds, etc. that can adapt to different screen sizes and resolutions. Allows images to maintain a good appearance on screens of different sizes without distortion. If .9.png files are filtered out, the application interface may not be displayed correctly. Therefore, .9.png files are images that cannot be deleted, so the file path of this format is deleted from the image file path set. That is, the similarity of the images corresponding to the .9.png file paths is not compared to avoid the .9.png files being accidentally deleted, resulting in incorrect display of the application interface.
[0111] In Android development, resource qualifiers are strings used to specify specific conditions or device configurations for which resource files are applicable. Resource qualifiers allow developers to provide different versions of resources for different device features, such as screen density, language, region, orientation, etc. Among them, resource qualifiers can be hdpi, xhdpi, etc. hdp means high-density screen (240dpi), and xhdpi means ultra-high-density screen (320dpi).
[0112] Pictures with the same name are stored in different resource qualifier files, which means that pictures with the same name can exist in different resource qualifier folders. These resource qualifier folders are organized according to conditions such as screen density, language, and region, so that applications can load the most appropriate resources according to the specific configuration of the device. Therefore, the picture file paths of pictures with the same name stored in different resource qualifier files are filtered out from multiple picture file paths. That is, the similarity of pictures with the same name stored in different resource qualifier files is not compared to avoid such pictures being accidentally deleted, resulting in the inability to provide different versions of pictures for different device characteristics.
[0113] In an embodiment of the present application, by deleting pictures in the picture file path that do not need to be compared for similarity, it is avoided that pictures are accidentally deleted, thereby affecting the use of the application.
[0114] In another embodiment, the file paths of all decompressed files in the decompressed file set are traversed, and the file paths whose file paths have a suffix of .png are recorded, and it is determined whether the .png file path is a .9.png file path. If the .png file path is a .9.png file path, the .9.png file path is not used as the image file path, and the file path of the new decompressed file is re-obtained for determination.
[0115] If the .png file path is not the .9.png file path, determine whether there is a picture corresponding to the file path with the same name but belonging to a different resource qualifier file. If there is a picture corresponding to the file path with the same name but belonging to a different resource qualifier file, do not use the file path corresponding to the picture as the picture file path, and re-obtain the file path of the new decompressed file for judgment.
[0116] If the .png file path is not the .9.png file path, and the image corresponding to the file path does not have the same name but belongs to a different resource qualifier file, then the file path with the suffix .png is recorded as the image file path, and the file path of the new decompressed file is obtained again for judgment.
[0117] S304: extracting images from decompressed files corresponding to multiple image file paths to obtain multiple images to be processed.
[0118] After obtaining multiple image file paths, a picture is stored in the storage location corresponding to each file path.
[0119] By extracting an image from the decompressed file corresponding to an image file path, you can get an image to be processed. After extracting the images corresponding to all image file paths, you can get a collection of images to be processed.
[0120] S305: Obtain a hash array of each of the pictures to be processed.
[0121] The hash array includes at least one of a transparency hash value and a color hash value of the image to be processed, and a content hash value of the image to be processed.
[0122] The calculation method of the hash array of the image to be processed can refer to the description in the above embodiment and is not specifically limited in the embodiments of the present application.
[0123] After calculating the hash array of the image to be processed, the file path of the image to be processed is used as the key and the hash array of the image to be processed is used as the value and stored in the hash table. Optionally, the string length of the content hash value, transparency hash value and color hash value in the hash array is 16 bits. The string length of the content hash value, transparency hash value and color hash value is not limited in the embodiment of the present application. The longer the string length of the content hash value, transparency hash value and color hash value is, the more picture information it stores.
[0124] S306: Perform similarity detection based on the hash arrays of the pictures to be processed to obtain detection results of the hash arrays.
[0125] S307: Filter out the hash arrays that meet the set conditions from the detection results of the hash arrays, and determine the corresponding at least two to-be-processed pictures as a similar picture set.
[0126] S305-S307 provided in the embodiment of the present application is the same as the execution process of S102-S104 provided in the above embodiment. For details, please refer to the description in the above embodiment, which will not be repeated in the embodiment of the present application.
[0127] The method for detecting the similarity of the images may refer to the description in the above embodiments and will not be specifically limited in the embodiments of the present application.
[0128] In an embodiment of the present application, the key-value pairs in the hash table are traversed, and the hash array stored in the value of the accessed key-value pair is used to calculate the Hamming distance in the transparency dimension, color dimension, and content dimension respectively. If the Hamming distance in the transparency dimension, color dimension, and content dimension is less than the set distance threshold, the similarity between the corresponding images is determined.
[0129] S308: Determine the picture to be deleted from the similar picture set.
[0130] The images to be deleted refer to the image files in the application package that can be deleted.
[0131] In a possible implementation, determining the to-be-deleted picture from the similar picture set includes: sending multiple pictures in the similar picture set to a client for display; receiving a deletion instruction sent by the client, and using the picture carried in the deletion instruction as the to-be-deleted picture.
[0132] In an embodiment of the present application, after determining a similar picture set in S307, each similar picture in the similar picture set is sent to the client interface of the staff for display. At the same time, the corresponding deletion control is stopped from being displayed on the client interface for each similar picture. The client generates a deletion instruction corresponding to the similar picture in response to the staff's triggering operation on the deletion control, and sends the deletion instruction to the server. After receiving the deletion instruction, the server parses the deletion instruction and obtains the picture carried in the deletion instruction as the picture to be deleted.
[0133] In this way, by displaying similar pictures and deleting them according to the staff's deletion instructions, the deletion accuracy can be improved and accidental deletion of pictures can be avoided.
[0134] In one possible implementation, determining pictures to be deleted from a similar picture set includes: obtaining picture quality parameters of each picture in the similar picture set; screening out pictures whose picture quality parameters are greater than a set quality threshold from the similar picture set as a preliminary picture set; screening out pictures whose similarity is less than a fourth similarity threshold from the preliminary picture set as a retained picture set; and selecting pictures in the similar picture set except for the retained picture set as pictures to be deleted.
[0135] The picture quality parameter can be represented by at least one or more of the following indicators: resolution, clarity, brightness, contrast, color saturation, etc. Further, the above multiple indicators can be normalized and weighted to obtain the picture quality difference parameter of the picture to be processed. The larger the picture quality parameter, the higher the quality of the picture to be processed, and the smaller the picture quality parameter, the lower the quality of the picture to be processed.
[0136] Set a quality threshold as the screening standard for the preliminary image collection. When the image quality parameter of a similar image exceeds the set quality threshold, it indicates that the quality of the similar image is higher and can be retained. When the image quality parameter of a similar image is lower than the set quality threshold, it indicates that the quality of the similar image is lower and needs to be deleted.
[0137] The fourth similarity threshold refers to the maximum similarity allowed between similar images. If the similarity value between two images is lower than the fourth similarity threshold, it is considered that they may show more information from different angles and should be retained. By comparing the similarity values of each pair of images in the preliminary image set, the images with similarity values less than the fourth similarity threshold are added to the retained image set.
[0138] The similarity value between the two pictures can be represented by the similarity value between the hash arrays corresponding to the two pictures. For details, please refer to the description in the above embodiment.
[0139] All images in the similar image set that are not in the retained image set are marked as images to be deleted. That is, the images to be deleted either do not meet the quality threshold or are too similar to a retained image and are therefore considered redundant.
[0140] It can effectively reduce the number of similar images while ensuring that only high-quality and unique images are retained.
[0141] S309: Delete the decompressed file corresponding to the to-be-deleted picture from the multiple decompressed files to obtain a compressed file set.
[0142] Get the image file path of the image to be deleted, and delete the image file in the storage location indicated by the image file path of the image to be deleted.
[0143] After deleting all the picture files indicated by the picture file paths of the multiple pictures to be deleted, the remaining decompressed files are used as a compressed file set.
[0144] In a possible implementation, after determining the image to be deleted, the key-value pair corresponding to the file path of the image to be deleted in the hash table is deleted to reduce the storage space occupied by the hash table. The key-value pair corresponding to the file path refers to the key-value pair whose key value is the file path.
[0145] S310: compress the decompressed files in the compressed file set to obtain an application package.
[0146] In an embodiment of the present application, compression software is used to compress the decompressed files in the compressed file set to obtain an application package. Similar images are deleted from the compressed application package, thereby greatly reducing the size of the application package.
[0147] On the basis of the above embodiments, the similar image detection method is further optimized, and the optimized similar image detection method also includes: obtaining the newly added image and the application package to which the newly added image belongs; performing hash processing on the newly added image to obtain a hash array of the newly added image; obtaining a pre-stored hash array corresponding to the application package to which the newly added image belongs; calculating the distance between the hash array of the newly added image and the hash array corresponding to the application package; if there is a hash array whose distance is less than a set distance threshold, the newly added image is treated as a newly added similar image, and the newly added similar image is used to indicate that it is prohibited to be added to the application package to which the newly added image belongs.
[0148] After the application is launched, in order to improve the user experience of the application, the application package needs to be continuously optimized. In the process of optimizing the application package, it is inevitable to add pictures to the application package. The embodiment of the present application is mainly used to determine whether there are pictures similar to the pictures to be added in the pictures stored in the application package.
[0149] The newly added image refers to the file that you want to add to the application package during the application package optimization process. The application package corresponding to the newly added image refers to the application package to which the newly added image is added.
[0150] The process of performing hash processing on the newly added picture to obtain the hash array of the newly added picture is the same as the process of performing hash processing on the picture to be processed to obtain the hash array of the picture to be processed in the above embodiment. For details, please refer to the description in the above embodiment, and it is not specifically limited in the embodiments of the present application.
[0151] Each application package has its corresponding hash table, which stores the hash array of all images in the application package. After determining the application package corresponding to the newly added image, its corresponding hash table is determined based on the package name of the application package. The hash array of all images in the application package is read from the hash table.
[0152] By calculating the distance between the hash array of the newly added picture and the hash array corresponding to the application package, it is determined whether there is a picture similar to the newly added picture in the pictures stored in the application package. The method of calculating the similarity of pictures is the same as the method of calculating the similarity of pictures in the above embodiment, which can be specifically referred to the description in the above embodiment and is not specifically limited in the embodiments of this application.
[0153] If there are pictures similar to the newly added picture among the pictures already stored in the application package, the newly added picture will no longer be added to the application package, thereby avoiding unlimited growth of the application package size caused by continuously adding pictures.
[0154] If there is no picture similar to the newly added picture among the pictures already stored in the application package, the newly added picture can be added to the application package, and the hash array corresponding to the newly added picture is stored in the hash table corresponding to the application package.
[0155] Figure 4 is a schematic diagram of the structure of a similar image detection device in an embodiment of the present application, such as Figure 4 As shown, the similar image detection device 40 provided in the embodiment of the present application mainly includes: an image acquisition module 41, a hash array acquisition module 42, a hash array detection module 43 and an image similarity detection module 44.
[0156] Among them, the image acquisition module 41 is used to acquire multiple images to be processed; the hash array acquisition module 42 is used to acquire the hash array of each image to be processed, the hash array includes at least one of the transparency hash value and the color hash value of the image to be processed, and the content hash value of the image to be processed, the content hash value is obtained by hashing the image content of the image to be processed, the transparency hash value is obtained by hashing the transparency information of the image to be processed, and the color hash value is obtained by hashing the color information of the image to be processed; the hash array detection module 43 is used to perform similarity detection based on the hash array of each image to be processed to obtain the detection results of each hash array, and the detection results of the hash array include: at least one of the similarity detection result of the transparency hash value and the color hash value detection result, and the similarity detection result of the content hash value; the image similarity detection module 44 is used to determine the similarity detection results of multiple images to be processed based on the detection results of each hash array.
[0157] The embodiment of the present application provides a similar picture detection device, which is used to perform the following process: obtain multiple pictures to be processed; obtain a hash array of each picture to be processed, the hash array includes at least one of the transparency hash value and the color hash value of the picture to be processed, and the content hash value of the picture to be processed, the content hash value is obtained by hashing the picture content of the picture to be processed, the transparency hash value is obtained by hashing the transparency information of the picture to be processed, and the color hash value is obtained by hashing the color information of the picture to be processed; perform similarity detection based on the hash array of each picture to be processed to obtain the detection results of each hash array, the detection results of the hash array include: at least one of the similarity detection results of the transparency hash value and the color hash value detection result, and the similarity detection result of the content hash value; determine the similarity detection results of multiple pictures to be processed based on the detection results of each hash array. The present application compresses the picture to be processed into a multi-dimensional hash array, and judges the similarity of the picture by comparing the distance between the hash values of each dimension in the hash array, the multi-dimensional hash array includes the content hash value representing the picture content, the transparency hash value representing the transparency information, and the color hash value representing the color information. By comparing the distances between the hash values of each dimension in the hash array, the similarity between images is determined. This solves the problem that a single hash algorithm only focuses on the similarity of images in a certain dimension, thereby ignoring the impact of other dimensional information on image similarity, thereby improving the accuracy of image similarity calculation.
[0158] In a possible implementation, the image similarity detection module 44 is specifically used to filter out a hash array that meets a set condition from the detection results of each hash array, wherein meeting the set condition includes: a similarity value of a transparency hash value is greater than at least one of a first similarity threshold and a color hash value is greater than a second similarity threshold, and a similarity value of a content hash value is greater than a third similarity threshold; and at least two to-be-processed images corresponding to the hash array that meets the set condition are determined as a similar image set.
[0159] In one possible implementation, the similarity value of the transparency hash value is greater than the first similarity threshold, including: the Hamming distance of the transparency hash value is less than the first distance threshold; the similarity value of the color hash value is greater than the second similarity threshold, including: the Hamming distance of the color hash value is less than the second distance threshold; the similarity value of the content hash value is greater than the third similarity threshold, including: the Hamming distance of the content hash value is less than the third distance threshold.
[0160] In a possible implementation, the picture acquisition module 41 is specifically configured to periodically acquire a plurality of pictures to be processed; or, when a new picture is detected, acquire a plurality of pictures to be processed, wherein the pictures to be processed include the new picture.
[0161] In one possible implementation, the image acquisition module 41 is also used to decompress the application package to be detected to obtain multiple decompressed files and the file path of each decompressed file; filter out multiple image file paths from the multiple file paths, where the image path is a file path with at least one suffix of a first data element, and the first data element is used to indicate that the file path indicates an image file; extract images from the decompressed files corresponding to the multiple image file paths to obtain multiple images to be processed.
[0162] In one possible implementation, the image acquisition module 41 is also used to, after filtering out multiple image file paths from multiple file paths, delete the file paths that meet the filtering conditions from the multiple image file paths to obtain a new image file path, wherein meeting the filtering conditions includes: the suffix of the file path is a second data element, or images with the same name are stored in different resource qualifier files; the second data element includes a first character and a first data element, and the first character is used to indicate that the image file corresponding to the file path is an image file with a set purpose in the operating system.
[0163] In a possible implementation, it also includes: a similar picture deletion module, which is used to determine the pictures to be deleted from the similar picture collection; delete the decompressed files corresponding to the pictures to be deleted from multiple decompressed files to obtain a compressed file collection; compress the decompressed files in the compressed file collection to obtain an application package.
[0164] In a possible implementation, the similar picture deletion module is specifically configured to send multiple pictures in a similar picture set to a client for display; upon receiving a deletion instruction sent by the client, the picture carried in the deletion instruction is used as a picture to be deleted.
[0165] In a possible implementation, the similar picture deletion module is specifically used to obtain the picture quality parameters of each picture in the similar picture set; filter out pictures whose picture quality parameters are greater than a set quality threshold from the similar picture set as a preliminary picture set; filter out pictures whose similarity is less than a fourth similarity threshold from the preliminary picture set as a retained picture set; and select pictures in the similar picture set except the retained picture set as pictures to be deleted.
[0166] The similar image detection device provided in the embodiment of the present application can execute the similar image detection method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0167] Figure 5 is a schematic diagram of the structure of an electronic device provided in this embodiment. The electronic device may include a similar picture detection device, such as Figure 5 As shown, the electronic device 500 includes a processor 510, a memory 520, an input device 530, and an output device 540; the number of the processor 510 in the electronic device can be one or more. Figure 5 A processor 510 is taken as an example; the processor 510, the memory 520, the input device 530 and the output device 540 in the electronic device can be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0168] The memory 520 is a computer-readable storage medium that can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the similar image detection method in the embodiment of the present invention. The processor 510 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 520, that is, implements the similar image detection method provided in the embodiment of the present invention.
[0169] The memory 520 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 520 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 520 may further include a memory remotely arranged relative to the processor 510, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0170] The input device 530 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device, and may include a keyboard, a mouse, etc. The output device 540 may include a display device such as a display screen.
[0171] This embodiment also provides a storage medium containing computer executable instructions, and when the computer executable instructions are executed by a computer processor, they are used to implement the similar image detection method provided by the embodiment of the present invention.
[0172] Of course, the computer executable instructions of a storage medium including computer executable instructions provided by an embodiment of the present invention are not limited to the operations of the method described above, and can also execute related operations in the similar image detection method provided by any embodiment of the present invention.
[0173] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0174] It is worth noting that in the embodiment of the above-mentioned similar image detection device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0175] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0176] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A similar picture detection method, characterized in that: The method comprises: Get multiple pictures to be processed; Obtain a hash array of each of the images to be processed, the hash array including at least one of a transparency hash value and a color hash value of the image to be processed, and a content hash value of the image to be processed, the content hash value being obtained by hashing the image content of the image to be processed, the transparency hash value being obtained by hashing the transparency information of the image to be processed, and the color hash value being obtained by hashing the color information of the image to be processed; Performing similarity detection based on the hash arrays of the images to be processed to obtain detection results of the hash arrays, wherein the detection results of the hash arrays include: at least one of the similarity detection results of the transparency hash value and the color hash value, and the similarity detection result of the content hash value; Based on the detection results of each of the hash arrays, similarity detection results of the plurality of images to be processed are determined.
2. The method according to claim 1, characterized in that The determining of similarity detection results of the plurality of images to be processed based on the detection results of each of the hash arrays includes: Filtering out a hash array that meets a set condition from the detection results of each of the hash arrays, wherein the set condition is satisfied including: the similarity value of the transparency hash value is greater than at least one of a first similarity threshold and the color hash value is greater than a second similarity threshold, and the similarity value of the content hash value is greater than a third similarity threshold; At least two of the to-be-processed pictures corresponding to the hash array that meet the set conditions are determined as a similar picture set.
3. The method according to claim 2, characterized in that The similarity value of the transparency hash value is greater than the first similarity threshold, including: the Hamming distance of the transparency hash value is less than the first distance threshold; The similarity value of the color hash value is greater than the second similarity threshold, including: the Hamming distance of the color hash value is less than the second distance threshold; The similarity value of the content hash value is greater than the third similarity threshold, including: the Hamming distance of the content hash value is less than the third distance threshold.
4. The method according to claim 1, characterized in that: The step of obtaining a plurality of pictures to be processed includes: Periodically obtain multiple images to be processed; or, When a new picture is detected, a plurality of pictures to be processed are obtained, wherein the pictures to be processed include the new picture.
5. The method according to any one of claims 1 to 4, characterized in that The step of obtaining a plurality of pictures to be processed includes: Decompressing the application package to be detected to obtain multiple decompressed files and the file path of each of the decompressed files; Filtering out a plurality of picture file paths from the plurality of file paths, wherein the picture path is a file path having at least one suffix of a first data element, wherein the first data element is used to indicate that the file path indicates a picture file; Extract pictures from the decompressed files corresponding to the multiple picture file paths to obtain multiple pictures to be processed.
6. The method according to claim 5, characterized in that After filtering out a plurality of image file paths from the plurality of file paths, the method further includes: Deleting a file path that satisfies a filtering condition from the plurality of image file paths to obtain a new image file path, wherein the satisfying the filtering condition includes: the suffix of the file path is a second data element, or images with the same name are stored in different resource qualifier files; The second data element includes a first character and the first data element, and the first character is used to indicate that the image file corresponding to the file path is an image file with a set purpose in the operating system.
7. The method according to claim 5, characterized in that Also includes: Determining a picture to be deleted from the similar picture set; Deleting the decompressed file corresponding to the to-be-deleted picture from the multiple decompressed files to obtain a compressed file set; The decompressed files in the compressed file set are compressed to obtain an application package.
8. The method according to claim 7, characterized in that The step of determining the image to be deleted from the similar image set includes: Sending multiple pictures in the similar picture set to a client for display; A deletion instruction sent by the client is received, and the picture carried in the deletion instruction is used as a picture to be deleted.
9. The method according to claim 7, characterized in that: The step of determining the image to be deleted from the similar image set includes: Obtaining a picture quality parameter of each picture in the similar picture set; Selecting pictures whose picture quality parameters are greater than a set quality threshold from the similar picture set as a preliminary picture set; Selecting pictures whose similarity is less than a fourth similarity threshold from the preliminary picture set as a reserved picture set; The pictures in the similar picture set except the reserved picture set are taken as pictures to be deleted.
10. A similar picture detection device, characterized in that: The device comprises: An image acquisition module is used to acquire multiple images to be processed; A hash array acquisition module, used to acquire a hash array of each of the to-be-processed images, wherein the hash array includes at least one of a transparency hash value and a color hash value of the to-be-processed image, and a content hash value of the to-be-processed image, wherein the content hash value is obtained by performing a hash process on the image content of the to-be-processed image, the transparency hash value is obtained by performing a hash process on the transparency information of the to-be-processed image, and the color hash value is obtained by performing a hash process on the color information of the to-be-processed image; A hash array detection module, configured to perform similarity detection based on the hash arrays of the images to be processed, and obtain detection results of the hash arrays, wherein the detection results of the hash arrays include: at least one of the similarity detection results of the transparency hash value and the color hash value, and the similarity detection result of the content hash value; The image similarity detection module is used to determine similarity detection results of multiple images to be processed based on the detection results of each hash array.
11. An electronic device, characterized in that: The device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the similar image detection method as described in any one of claims 1-9.
12. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the similar image detection method as described in any one of claims 1 to 9 is implemented.