Document occlusion area detection method and apparatus, electronic device, and storage medium
By performing image preprocessing and morphological processing on document images, combined with sliding window and threshold judgment, the problem that the detection accuracy of existing technologies depends on the dataset and computing resources is solved, and fast and accurate document occlusion region detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING TOPSEC NETWORK SECURITY TECH
- Filing Date
- 2022-09-29
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies for detecting occluded regions in document images, especially graffiti occlusion detection, suffer from the problem that detection accuracy depends on a large dataset and high computing resources, and cannot effectively detect samples of the image before occlusion.
By performing image preprocessing and morphological processing on the document image to be detected, including grayscale conversion, binarization, dilation and erosion, and combining sliding window and threshold judgment, the target occlusion area is gradually screened out.
It enables fast and accurate detection of document occlusion areas under low computing power conditions, avoiding dependence on high computing resources and reducing hardware requirements.
Smart Images

Figure CN115690412B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method, apparatus, electronic device, and storage medium for detecting document occlusion areas. Background Technology
[0002] With the increasing level of informatization, the management of sensitive documents has encountered new difficulties and challenges, making proper management of classified documents crucial. During the review of classified documents, it has been discovered that some individuals are attempting to evade review by obscuring text or document titles with graffiti. Failure to detect such graffiti in a timely manner could lead to serious leaks.
[0003] Currently, there is limited publicly available research on document image graffiti occlusion detection. Research on image occlusion mainly focuses on analyzing image features from the difference images between multiple frames to identify graffiti occlusion; or manually collecting and creating datasets of graffiti-occluded and unoccluded images, and using deep learning classification to determine the presence of graffiti occlusion. However, these methods cannot detect graffiti on samples of images before occlusion. Furthermore, the accuracy of deep learning methods is directly affected by the dataset, requiring the collection and creation of a large number of image data samples, consuming significant manpower and time. Additionally, model training relies on computing power, placing high demands on hardware capabilities. Summary of the Invention
[0004] In view of the above, this application provides a document occlusion area detection method, apparatus, electronic device and storage medium, the purpose of which is to detect document occlusion areas quickly and accurately while reducing computing power.
[0005] Firstly, this application provides a method for detecting document occlusion regions, wherein the method includes:
[0006] Image preprocessing and morphological processing are performed on the document image to be detected to obtain the first image;
[0007] Perform a first occlusion region detection on the first image to obtain one or more first candidate regions, and obtain a second image based on the first candidate regions;
[0008] Perform a second occlusion region detection on the second image to obtain one or more second candidate regions;
[0009] Perform a third occlusion region detection on the second candidate region to obtain the target occlusion region corresponding to the document image to be detected.
[0010] Optionally, performing a first occlusion region detection on the first image to obtain one or more first candidate regions, and obtaining a second image based on the first candidate regions, includes:
[0011] Set the sliding window and step size;
[0012] The sliding window is slid across the first image according to the step size to obtain multiple initial regions;
[0013] Determine whether each initial area is covered by graffiti;
[0014] Based on the judgment result, the first image is subjected to denoising processing to obtain the second image.
[0015] Optionally, the step of performing denoising processing on the first image based on the judgment result to obtain the second image includes:
[0016] The area identified as being covered by graffiti is selected as the first candidate area, and the pixel values in the first candidate area are kept unchanged.
[0017] The pixel values in the areas determined to be uncovered by graffiti are set to the pixel values corresponding to white, thus obtaining the second image.
[0018] Optionally, performing a second occlusion region detection on the second image to obtain one or more second candidate regions includes:
[0019] The second image is subjected to dilation, erosion and dilation processes in sequence to obtain the third image;
[0020] One or more second candidate regions are determined from the third image.
[0021] Optionally, determining whether each initial area is an area covered by graffiti includes:
[0022] Calculate the percentage of black pixels in each initial region;
[0023] The initial area with a proportion less than the first threshold is determined to be an area without graffiti obscuring the area.
[0024] The initial area with a proportion greater than or equal to the first threshold is determined to be an area covered by graffiti.
[0025] Optionally, performing a third occlusion region detection on the second candidate region to obtain the target occlusion region corresponding to the document image to be detected includes:
[0026] Count the number of black pixels in each second candidate region;
[0027] The second candidate region with a number of black pixels greater than or equal to the second threshold is selected as the third candidate region.
[0028] The third candidate region whose width and height are both greater than or equal to the third threshold is taken as the target occlusion region.
[0029] Optionally, the step of performing image preprocessing and morphological processing on the document image to be detected to obtain a first image includes:
[0030] Obtain the initial image corresponding to the document image to be detected;
[0031] The initial image is converted to grayscale to obtain a grayscale image;
[0032] The grayscale image is binarized to obtain a binary image;
[0033] The binary image is dilated to obtain the first image.
[0034] Optionally, obtaining the initial image corresponding to the document image to be detected includes:
[0035] Read the binary form image data of the document image to be detected;
[0036] The width and height of the document image to be detected are determined from the image data;
[0037] The initial image corresponding to the document image to be detected is determined based on the width and height.
[0038] Secondly, this application also provides a document occlusion region detection device, wherein the device includes:
[0039] The image processing module is used to perform image preprocessing and morphological processing on the document image to be detected, so as to obtain the first image;
[0040] The first detection module is used to perform a first occlusion region detection on the first image to obtain one or more first candidate regions, and to obtain a second image based on the first candidate regions.
[0041] The second detection module is used to perform second occlusion region detection on the second image to obtain one or more second candidate regions;
[0042] The third detection module is used to perform third occlusion region detection on the second candidate region to obtain the target occlusion region corresponding to the document image to be detected.
[0043] Thirdly, this application also provides an electronic device, wherein the electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a document occlusion region detection program executable by the at least one processor, the document occlusion region detection program being executed by the at least one processor to enable the at least one processor to perform the document occlusion region detection method described in any of the above claims.
[0044] Fourthly, this application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a document occlusion region detection program, and when the document occlusion region detection program is executed by a processor, it implements the steps of the document occlusion region detection method described in any of the above claims.
[0045] The document occlusion region detection method, apparatus, electronic device, and storage medium proposed in this application first perform image preprocessing and morphological processing on the document image to be detected to obtain a first image; then, perform a first occlusion region detection on the first image to obtain one or more first candidate regions, and obtain a second image based on the first candidate regions; then, perform a second occlusion region detection on the second image to obtain one or more second candidate regions; finally, perform a third occlusion region detection on the second candidate regions to obtain the target occlusion region corresponding to the document image to be detected. This application does not require the creation of image samples or high computing power to train the model, and can quickly and accurately detect document occlusion regions.
[0046] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above-mentioned solutions and other objects, features and advantages of this application more obvious and understandable, the following are preferred embodiments, and are described in detail with reference to the accompanying drawings. Attached Figure Description
[0047] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 A flowchart illustrating the document occlusion region detection method provided in this application embodiment;
[0049] Figure 2-1 This is the initial image corresponding to the un-graffiti-covered document image provided in the embodiments of this application;
[0050] Figure 2-2 This is the initial image corresponding to the graffiti-covered document image provided in the embodiments of this application;
[0051] Figure 2-3 This is a grayscale image corresponding to the un-graffiti-covered document image provided in the embodiments of this application;
[0052] Figure 2-4 This is a grayscale image corresponding to the graffiti-covered document image provided in the embodiments of this application;
[0053] Figure 2-5 This is a binary image corresponding to the un-graffiti-covered document image provided in the embodiments of this application;
[0054] Figure 2-6 This is a binary image corresponding to a document image with graffiti overlay provided in the embodiments of this application;
[0055] Figure 2-7 The first image after inflation corresponding to the document image without graffiti cover provided in the embodiments of this application;
[0056] Figure 2-8 The first image after inflation corresponding to the graffiti-covered document image provided in this application embodiment;
[0057] Figure 3-1 The second image corresponding to the un-graffiti-covered document image provided in the embodiments of this application;
[0058] Figure 3-2 The second image provided in this application is a document image with graffiti covering.
[0059] Figure 4-1 The second image corresponding to the un-graffiti-covered document image provided in the embodiments of this application is a dilated image;
[0060] Figure 4-2 The image is a second image corresponding to the un-graffiti-covered document image provided in the embodiments of this application, after dilation and erosion processing;
[0061] Figure 4-3 The image corresponding to the un-graffiti-covered document image provided in the embodiments of this application is an image after dilation, erosion and dilation processing;
[0062] Figure 4-4 The image provided in this application is a second image corresponding to a document image with graffiti covering, after being dilated.
[0063] Figure 4-5 The image provided in this application embodiment is a second image corresponding to a document image with graffiti covering, after dilation and erosion processing;
[0064] Figure 4-6 The image provided in this application embodiment is a second image corresponding to a document image with graffiti covering it, after dilation, erosion, and dilation processing;
[0065] Figure 5 A schematic diagram of the document occlusion area detection device provided in the embodiments of this application;
[0066] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0067] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0068] It should be understood that the following specific examples illustrate the implementation of this application, and those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. This application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments can be combined with each other. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0069] It should be noted that the following description covers various aspects of embodiments within the scope of the appended claims. It will be apparent that the aspects described herein can be embodied in a wide variety of forms, and any particular structure and / or function described herein is merely illustrative. Based on this application, those skilled in the art will understand that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects set forth herein can be used to implement the device and / or practice the method. Additionally, this device and / or method can be implemented using structures and / or functionalities other than one or more of the aspects set forth herein.
[0070] It should also be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this application. The drawings only show the components related to this application and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0071] Furthermore, specific details are provided in the following description to facilitate a thorough understanding of the examples. However, those skilled in the art will understand that the described aspects can be practiced without these specific details.
[0072] This application provides a method for detecting document occlusion areas. (Refer to...) Figure 1 The diagram shown is a flowchart illustrating the document occlusion region detection method provided in this application embodiment. This method can be executed by an electronic device, which can be implemented in software and / or hardware. The method includes steps S1-S4:
[0073] S1. Perform image preprocessing and morphological processing on the document image to be detected to obtain the first image.
[0074] In this embodiment, after obtaining the image of the document to be detected, image preprocessing is performed to simplify the image data and improve the efficiency of subsequent processing; then morphological processing is performed to reduce noise and compensate for defects, making the detection results of the occluded areas in the image more accurate.
[0075] The image preprocessing and morphological processing of the document image to be detected are performed to obtain a first image, including the following steps A11-A14:
[0076] A11. Obtain the initial image corresponding to the document image to be detected;
[0077] The process of obtaining the initial image corresponding to the document image to be detected includes the following steps B11-B13:
[0078] B11. Read the binary image data of the document image to be detected;
[0079] In this embodiment, based on the file extension information of the document image file to be detected, common image types are adapted. Images in "jpg", "jpeg", "png", "tif", "tiff", "bmp", and "webp" formats are read directly; for "gif" format images, a frame is extracted and then read; for wbmp format images, they are converted into common image formats for processing, and the images are read in binary form, with the image width and height data in the binary data.
[0080] B12. Determine the width and height of the document image to be detected from the image data;
[0081] The process of determining the width W of the document image to be detected includes: starting from the 3rd byte A of the binary image data, if the high bit is 1, it means it is not the last bit. At this time, take A&0111 1111 to get B, shift B left by 7 bits to get D, continue to traverse the next byte C, calculate C&01110 1111 to get E, calculate D|E to get F. If the first value with the high bit is 1 is encountered, the obtained F is the binary data corresponding to the width.
[0082] Using the same method, the height H of the document image to be detected can be calculated by traversing the next byte.
[0083] B13. Determine the initial image corresponding to the document image to be detected based on the width and height.
[0084] After obtaining the width W and height H, the image data is converted into a matrix of size (H, W). Then, the 1s in the matrix are replaced with 255 to obtain the initial image corresponding to the document image to be detected.
[0085] like Figure 2-1 The image shown is the initial image corresponding to the un-graffiti-covered document image provided in the embodiments of this application.
[0086] like Figure 2-2 As shown, this is the initial image corresponding to the graffiti-covered document image provided in an embodiment of this application.
[0087] A12. Perform grayscale processing on the initial image to obtain a grayscale image;
[0088] In this embodiment, the initial image corresponding to the document image to be detected is converted into a grayscale image using cv2.cvtColor.
[0089] like Figure 2-3 The image shown is a grayscale image corresponding to the un-graffiti-covered document image provided in this application embodiment.
[0090] like Figure 2-4 As shown, this is a grayscale image corresponding to a document image with graffiti covering provided in an embodiment of this application.
[0091] A13. Perform binarization processing on the grayscale image to obtain a binary image;
[0092] In this embodiment, the grayscale image corresponding to the document image to be detected is converted into a binary image using cv2.threshold. In other embodiments, other methods can also be used for grayscale and binarization processing.
[0093] like Figure 2-5 As shown, this is a binary image corresponding to the document image without graffiti cover provided in the embodiment of this application.
[0094] like Figure 2-6 As shown, this is a binary image corresponding to a document image covered with graffiti, provided in an embodiment of this application.
[0095] A14. Perform dilation processing on the binary image to obtain the first image.
[0096] In this embodiment, a 4x4 structuring element is used to perform morphological processing on the binary image. The structuring element is a matrix consisting only of 0s and 1s, and can be set to different shapes as needed, such as rectangles, ellipses, or crosses.
[0097] The structuring element is slid across the binary image sequentially from left to right and top to bottom for convolution calculation. If there is white space within the bounding box, all colors within the box are converted to white. Thus, for images of documents with black text on white paper, noise can be eliminated, and most of the scattered text can also be removed.
[0098] like Figure 2-7 As shown, this is the first image after inflation corresponding to the document image without graffiti cover provided in the embodiment of this application.
[0099] like Figure 2-8 As shown, this is the first image after inflation corresponding to the graffiti-covered document image provided in an embodiment of this application.
[0100] S2. Perform a first occlusion region detection on the first image to obtain one or more first candidate regions, and obtain a second image based on the first candidate regions.
[0101] This step is used to initially filter candidate occlusion regions from the first image.
[0102] The step of performing a first occlusion region detection on the first image to obtain one or more first candidate regions, and obtaining a second image based on the first candidate regions, includes the following steps C11-C14:
[0103] C11. Set the sliding window and step size;
[0104] In this embodiment, the size of the sliding window can be set to 10*10, and the step size can be set to 10.
[0105] C12. Slide the sliding window in the first image according to the step size to obtain multiple initial regions;
[0106] Starting from the first pixel of the first image, the sliding window is moved across the first image in a left-to-right, top-to-bottom order, according to its step size, to obtain multiple initial regions.
[0107] C13. Determine whether each initial area is covered by graffiti;
[0108] The determination of whether each initial area is covered by graffiti includes the following steps D11-D13:
[0109] D11. Calculate the percentage of black pixels in each initial region;
[0110] For example, if the sliding window is 10*10 in size, then the total number of pixels in each initial region is 100. If there are 15 black pixels in initial region 1, then the proportion of black pixels in initial region 1 is 0.15.
[0111] D12. Determine that the initial area with a proportion less than the first threshold is an area without graffiti obscuring the area.
[0112] If the first threshold is 0.3, then the initial region 1 is the region without graffiti obscuring the area.
[0113] In a document image without graffiti, each character exists independently without overlap. After dilation processing, the white pixels are expanded, which eliminates most of the text. At this point, only a small amount of discretized text noise remains, resulting in a smaller proportion of black pixels in each initial region.
[0114] D13. Determine that the initial area with a proportion greater than or equal to the first threshold is an area covered by graffiti.
[0115] If graffiti exists, there will be a large number of consecutive black pixels in one or more initial regions, and the proportion of black pixels in the region is greater than or equal to the first threshold.
[0116] C14. Based on the judgment result, perform noise reduction processing on the first image to obtain the second image.
[0117] The step of performing denoising processing on the first image based on the judgment result to obtain the second image includes the following steps E11-E12:
[0118] E11. The area determined to be covered by graffiti is taken as the first candidate area, and the pixel values in the first candidate area are kept unchanged.
[0119] E12. Set the pixel values in the areas determined to be uncovered by graffiti to the pixel values corresponding to white to obtain the second image.
[0120] like Figure 3-1 As shown, this is the second image corresponding to the un-graffiti-covered document image provided in the embodiments of this application.
[0121] like Figure 3-2 As shown, this is the second image corresponding to the graffiti-covered document image provided in an embodiment of this application.
[0122] S3. Perform second occlusion region detection on the second image to obtain one or more second candidate regions.
[0123] After step S2, most of the text regions in the second image are eliminated. However, noise still exists for characters with thick and large fonts, requiring further detection of occluded areas.
[0124] The second occlusion region detection is performed on the second image to obtain one or more second candidate regions, including the following steps F11-F12:
[0125] F11. Perform dilation, erosion, and dilation processing on the second image sequentially to obtain the third image;
[0126] Dilatation of the second image: If the structuring element has the same pixel value as at least one pixel in the corresponding region of the image, the pixel value of that pixel is retained. This can remove some black pixels. However, sometimes this step cannot completely remove black pixels. Also, for small and narrow document images, some pixels will be lost in this process.
[0127] Erosion is applied to the image, causing the structuring element to move throughout the image and onto each pixel. Only when the structuring element's pixel value is equal to the corresponding pixel value in the image is the value of that pixel retained. After this step, black pixels are filled and enlarged. This can compensate for the loss of black pixels in small, narrow, and obscured document images.
[0128] The structuring element in this step can be a 5x5 matrix.
[0129] Then, the dilation process is repeated alternately to remove the black pixels that are not actually covered by the graffiti, resulting in the third image.
[0130] F12. Determine one or more second candidate regions from the third image.
[0131] Traverse the third image from left to right and from top to bottom, selecting the regions with the minimum and maximum x and y coordinates of black pixels to obtain one or more second candidate regions.
[0132] This embodiment does not directly perform multiple dilations on the image. Instead, it uses an alternating dilation and erosion method to obtain the target area. This is to prevent the omission of small, narrow, and obscured graffiti parts in the image.
[0133] like Figure 4-1 As shown, this is the second image corresponding to the un-graffiti-covered document image provided in this application embodiment, after dilation processing.
[0134] like Figure 4-2 The image shown is a second image corresponding to the un-graffiti-covered document image provided in this application embodiment, after dilation and erosion processing.
[0135] like Figure 4-3 As shown, this is the second image corresponding to the un-graffiti-covered document image provided in the embodiment of this application, after dilation, erosion, and dilation processing.
[0136] like Figure 4-4 The image shown is a second image corresponding to a document image covered by graffiti, after dilation processing, provided in an embodiment of this application.
[0137] like Figure 4-5 The image shown is a second image corresponding to a graffiti-covered document image provided in this application embodiment, after dilation and erosion processing.
[0138] like Figure 4-6 As shown, this is the second image corresponding to the graffiti-covered document image provided in the embodiment of this application, after dilation, erosion, and dilation processing.
[0139] S4. Perform third occlusion region detection on the second candidate region to obtain the target occlusion region corresponding to the document image to be detected.
[0140] This step is used to determine the target occlusion area from the candidate occlusion areas.
[0141] The third occlusion region detection is performed on the second candidate region to obtain the target occlusion region corresponding to the document image to be detected, including the following steps G11-G13:
[0142] G11, Count the number of black pixels in each second candidate region;
[0143] G12. Select the second candidate region with a number of black pixels greater than or equal to the second threshold as the third candidate region.
[0144] G13. The third candidate region whose width and height are both greater than or equal to the third threshold is taken as the target occlusion region.
[0145] In this embodiment, the second threshold can be 1000, and the third threshold can be 20.
[0146] The document occlusion region detection method, apparatus, electronic device, and storage medium proposed in this application first perform image preprocessing and morphological processing on the document image to be detected to obtain a first image; then, perform a first occlusion region detection on the first image to obtain one or more first candidate regions, and obtain a second image based on the first candidate regions; then, perform a second occlusion region detection on the second image to obtain one or more second candidate regions; finally, perform a third occlusion region detection on the second candidate regions to obtain the target occlusion region corresponding to the document image to be detected. This application does not require the creation of image samples or high computing power to train the model, and can quickly and accurately detect document occlusion regions.
[0147] like Figure 5 As shown, a document occlusion area detection device 50 is provided in an embodiment of this application. The device 50 includes:
[0148] Image processing module 51 is used to perform image preprocessing and morphological processing on the document image to be detected to obtain a first image.
[0149] The image preprocessing and morphological processing of the document image to be detected are performed to obtain a first image, including the following steps A21-A24:
[0150] A21. Obtain the initial image corresponding to the document image to be detected;
[0151] A22. Perform grayscale processing on the initial image to obtain a grayscale image;
[0152] A23. Perform binarization processing on the grayscale image to obtain a binary image;
[0153] A24. Perform dilation processing on the binary image to obtain the first image.
[0154] The process of obtaining the initial image corresponding to the document image to be detected includes the following steps B21-B23:
[0155] B21. Read the binary image data of the document image to be detected;
[0156] B22. Determine the width and height of the document image to be detected from the image data;
[0157] B23. Determine the initial image corresponding to the document image to be detected based on the width and height.
[0158] The first detection module 51 is used to perform a first occlusion region detection on the first image to obtain one or more first candidate regions, and to obtain a second image based on the first candidate regions.
[0159] The step of performing a first occlusion region detection on the first image to obtain one or more first candidate regions, and obtaining a second image based on the first candidate regions, includes the following steps C21-C24:
[0160] C21. Set the sliding window and step size;
[0161] C22. Slide the sliding window in the first image according to the step size to obtain multiple initial regions;
[0162] C23. Determine whether each initial area is covered by graffiti;
[0163] C24. Based on the judgment result, perform noise reduction processing on the first image to obtain the second image.
[0164] The determination of whether each initial area is covered by graffiti includes the following steps D21-D23:
[0165] D21. Calculate the percentage of black pixels in each initial region;
[0166] D22. Determine that the initial area with a proportion less than the first threshold is an area without graffiti obscuring the area.
[0167] D23. Determine that the initial area with a proportion greater than or equal to the first threshold is an area covered by graffiti.
[0168] The step of performing denoising processing on the first image based on the judgment result to obtain the second image includes the following steps E21-E22:
[0169] E21. The area determined to be covered by graffiti is taken as the first candidate area, and the pixel values in the first candidate area are kept unchanged.
[0170] E22. Set the pixel values in the areas determined to be uncovered by graffiti to the pixel values corresponding to white to obtain the second image.
[0171] The second detection module 53 is used to perform second occlusion region detection on the second image to obtain one or more second candidate regions.
[0172] The second occlusion region detection is performed on the second image to obtain one or more second candidate regions, including the following steps F21-F22:
[0173] F21. Perform dilation, erosion, and dilation processing on the second image sequentially to obtain the third image;
[0174] F22. Determine one or more second candidate regions from the third image.
[0175] The third detection module 54 is used to perform a third occlusion region detection on the second candidate region to obtain the target occlusion region corresponding to the document image to be detected.
[0176] The third occlusion region detection is performed on the second candidate region to obtain the target occlusion region corresponding to the document image to be detected, including the following steps G21-G23:
[0177] G21. Count the number of black pixels in each second candidate region;
[0178] G22. Select the second candidate region with a number of black pixels greater than or equal to the second threshold as the third candidate region.
[0179] G23. The third candidate region whose width and height are both greater than or equal to the third threshold is taken as the target occlusion region.
[0180] like Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. It illustrates a structural schematic diagram suitable for implementing the electronic device in the embodiment of this application. Figure 6The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0181] like Figure 6 As shown, an electronic device may include a processing unit (such as a central processing unit, graphics processing unit, etc.) that can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) or a program loaded from a storage device into random access memory (RAM). The RAM also stores various programs and data required for the operation of the electronic device. The processing unit, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.
[0182] Typically, the following devices can be connected to the I / O interface: input devices, such as sensors or visual information acquisition devices; output devices, such as displays; storage devices, such as magnetic tapes or hard drives; and communication devices. Communication devices allow electronic devices to communicate wirelessly or wiredly with other devices (such as edge computing devices) to exchange data. Although Figure 6 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.
[0183] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, all or part of the steps of the document occlusion region detection method of the embodiments of this application are performed.
[0184] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.
[0185] A computer-readable storage medium according to embodiments of this application stores non-transitory computer-readable instructions. When these non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the document occlusion region detection methods described in the foregoing embodiments of this application are performed.
[0186] The aforementioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or portable hard drive), media with built-in rewritable non-volatile memory (e.g., memory card), and media with built-in ROM (e.g., ROM cartridge).
[0187] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.
[0188] The basic principles of this application have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this application are merely examples and not limitations, and should not be considered as essential features of each embodiment of this application. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the application to the necessity of employing the aforementioned specific details for implementation.
[0189] In this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The block diagrams of devices, apparatuses, devices, and systems involved in this application are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as "comprising," "including," "having," etc., are open-ended terms meaning "including but not limited to," and are used interchangeably with them. The terms "or" and "and" as used herein refer to the terms "and / or," and are used interchangeably with them unless the context clearly indicates otherwise. The term "such as" as used herein refers to the phrase "such as but not limited to," and is used interchangeably with it.
[0190] Additionally, as used herein, the “or” used in a list of items beginning with “at least one” indicates a separate list, such that a list of, for example, “at least one of A, B, or C” means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word “exemplary” does not imply that the described example is preferred or better than other examples.
[0191] It should also be noted that in the system and method of this application, the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered as equivalent solutions of this application.
[0192] Various changes, substitutions, and modifications can be made to the technology described herein without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims is not limited to the specific aspects of the processes, machines, manufactures, events, means, methods, and actions described above. Currently existing or later-developed processes, machines, manufactures, events, means, methods, or actions that perform substantially the same function or achieve substantially the same result as the corresponding aspects described herein can be utilized. Therefore, the appended claims include such processes, machines, manufactures, events, means, methods, or actions within their scope.
[0193] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of this application. Therefore, this application is not intended to be limited to the aspects shown herein, but rather to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0194] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this application to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.
Claims
1. A method for detecting document occlusion areas, characterized in that, The method includes: The process of performing image preprocessing and morphological processing on the document image to be detected to obtain a first image specifically includes: obtaining an initial image corresponding to the document image to be detected; performing grayscale processing on the initial image to obtain a grayscale image; performing binarization processing on the grayscale image to obtain a binary image; and performing dilation processing on the binary image to obtain the first image. Perform a first occlusion region detection on the first image to obtain one or more first candidate regions, and obtain a second image based on the first candidate regions; Perform a second occlusion region detection on the second image to obtain one or more second candidate regions. Specifically, this includes: performing dilation, erosion, and dilation processing on the second image in sequence to obtain a third image; determining one or more second candidate regions from the third image; further, traversing the third image from left to right and from top to bottom, selecting the regions with the minimum x and y coordinates of black pixels and the maximum x and y coordinates of black pixels to obtain one or more second candidate regions. Perform third occlusion region detection on the second candidate region to obtain the target occlusion region corresponding to the document image to be detected. Specifically, this includes: counting the number of black pixels in each second candidate region; taking the second candidate region with the number of black pixels greater than or equal to a second threshold as the third candidate region; and taking the third candidate region with both width and height greater than or equal to the third threshold as the target occlusion region.
2. The method as described in claim 1, characterized in that, The step of performing a first occlusion region detection on the first image to obtain one or more first candidate regions, and obtaining a second image based on the first candidate regions, includes: Set the sliding window and step size; The sliding window is slid across the first image according to the step size to obtain multiple initial regions; Determine whether each initial area is covered by graffiti; Based on the judgment result, the first image is subjected to denoising processing to obtain the second image.
3. The method as described in claim 2, characterized in that, The step of performing denoising processing on the first image based on the judgment result to obtain the second image includes: The area identified as being covered by graffiti is selected as the first candidate area, and the pixel values in the first candidate area are kept unchanged. The pixel values in the areas determined to be uncovered by graffiti are set to the pixel values corresponding to white, thus obtaining the second image.
4. The method as described in claim 2, characterized in that, The determination of whether each initial area is covered by graffiti includes: Calculate the percentage of black pixels in each initial region; The initial area with a proportion less than the first threshold is determined to be an area without graffiti obscuring the area. The initial area with a proportion greater than or equal to the first threshold is determined to be an area covered by graffiti.
5. The method as described in claim 1, characterized in that, The step of obtaining the initial image corresponding to the document image to be detected includes: Read the binary form image data of the document image to be detected; The width and height of the document image to be detected are determined from the image data; The initial image corresponding to the document image to be detected is determined based on the width and height.
6. A document occlusion area detection device, characterized in that, The device includes: The image processing module is used to perform image preprocessing and morphological processing on the document image to be detected to obtain a first image. Specifically, it includes: obtaining an initial image corresponding to the document image to be detected; performing grayscale processing on the initial image to obtain a grayscale image; performing binarization processing on the grayscale image to obtain a binary image; and performing dilation processing on the binary image to obtain the first image. The first detection module is used to perform a first occlusion region detection on the first image to obtain one or more first candidate regions, and to obtain a second image based on the first candidate regions, and to preliminarily screen candidate occlusion regions from the first image. The second detection module is used to perform a second occlusion region detection on the second image to obtain one or more second candidate regions. Specifically, it includes: performing dilation, erosion and dilation processing on the second image in sequence to obtain a third image; determining one or more second candidate regions from the third image; further, traversing the third image from left to right and from top to bottom, selecting the regions with the minimum x and y coordinates of black pixels and the maximum x and y coordinates of black pixels to obtain one or more second candidate regions. The third detection module is used to perform third occlusion region detection on the second candidate region to obtain the target occlusion region corresponding to the document image to be detected. Specifically, it includes: counting the number of black pixels in each second candidate region; taking the second candidate region with the number of black pixels greater than or equal to the second threshold as the third candidate region; and taking the third candidate region with both width and height greater than or equal to the third threshold as the target occlusion region.
7. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a document occlusion region detection program that can be executed by the at least one processor, the document occlusion region detection program being executed by the at least one processor to enable the at least one processor to perform the steps of the document occlusion region detection method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a document occlusion region detection program, which, when executed by a processor, implements the steps of the document occlusion region detection method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Image processing method and device, processor, electronic equipment and storage medium
CN113222973A
Face shielding detection method and device, model training method and device and electronic equipment
CN114399813A