Method, device and equipment for desensitizing red seal in image

The maximum inter-class variance method is used to grayscale the image and identify the red badge area, which solves the problem of missed red badge detection in the existing technology and achieves a more accurate and reliable red badge desensitization effect.

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

Patent Information

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

AI Technical Summary

Technical Problem

The prior art has missed detection problems in the desensitization process of red chapters in images, especially the poor detection and desensitization effect of non-circular red chapters.

Method used

采用最大类间方差法(OTSU算法)对图像进行灰度化处理,自适应确定最优阈值,识别出红章区域,并基于像素的灰度值与阈值的比较进行脱敏处理。

Benefits of technology

It improves the accuracy of red seal detection and desensitization, avoids complicated training of the seal detection model, and achieves a more reliable red seal desensitization effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119313870A_ABST
    Figure CN119313870A_ABST
Patent Text Reader

Abstract

One or more embodiments of the present specification provide a method, apparatus and device for desensitizing a red seal in an image, the method comprising: acquiring a target image to be processed, the target image comprising a red seal; performing graying processing on the target image, and converting the target image into a grayscale image; for the grayscale image, identifying a red stamp region in the image through a maximum between-class variance method; and desensitizing the red seal area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of computer application technology, and in particular, to a method, device and apparatus for desensitizing red stamps in images. Background Art

[0002] Due to business needs, some file information is sometimes disclosed, and usually this file information is disclosed in the form of electronic images. For example, taking medical documents as an example, sometimes for the purpose of medical business communication and sharing, medical document images need to be disclosed. However, medical document images often include some information involving privacy. For example, one type of privacy information is the information in the red seal in the medical document. The red seal often contains sensitive data such as hospital name and doctor's personal information. Even if business communication and sharing are carried out, this information should be protected from being disclosed as much as possible to prevent information abuse. Based on this, in practice, before disclosing image data with a red seal, it is usually necessary to desensitize the red seal so that privacy can be protected from being leaked, while other information outside the red seal can be disclosed for business use.

[0003] In the related art, the red seal desensitization in the image is mostly done by using a pre-trained model, detecting the red seal in the image through the target detection method, and desensitizing the red seal. However, it is found in practice that this method sometimes misses detections, such as failing to detect non-circular red seals in some images, and thus failing to desensitize the red seal. Therefore, it is urgent to provide a more reliable red seal desensitization method. Summary of the invention

[0004] In view of this, one or more embodiments of the present specification provide a method, device and apparatus for desensitizing a red seal in an image, so as to improve the reliability of desensitizing a red seal in an image.

[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:

[0006] According to a first aspect of an embodiment of this specification, a method for desensitizing a red seal in an image is provided, the method comprising:

[0007] Acquire a target image to be processed, wherein the target image includes a red seal;

[0008] Gray-scale the target image to convert it into a grayscale image;

[0009] For the grayscale image, identifying the red seal area in the image by using the maximum inter-class variance method;

[0010] Desensitization is performed on the red seal area.

[0011] According to a second aspect of an embodiment of this specification, a device for desensitizing a red seal in an image is provided, the device comprising:

[0012] An image acquisition module, used for acquiring a target image to be processed, wherein the target image includes a red seal;

[0013] An image processing module, used for graying the target image and converting it into a grayscale image;

[0014] A red seal recognition module, for identifying the red seal area in the grayscale image by using the maximum inter-class variance method;

[0015] The desensitization processing module is used to desensitize the red seal area.

[0016] According to a third aspect of the embodiments of this specification, an electronic device is provided, including:

[0017] processor;

[0018] a memory for storing processor-executable instructions;

[0019] The processor implements the method described in any embodiment of this specification by running the executable instructions.

[0020] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the method described in any embodiment of this specification is implemented.

[0021] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method described in any embodiment of this specification is implemented.

[0022] The method, device and equipment for desensitizing the red seal in the image of the embodiments of this specification determine the optimal threshold by adopting the maximum inter-class variance method, and determine the red seal area in the image based on the optimal threshold. Since the maximum inter-class variance method can adaptively determine the optimal threshold for segmentation, the red seal area can be determined more accurately based on the optimal threshold; and the red seal area determined based on this method can be determined based on the comparison between the grayscale value of the pixel and the threshold to determine the pixels belonging to the red seal area, which is a pixel-level recognition, so that the recognition of the red seal area is more accurate, thereby achieving a better red seal desensitization effect; furthermore, by adopting the maximum inter-class variance method to identify the red seal area, the complicated training of the seal detection model can also be avoided, which is more convenient and simple. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in one or more embodiments of the present disclosure or related technologies, the drawings required for use in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in one or more embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0024] Figure 1 It is a flowchart of a method for desensitizing a red stamp in an image provided by an exemplary embodiment.

[0025] Figure 2 It is a flowchart of another method for desensitizing a red stamp in an image provided by an exemplary embodiment.

[0026] Figure 3 It is a flowchart of another method for desensitizing a red stamp in an image provided by an exemplary embodiment.

[0027] Figure 4 It is a structural schematic diagram of a red seal desensitization device in an image provided by an exemplary embodiment.

[0028] Figure 5 is a schematic diagram of an electronic device provided by an exemplary embodiment. DETAILED DESCRIPTION

[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0030] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0031] In the related art, when desensitizing the red seal in the image, most of the methods are to detect the red seal in the image by using a pre-trained model for target detection. However, it is found in practice that this method has defects: on the one hand, the training of the seal detection model is costly and cumbersome; on the other hand, there are many shapes of red seals, such as round, oval, square, diamond or custom shapes, etc. In many cases, for some irregular-shaped seals (for example, non-circular or non-oval), they will be missed when detected by the detection model.

[0032] Based on this, an embodiment of this specification provides a method for desensitizing red seals in an image. The method utilizes the maximum between-class variance method (OTSU, also known as the Otsu algorithm), and practice has proved that when the OTSU algorithm is applied to remove red seals, it can achieve better effects of red seal detection and desensitization.

[0033] Figure 1 The present invention is a flowchart of a method for desensitizing a red stamp in an image provided by an exemplary embodiment. The method may include:

[0034] In step 100, a target image to be processed is obtained, wherein the target image includes a red seal.

[0035] The target image may be an image to be desensitized. For example, medical document images such as medical test reports, B-ultrasound reports, medical bills, and consultation reports contain sensitive information such as hospital official seals or doctor's personal official seals. The sensitive information in these red seals needs to be desensitized to prevent privacy leakage. Then, these medical document images can be called target images, and the official seals to be desensitized are the above-mentioned hospital official seals or doctor's personal official seals.

[0036] In step 102, the target image is grayscaled and converted into a grayscale image.

[0037] Since the OTSU algorithm is usually used for processing grayscale images, before applying the algorithm, the target image can be grayscaled and converted into a grayscale image.

[0038] Specifically, the target image can be grayed out by using a graying conversion tool to obtain a gray image. In addition, the gray value of each pixel in the gray image can be calculated during the graying process.

[0039] For example, OpenCV provides a function tool for converting a color image into a grayscale image, and the grayscale processing of the image can be performed through OpenCV. After the grayscale image is obtained by grayscale processing, the grayscale image is usually represented in the form of a two-dimensional array, in which each element corresponds to the grayscale value of a pixel. The grayscale value can be an integer between 0 and 255, where 0 represents black, 255 represents white, and the intermediate values ​​represent different degrees of gray.

[0040] It is understandable that this embodiment does not limit the method of grayscale processing of the target image, and other methods may be used.

[0041] In step 104, for the grayscale image, the red seal area in the image is identified by using the maximum inter-class variance method.

[0042] In this step, the maximum inter-class variance OTSU algorithm can be applied to the grayscale image. The OTSU algorithm can be used to adaptively determine the optimal threshold for segmenting the grayscale image into foreground and background, and then identify the red seal area included in the grayscale image based on the optimal threshold.

[0043] Specifically, first, the histogram of the grayscale image can be calculated, which includes: statistics on the number of occurrences of each grayscale value in the image, also known as the number of pixels corresponding to each grayscale value. For example, in the grayscale image, the number of pixels with a grayscale value of 50 is 120, the number of pixels with a grayscale value of 70 is 80, and so on.

[0044] Next, traverse each first grayscale value as the assumed threshold, and calculate the inter-class variance for each first grayscale value. And take the first grayscale value corresponding to the maximum inter-class variance as the aforementioned optimal threshold. Among them, the first grayscale value is the assumed threshold. For example, assuming that the grayscale value t is the optimal threshold that can maximize the inter-class variance of the image foreground and background, the assumed optimal threshold-grayscale value t can be called the first grayscale value. This is a traversal process, which is equivalent to trying to use each grayscale value as the assumed optimal threshold one by one, to calculate the inter-class variance, and find the grayscale value corresponding to the maximum inter-class variance as the threshold.

[0045] Finally, after the threshold is determined, the pixels in the grayscale image belonging to the red seal area can be identified based on the threshold. For example, the grayscale value of the pixel in the grayscale image is compared with the threshold, and if the grayscale value is greater than or equal to the threshold, it is determined that the pixel belongs to the red seal area.

[0046] The process of calculating the inter-class variance for each first grayscale value is described as follows:

[0047] When calculating the inter-class variance, it can be calculated based on the number of pixels counted in the histogram and the grayscale value of the pixels.

[0048] The following is a diagram of the derivation process of the formula for between-class variance:

[0049] The calculation formula for between-class variance is as follows:

[0050] δ 2 =ω1(μ1-μ) 2 +ω2(μ2-μ)............(1)

[0051] Among them, δ 2 represents the inter-class variance, which is the inter-class variance of two sets obtained by segmenting the image based on the threshold determined by the OTSU algorithm. The two sets can be a first set and a second set. For example, the first set can be the foreground of the image, and the second set can be the background of the image.

[0052] ω1 represents the probability that any pixel in the image belongs to the first set, and ω2 represents the probability that any pixel in the image belongs to the second set. μ1 is the average grayscale value of the pixels in the first set, and μ2 is the average grayscale value of the pixels in the second set. μ is the average grayscale value of the pixels in the entire image.

[0053] Since ω1+ω2=1, and μ=ω1μ1+ω2μ2, the above formula (1) can be deduced as follows:

[0054]

[0055] That is: 2 =ω1ω2(μ1-μ2) 2 ..........(2)

[0056] Next, this embodiment defines the following parameters:

[0057]

[0058] Wherein, t is the first gray value used as the assumed threshold. Assume that the gray level of the image is L. i is the gray value of the pixel.

[0059] p t It represents the probability that the gray value is equal to i, referred to as gray value probability. t The calculation can be: obtain the number of pixels n in the image whose gray value is equal to i, and obtain the total number of pixels in the image, and determine the ratio of the number of pixels n to the total number of pixels as p. i .

[0060] Among the above three parameters, ω1 represents the probability that any pixel in the image belongs to the first set, which can be called the first probability. m1 can be called the first cumulative value, which is the cumulative mean of the gray level t. m can be called the second cumulative value, which is the cumulative mean of the gray level L.

[0061] Based on the three parameters ω1, m1 and m defined in the above formulas (3) to (5), μ1 and μ2 are derived as follows:

[0062]

[0063] Substitute the above formulas (6) and (7) into formula (2) to derive:

[0064]

[0065] That is, we finally get the following formula (8):

[0066]

[0067] As can be seen from the above formula, if we want to calculate the between-class variance δ 2 , we can first calculate the three parameters ω1, m1 and m, and then use formula (8) to calculate the between-class variance.

[0068] From the above derivation process, we can get the calculation process of the between-class variance as follows:

[0069] First, the total number of pixels in the grayscale image is obtained, and then the grayscale value probability p can be calculated based on the number of pixels corresponding to each grayscale value i in the image and the total number of pixels total. t , the gray value probability p i Indicates the ratio of the number of pixels with the gray value i to the total number of pixels.

[0070] Next, it can be assumed that the threshold is the first grayscale value t, and each possible first grayscale value t is traversed step by step, and the first probability ω1, the first accumulated value m1 and the second accumulated value m are calculated respectively according to formula (3) to formula (5).

[0071] Finally, according to formula (8), the inter-class variance δ can be calculated 2 .

[0072] For each first gray value t, the corresponding inter-class variance δ can be calculated 2 . Select the largest between-class variance δ 2 The corresponding first grayscale value can be used as the optimal threshold determined by the OTSU algorithm. After the threshold is determined, the pixels belonging to the red seal area in the grayscale image can be identified based on the threshold.

[0073] In step 106, the red seal area is desensitized.

[0074] In this step, the pixels determined as the red seal area in step 104 may be desensitized.

[0075] This embodiment does not limit the specific desensitization processing method. For example, the color of the pixels belonging to the red seal area can be replaced, and the color of these pixels can be replaced from red to gray, white or the background color around the red seal area. For another example, Gaussian blur can be applied to the pixels in the red seal area to achieve the desensitization effect. For another example, graphic elements such as rectangles can also be used to cover the pixels in these red seal areas.

[0076] The method for desensitizing the red seal in the image of the present embodiment determines the optimal threshold by adopting the maximum inter-class variance method, and determines the red seal area in the image based on the optimal threshold. Since the maximum inter-class variance method can adaptively determine the optimal threshold for segmentation, the red seal area can be determined more accurately based on the optimal threshold; and the red seal area determined based on the method can be determined based on the comparison between the grayscale value of the pixel and the threshold to determine the pixels belonging to the red seal area, which is a pixel-level recognition, so that the recognition of the red seal area is more accurate, thereby achieving a better red seal desensitization effect; furthermore, by adopting the maximum inter-class variance method to identify the red seal area, the complicated training of the seal detection model can be avoided, which is more convenient and simple.

[0077] also, Figure 2 is a flowchart of another method for desensitizing a red stamp in an image provided by an exemplary embodiment. Figure 1 Based on the process of further improving the recognition accuracy of the red seal area, the following processing may be included, wherein the same steps as the previous embodiment will not be described in detail, and can be combined with any of the previous embodiments:

[0078] In step 200, a target image to be processed is obtained, wherein the target image includes a red seal.

[0079] In step 202, the target image is subjected to color space transformation and converted into the HSV color space.

[0080] In this embodiment, the target image may be subjected to color space transformation and converted into an HSV (Hue, Saturation, Value) color space.

[0081] In step 204, color enhancement is performed on the red seal area of ​​the target image in the HSV color space.

[0082] In this step, the red seal area of ​​the target image can be color enhanced in the HSV color space. For example, the color saturation and brightness of the red seal area can be enhanced. After color enhancement, it helps to increase the grayscale value of the red seal area after it is converted into a grayscale image in the subsequent step.

[0083] In step 206, the color-enhanced target image is converted back to the RGB color space.

[0084] In step 208, the target image is grayscaled and converted into a grayscale image.

[0085] In step 210, for the grayscale image, the red seal region in the image is identified by using the maximum inter-class variance method, and the red seal region is desensitized.

[0086] The method for desensitizing the red seal in the image of the present embodiment determines the optimal threshold by adopting the maximum inter-class variance method, and determines the red seal area in the image based on the optimal threshold. Since the maximum inter-class variance method can adaptively determine the optimal threshold for segmentation, the red seal area can be determined more accurately based on the optimal threshold. Moreover, the red seal area determined based on the method can be determined based on the comparison between the grayscale value of the pixel and the threshold to determine the pixels belonging to the red seal area, which is a pixel-level recognition, so that the recognition of the red seal area is more accurate, thereby achieving a better red seal desensitization effect. Moreover, the embodiment also enhances the color of the red seal area in the HSV color space of the image before grayscale processing, so that the red seal area has a larger grayscale value after being converted into a grayscale image, so that it is easier to be identified as a foreground when the threshold recognition determined by the Otsu method is applied, thereby improving the accuracy of red seal area recognition.

[0087] Figure 3 is a flowchart of another method for desensitizing a red stamp in an image provided by an exemplary embodiment. Figure 1 Based on the process of further improving the recognition accuracy of the red seal area, the following processing may be included, wherein the same steps as the previous embodiment will not be described in detail, and can be combined with any of the previous embodiments:

[0088] In step 300, a target image to be processed is obtained, wherein the target image includes a red seal.

[0089] In step 302, the target image is subjected to color space transformation and converted into the HSV color space.

[0090] In this embodiment, the target image may be subjected to color space transformation and converted into an HSV (Hue, Saturation, Value) color space.

[0091] In step 304, a mask image retaining the red seal area is obtained by color filtering in the HSV color space.

[0092] In this step, a color filtering range can be set in the HSV color space according to the specific color tone of the red seal area in the target image, and a mask image (mask) that only retains the red seal area can be obtained through the color filtering range.

[0093] In step 306, grayscale processing is performed based on the mask image to obtain a grayscale image.

[0094] In step 308, for the grayscale image, the red seal area in the image is identified by using the maximum inter-class variance method, and the red seal area is desensitized.

[0095] In step 310 , the desensitized mask image is combined with the target image.

[0096] In this step, in the combined image, the red seal area in the mask image has been desensitized, and the desensitized area is then combined with the non-red seal area in the target image, that is, the non-red seal area is added to the desensitized red seal area to obtain the final image in which the red seal area is desensitized.

[0097] The method for desensitizing the red seal in the image of the present embodiment determines the optimal threshold by adopting the maximum inter-class variance method, and determines the red seal area in the image based on the optimal threshold. Since the maximum inter-class variance method can adaptively determine the optimal threshold for segmentation, the red seal area can be determined more accurately based on the optimal threshold. Moreover, the red seal area determined based on the method can be determined based on the comparison between the grayscale value of the pixel and the threshold, so as to determine the pixels belonging to the red seal area, which is a pixel-level recognition, so that the recognition of the red seal area is more accurate, thereby achieving a better red seal desensitization effect. Moreover, the embodiment combines color filtering with the Otsu method, so that the accuracy of red seal area recognition can be further improved through the Otsu method, and the influence of noise in the color recognition result can be reduced.

[0098] Figure 4 is a schematic diagram of a structure of a red seal desensitization device in an image provided by an exemplary embodiment. Figure 4 As shown, the device may include: an image acquisition module 41, an image processing module 42, a red seal recognition module 43 and a desensitization processing module 44, wherein:

[0099] The image acquisition module 41 is used to acquire a target image to be processed, wherein the target image includes a red seal.

[0100] The image processing module 42 is used to perform grayscale processing on the target image to convert it into a grayscale image.

[0101] The red seal recognition module 43 is used to recognize the red seal area in the grayscale image by using the maximum inter-class variance method.

[0102] The desensitization processing module 44 is used to desensitize the red seal area.

[0103] In some examples, the image processing module 42, when used to grayscale the target image and convert it into a grayscale image, includes: grayscaleing the target image through a grayscale conversion tool to obtain a grayscale image, and determining the grayscale value of each pixel in the grayscale image.

[0104] In some examples, the red seal identification module 43, when used to identify the red seal area in the grayscale image by the maximum inter-class variance method, includes: calculating the histogram of the grayscale image, the histogram including: the number of pixels corresponding to each grayscale value in the image; traversing each first grayscale value as the assumed threshold, and for each first grayscale value, calculating the inter-class variance according to the number of pixels and the grayscale value of the pixel, and obtaining the first grayscale value corresponding to the maximum inter-class variance as the threshold; based on the threshold, identifying the pixels in the grayscale image belonging to the red seal area.

[0105] In some examples, the red seal recognition module 43, when used to calculate the inter-class variance for each first grayscale value according to the number of pixels and the grayscale value of the pixels, includes: obtaining the total number of pixels in the grayscale image; calculating the grayscale value probability according to the number of pixels corresponding to each grayscale value and the total number of pixels, the grayscale value probability indicating the proportion of the number of pixels of the grayscale value to the total number of pixels; for each first grayscale value, calculating a first probability, a first cumulative value, and a second cumulative value based on the grayscale value probability; wherein the first probability indicates the probability that the pixel belongs to a first set, the first set being a range of grayscale values ​​from 0 to the first grayscale value; the first cumulative value is the accumulation of grayscale values ​​within the range of the first set; the second cumulative value is the accumulation of grayscale values ​​of the entire image; calculating the inter-class variance according to the first probability, the first cumulative value, and the second cumulative value.

[0106] In some examples, the image processing module 42 is also used to: before gray-scaling the target image and converting it into a grayscale image, perform a color space transformation on the target image and convert it into an HSV color space; perform color enhancement on the red stamp area of ​​the target image in the HSV color space; and convert the color-enhanced target image back into the RGB color space.

[0107] In some examples, the image processing module 42, when used to grayscale the target image and convert it into a grayscale image, includes: performing a color space transformation on the target image and converting it into an HSV color space; in the HSV color space, obtaining a mask image that retains the red seal area through color filtering; performing a grayscale process based on the mask image to obtain a grayscale image; and combining the desensitized mask image with the target image.

[0108] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0109] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.

[0110] like Figure 5 As shown, Figure 5 A hardware structure diagram of an electronic device in which the navigation broadcast device of an embodiment of the specification is located is shown, and the device may include: a processor 510, a memory 520, an input / output interface 530, a communication interface 540, and a bus 550. The processor 510, the memory 520, the input / output interface 530, and the communication interface 540 are connected to each other in communication within the device through the bus 550.

[0111] The processor 510 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification. The processor implements the above method by running executable instructions.

[0112] The memory 520 for storing processor executable instructions can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 520 can store operating systems and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 520.

[0113] The input / output interface 530 is used to connect the input / output module to realize information input and output. The input / output module can be configured as a component in the device (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0114] The communication interface 540 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).

[0115] The bus 550 comprises a pathway that transmits information between the various components of the device (eg, the processor 510 , the memory 520 , the input / output interface 530 , and the communication interface 540 ).

[0116] It should be noted that, although the above device only shows the processor 510, the memory 520, the input / output interface 530, the communication interface 540 and the bus 550, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.

[0117] The embodiments of the present specification also provide a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned method for desensitizing the red seal in the image is implemented.

[0118] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0119] The embodiments of the present specification also provide a computer program, which, when executed, is used to implement the method for desensitizing the red seal in an image described in any embodiment of the present specification.

[0120] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0121] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do 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.

[0122] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data 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, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0123] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.

Claims

1. A method for desensitizing red stamps in an image, characterized in that: The method comprises: Acquire a target image to be processed, wherein the target image includes a red seal; Gray-scale the target image to convert it into a grayscale image; For the grayscale image, identifying the red seal area in the image by using the maximum inter-class variance method; Desensitization is performed on the red seal area.

2. The method according to claim 1, characterized in that The grayscale processing of the target image to convert it into a grayscale image includes: The target image is grayed out by a grayscale conversion tool to obtain a grayscale image, and the grayscale value of each pixel in the grayscale image is determined.

3. The method according to claim 1, characterized in that The step of identifying the red seal area in the grayscale image by using the maximum inter-class variance method includes: Calculating a histogram of a grayscale image, wherein the histogram includes: the number of pixels corresponding to each grayscale value in the image; Traversing each first grayscale value as an assumed threshold, for each first grayscale value, calculating the inter-class variance according to the number of pixels and the grayscale value of the pixel, and obtaining the first grayscale value corresponding to the maximum inter-class variance as the threshold; Based on the threshold, pixels in the grayscale image belonging to the red seal area are identified.

4. The method according to claim 3, characterized in that The step of calculating the inter-class variance for each first grayscale value according to the number of pixels and the grayscale value of the pixels comprises: Get the total number of pixels in the grayscale image; Calculate the gray value probability according to the number of pixels corresponding to each gray value and the total number of pixels, wherein the gray value probability represents the ratio of the number of pixels of the gray value to the total number of pixels; For each first gray value, based on the gray value probability, a first probability, a first accumulated value, and a second accumulated value are calculated; wherein the first probability represents the probability that the pixel belongs to a first set, and the first set is a range of gray values ​​from 0 to the first gray value; the first accumulated value is the accumulated gray values ​​within the range of the first set; and the second accumulated value is the accumulated gray values ​​of the entire image; The inter-class variance is calculated according to the first probability, the first accumulated value and the second accumulated value.

5. The method according to claim 1, characterized in that Before graying the target image and converting it into a grayscale image, the method further includes: Performing a color space transformation on the target image to convert it into an HSV color space; Perform color enhancement on the red stamp area of ​​the target image in the HSV color space; Convert the color enhanced target image back to RGB color space.

6. The method according to claim 1, characterized in that The grayscale processing of the target image to convert it into a grayscale image includes: Performing a color space transformation on the target image to convert it into an HSV color space; In the HSV color space, through color filtering, a mask image that retains the red seal area is obtained; Performing grayscale processing based on the mask image to obtain a grayscale image; The method further includes: combining the desensitized mask image with the target image.

7. A device for desensitizing red seals in images, characterized in that: The device comprises: An image acquisition module, used for acquiring a target image to be processed, wherein the target image includes a red seal; An image processing module, used for graying the target image and converting it into a grayscale image; A red seal recognition module, for identifying the red seal area in the grayscale image by using the maximum inter-class variance method; The desensitization processing module is used to desensitize the red seal area.

8. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 6 by running the executable instructions.

9. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instruction is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.