Image desensitization method, device, equipment, medium and program product

Directly detecting seals and QR codes in images through the maximum inter-class difference method and QR code scanning technology, solving the problems of inefficient efficiency and incomplete desensitization in the existing technology, and achieving an efficient and complete image desensitization process.

CN119276997APending Publication Date: 2025-01-07ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411295561.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

The prior art is difficult to efficiently detect and remove seals and QR codes during image desensitization, and model training is often required, resulting in inefficiency and incomplete desensitization.

Method used

The maximum inter-class difference method is used to determine the target segmentation threshold of the image, and combined with QR code scanning technology, the seals and QR codes in the image are directly detected and removed to avoid the model training process.

Benefits of technology

It improves the efficiency and integrity of image desensitization, realizes agile and efficient detection and removal of seals and QR codes, and enhances data privacy protection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119276997A_ABST
    Figure CN119276997A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an image desensitization method and device, equipment, a medium and a program product. The method comprises the following steps: acquiring a to-be-desensitized image; determining a target segmentation threshold value corresponding to the image to be desensitized by using a maximum between-class difference method; determining a foreground region corresponding to the image to be desensitized based on the target segmentation threshold; the foreground area is used for representing a first sensitive area where a seal is located in the to-be-desensitized image; scanning the to-be-desensitized image to obtain a second sensitive area where the two-dimensional code in the to-be-desensitized image is located; and coding the first sensitive area and the second sensitive area in the to-be-desensitized image to obtain a desensitized image corresponding to the to-be-desensitized image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an image desensitization method, device, equipment, medium and program product. Background Art

[0002] Data desensitization is a technical measure to process sensitive fields in raw data without affecting the accuracy of data analysis results, aiming to reduce data sensitivity and personal privacy risks. The core of data desensitization lies in de-identification and anonymization, that is, through technical processing of personal information, it is impossible to identify the subject of personal information without the help of additional information, or the subject of personal information cannot be identified or associated, and the processed information cannot be restored.

[0003] In related technologies, sensitive data such as seals in image data are often detected and removed by using pre-trained models for target detection. Summary of the invention

[0004] The embodiments of this specification provide an image desensitization method, device, equipment, medium and program product, which uses the maximum inter-class difference method to desensitize the seal in the image to be desensitized, and uses the two-dimensional code scanning technology to realize the desensitization of the two-dimensional code in the image to be desensitized, which not only avoids the model training process required when using the model to detect the seal and two-dimensional code in the image to be desensitized, but also can quickly and efficiently realize the detection and removal of the seal and two-dimensional code in the image to be desensitized, thereby improving the efficiency and integrity of image desensitization. The above technical solution is as follows:

[0005] In a first aspect, an embodiment of the present specification provides an image desensitization method, comprising:

[0006] Obtaining the image to be desensitized;

[0007] The maximum inter-class difference method is used to determine the target segmentation threshold corresponding to the above-mentioned image to be desensitized;

[0008] Determine the foreground area corresponding to the image to be desensitized based on the target segmentation threshold; the foreground area is used to represent the first sensitive area where the seal is located in the image to be desensitized;

[0009] Scan the image to be desensitized to obtain a second sensitive area where the QR code in the image to be desensitized is located;

[0010] The first sensitive area and the second sensitive area in the image to be desensitized are coded to obtain a desensitized image corresponding to the image to be desensitized.

[0011] In a possible implementation, the method of determining the target segmentation threshold corresponding to the image to be desensitized by using the maximum inter-class difference method includes:

[0012] Calculate the first probability that the gray value of any pixel in the above-mentioned image to be desensitized is i; the above-mentioned i is a value within the gray value range corresponding to the above-mentioned image to be desensitized;

[0013] Determine a second probability based on the first probability and the threshold variable; the second probability is used to characterize the probability that any pixel in the image to be desensitized belongs to a foreground pixel;

[0014] Determine a first cumulative mean based on the threshold variable, the first probability, and the gray value i corresponding to the first probability; the first cumulative mean is used to represent the cumulative mean of all gray values ​​in the image to be desensitized from 0 to the threshold variable;

[0015] Determine a second cumulative mean based on the maximum grayscale value corresponding to the image to be desensitized, the first probability, and the grayscale value i corresponding to the first probability; the second cumulative mean is used to represent the cumulative mean of all grayscale values ​​in the image to be desensitized from 0 to the maximum grayscale value;

[0016] Based on the second probability, the first cumulative mean and the second cumulative mean, a maximum inter-class variance value corresponding to the foreground and the background in the image to be desensitized is determined according to a preset inter-class variance formula;

[0017] The value of the threshold variable corresponding to the maximum inter-class variance value is determined as the target segmentation threshold corresponding to the image to be desensitized.

[0018] In a possible implementation, the above preset inter-class variance formula is:

[0019] Among them, the above δ 2 is the between-class variance; ω1 is the above-mentioned second probability; m1 is the above-mentioned first cumulative mean; m is the above-mentioned second cumulative mean.

[0020] In a possible implementation, the second probability The first cumulative mean The second cumulative mean The above t is the threshold variable corresponding to the segmentation of foreground and background of the above image to be desensitized; the above L is the maximum grayscale value corresponding to the above image to be desensitized; the above p i is the first probability that the gray value of any pixel in the above-mentioned image to be desensitized is i.

[0021] In a possible implementation, determining the foreground area corresponding to the image to be desensitized based on the target segmentation threshold includes:

[0022] The area composed of multiple target pixel points in the above-mentioned image to be desensitized is determined as the foreground area corresponding to the image to be desensitized; the above-mentioned target pixel points are used to represent the pixel points in the above-mentioned image to be desensitized whose grayscale values ​​are less than the above-mentioned target segmentation threshold.

[0023] In a possible implementation, scanning the image to be desensitized to obtain the second sensitive area where the QR code in the image to be desensitized is located includes:

[0024] Scanning the image to be desensitized to determine whether there is a positioning feature in the image to be desensitized;

[0025] If the above positioning feature exists in the above image to be desensitized, the above positioning feature is matched with the preset QR code positioning feature to obtain a corresponding positioning matching result;

[0026] Based on the target positioning feature in the positioning matching result that matches the preset QR code positioning feature, the second sensitive area where the QR code in the image to be desensitized is located is determined.

[0027] In a possible implementation, the target positioning feature includes a plurality of target position detection patterns; the plurality of target position detection patterns are used to locate the position and direction of the QR code in the image to be desensitized.

[0028] In a second aspect, an embodiment of the present specification provides an image desensitization device, the image desensitization device comprising:

[0029] An acquisition module, used for acquiring images to be desensitized;

[0030] The first determination module is used to determine the target segmentation threshold corresponding to the above-mentioned image to be desensitized by using the maximum inter-class difference method;

[0031] The second determination module is used to determine the foreground area corresponding to the image to be desensitized based on the target segmentation threshold; the foreground area is used to represent the first sensitive area where the seal is located in the image to be desensitized;

[0032] A scanning module, used for scanning the image to be desensitized to obtain a second sensitive area where the QR code in the image to be desensitized is located;

[0033] The coding module is used to code the first sensitive area and the second sensitive area in the image to be desensitized to obtain a desensitized image corresponding to the image to be desensitized.

[0034] In a possible implementation, the first determining module includes:

[0035] A calculation unit, used to calculate a first probability that the gray value of any pixel in the above-mentioned image to be desensitized is i; the above-mentioned i is a value within the gray value range corresponding to the above-mentioned image to be desensitized;

[0036] A first determination unit is used to determine a second probability based on the first probability and a threshold variable; the second probability is used to characterize the probability that any pixel in the image to be desensitized belongs to a foreground pixel;

[0037] A second determination unit is used to determine a first cumulative mean based on the threshold variable, the first probability, and the gray value i corresponding to the first probability; the first cumulative mean is used to represent the cumulative mean of all gray values ​​in the image to be desensitized from 0 to the threshold variable;

[0038] A third determining unit is used to determine a second cumulative mean based on the maximum grayscale value corresponding to the image to be desensitized, the first probability, and the grayscale value i corresponding to the first probability; the second cumulative mean is used to represent the cumulative mean of all grayscale values ​​in the image to be desensitized from 0 to the maximum grayscale value;

[0039] A fourth determining unit, configured to determine the maximum inter-class variance value corresponding to the foreground and the background in the image to be desensitized according to a preset inter-class variance formula based on the second probability, the first cumulative mean, and the second cumulative mean;

[0040] The fifth determining unit is used to determine the value of the above-mentioned maximum inter-class variance value corresponding to the above-mentioned threshold variable as the target segmentation threshold corresponding to the above-mentioned image to be desensitized.

[0041] In a possible implementation, the above preset inter-class variance formula is:

[0042] Among them, the above δ 2 is the between-class variance; ω1 is the above-mentioned second probability; m1 is the above-mentioned first cumulative mean; m is the above-mentioned second cumulative mean.

[0043] In a possible implementation, the second probability The first cumulative mean The second cumulative mean The above t is the threshold variable corresponding to the segmentation of foreground and background of the above image to be desensitized; the above L is the maximum grayscale value corresponding to the above image to be desensitized; the above p i is the first probability that the gray value of any pixel in the above-mentioned image to be desensitized is i.

[0044] In a possible implementation manner, the second determining module is specifically configured to:

[0045] The area composed of multiple target pixel points in the above-mentioned image to be desensitized is determined as the foreground area corresponding to the image to be desensitized; the above-mentioned target pixel points are used to represent the pixel points in the above-mentioned image to be desensitized whose grayscale values ​​are less than the above-mentioned target segmentation threshold.

[0046] In a possible implementation, the scanning module includes:

[0047] A sixth determination unit is used to scan the image to be desensitized to determine whether there is a positioning feature in the image to be desensitized;

[0048] A matching unit, configured to match the positioning feature with a preset QR code positioning feature if the positioning feature exists in the image to be desensitized, to obtain a corresponding positioning matching result;

[0049] The seventh determination unit is used to determine the second sensitive area where the QR code in the above-mentioned image to be desensitized is located based on the target positioning feature in the above-mentioned positioning matching result that matches the above-mentioned preset QR code positioning feature.

[0050] In a possible implementation, the target positioning feature includes a plurality of target position detection patterns; the plurality of target position detection patterns are used to locate the position and direction of the QR code in the image to be desensitized.

[0051] In a third aspect, an embodiment of this specification provides an electronic device, including: a processor and a memory;

[0052] The processor is connected to the memory;

[0053] The above-mentioned memory is used to store executable program code;

[0054] The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the image desensitization method provided by the first aspect of the embodiment of this specification or any possible implementation method of the first aspect.

[0055] In a fourth aspect, an embodiment of the present specification provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the image desensitization method provided by the first aspect of the embodiment of the present specification or any possible implementation method of the first aspect.

[0056] In a fifth aspect, an embodiment of this specification provides a computer program product comprising instructions. When the above-mentioned computer program product runs on a computer or a processor, the above-mentioned computer or the above-mentioned processor executes the image desensitization method provided by the first aspect of the embodiment of this specification or any possible implementation method of the first aspect.

[0057] In an embodiment of the present specification, an image to be desensitized is obtained; a target segmentation threshold corresponding to the image to be desensitized is determined by using the maximum inter-class difference method; a foreground area corresponding to the image to be desensitized is determined based on the target segmentation threshold; the foreground area is used to characterize a first sensitive area where a seal is located in the image to be desensitized; the image to be desensitized is scanned to obtain a second sensitive area where a QR code is located in the image to be desensitized; the first sensitive area and the second sensitive area in the image to be desensitized are coded to obtain a desensitized image corresponding to the image to be desensitized, thereby desensitizing the seal in the image to be desensitized by using the maximum inter-class difference method and desensitizing the QR code in the image to be desensitized by using the QR code scanning technology, thereby avoiding the model training process required for detecting seals and QR codes in the image to be desensitized by using a model, and quickly and efficiently realizing the detection and removal of seals and QR codes in the image to be desensitized, thereby improving the efficiency and integrity of image desensitization. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions in the embodiments of this specification, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0059] Figure 1 A schematic diagram of the architecture of an image desensitization system provided by an exemplary embodiment of this specification;

[0060] Figure 2 A flowchart of an image desensitization method provided by an exemplary embodiment of this specification;

[0061] Figure 3 A schematic diagram of a second sensitive area determination process provided by an exemplary embodiment of this specification;

[0062] Figure 4 A schematic diagram of a desensitized image provided as an exemplary embodiment of this specification;

[0063] Figure 5 A schematic diagram of the structure of an image desensitization device provided as an exemplary embodiment of this specification;

[0064] Figure 6 The present invention is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0065] The technical solutions in the embodiments of this specification will be described clearly and completely below in conjunction with the drawings in the embodiments of this specification.

[0066] The terms "first", "second", "third", etc. in this specification and claims and the above drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.

[0067] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of this specification are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions. For example, the images to be desensitized involved in this specification are all obtained with full authorization.

[0068] The shapes and contents of the seals in the images to be desensitized are different. The shapes of the seals are circular, elliptical, square, diamond or custom shapes. In the related image desensitization technology, most of them use target detection to detect the seals and perform image segmentation; or, remove the red seals by color recognition method. However, the former is easy to miss detection or miss removal for some non-circular and non-elliptical seals; while the latter is easy to have difficulty in determining the threshold, thus also missing detection. In addition, both of the above methods require the use of models to participate in detection, and before detection, they often need to go through a relatively complicated model training process. At the same time, if there is a QR code in the image to be desensitized, it is also easy to leak personal privacy due to the QR code. However, the related image desensitization technology only detects and removes the seals in the image to be desensitized, and often ignores the desensitization process of the QR code in the image to be desensitized, which leads to the problem of incomplete desensitization.

[0069] Based on this, the embodiments of this specification provide a desensitization method, which uses the maximum inter-class difference method to desensitize the seal in the image to be desensitized, and uses the QR code scanning technology to desensitize the QR code in the image to be desensitized. It avoids the model training process required when using the model to detect the seal and QR code in the image to be desensitized, and can quickly and efficiently realize the detection and removal of the seal and QR code in the image to be desensitized, thereby improving the efficiency and integrity of image desensitization.

[0070] Please refer to the following Figure 1 , which is a schematic diagram of the architecture of an image desensitization system provided by an exemplary embodiment of this specification. Figure 1As shown, the image desensitization system includes: a terminal 110 and a server 120. Among them:

[0071] The terminal 110 may be a user terminal corresponding to the user, and the terminal 110 may be installed with, but not limited to, an image desensitization program or application, so that the user can use the image desensitization program or application to implement desensitization processing of the image to be desensitized. It can interact with the server 120 through a network to receive messages from the server 120 or send messages to the server 120, or the terminal 110 can interact with the server 120 through a network to receive messages or data sent by other users to the server 120. The terminal 120 can be hardware or software. When the terminal 120 is hardware, it can be various electronic devices, including but not limited to smart watches, smart phones, tablet computers, laptop portable computers, and desktop computers. When the terminal 110 is software, it can be installed in the electronic devices listed above, which can be implemented as multiple software or software modules (for example: used to provide distributed services), or it can be implemented as a single software or software module, which is not specifically limited here.

[0072] In the embodiment of the present specification, after the terminal 110 obtains the image to be desensitized, the maximum inter-class difference method can be used to first determine the target segmentation threshold corresponding to the image to be desensitized; then, based on the target segmentation threshold, the foreground area corresponding to the image to be desensitized is determined, and the foreground area is used to characterize the first sensitive area where the seal is located in the image to be desensitized, and the image to be desensitized is scanned to obtain the second sensitive area where the QR code is located in the image to be desensitized; finally, the first sensitive area and the second sensitive area in the image to be desensitized are coded to obtain the desensitized image corresponding to the image to be desensitized.

[0073] The server 120 may be a server that provides image desensitization services, such as but not limited to a server corresponding to an image desensitization application. It should be noted that the server 120 may be hardware or software. When the server 120 is hardware, it may be implemented as a distributed server cluster consisting of multiple servers, or it may be implemented as a single server. When the server 120 is software, it may be implemented as multiple software or software modules (for example, used to provide distributed services), or it may be implemented as a single software or software module, which is not specifically limited here. The server 120 may be, but is not limited to, a hardware server, a virtual server, a cloud server, etc.

[0074] It can be understood that the image desensitization method provided in the embodiments of this specification can be executed by the terminal 110 or by the server 120, and the embodiments of this specification are not limited to this.

[0075] The network may be a medium providing a communication link between the terminal 110 and the server 120, or may be the Internet including network devices and transmission media, but is not limited thereto. The transmission media may be a wired link, such as but not limited to coaxial cable, optical fiber, and digital subscriber line (DSL), or a wireless link, such as but not limited to wireless fidelity (WIFI), Hypertext Transfer Protocol (HTTP), Bluetooth, and mobile device network, etc.

[0076] Understandably, Figure 1 The number of terminals 110 and servers 120 in the image desensitization system shown is only an example. In a specific implementation, the image desensitization system may include any number of terminals 110 and servers 120, and the embodiments of this specification do not specifically limit this. For example, but not limited to, the terminal 110 may be a terminal cluster composed of multiple terminals, and the server 120 may be a server cluster composed of multiple servers.

[0077] In order to solve the problems existing in the above-mentioned related technologies, Figure 1 , introduces the image desensitization method provided by the embodiment of this specification. For details, please refer to Figure 2 , which is a flow chart of an image desensitization method provided by an exemplary embodiment of this specification. Figure 2 As shown, the image desensitization method includes the following steps:

[0078] S202, obtaining an image to be desensitized.

[0079] Specifically, the above-mentioned image to be desensitized can be an image input by a user that needs to be desensitized, or an image that needs to be desensitized and sent by other devices received through the network, or an image corresponding to a file to be desensitized, which is not limited in the embodiments of this specification. The above-mentioned image to be desensitized includes sensitive information such as seals and QR codes.

[0080] Exemplarily, the above-mentioned image to be desensitized can be, but is not limited to, an image corresponding to medical file data. Medical file data usually contains the patient's personal health information, which is highly sensitive because it involves personal privacy and health records. The sensitivity of this type of data is reflected in its involvement in the patient's diagnosis, treatment history, drug use records, and personal identity information that may be contained, such as name, address, contact information, and social security number. Due to the sensitivity of this information, if it is obtained by unauthorized individuals or entities, it may lead to privacy leakage, identity theft or other forms of abuse, which will bring serious consequences to the patient. Therefore, it is necessary to desensitize the medical file data. This process involves removing or modifying certain information to prevent the patient's identity from being identified, while still retaining the validity and usefulness of the data for research and analysis. In the process of making a medical public data set, it is often necessary to process sensitive information, especially the official seal of the unit, the official seal of the doctor's private person, and the two-dimensional code. These sensitive information all need to be desensitized. Therefore, the embodiment of this specification can be used for medical documents, including medical test reports, B-ultrasound orders, medical orders, medical bills, consultation reports and other scenes, to make a general solution for image desensitization of seals and two-dimensional codes.

[0081] S204, using the maximum inter-class difference method to determine the target segmentation threshold corresponding to the image to be desensitized.

[0082] Specifically, the maximum inter-class variance method is a method for determining an adaptive value, also known as the Otsu method, or OTSU for short. It is a global binarization algorithm that can divide an image into two parts, the foreground and the background, according to the grayscale characteristics of the image. After obtaining the image to be desensitized, the first sensitive area where the seal is located in the image to be desensitized can be set as the foreground area of ​​the image to be desensitized, but is not limited to, and the OTSU algorithm is used to automatically select the target segmentation threshold corresponding to the image to be desensitized by maximizing the inter-class variance between the foreground and the background in the image to be desensitized, thereby achieving accurate segmentation of the foreground and background areas of the image to be desensitized. This method is not only simple to calculate and has good robustness, but is also not affected by image brightness and contrast, and can quickly and efficiently detect and remove seals in the image to be desensitized.

[0083] Optionally, the above S204, the implementation process of determining the target segmentation threshold corresponding to the image to be desensitized by using the maximum inter-class difference method may include but is not limited to: first calculating the first probability that the grayscale value of any pixel in the image to be desensitized is i, where i is an integer value within the grayscale value range (for example, but not limited to [0, 255]) corresponding to the image to be desensitized, for example, but not limited to first counting the grayscale value of each pixel in the image to be desensitized, and calculating the ratio of the number of pixels corresponding to the specific grayscale value i to the total number of pixels in the image to be desensitized, to obtain the first probability p that the grayscale value of any pixel in the image to be desensitized is ii ; Then, based on the first probability and the threshold variable, a second probability is determined, the second probability is used to characterize the probability that any pixel in the image to be desensitized belongs to a foreground pixel, the threshold variable is used to characterize the threshold for segmenting the foreground and background of the image to be desensitized, and its value range is within the grayscale value range corresponding to the image to be desensitized; Then, based on the threshold variable, the first probability and the grayscale value i corresponding to the first probability, a first cumulative mean is determined, the first cumulative mean is used to characterize the cumulative mean of all grayscale values ​​in the image to be desensitized from 0 to the threshold variable; And, based on the maximum gray value corresponding to the image to be desensitized, the first probability and the gray value i corresponding to the first probability, the second cumulative mean is determined, and the second cumulative mean is used to characterize the cumulative mean of all gray values ​​from 0 to the maximum gray value in the image to be desensitized; finally, based on the second probability, the first cumulative mean and the second cumulative mean, the maximum inter-class variance value corresponding to the foreground and background in the image to be desensitized is determined according to the preset inter-class variance formula; and, the value of the threshold variable corresponding to the maximum inter-class variance value is determined as the target segmentation threshold corresponding to the image to be desensitized. That is, firstly calculate the multiple inter-class variance values ​​corresponding to the multiple values ​​of the threshold variable within the gray value range according to the preset inter-class variance formula. Since the greater the difference between the background and the foreground of the image, the greater the inter-class variance gap between them, therefore, the value of the threshold variable used in the calculation corresponding to the maximum inter-class variance value among the multiple inter-class variance values ​​can be determined as the target segmentation threshold corresponding to the image to be desensitized.

[0084] Furthermore, the above preset inter-class variance formula may be, but is not limited to:

[0085] Among them, the above δ 2 is the between-class variance; ω1 is the above-mentioned second probability; m1 is the above-mentioned first cumulative mean; m is the above-mentioned second cumulative mean.

[0086] Furthermore, the second probability The first cumulative mean The second cumulative mean The above t is the threshold variable for segmenting the foreground and background of the image to be desensitized; the above L is the maximum grayscale value corresponding to the image to be desensitized, that is, the upper limit of the grayscale value range; the above p i is the first probability that the gray value of any pixel in the above-mentioned image to be desensitized is i.

[0087] It can be understood that the above preset inter-class variance formula can be obtained by inferring and calculating the target inter-class variance formula. The specific inference process can be, but is not limited to, as follows:

[0088] Assume that the probability that any point on the image to be desensitized belongs to the foreground is ω1, and the probability that it belongs to the background is ω2. The average grayscale value of the foreground of the image to be desensitized is μ1, and the average grayscale value of the background is μ2. Then the average grayscale value of the image to be desensitized is μ=ω1μ1+ω2μ2; According to the target inter-class variance formula, the inter-class variance of the foreground and background in the image to be desensitized is calculated as δ 2 =ω1(μ1-μ) 2 +ω2(μ2-μ) 2 ;

[0089] Since ω1+ω2=1, the above target inter-class variance formula can be simplified to δ 2 =ω1ω2(μ1-μ2) 2 ;in, Substituting the above inter-class variance formula into the above inter-class variance formula can further be deduced to obtain the preset inter-class variance formula:

[0090] Please continue to refer to Figure 2 ,like Figure 2 As shown, in the above S204, after using the maximum inter-class difference method to determine the target segmentation threshold corresponding to the image to be desensitized, the image desensitization method further includes:

[0091] S206, determining a foreground area corresponding to the image to be desensitized based on the target segmentation threshold.

[0092] Specifically, the foreground area is used to characterize the first sensitive area where the seal is located in the image to be desensitized.

[0093] Optionally, the area composed of multiple target pixels in the image to be desensitized can be determined as the foreground area corresponding to the image to be desensitized, but is not limited to, so that the maximum inter-class difference method can be directly used to determine the target segmentation threshold without using a model for seal detection to efficiently and accurately determine the first sensitive area where the seal is located. The above target pixel points are used to characterize the pixel points in the image to be desensitized whose grayscale values ​​are less than the target segmentation threshold.

[0094] It can be understood that in a specific implementation, the foreground area corresponding to the above-mentioned image to be desensitized can be the area corresponding to the pixel points whose grayscale values ​​are less than the target segmentation threshold, or it can be the area corresponding to the pixel points whose grayscale values ​​are greater than or equal to the target segmentation threshold. It can be set according to the actual situation of the image to be desensitized and user needs, and the embodiments of this specification do not make specific limitations on this.

[0095] S208, scanning the image to be desensitized to obtain a second sensitive area where the QR code in the image to be desensitized is located.

[0096] Specifically, after obtaining the image to be desensitized, the QR code detection open source package of OpenCV can be used, but is not limited to, to perform QR code recognition on the image to be desensitized, and identify the second sensitive area where the QR code is located in the image to be desensitized.

[0097] It can be understood that the two-dimensional code scanning process corresponding to the above S208 can be executed before the seal detection process corresponding to the above S204-S206, or can be executed thereafter or synchronously, and the embodiments of this specification do not limit this.

[0098] Alternatively, if Figure 3 As shown, the implementation process of the above S208, scanning the image to be desensitized to obtain the second sensitive area where the QR code in the image to be desensitized is located, may include but is not limited to:

[0099] S302, scanning the image to be desensitized to determine whether there is a positioning feature in the image to be desensitized.

[0100] Specifically, after acquiring the image to be desensitized, it is possible to determine whether there is a positioning feature in the image to be desensitized without scanning the image to be desensitized, that is, to determine whether there is a specific pattern element of the QR code in the image to be desensitized, such as the positioning points on the three corners of the QR code.

[0101] S304: If there is a positioning feature in the image to be desensitized, the positioning feature is matched with a preset QR code positioning feature to obtain a corresponding positioning matching result.

[0102] Specifically, if there is a positioning feature in the image to be desensitized, in order to ensure the accuracy of the QR code detection, the positioning feature will also be matched with the preset QR code positioning feature to obtain the corresponding positioning matching result. The above positioning matching result is used to determine whether the positioning feature belongs to the feature corresponding to the complete QR code.

[0103] S306, determining a second sensitive area where the QR code in the image to be desensitized is located based on the target positioning feature in the positioning matching result that matches the preset QR code positioning feature.

[0104] Specifically, the target positioning feature includes a plurality of target position detection patterns, and the plurality of target position detection patterns are used to locate the position and direction of the two-dimensional code in the image to be desensitized. If there is a target positioning feature that matches the preset two-dimensional code positioning feature in the positioning feature of the image to be desensitized in the positioning matching result, the second sensitive area where the two-dimensional code in the image to be desensitized is located can be calculated based on the size and relative position corresponding to the plurality of target position detection patterns in the target positioning feature, but is not limited to, without edge detection or model detection, etc., and the second sensitive area where the two-dimensional code in the image to be desensitized is accurately and efficiently determined through the two-dimensional code scanning technology (i.e., the two-dimensional code recognition technology), thereby achieving accurate desensitization of the two-dimensional code in the image to be desensitized.

[0105] Optionally, after acquiring the image to be desensitized, the image to be desensitized may be scanned, but not limited to, to extract multiple scanning features in the image to be desensitized, and then the multiple scanning features are matched with the two-dimensional code features in the preset two-dimensional code feature set, and the area where the target scanning features matching the two-dimensional code features in the multiple scanning features are located is determined as the second sensitive area where the two-dimensional code in the image to be desensitized is located. The above-mentioned two-dimensional code features may include, but are not limited to, position detection graphics, position detection graphic separators, calculation mode patterns, alignment mark patterns, etc. The above-mentioned position detection graphic separators are used to help the scanning device distinguish between the position detection graphics and the data area of ​​the two-dimensional code, the above-mentioned calculation mode patterns are used to calibrate the scanning device to capture and decode the image of the two-dimensional code, and the above-mentioned alignment mark patterns are used to help the scanning device better align and decode the two-dimensional code at different distances and angles.

[0106] S210, coding the first sensitive area and the second sensitive area in the image to be desensitized to obtain a desensitized image corresponding to the image to be desensitized.

[0107] Specifically, after determining the first sensitive area corresponding to the seal in the image to be desensitized and the second sensitive area corresponding to the QR code, the first sensitive area and the second sensitive area can be directly blurred, covered or replaced, but not limited to, to obtain a desensitized image corresponding to the image to be desensitized, so as to protect personal privacy or data security in the image to be desensitized.

[0108] For example, the desensitized image obtained by coding the first sensitive area corresponding to the seal and the second sensitive area corresponding to the QR code in the image to be desensitized can be, but is not limited to, Figure 4 At the same time, while desensitizing the seal and QR code in the image to be desensitized, the embodiment of this specification can also, but is not limited to, identify sensitive text information such as names and addresses in the image to be desensitized, and also perform coding processing on the sensitive text information, to obtain a desensitized image that has been desensitized for both pattern and text (for example, but not limited to, Figure 4 shown).

[0109] In an embodiment of the present specification, an image to be desensitized is obtained; a target segmentation threshold corresponding to the image to be desensitized is determined by using the maximum inter-class difference method; a foreground area corresponding to the image to be desensitized is determined based on the target segmentation threshold; the foreground area is used to characterize a first sensitive area where a seal is located in the image to be desensitized; the image to be desensitized is scanned to obtain a second sensitive area where a QR code is located in the image to be desensitized; the first sensitive area and the second sensitive area in the image to be desensitized are coded to obtain a desensitized image corresponding to the image to be desensitized, thereby desensitizing the seal in the image to be desensitized by using the maximum inter-class difference method and desensitizing the QR code in the image to be desensitized by using the QR code scanning technology, thereby avoiding the model training process required for detecting seals and QR codes in the image to be desensitized by using a model, and quickly and efficiently realizing the detection and removal of seals and QR codes in the image to be desensitized, thereby improving the efficiency and integrity of image desensitization.

[0110] Please refer to the following Figure 5 , which is a schematic diagram of the structure of an image desensitization device provided by an exemplary embodiment of this specification. Figure 5 As shown, the image desensitization device 500 includes:

[0111] An acquisition module 510 is used to acquire the image to be desensitized;

[0112] The first determination module 520 is used to determine the target segmentation threshold corresponding to the above-mentioned image to be desensitized by using the maximum inter-class difference method;

[0113] The second determination module 530 is used to determine the foreground area corresponding to the image to be desensitized based on the target segmentation threshold; the foreground area is used to represent the first sensitive area where the seal is located in the image to be desensitized;

[0114] The scanning module 540 is used to scan the image to be desensitized to obtain the second sensitive area where the QR code is located in the image to be desensitized;

[0115] The coding module 550 is used to code the first sensitive area and the second sensitive area in the image to be desensitized to obtain a desensitized image corresponding to the image to be desensitized.

[0116] In a possible implementation, the first determining module 520 includes:

[0117] A calculation unit, used to calculate a first probability that the gray value of any pixel in the above-mentioned image to be desensitized is i; the above-mentioned i is a value within the gray value range corresponding to the above-mentioned image to be desensitized;

[0118] A first determination unit is used to determine a second probability based on the first probability and a threshold variable; the second probability is used to characterize the probability that any pixel in the image to be desensitized belongs to a foreground pixel;

[0119] A second determination unit is used to determine a first cumulative mean based on the threshold variable, the first probability, and the gray value i corresponding to the first probability; the first cumulative mean is used to represent the cumulative mean of all gray values ​​in the image to be desensitized from 0 to the threshold variable;

[0120] A third determining unit is used to determine a second cumulative mean based on the maximum grayscale value corresponding to the image to be desensitized, the first probability, and the grayscale value i corresponding to the first probability; the second cumulative mean is used to represent the cumulative mean of all grayscale values ​​in the image to be desensitized from 0 to the maximum grayscale value;

[0121] A fourth determining unit, configured to determine the maximum inter-class variance value corresponding to the foreground and the background in the image to be desensitized according to a preset inter-class variance formula based on the second probability, the first cumulative mean, and the second cumulative mean;

[0122] The fifth determining unit is used to determine the value of the above-mentioned maximum inter-class variance value corresponding to the above-mentioned threshold variable as the target segmentation threshold corresponding to the above-mentioned image to be desensitized.

[0123] In a possible implementation, the above preset inter-class variance formula is:

[0124] Among them, the above δ 2 is the between-class variance; ω1 is the above-mentioned second probability; m1 is the above-mentioned first cumulative mean; m is the above-mentioned second cumulative mean.

[0125] In a possible implementation, the second probability The first cumulative mean The second cumulative mean The above t is the threshold variable corresponding to the segmentation of foreground and background of the above image to be desensitized; the above L is the maximum grayscale value corresponding to the above image to be desensitized; the above p i is the first probability that the gray value of any pixel in the above-mentioned image to be desensitized is i.

[0126] In a possible implementation, the second determining module 530 is specifically configured to:

[0127] The area composed of multiple target pixel points in the above-mentioned image to be desensitized is determined as the foreground area corresponding to the image to be desensitized; the above-mentioned target pixel points are used to represent the pixel points in the above-mentioned image to be desensitized whose grayscale values ​​are less than the above-mentioned target segmentation threshold.

[0128] In a possible implementation, the scanning module 540 includes:

[0129] A sixth determination unit is used to scan the image to be desensitized to determine whether there is a positioning feature in the image to be desensitized;

[0130] A matching unit, configured to match the positioning feature with a preset QR code positioning feature if the positioning feature exists in the image to be desensitized, to obtain a corresponding positioning matching result;

[0131] The seventh determination unit is used to determine the second sensitive area where the QR code in the above-mentioned image to be desensitized is located based on the target positioning feature in the above-mentioned positioning matching result that matches the above-mentioned preset QR code positioning feature.

[0132] In a possible implementation, the target positioning feature includes a plurality of target position detection patterns; the plurality of target position detection patterns are used to locate the position and direction of the QR code in the image to be desensitized.

[0133] The division of the modules in the above-mentioned image desensitization device is only for illustration. In other embodiments, the image desensitization device can be divided into different modules as needed to complete all or part of the functions of the above-mentioned image desensitization device. The implementation of each module in the image desensitization device provided in the embodiments of this specification may be in the form of a computer program. The computer program can be run on a terminal or a server. The program modules constituting the computer program can be stored in the memory of a terminal or a server. When the computer program is executed by the processor, all or part of the steps of the image desensitization method described in the embodiments of this specification are implemented.

[0134] See next Figure 6 , which is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of this specification. Figure 6 As shown, the electronic device 600 may include: at least one processor 610, at least one communication bus 620, a user interface 630, at least one network interface 640, and a memory 650. The communication bus 620 may be used to realize the connection and communication of the above components.

[0135] The user interface 630 may include a display screen (Display) and a camera (Camera), and the optional user interface may also include a standard wired interface and a wireless interface.

[0136] The network interface 640 may optionally include a Bluetooth module, a Near Field Communication (NFC) module, a Wireless Fidelity (Wi-Fi) module, and the like.

[0137] The processor 610 may include one or more processing cores. The processor 610 uses various interfaces and lines to connect various parts of the entire electronic device 600, and executes various functions and processes data of the routing electronic device 600 by running or executing instructions, programs, code sets or instruction sets stored in the memory 650, and calling data stored in the memory 650. Optionally, the processor 610 can be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor 610 can integrate one or a combination of a processor (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem is used to process wireless communications. It is understandable that the above-mentioned modem may not be integrated into the processor 610, but may be implemented by a separate chip.

[0138] The memory 650 may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory 650 includes a non-transitory computer-readable medium. The memory 650 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 650 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a determination function, a scanning function, a coding function, etc.), instructions for implementing the above-mentioned method embodiments, etc.; the data storage area may store data involved in the above-mentioned method embodiments, etc. The memory 650 may optionally be at least one storage device located away from the aforementioned processor 610. As Figure 6 As shown, the memory 650 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an application program.

[0139] In some possible embodiments, the electronic device 600 is the image desensitization device mentioned in the above embodiments, and the processor 610 can be used to call the application stored in the memory 650, and specifically perform the following operations:

[0140] Obtain the image to be desensitized.

[0141] The maximum inter-class difference method is used to determine the target segmentation threshold corresponding to the above-mentioned image to be desensitized.

[0142] The foreground area corresponding to the image to be desensitized is determined based on the target segmentation threshold; the foreground area is used to characterize the first sensitive area where the seal is located in the image to be desensitized.

[0143] The image to be desensitized is scanned to obtain a second sensitive area where the QR code in the image to be desensitized is located.

[0144] The first sensitive area and the second sensitive area in the image to be desensitized are coded to obtain a desensitized image corresponding to the image to be desensitized.

[0145] In some possible embodiments, when the processor 610 performs the above-mentioned determination of the target segmentation threshold corresponding to the image to be desensitized by using the maximum inter-class difference method, it is specifically used to perform:

[0146] Calculate the first probability that the grayscale value of any pixel in the above-mentioned image to be desensitized is i; the above-mentioned i is a value within the grayscale value range corresponding to the above-mentioned image to be desensitized.

[0147] The second probability is determined based on the first probability and the threshold variable; the second probability is used to characterize the probability that any pixel in the image to be desensitized belongs to a foreground pixel.

[0148] A first cumulative mean is determined based on the threshold variable, the first probability and the grayscale value i corresponding to the first probability; the first cumulative mean is used to characterize the cumulative mean of all grayscale values ​​in the image to be desensitized ranging from 0 to the threshold variable.

[0149] The second cumulative mean is determined based on the maximum grayscale value corresponding to the above-mentioned image to be desensitized, the above-mentioned first probability, and the grayscale value i corresponding to the above-mentioned first probability; the above-mentioned second cumulative mean is used to characterize the cumulative mean of all grayscale values ​​in the above-mentioned image to be desensitized from 0 to the above-mentioned maximum grayscale value.

[0150] Based on the second probability, the first cumulative mean and the second cumulative mean, the maximum inter-class variance value corresponding to the foreground and the background in the image to be desensitized is determined according to a preset inter-class variance formula.

[0151] The value of the threshold variable corresponding to the maximum inter-class variance value is determined as the target segmentation threshold corresponding to the image to be desensitized.

[0152] In some possible embodiments, the above preset inter-class variance formula is:

[0153] Among them, the above δ 2 is the between-class variance; ω1 is the above-mentioned second probability; m1 is the above-mentioned first cumulative mean; m is the above-mentioned second cumulative mean.

[0154] In some possible embodiments, the second probability The first cumulative mean The second cumulative mean The above t is the threshold variable corresponding to the segmentation of foreground and background of the above image to be desensitized; the above L is the maximum grayscale value corresponding to the above image to be desensitized; the above p i is the first probability that the gray value of any pixel in the above-mentioned image to be desensitized is i.

[0155] In some possible embodiments, when the processor 610 performs the above-mentioned determination of the foreground area corresponding to the image to be desensitized based on the above-mentioned target segmentation threshold, it is specifically used to perform:

[0156] The area composed of multiple target pixel points in the above-mentioned image to be desensitized is determined as the foreground area corresponding to the image to be desensitized; the above-mentioned target pixel points are used to represent the pixel points in the above-mentioned image to be desensitized whose grayscale values ​​are less than the above-mentioned target segmentation threshold.

[0157] In some possible embodiments, when the processor 610 performs the scanning of the image to be desensitized to obtain the second sensitive area where the QR code in the image to be desensitized is located, it is specifically used to perform:

[0158] Scan the image to be desensitized to determine whether there is a positioning feature in the image to be desensitized.

[0159] If the above positioning feature exists in the above image to be desensitized, the above positioning feature is matched with the preset QR code positioning feature to obtain a corresponding positioning matching result.

[0160] Based on the target positioning feature in the positioning matching result that matches the preset QR code positioning feature, the second sensitive area where the QR code in the image to be desensitized is located is determined.

[0161] In some possible embodiments, the target positioning feature includes a plurality of target position detection patterns; the plurality of target position detection patterns are used to locate the position and direction of the QR code in the image to be desensitized.

[0162] The embodiments of this specification also provide a computer-readable storage medium, which stores instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes one or more steps in the above embodiments. If the components of the above image desensitization device are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium.

[0163] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The above computer program product includes one or more computer instructions. When the above computer program instructions are loaded and executed on a computer, the above process or function according to the embodiment of this specification is generated in whole or in part. The above computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The above computer instructions can be stored in a computer-readable storage medium or transmitted by the above computer-readable storage medium. The above computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The above computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that contains one or more available media integrated. The above-mentioned available media can be magnetic media (for example, floppy disks, hard disks, tapes), optical media (for example, digital versatile disks (DVD)), or semiconductor media (for example, solid-state drives (SSD)), etc.

[0164] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes. In the absence of conflict, the technical features in this embodiment and the implementation scheme can be combined arbitrarily.

[0165] The embodiments described above are merely preferred embodiments of this specification and are not intended to limit the scope of this specification. Without departing from the design spirit of this specification, various modifications and improvements made to the technical solutions of this specification by ordinary technicians in this field should fall within the scope of protection determined by the claims.

[0166] The above is a description of a specific embodiment of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims and the specification can be performed in an order different from that in the embodiment recorded in the specification and still achieve the desired results. In addition, the process depicted in the drawings does not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

Claims

1. An image desensitization method, the method comprising: Obtaining the image to be desensitized; Determine the target segmentation threshold corresponding to the image to be desensitized by using the maximum inter-class difference method; Determine the foreground area corresponding to the image to be desensitized based on the target segmentation threshold; The foreground area is used to represent the first sensitive area where the seal is located in the image to be desensitized; Scan the image to be desensitized to obtain a second sensitive area where the QR code in the image to be desensitized is located; The first sensitive area and the second sensitive area in the image to be desensitized are coded to obtain a desensitized image corresponding to the image to be desensitized.

2. The method according to claim 1, wherein the step of determining the target segmentation threshold corresponding to the image to be desensitized by using the maximum inter-class difference method comprises: Calculate the first probability that the gray value of any pixel in the image to be desensitized is i; The i is a value within the grayscale value range corresponding to the image to be desensitized; Determine a second probability based on the first probability and the threshold variable; the second probability is used to characterize the probability that any pixel in the image to be desensitized belongs to a foreground pixel; Determine a first cumulative mean based on the threshold variable, the first probability, and the gray value i corresponding to the first probability; the first cumulative mean is used to represent the cumulative mean of all gray values ​​in the image to be desensitized from 0 to the threshold variable; Determine a second cumulative mean based on the maximum grayscale value corresponding to the image to be desensitized, the first probability, and the grayscale value i corresponding to the first probability; the second cumulative mean is used to represent the cumulative mean of all grayscale values ​​in the image to be desensitized from 0 to the maximum grayscale value; Determine the maximum inter-class variance value corresponding to the foreground and the background in the image to be desensitized according to a preset inter-class variance formula based on the second probability, the first cumulative mean, and the second cumulative mean; The value of the threshold variable corresponding to the maximum inter-class variance value is determined as the target segmentation threshold corresponding to the image to be desensitized.

3. The method according to claim 2, wherein the preset inter-class variance formula is: in, The δ 2 is the inter-class variance; ω1 is the second probability; m1 is the first cumulative mean; and m is the second cumulative mean.

4. The method according to claim 3, wherein the second probability The first cumulative mean The second cumulative mean The t is the threshold variable for segmenting the foreground and background of the image to be desensitized; the L is the maximum grayscale value corresponding to the image to be desensitized; the p i is the first probability that the gray value of any pixel in the image to be desensitized is i.

5. The method according to claim 1, wherein determining the foreground area corresponding to the image to be desensitized based on the target segmentation threshold comprises: Determine an area composed of a plurality of target pixels in the image to be desensitized as a foreground area corresponding to the image to be desensitized; The target pixel point is used to represent the pixel point whose grayscale value in the image to be desensitized is less than the target segmentation threshold.

6. The method according to claim 1, wherein scanning the image to be desensitized to obtain the second sensitive area where the QR code is located in the image to be desensitized comprises: Scanning the image to be desensitized to determine whether there is a positioning feature in the image to be desensitized; If the positioning feature exists in the image to be desensitized, the positioning feature is matched with the preset two-dimensional code positioning feature to obtain a corresponding positioning matching result; The second sensitive area where the QR code in the image to be desensitized is located is determined based on the target positioning feature in the positioning matching result that matches the preset QR code positioning feature.

7. According to the method as claimed in claim 5, the target positioning feature includes a plurality of target position detection graphics; the plurality of target position detection graphics are used to locate the position and direction of the two-dimensional code in the image to be desensitized.

8. An image desensitization device, comprising: An acquisition module, used for acquiring images to be desensitized; A first determination module is used to determine the target segmentation threshold corresponding to the image to be desensitized by using the maximum inter-class difference method; A second determination module is used to determine the foreground area corresponding to the image to be desensitized based on the target segmentation threshold; The foreground area is used to represent the first sensitive area where the seal is located in the image to be desensitized; A scanning module, used for scanning the image to be desensitized to obtain a second sensitive area where the QR code in the image to be desensitized is located; The coding module is used to code the first sensitive area and the second sensitive area in the image to be desensitized to obtain a desensitized image corresponding to the image to be desensitized.

9. An electronic device, comprising: Processor and memory; The processor is connected to the memory; The memory is used to store executable program code; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the method according to any one of claims 1 to 7.

10. A computer storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 7.

11. A computer program product comprising instructions, which, when executed on a computer or a processor, enables the computer or the processor to execute the image desensitization method according to any one of claims 1 to 7.