Image processing method and device, electronic equipment and storage medium
By preprocessing and type determination of images, and combining coarse and fine similarity calculations, the problem of image deduplication accuracy caused by hash collisions is solved, achieving efficient and accurate image deduplication results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TAIKANG ONLINE HEALTH TECH (WUHAN) CO LTD
- Filing Date
- 2023-09-13
- Publication Date
- 2026-07-10
AI Technical Summary
In existing technologies, image deduplication methods suffer from hash collisions, leading to missed or false judgments and low accuracy. They cannot effectively identify and remove duplicate images, and are particularly difficult to balance accuracy and real-time performance in scenarios with high real-time requirements.
By preprocessing the images to determine their type, compression and grayscale processing are performed. Coarse similarity calculation is used to filter out non-repeating images, and fine similarity calculation is performed on high similarity images. Combining the MD5 algorithm and pixel histogram features, duplicate images are quickly identified and removed.
It improves the accuracy and efficiency of image deduplication, reduces the amount of computation, and enhances the speed and accuracy of identifying and removing duplicate images, making it suitable for large-scale image data deduplication scenarios.
Smart Images

Figure CN117274641B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image processing method, apparatus, electronic device and storage medium. Background Technology
[0002] Image deduplication is an essential technique in data cleaning, and it is usually used in large-scale image data deduplication or retrieval scenarios. However, due to the large amount of time required for large-scale image comparison or similarity calculation, it has great limitations for scenarios with high real-time requirements. In particular, the accuracy and real-time performance of image deduplication are mutually restrictive.
[0003] In existing technologies, images can be hashed and converted into unique digital fingerprints. Furthermore, duplicate images can be identified and excluded by comparing the digital fingerprints of the images.
[0004] However, the above method may have the problem of hash collisions, that is, different images may have the same hash value, leading to missed or false judgments, and it cannot accurately identify and remove duplicate images, resulting in low accuracy. Summary of the Invention
[0005] This application provides an image processing method, apparatus, electronic device, and storage medium to address the problem that different images may have the same hash value, leading to missed or false judgments, and that there is a lack of accurate identification and removal of duplicate images, resulting in low accuracy.
[0006] In a first aspect, this application provides an image processing method, the method comprising:
[0007] For any two images, perform image preprocessing to obtain the first image group;
[0008] Determine whether the first image group consists of files of the same type; the type includes electronic files and non-electronic files.
[0009] If the first image group consists of files of the same type, the first image group is compressed and grayscale processed to obtain the second image group. The first algorithm is used to calculate the coarse similarity of the second image group to obtain the coarse similarity, and it is determined whether the coarse similarity is less than the first similarity threshold.
[0010] When the coarse similarity is determined to be greater than or equal to the first similarity threshold, the second algorithm is used to calculate the fine similarity of the first image group to obtain the fine similarity, and the first image group is deduplicated based on the fine similarity.
[0011] Optionally, for any two images, perform image preprocessing to obtain a first image group, including:
[0012] For any two images, determine whether the aspect ratios of the two images are the same;
[0013] If any two images have the same aspect ratio, then the two images are determined to be duplicate images.
[0014] If the aspect ratios of any two images are inconsistent, the MD5 value of any two images is calculated using the message digest MD5 algorithm, and at least one image group with no repetition is determined based on the MD5 value to obtain the first image group; the image group includes two images.
[0015] Optionally, determining whether the first image group consists of files of the same type includes:
[0016] Obtain the pixel histogram features of the first image group, and calculate multiple pixel number peaks based on the pixel histogram features;
[0017] The multiple pixel number peaks are sorted from largest to smallest, the top N pixel number peaks are selected, and the sum of the top N pixel number peaks is calculated as a percentage of the total number of pixel number peaks to obtain the pixel ratio; N is a positive integer greater than or equal to 1.
[0018] The size of the pixel ratio is used to determine whether the first image group consists of files of the same type.
[0019] Optionally, the first image group is compressed and grayscale processed to obtain a second image group. A coarse similarity calculation is then performed on the second image group using the first algorithm to obtain the coarse similarity, including:
[0020] The first image group is processed into grayscale, and the first image group after grayscale processing is scaled using the spline interpolation method to obtain the second image group.
[0021] For each image in the second image group, the column-related feature vector and the row-related feature vector of the image are extracted, and the column-related feature vector and the row-related feature vector are concatenated to obtain the first feature vector;
[0022] Calculate the difference between the first feature vectors corresponding to two images in the second image group, and binarize the difference to obtain the coarse similarity.
[0023] Optionally, the first image group is subjected to fine image similarity calculation using the second algorithm to obtain fine similarity, and the first image group is deduplicated based on the fine similarity, including:
[0024] The first image group is compressed to obtain two channel images of the same size. Based on the pixel values of each channel corresponding to the two channel images, the second feature vector of the two channel images is calculated using the difference summation algorithm.
[0025] The second feature vector is binarized to obtain a fine similarity, and it is determined whether the fine similarity is less than a second similarity threshold.
[0026] If so, then the first image group is determined not to be a duplicate image;
[0027] If not, then the first image group is determined to be a duplicate image, and any one image in the first image group is removed.
[0028] Optionally, based on the pixel values of each channel corresponding to the two channel images, a second feature vector of the two channel images is calculated using a difference summation algorithm, including:
[0029] At preset intervals, sample pixel values of each channel corresponding to the two channel images are collected. Based on the sample pixel values, the second feature vector of the two channel images is calculated using a difference summation algorithm.
[0030] Optionally, the method further includes:
[0031] The first image group, after deduplication, is encrypted using an encryption algorithm to obtain an encrypted image, which is then asynchronously uploaded to the cloud for storage.
[0032] Secondly, this application also provides an image processing apparatus, the apparatus comprising:
[0033] The preprocessing module is used to perform image preprocessing on any two images to obtain the first image group;
[0034] The determination module is used to determine whether the first image group consists of files of the same type; the type includes electronic files and non-electronic files.
[0035] The calculation module is used to compress and grayscale the first image group to obtain a second image group when it is determined that the first image group is a file of the same type, and to calculate the coarse similarity of the second image group using a first algorithm to obtain a coarse similarity, and to determine whether the coarse similarity is less than a first similarity threshold.
[0036] The deduplication module is used to calculate the fine similarity of the first image group using a second algorithm when the coarse similarity is determined to be greater than or equal to the first similarity threshold, obtain the fine similarity, and perform deduplication processing on the first image group based on the fine similarity.
[0037] Thirdly, this application also provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0038] The memory stores computer-executed instructions;
[0039] The processor executes computer execution instructions stored in the memory to implement the method as described in any one of the first aspects.
[0040] Fourthly, this application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of the first aspects.
[0041] In summary, this application provides an image processing method, apparatus, electronic device, and storage medium. It can quickly determine whether two images are duplicates by preprocessing the images and determining whether both images are electronic components or non-electronic components. Furthermore, after determining whether both images are electronic components or non-electronic components, a coarse similarity comparison is performed on the two images to quickly filter out non-duplicate images. Further, only images with a coarse similarity higher than a threshold are subjected to fine similarity calculation to remove duplicate images, reducing computational load and improving the accuracy of identifying and removing duplicate images. Attached Figure Description
[0042] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0043] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application;
[0044] Figure 2 A schematic flowchart of an image processing method provided in an embodiment of this application;
[0045] Figure 3A A histogram of an electronic component image provided in an embodiment of this application;
[0046] Figure 3B A histogram of a non-electronic component image provided in an embodiment of this application;
[0047] Figure 4 This is a schematic diagram illustrating a process for extracting image features according to an embodiment of this application;
[0048] Figure 5 A schematic flowchart illustrating a specific image processing method provided in an embodiment of this application;
[0049] Figure 6This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of this application;
[0050] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0051] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation
[0052] To facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with essentially the same function and purpose. For example, "first device" and "second device" are merely used to distinguish different devices and do not limit their order of execution. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply that they are different.
[0053] It should be noted that, in this application, the terms "exemplary" or "for example" are used to indicate that something is being described as an example, illustration, or illustration. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0054] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0055] Image deduplication is a very practical technique, usually used in large-scale image data deduplication or retrieval scenarios. However, due to the large amount of time required for large-scale image comparison or similarity calculation, it has great limitations for scenarios with high real-time requirements. In particular, the accuracy and real-time performance of image deduplication are mutually restrictive.
[0056] In the underwriting, coverage, and claims processes of insurance, customers upload a wealth of image files, such as cards, invoices, lists, and reports. However, when uploading images in batches or multiple times, duplicate images are inevitably uploaded. Therefore, image deduplication is a very useful technique, especially in the following business scenarios:
[0057] In the business scenarios of insurance company systems, image deduplication algorithms can be used to quickly identify and eliminate duplicate content, reduce storage and processing costs, and provide more accurate and efficient information, thereby alleviating the burden of manual screening.
[0058] In client-side business scenarios, when customers upload images in batches via terminal devices, image deduplication technology can identify and prompt duplicate content, improving user experience and efficiency while reducing storage and bandwidth costs.
[0059] In the business scenario of digital archive management, the same document may exist in different formats and resolutions. Therefore, image deduplication technology can be used to find and delete duplicate files, reducing storage space and maintenance costs.
[0060] In business scenarios involving data cleaning and analysis, removing duplicate images can increase the accuracy and reliability of data in big data analytics. Image deduplication technology can help clean datasets and improve the quality and credibility of analysis results.
[0061] Therefore, image deduplication is an essential technique in data cleaning. By deduplicating images, storage space can be saved, that is, removing duplicate image content can significantly reduce storage requirements, storage costs, and maintenance costs. It can also reduce costs, that is, image deduplication technology can reduce the workload of manual screening, reduce labor costs, and at the same time improve work efficiency and reduce time costs.
[0062] Understandably, deduplication of large-scale image data can improve user experience. By deduplication, the interference of duplicate content can be reduced, providing users with clearer and more useful content, thus enhancing the user experience.
[0063] In one possible implementation, the image can be hashed to convert it into a unique digital fingerprint, and then duplicate images can be identified and excluded by comparing the digital fingerprints of the images.
[0064] However, the above method may have the problem of hash collisions, that is, different images may have the same hash value, leading to missed or false judgments, and it cannot accurately identify and remove duplicate images, resulting in low accuracy.
[0065] Another possible implementation involves comparing and identifying duplicate images by extracting their feature vectors, such as by extracting color histograms and texture features.
[0066] However, since the accuracy and robustness of feature extraction are challenging, variations in lighting, scale, and rotation between different images can lead to differences in feature extraction results, resulting in lower accuracy of deduplication.
[0067] It should be noted that in robust and complex scenarios, such as those with blurred, partially occluded, or distorted images, image deduplication technology may face challenges in recognition and comparison. How to balance robustness and accuracy is an issue that needs attention.
[0068] To address the aforementioned issues, this application provides an image processing method that can quickly determine whether two images are duplicates by preprocessing the images and determining whether both images consist entirely of electronic components or entirely of non-electronic components. Furthermore, after determining whether both images consist entirely of electronic components or entirely of non-electronic components, a coarse similarity comparison is performed on the two images to quickly filter out non-duplicate images. Further, only images with a coarse similarity score higher than a threshold are subjected to fine similarity calculation to remove duplicate images, thereby reducing computational load and improving the accuracy of identifying and removing duplicate images.
[0069] It should be noted that some image analysis tasks require calculations on a large number of images, such as feature extraction and similarity calculation. However, this application performs fine similarity calculations on images only after preprocessing, electronic judgment processing, and coarse similarity comparison, which reduces the number of images to be finely compared and can quickly filter out non-repeating images.
[0070] For example, Figure 1 This is a schematic diagram of an application scenario provided in an embodiment of this application, such as... Figure 1 As shown, this application scenario can be applied to the fields of insurance and finance, as well as healthcare. The application scenario may include: a user's first terminal device 101, a second terminal device 102, an intelligent image service platform 103, and a display device 104 corresponding to the intelligent image service platform 103; wherein, the user's first terminal device 101 and second terminal device 102 are used to collect images uploaded by the user, including videos and images; and the intelligent image service platform 103 can process the videos to obtain multiple images to be processed.
[0071] Specifically, if a user uploads multiple images to be reviewed by an insurance company for eligibility verification based on terminal device 101, the images to be reviewed can be sent to the intelligent image service platform 103 for deduplication. Then, the intelligent image service platform 103 sends the deduplicated images to the business review system for eligibility verification. Alternatively, the intelligent image service platform 103 can also perform eligibility verification on the deduplicated images. This application embodiment does not specifically limit this.
[0072] Among them, the intelligent image service platform 103 uses image features to quickly determine whether multiple images to be reviewed are duplicates. For cases where duplication cannot be determined, a coarse comparison of image similarity is performed to quickly filter out non-duplicate images. For images with high similarity in the coarse comparison, a fine comparison of similarity is performed to improve the accuracy of image deduplication.
[0073] Correspondingly, the intelligent image service platform 103 can display the deduplication results or review results on the display device 104 for users to view.
[0074] Optionally, the video to be reviewed can be uploaded based on the second terminal device 102, and then the intelligent image service platform 103 can segment the video to be reviewed into multiple frames for image processing. In this embodiment, the type of image data received by the intelligent image service platform 103 is not specifically limited.
[0075] It is understood that the image processing method provided in this application has strong universality and is applicable to deduplication of various types of images such as captured images, scanned images, screenshots, and electronic images. It can also be applied to deduplication of moving images such as videos. The specific scope of application is not limited in the embodiments of this application.
[0076] Optionally, the aforementioned terminal devices can be various electronic devices with a display screen and support web browsing. Terminal devices can also be referred to as terminals, user equipment (UE), mobile stations (MS), mobile terminals (MT), etc. Terminal devices can include mobile phones, smart TVs, wearable devices, smart speakers, smart security devices, smart gateways, tablets, computers with wireless transceiver capabilities, virtual reality (VR) terminal devices, augmented reality (AR) terminal devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, and wireless terminals in smart homes. These terminal devices include, but are not limited to, smartphones, tablets, laptops, and desktop computers.
[0077] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0078] Figure 2 This is a schematic flowchart of an image processing method provided in an embodiment of this application, as shown below. Figure 2 As shown, the image processing method can be applied not only to the fields of insurance, finance, and medicine, but also to other conventional technical fields. This application embodiment does not specifically limit its application in this regard. The execution entity of the image processing method is a server, and the image processing method includes the following steps:
[0079] S201. Perform image preprocessing on any two images to obtain the first image group.
[0080] In this step, image preprocessing can be performed by deduplicating images based on a hash algorithm to obtain a first image group; or by filtering blurred images, partially occluded or deformed images to obtain a first image group; or by using aspect ratio to find images with inconsistent aspect ratios and then performing deduplication to obtain a first image group; the embodiments of this application do not specifically limit the preprocessing.
[0081] It should be noted that image preprocessing for any two images only involves using algorithms with high computation speed and low computational cost to perform preliminary processing on the images in order to quickly remove duplicate images.
[0082] S202. Determine whether the first image group consists of files of the same type; the type includes electronic files and non-electronic files.
[0083] In this embodiment of the application, since the pixel values in a large area of the electronic component image have the same characteristics, it is possible to determine whether the image is an electronic component by calculating the histogram features of the image; when both images are electronic components or both are non-electronic components, it indicates that the two images may be duplicates.
[0084] In this step, the judgment can be made based on the histogram features of the two images in the first image group. That is, the two images are converted into multiple pixel values and the pixel histogram is calculated. Then, based on the pixel histogram, the pixels are sorted from high to low according to the number of pixels. The peak values of the first N pixels are summed. Furthermore, the proportion of the sum of the first N peak values in the total number of pixels is calculated. Based on the proportion, it is determined whether the first image group consists entirely of electronic components or entirely of non-electronic components.
[0085] S203. If the first image group is a file of the same type, the first image group is compressed and grayscale processed to obtain a second image group. The first algorithm is used to calculate the coarse similarity of the second image group to obtain the coarse similarity, and it is determined whether the coarse similarity is less than the first similarity threshold.
[0086] In this embodiment of the application, compression and grayscale processing can refer to scaling the image according to a predefined ratio and converting a multi-channel image into a grayscale image. This embodiment of the application does not specifically limit the predefined ratio and the number of channels corresponding to the image. It can be an image scaled to M×M and the image has 3 channels, where M is a positive integer greater than 1.
[0087] The first similarity threshold is a pre-set threshold used to determine if the similarity between two images is too high. If the threshold is too high, it means that the two images are likely to be duplicates. In this embodiment, the specific value corresponding to the first similarity threshold is not limited, such as a similarity threshold of 1.
[0088] In this step, if the first image group consists entirely of electronic components or entirely of non-electronic components, the first image group is compressed and grayscale processed to obtain the second image group. The first algorithm is then used to perform a coarse image similarity comparison calculation on the second image group. If the coarse similarity is determined to be lower than the similarity threshold 1, it is determined that the two images are not duplicated; otherwise, step S204 is executed. If the first image group consists entirely of electronic components and non-electronic components, it indicates that the two images are not duplicated.
[0089] It should be noted that the first algorithm is a similarity calculation algorithm, that is, an algorithm for calculating the similarity of the feature vectors corresponding to two images in the second image group. The first algorithm may also refer to other types of similarity calculation algorithms, such as the Jaccard similarity algorithm, Euclidean distance algorithm, Hamming distance algorithm, or cosine similarity algorithm, etc. The embodiments of this application do not specifically limit the first algorithm, and it can refer to existing similarity calculation algorithms.
[0090] Optionally, if the first image group is not composed of files of the same type, then any one image in the first image group is removed.
[0091] S204. When it is determined that the coarse similarity is greater than or equal to the first similarity threshold, the second algorithm is used to calculate the fine similarity of the first image group to obtain the fine similarity, and the first image group is deduplicated based on the fine similarity.
[0092] In this step, when the coarse similarity is determined to be greater than or equal to the similarity threshold 1, the second algorithm can be used to calculate the fine similarity of the first image group. That is, the second algorithm is used to perform fine image similarity comparison calculation on the images that have not undergone grayscale processing to obtain the fine similarity, and the size of the fine similarity determines whether the two images are duplicates. If the two images are duplicates, then any duplicate image is removed; if the two images are not duplicates, then the images are stored.
[0093] Understandably, the server performs multiple deduplication processes on any two images asynchronously to improve the image processing speed.
[0094] It should be noted that the second algorithm is similar in definition to the first algorithm. For details, please refer to the description of the first algorithm, which will not be repeated here.
[0095] Since fine image comparison is relatively time-consuming, the image processing method provided in this application uses image features to quickly determine whether they are files of the same type, reducing the number of images to be finely compared and thus saving comparison time. This application also uses coarse image similarity comparison to improve comparison efficiency. After coarse image similarity comparison, only images with high coarse similarity need to be finely compared, effectively improving the overall accuracy.
[0096] Optionally, for any two images, perform image preprocessing to obtain a first image group, including:
[0097] For any two images, determine whether the aspect ratios of the two images are the same;
[0098] If any two images have the same aspect ratio, then the two images are determined to be duplicate images.
[0099] If the aspect ratios of any two images are inconsistent, the MD5 value of any two images is calculated using the message digest MD5 algorithm, and at least one image group with no repetition is determined based on the MD5 value to obtain the first image group; the image group includes two images.
[0100] In this embodiment, the aspect ratio can refer to the ratio of image width to image height; the Message-Digest Algorithm 5 (MD5) is a type of hash algorithm. The MD5 value of an image can be calculated using the Message-Digest Algorithm 5. The MD5 value is a unique value of the image. The MD5 value is used to map data of arbitrary length to a hash value of fixed length. In this embodiment, the specific numerical value corresponding to the MD5 value is not limited, and the same image corresponds to the same MD5 value.
[0101] In this step, any two images are acquired, and it is determined whether the aspect ratios of the two images are the same. If the aspect ratios are the same, the MD5 values of the two images are also determined. If the aspect ratios are different, the two images are not duplicates, and the two images are stored. Specifically, if the MD5 values of the two images are different, it also means that the two images are not duplicates, and the two images are stored. If the MD5 values of the two images are the same, the two images are regarded as the first image group, which requires further evaluation of the two images, such as using a similarity algorithm.
[0102] Optionally, if the aspect ratios of any two images are inconsistent, a hash algorithm is used to calculate the digital fingerprints of the two images, and at least one image group with no repetition is determined based on the digital fingerprints to obtain the first image group; the specific algorithm corresponding to the hash algorithm is not limited in the embodiments of this application.
[0103] It is understood that this application may also determine whether two images are duplicate images by only checking the aspect ratio, or by only checking the width MD5 value, and obtain the corresponding first image group.
[0104] Therefore, the embodiments of this application can perform preliminary image processing on any two images, initially removing simple duplicate images, reducing redundant calculations, and thus improving the subsequent calculation speed.
[0105] Optionally, determining whether the first image group consists of files of the same type includes:
[0106] Obtain the pixel histogram features of the first image group, and calculate multiple pixel number peaks based on the pixel histogram features;
[0107] The multiple pixel number peaks are sorted from largest to smallest, the top N pixel number peaks are selected, and the sum of the top N pixel number peaks is calculated as a percentage of the total number of pixel number peaks to obtain the pixel ratio; N is a positive integer greater than or equal to 1.
[0108] The size of the pixel ratio is used to determine whether the first image group consists of files of the same type.
[0109] In this step, since large areas of the electronic component image usually have the same pixel value, it is possible to determine whether two images are duplicate images by judging whether both are electronic components or both are non-electronic components. Specifically, the histogram features of the images can be used for judgment; each image corresponds to multiple channels.
[0110] For example, for each image, the multi-channel image is converted into a grayscale image with (0, 255) pixel values, and the grayscale pixel histogram of the grayscale image is calculated. The number of pixels in the grayscale pixel histogram is then sorted from highest to lowest. For the grayscale pixel histogram of the electronic component image, Figure 3A A histogram of an electronic document image provided in an embodiment of this application; such as Figure 3A As shown, the distribution trend is uniform, sorted from high to low according to the number of pixels; for the grayscale pixel histogram of non-electronic component images, Figure 3B A histogram of a non-electronic component image provided in an embodiment of this application; such as Figure 3B As shown, the distribution trend of the fluctuations is also sorted from high to low according to the number of pixels.
[0111] Furthermore, the sum of the peak values of the first N pixels is used to obtain SUM. tops And calculate the number of the first N peak pixels in the total pixel SUM. all The proportion, denoted as pixel ratio R tops =SUM tops / SUM all When R tops If the image is less than 1, it is a non-electronic image; otherwise, it is an electronic image. If both images are electronic or both are non-electronic, it is preliminarily determined that the two images may be duplicates and further judgment is required. If both images are electronic or non-electronic, it means that the two images are not duplicates and can be stored.
[0112] It should be noted that Thresh1 is a pre-set threshold for determining whether an image is an electronic component. If the pixel ratio is less than Thresh1, the image is not an electronic component. If the pixel ratio is greater than or equal to Thresh1, the image is an electronic component. In this application embodiment, the specific value of Thresh1 is not limited, and it can be set based on the type of image.
[0113] It is understood that, for each image, the multi-channel image may not be converted into a grayscale image, but instead the pixel histogram of the multi-channel image may be calculated, and the number of pixels in the pixel histogram may be sorted from high to low; this application does not specifically limit this.
[0114] Therefore, the embodiments of this application can utilize the image pixel histogram features to calculate the proportion of the number of pixels with several peaks to determine whether it is an electronic component. When it is determined that both images are electronic components or both are non-electronic components, it can quickly determine that the two images are not duplicates. Furthermore, based on simple calculation of image features, a rapid judgment can be made, thereby improving the efficiency and speed of the algorithm.
[0115] Optionally, the first image group is compressed and grayscale processed to obtain a second image group. A coarse similarity calculation is then performed on the second image group using the first algorithm to obtain the coarse similarity, including:
[0116] The first image group is processed into grayscale, and the first image group after grayscale processing is scaled using the spline interpolation method to obtain the second image group.
[0117] For each image in the second image group, the column-related feature vector and the row-related feature vector of the image are extracted, and the column-related feature vector and the row-related feature vector are concatenated to obtain the first feature vector;
[0118] Calculate the difference between the first feature vectors corresponding to two images in the second image group, and binarize the difference to obtain the coarse similarity.
[0119] In this embodiment of the application, the spline interpolation method is used to perform magnification, reduction, smoothing and other processing on the image in image processing; the binarization processing is used to convert each pixel in the image into black and white (binary), that is, to convert a color image into a grayscale image, or a grayscale image into a black and white image, thereby extracting useful feature information.
[0120] For example, in the binarization process, pixels with gray values below a threshold are converted to 0, while pixels with gray values above the threshold are converted to 1. Therefore, binarization can be used to remove noise from an image and improve image quality.
[0121] In this step, during the coarse comparison calculation of image similarity, in order to quickly filter out non-repeating images, the images can be compressed, that is, to use less information to quickly compare images. For example, for each multi-channel image, the multi-channel image can be converted into a grayscale image, and the matrix O (M×M) can be obtained by scaling using the spline interpolation method. Furthermore, the column correlation feature vector and row correlation feature vector of the image are extracted.
[0122] For example, Figure 4 This is a schematic diagram illustrating a process for extracting image features according to an embodiment of this application, such as... Figure 4 As shown, each column of matrix O is shifted forward one column, with the first column moving to the last column, resulting in matrix P. Further, the column-related feature matrix Q = PO is calculated. Similarly, each row of O is shifted forward one row, with the first row moving to the last row, resulting in matrix S. Correspondingly, the row-related feature matrix T = SO is calculated. Then, the row and column feature matrices are concatenated to obtain the image's feature matrix. The feature matrices of the two images are then F1 and F2, each with a size of M × 2M. The column feature matrix includes multiple column-related feature vectors, the row feature matrix includes multiple row-related feature vectors, and the image feature matrix includes multiple first feature vectors. The matrix O of the two images corresponds to the matrix of the second image group.
[0123] Furthermore, calculate the difference F between the row feature matrix and the column feature matrix. Δ =F1-F2, and F Δ The element is binarized using Thresh2 thresholding to obtain F. Δ ′, when F Δ If the proportion of 0 elements in the image is lower than the similarity threshold Thresh3 (the first similarity threshold), it means that the two images are not duplicates. Otherwise, the two images need to be further judged to determine whether they are duplicate images.
[0124] It should be noted that the values corresponding to Thresh2 and Thresh3 can be set based on the image type or set directly by the user. This application does not impose any specific limitations on this.
[0125] Therefore, the embodiments of this application can extract simple image row and column feature matrices, perform coarse similarity comparison between two images, and quickly filter out non-repeating images. By using coarse image similarity comparison, the comparison efficiency can be improved.
[0126] Optionally, the first image group is subjected to fine image similarity calculation using the second algorithm to obtain fine similarity, and the first image group is deduplicated based on the fine similarity, including:
[0127] The first image group is compressed to obtain two channel images of the same size. Based on the pixel values of each channel corresponding to the two channel images, the second feature vector of the two channel images is calculated using the difference summation algorithm.
[0128] The second feature vector is binarized to obtain a fine similarity, and it is determined whether the fine similarity is less than a second similarity threshold.
[0129] If so, then the first image group is determined not to be a duplicate image;
[0130] If not, then the first image group is determined to be a duplicate image, and any one image in the first image group is removed.
[0131] In this step, during the fine-grained image similarity comparison calculation, to improve the overall deduplication accuracy, when two images are of different sizes, they can be scaled to the same size. For example, the sizes of two 3-channel images I1 and I2 can be scaled to the same size H1×W1×3, H2×W2×3 respectively. Further, the pixel values of each channel of the scaled images are subtracted, and the 3 channels of the two images are summed using a difference algorithm to obtain matrix I. Δ The dimensions are H1×W1. Further, I... Δ Elements are binarized using Thresh4 to obtain I. Δ ′, when I Δ If the proportion of 0 elements in a ' is lower than the similarity threshold Thresh5 (the second similarity threshold), it means that the two images are not duplicates; otherwise, the two images are duplicates. Correspondingly, a prompt message can be generated to remind the user.
[0132] It should be noted that the values corresponding to Thresh4 and Thresh5 can be set based on the image type or set directly by the user. This application does not impose any specific limitations on this.
[0133] Therefore, the embodiments of this application can perform fine similarity calculation only on images with a coarse similarity higher than the threshold, effectively improving the overall accuracy.
[0134] Optionally, based on the pixel values of each channel corresponding to the two channel images, a second feature vector of the two channel images is calculated using a difference summation algorithm, including:
[0135] At preset intervals, sample pixel values of each channel corresponding to the two channel images are collected. Based on the sample pixel values, the second feature vector of the two channel images is calculated using a difference summation algorithm.
[0136] In this embodiment, the preset distance may refer to the pre-set sampling interval of the image in the vertical and horizontal directions. The sampling interval can be adaptively adjusted according to the resolution of the image. This embodiment does not limit the specific value corresponding to the preset distance.
[0137] In this step, after scaling the two 3-channel images I1 and I2 to the same size H1×W1×3, the two images can be sampled separately. Specifically, the first image is sampled based on a preset distance, resulting in I1′=I1[::h_slice_num,:,:][:,::w_slice_num,:], with dimensions H1′×W1′×3. Here, h_slice_num and w_slice_num represent the sampling intervals in the vertical and horizontal directions, respectively. Further, the pixel values of each channel in the sampled images are subtracted, and the differences between the two 3-channel images are summed to obtain matrix i. Δ The dimensions are H1′×W1′, and i Δ The element is binarized using Thresh6 to obtain i. Δ ′, when i Δ If the proportion of 0 elements in a ' is lower than the similarity threshold Thresh7 (the second similarity threshold), it means that the two images are not duplicates; otherwise, the two images are duplicates. Accordingly, a prompt message can be generated to remind the user.
[0138] Therefore, the embodiments of this application can perform vertical and horizontal sampling on two images and then calculate fine similarity, thereby reducing data acquisition and improving comparison efficiency.
[0139] Optionally, the method further includes:
[0140] The first image group, after deduplication, is encrypted using an encryption algorithm to obtain an encrypted image, which is then asynchronously uploaded to the cloud for storage.
[0141] In this application embodiment, the encryption algorithm can refer to a method that encrypts the original plaintext file or image data according to a certain algorithm, making it an unreadable piece of code "ciphertext", such as symmetric key encryption algorithm, asymmetric key encryption algorithm, etc.
[0142] In this step, a symmetric key encryption algorithm such as DES (Data Encryption Standard) can be used to encrypt the first image group after deduplication to obtain an encrypted image. The encrypted image corresponding to each first image group is stored asynchronously, and the encrypted image can be uploaded to the cloud for storage.
[0143] Accordingly, if it is necessary to obtain the encrypted image, the encrypted image can be decrypted using a decryption algorithm to obtain the first decrypted image group. The decryption algorithm is the reverse process of the encryption algorithm, that is, the process of converting the encrypted image into its original image data. The specific algorithms corresponding to the encryption algorithm and the decryption algorithm are not limited in the embodiments of this application.
[0144] Therefore, the embodiments of this application can encrypt and store images, thereby improving the security of image data storage.
[0145] In conjunction with the above embodiments, Figure 5 A flowchart illustrating a specific image processing method provided in this application embodiment is shown below. Figure 5 As shown, the image processing method is executed by a server or an intelligent image service platform; the image processing method includes the following steps:
[0146] Step 1: Obtain the two input images and determine whether the aspect ratios of the two images are the same. The aspect ratio is equal to the image width / image height. If the aspect ratios are the same, proceed to step 2; otherwise, it means that the two images are not duplicates.
[0147] Step 2: Determine if the MD5 values of the two images are the same. If the MD5 values are the same, it means that the two images are duplicates; otherwise, proceed to step 3.
[0148] Step 3: Determine whether both images are electronic components. If both are electronic components, proceed to Step 4. Otherwise, determine whether both images are non-electronic components. If both are non-electronic components, proceed to Step 4. Otherwise, it means that the two images are not duplicates.
[0149] Step 4: Perform a coarse comparison calculation of image similarity. If the image similarity is determined to be lower than the similarity threshold of 1, it means that the two images are not duplicates; otherwise, proceed to step 5.
[0150] Step 5: Perform fine-grained image similarity comparison calculation. If the image similarity is determined to be lower than the similarity threshold of 2, it means that the two images are not duplicates; otherwise, the two images are duplicates.
[0151] In this way, image deduplication is performed using the above image processing method. By sequentially comparing the aspect ratio, comparing the MD5 values, determining the electronic and non-electronic components, and comparing the coarse and fine similarity of the two images, the accuracy of identifying and removing duplicate images is greatly improved.
[0152] In the foregoing embodiments, the image processing method provided by the embodiments of this application has been described. To implement the functions of the methods provided by the embodiments of this application, the electronic device serving as the execution subject may include hardware structures and / or software modules, implementing the above functions in the form of hardware structures, software modules, or a combination of hardware structures and software modules. Whether a particular function is executed in the form of hardware structures, software modules, or a combination of hardware structures and software modules depends on the specific application and design constraints of the technical solution.
[0153] For example, Figure 6 This is a schematic diagram of the structure of an image processing device provided in an embodiment of this application. The device includes: a preprocessing module 601, a judgment module 602, a calculation module 603, and a deduplication module 604; wherein, the preprocessing module 601 is used to perform image preprocessing on any two images to obtain a first image group;
[0154] The judgment module 602 is used to determine whether the first image group consists of files of the same type; the type includes electronic files and non-electronic files.
[0155] The calculation module 603 is used to compress and grayscale the first image group to obtain a second image group when it is determined that the first image group is a file of the same type, and to calculate the coarse similarity of the second image group using a first algorithm to obtain a coarse similarity, and to determine whether the coarse similarity is less than a first similarity threshold.
[0156] The deduplication module 604 is used to calculate the fine similarity of the first image group using a second algorithm when the coarse similarity is determined to be greater than or equal to the first similarity threshold, obtain the fine similarity, and perform deduplication processing on the first image group based on the fine similarity.
[0157] Optionally, the preprocessing module 601 is specifically used for:
[0158] For any two images, determine whether the aspect ratios of the two images are the same;
[0159] If any two images have the same aspect ratio, then the two images are determined to be duplicate images.
[0160] If the aspect ratios of any two images are inconsistent, the MD5 value of any two images is calculated using the message digest MD5 algorithm, and at least one image group with no repetition is determined based on the MD5 value to obtain the first image group; the image group includes two images.
[0161] Optionally, the determination module 602 is specifically used for:
[0162] Obtain the pixel histogram features of the first image group, and calculate multiple pixel number peaks based on the pixel histogram features;
[0163] The multiple pixel number peaks are sorted from largest to smallest, the top N pixel number peaks are selected, and the sum of the top N pixel number peaks is calculated as a percentage of the total number of pixel number peaks to obtain the pixel ratio; N is a positive integer greater than or equal to 1.
[0164] The size of the pixel ratio is used to determine whether the first image group consists of files of the same type.
[0165] Optionally, the calculation module 603 is specifically used for:
[0166] The first image group is processed into grayscale, and the first image group after grayscale processing is scaled using the spline interpolation method to obtain the second image group.
[0167] For each image in the second image group, the column-related feature vector and the row-related feature vector of the image are extracted, and the column-related feature vector and the row-related feature vector are concatenated to obtain the first feature vector;
[0168] Calculate the difference between the first feature vectors corresponding to two images in the second image group, and binarize the difference to obtain the coarse similarity.
[0169] Optionally, the deduplication module 604 includes a calculation unit, a judgment unit, a determination unit, and a deduplication unit;
[0170] Specifically, the computing unit is used to compress the first image group to obtain two channel images of the same size, and to calculate the second feature vector of the two channel images based on the pixel values of each channel corresponding to the two channel images using a difference summation algorithm;
[0171] The judgment unit is used to binarize the second feature vector to obtain a fine similarity, and to determine whether the fine similarity is less than a second similarity threshold.
[0172] The determining unit is used to determine that the first image group is not a duplicate image when the fine similarity is less than the second similarity threshold.
[0173] The deduplication unit is used to determine that the first image group is a duplicate image when the fine similarity is greater than or equal to the second similarity threshold, and then remove any image from the first image group.
[0174] Optionally, the computing unit is specifically used for:
[0175] At preset intervals, sample pixel values of each channel corresponding to the two channel images are collected. Based on the sample pixel values, the second feature vector of the two channel images is calculated using a difference summation algorithm.
[0176] Optionally, the device further includes a storage module, the storage module being used for:
[0177] The first image group, after deduplication, is encrypted using an encryption algorithm to obtain an encrypted image, which is then asynchronously uploaded to the cloud for storage.
[0178] The specific implementation principle and effects of the image processing device provided in this application embodiment can be found in the relevant descriptions and effects of the above embodiments, and will not be elaborated further here.
[0179] This application also provides a schematic diagram of the structure of an electronic device. Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 7 As shown, the electronic device may include: a processor 702 and a memory 701 communicatively connected to the processor; the memory 701 stores a computer program; the processor 702 executes the computer program stored in the memory 701, causing the processor 702 to perform the method described in any of the above embodiments.
[0180] The memory 701 and the processor 702 can be connected via bus 703.
[0181] This application also provides a computer-readable storage medium storing computer program execution instructions, which, when executed by a processor, are used to implement the methods as described in any of the foregoing embodiments of this application.
[0182] This application also provides a chip for executing instructions, which is used to perform the methods executed by an electronic device as described in any of the foregoing embodiments of this application.
[0183] This application also provides a computer program product, which includes a computer program that, when executed by a processor, can implement the method performed by an electronic device as described in any of the foregoing embodiments of this application.
[0184] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0185] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to implement the solution of this embodiment according to actual needs.
[0186] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The unit composed of the above modules can be implemented in hardware or in the form of hardware plus software functional units.
[0187] The integrated modules implemented as software functional modules described above can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application.
[0188] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0189] The memory may include high-speed random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk or optical disc, etc.
[0190] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0191] The aforementioned storage media can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage media can be any available medium accessible to general-purpose or special-purpose computers.
[0192] An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of the processor. Both the processor and the storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and storage medium can exist as discrete components in an electronic device or host device.
[0193] The above description is merely a specific implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the embodiments of this application should be covered within the protection scope of the embodiments of this application. Therefore, the protection scope of the embodiments of this application should be determined by the protection scope of the claims.
Claims
1. An image processing method, characterized in that, The method includes: For any two images, perform image preprocessing to obtain the first image group; Determine whether the first image group consists of files of the same type; the type includes electronic files and non-electronic files. If the first image group is not composed of files of the same type, then it is determined that the images in the first image group are not duplicates. If the first image group consists of files of the same type, the first image group is compressed and processed into grayscale to obtain a second image group. The first algorithm is used to calculate the coarse similarity of the second image group to obtain a coarse similarity, and it is determined whether the coarse similarity is less than a first similarity threshold. When it is determined that the coarse similarity is greater than or equal to the first similarity threshold, the second algorithm is used to calculate the fine similarity of the first image group to obtain a fine similarity, and the first image group is deduplicated based on the fine similarity. The determination of whether the first image group consists of files of the same type includes: Obtain the pixel histogram features of the first image group, and calculate multiple pixel number peaks based on the pixel histogram features; The multiple pixel number peaks are sorted from largest to smallest, the top N pixel number peaks are selected, and the sum of the top N pixel number peaks is calculated as a percentage of the total number of pixel number peaks to obtain the pixel ratio; N is a positive integer greater than or equal to 1. The size of the pixel ratio is used to determine whether the first image group consists of files of the same type.
2. The method according to claim 1, characterized in that, For any two images, perform image preprocessing to obtain the first image group, which includes: For any two images, determine whether the aspect ratios of the two images are the same; If any two images have the same aspect ratio, then the two images are determined to be duplicate images. If the aspect ratios of any two images are inconsistent, the MD5 value of any two images is calculated using the message digest MD5 algorithm, and at least one image group with no repetition is determined based on the MD5 value to obtain the first image group; the image group includes two images.
3. The method according to claim 1, characterized in that, The first image group is compressed and grayscale processed to obtain the second image group. A coarse similarity calculation is then performed on the second image group using the first algorithm to obtain the coarse similarity, including: The first image group is processed into grayscale, and the first image group after grayscale processing is scaled using the spline interpolation method to obtain the second image group. For each image in the second image group, the column-related feature vector and the row-related feature vector of the image are extracted, and the column-related feature vector and the row-related feature vector are concatenated to obtain the first feature vector; Calculate the difference between the first feature vectors corresponding to two images in the second image group, and binarize the difference to obtain the coarse similarity.
4. The method according to claim 1, characterized in that, The first image group is processed using a second algorithm to calculate fine similarity, and then deduplication is performed on the first image group based on the fine similarity, including: The first image group is compressed to obtain two channel images of the same size. Based on the pixel values of each channel corresponding to the two channel images, the second feature vector of the two channel images is calculated using the difference summation algorithm. The second feature vector is binarized to obtain a fine similarity, and it is determined whether the fine similarity is less than a second similarity threshold. If so, then the first image group is determined not to be a duplicate image; If not, then the first image group is determined to be a duplicate image, and any one image in the first image group is removed.
5. The method according to claim 4, characterized in that, Based on the pixel values of each channel corresponding to the two channel images, the second feature vector of the two channel images is calculated using a difference summation algorithm, including: At preset intervals, sample pixel values of each channel corresponding to the two channel images are collected. Based on the sample pixel values, the second feature vector of the two channel images is calculated using a difference summation algorithm.
6. The method according to any one of claims 1-5, characterized in that, The method further includes: The first image group, after deduplication, is encrypted using an encryption algorithm to obtain an encrypted image, which is then asynchronously uploaded to the cloud for storage.
7. An image processing apparatus, characterized in that, The device includes: The preprocessing module is used to perform image preprocessing on any two images to obtain the first image group; The determination module is used to determine whether the first image group consists of files of the same type; the type includes electronic files and non-electronic files. The judgment module is specifically used to obtain the pixel histogram features of the first image group and calculate multiple pixel number peaks based on the pixel histogram features; The multiple pixel number peaks are sorted from largest to smallest, the top N pixel number peaks are selected, and the sum of the top N pixel number peaks is calculated as a percentage of the total number of pixel number peaks to obtain the pixel ratio; N is a positive integer greater than or equal to 1. Based on the pixel ratio, determine whether the first image group consists of files of the same type; The determination module is used to determine that the images in the first image group are not duplicates if the first image group is not composed of files of the same type. The calculation module is used to compress and grayscale the first image group to obtain a second image group when it is determined that the first image group is a file of the same type, and to calculate the coarse similarity of the second image group using a first algorithm to obtain a coarse similarity, and to determine whether the coarse similarity is less than a first similarity threshold. The deduplication module is used to calculate the fine similarity of the first image group using a second algorithm when the coarse similarity is determined to be greater than or equal to the first similarity threshold, obtain the fine similarity, and perform deduplication processing on the first image group based on the fine similarity.
8. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-6.