Image processing method and apparatus

By determining the binarized image, filling the edge region, and generating the mask image in image processing, the problem of cropping useful content during the black border removal process in existing technologies is solved, thereby improving the image processing accuracy and image quality of downstream services.

CN116012397BActive Publication Date: 2025-11-04BEIJING FLYING ELEPHANT PLANET TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310120040.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-13
Publication Date
2025-11-04
Estimated Expiration
2043-02-13

AI Technical Summary

Technical Problem

Existing technologies tend to crop out useful content during the image black border removal process, affecting the image quality of downstream applications.

Method used

By determining the binarized image of the image to be processed, filling the edge regions, performing dilation processing, generating a mask image, and using the pixel distribution information of the mask image for segmentation, useful features are avoided being cropped.

Benefits of technology

This achieves the goal of not cropping useful features during image processing, improving image processing accuracy and ensuring the image quality used in downstream applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116012397B_ABST
    Figure CN116012397B_ABST
Patent Text Reader

Abstract

The present specification provides an image processing method and device, wherein the image processing method comprises: determining a binary image corresponding to a to-be-processed image, filling an edge region in the binary image, and obtaining a first image containing a filled region; performing dilation processing on the filled region in the first image to obtain a second image, and determining an object region in the second image; performing dilation processing on the object region in the second image to obtain a third image, and generating a mask image based on the third image and the second image; performing segmentation processing on the to-be-processed image according to distribution information of pixel points in the mask image, and obtaining a target image according to a segmentation processing result.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present specification relates to the technical field of image processing, and in particular to an image processing method and device. BACKGROUND

[0002] With the development of Internet technology, image processing technology is applied in more and more scenarios, especially in the image optimization scenario, the image processing effect determines the accuracy when finally processing at the business level. In the prior art, when processing an image, in order to be able to use an image closer to the original image content for downstream business in subsequent use, most of them will process the image multiple times, such as image trapezoidal correction, image binarization and image black border removal processing, etc. In this process, the removal of the black border of the image determines the quality of the image that can be used by the downstream business. In the prior art, the black border removal processing is mostly achieved by cropping after positioning the region, but this removal method may also crop useful content in the image, thereby affecting the use of the downstream business, so there is an urgent need for an effective solution to solve the above problems. SUMMARY

[0003] Therefore, the embodiments of the present specification provide an image processing method. The present specification also relates to an image processing device, a computing device, and a computer readable storage medium to solve the technical defects existing in the prior art.

[0004] According to a first aspect of the embodiments of the present specification, an image processing method is provided, comprising:

[0005] determining a binarized image corresponding to the to-be-processed image, and filling an edge region in the binarized image to obtain a first image containing a filled region;

[0006] performing dilation processing on the filled region in the first image to obtain a second image, and determining an object region in the second image;

[0007] performing dilation processing on the object region in the second image to obtain a third image, and generating a mask image based on the third image and the second image;

[0008] segmenting the to-be-processed image according to the distribution information of the pixel points in the mask image, and obtaining a target image according to the segmentation result.

[0009] Optionally, the determination of the binarized image corresponding to the to-be-processed image comprises:

[0010] obtaining the to-be-processed image;

[0011] performing preprocessing on the to-be-processed image to obtain an intermediate image;

[0012] convert the intermediate image into a gray-scale image, and binarize the gray-scale image to obtain the binarized image corresponding to the to-be-processed image.

[0013] Optionally, the filling of the edge region in the binarized image to obtain a first image containing a filled region comprises:

[0014] selecting, in the binarized image, an image region outside a target object as the edge region;

[0015] adjusting pixel values of pixel points in the edge region, and obtaining the first image containing the filled region according to an adjustment result.

[0016] Optionally, the dilation processing of the filled region in the first image to obtain a second image comprises:

[0017] determining a region growth degree parameter and a region growth number parameter according to a preset dilation strategy;

[0018] creating a region dilation task corresponding to the filled region based on the region growth degree parameter and the region growth number parameter;

[0019] performing the region dilation task to dilate the filled region in the first image, and obtaining the second image.

[0020] Optionally, the determination of the object region in the second image comprises:

[0021] performing edge detection processing on the second image by using a preset edge detection algorithm;

[0022] determining at least one element region corresponding to the second image according to an edge detection processing result;

[0023] selecting a target element region in the at least one element region as the object region.

[0024] Optionally, the generation of a mask image based on the third image and the second image comprises:

[0025] comparing the third image and the second image to determine an object edge region according to a comparison result;

[0026] generating the mask image based on the object edge region.

[0027] Optionally, the generation of the mask image based on the object edge region comprises:

[0028] calculating connected components corresponding to the object edge region, and determining a target object edge according to a largest connected component.

[0029] The first image region within the target object edge and the second image region outside the target object edge are respectively adjusted, and the mask image is generated according to the adjustment result.

[0030] Optionally, the first image region within the target object edge and the second image region outside the target object edge are respectively adjusted, and the mask image is generated according to the adjustment result, including:

[0031] The image region within the target object edge is selected as the first image region, and the image region outside the target object edge is selected as the second image region.

[0032] The pixel points in the first image region are filled according to a first reference pixel value, and the pixel points in the second image region are filled according to a second reference pixel value.

[0033] The mask image is generated according to the pixel filling result.

[0034] Optionally, the mask image is adjusted according to the distribution information of the pixel points in the mask image, and a target image is obtained according to the segmentation processing result.

[0035] The mask image is adjusted according to the image attribute information of the to-be-processed image, and a target mask image is obtained.

[0036] According to the distribution information of the pixel points in the target mask image, image segmentation information corresponding to the to-be-processed image is determined.

[0037] The to-be-processed image is segmented according to the image segmentation information, and the target image is obtained according to the segmentation processing result.

[0038] According to a second aspect of an embodiment of the present specification, an image processing device is provided, including:

[0039] The image determining module is configured to determine a binary image corresponding to a to-be-processed image, and fill an edge region in the binary image to obtain a first image containing a filled region.

[0040] The region determining module is configured to perform dilation processing on the filled region in the first image to obtain a second image, and determine an object region in the second image.

[0041] The image generating module is configured to perform dilation processing on the object region in the second image to obtain a third image, and generate a mask image based on the third image and the second image.

[0042] The segmentation processing module is configured to perform segmentation processing on the to-be-processed image according to distribution information of pixel points in the mask image, and obtain a target image according to a segmentation processing result.

[0043] According to a third aspect of an embodiment of the present specification, another image processing method is provided, including:

[0044] A binary image corresponding to a to-be-processed test paper image is determined, and an edge region of the test paper in the binary image is filled to obtain a first test paper image containing a filled region;

[0045] The filled region in the first test paper image is dilated to obtain a second test paper image, and a test paper region is determined in the second test paper image;

[0046] The test paper region in the second test paper image is dilated to obtain a third test paper image, and a test paper mask image is generated based on the third test paper image and the second test paper image;

[0047] The to-be-processed test paper image is segmented according to distribution information of pixel points in the test paper mask image, and a target test paper image is obtained according to a segmentation processing result.

[0048] According to a fourth aspect of an embodiment of the present specification, another image processing device is provided, including:

[0049] The determination module is configured to determine a binary image corresponding to a to-be-processed test paper image, and fill an edge region of the test paper in the binary image to obtain a first test paper image containing a filled region;

[0050] The determination module is configured to determine a binary image corresponding to a to-be-processed test paper image, and fill an edge region of the test paper in the binary image to obtain a first test paper image containing a filled region;

[0051] The generation module is configured to dilate the test paper region in the second test paper image to obtain a third test paper image, and generate a test paper mask image based on the third test paper image and the second test paper image;

[0052] The segmentation processing module is configured to perform segmentation processing on the to-be-processed image according to distribution information of pixel points in the mask image, and obtain a target image according to a segmentation processing result.

[0053] According to a fifth aspect of an embodiment of the present specification, a computing device is provided, including:

[0054] A memory and a processor;

[0055] The memory is configured to store computer-executable instructions, and the processor is configured to implement the steps of the image processing method when executing the computer-executable instructions.

[0056] According to a sixth aspect of an embodiment of the present specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and the instructions implement the steps of the image processing method when executed by a processor.

[0057] The image processing method provided by the embodiment can improve the image processing accuracy and does not affect the use of downstream services. The binary image corresponding to the image to be processed can be determined first, and subsequent processing can be performed on the basis of the binary image, so that the interference of redundant features in the image can be reduced. After obtaining the binary image, the edge region in the binary image can be filled first to obtain a first image containing a filled region. Then, the filled region in the first image is dilated to obtain a second image, and an object region is determined in the second image. Then, the object region in the second image is dilated to obtain a third image. At this time, the edge of the object in the image can be located according to the third image and the second image obtained by dilating. Then, a mask image is constructed on the basis of this, and the target image is segmented by using the distribution information of the pixel points in the mask image, so that the region outside the object in the image to be processed can be cut, and the content of the region corresponding to the object will not be affected. In this way, the target image is obtained. In the processing from the image to be processed to the target image, the content in the image will not be modified, and the useful features will not be cropped, so that the downstream service can use the target image with higher quality. BRIEF DESCRIPTION OF DRAWINGS

[0058] Figure 1 FIG. 1 is a schematic diagram of an image processing method provided by an embodiment of the present specification;

[0059] Figure 2 FIG. 2 is a flowchart of an image processing method provided by an embodiment of the present specification;

[0060] Figure 3 FIG. 3 is a schematic diagram of a test paper image provided by an embodiment of the present specification;

[0061] Figure 4 FIG. 4 is a schematic diagram of another test paper image provided by an embodiment of the present specification;

[0062] Figure 5 FIG. 5 is a processing flowchart of an image processing method provided by an embodiment of the present specification;

[0063] Figure 6 FIG. 6 is a structural schematic diagram of an image processing device provided by an embodiment of the present specification;

[0064] Figure 7 is a flowchart of another image processing method provided by an embodiment of the present specification;

[0065] Figure 8 is a structural schematic diagram of another image processing apparatus provided by an embodiment of the present specification;

[0066] Figure 9 is a structural block diagram of a computing device provided by an embodiment of the present specification. DETAILED DESCRIPTION

[0067] In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present specification. However, the present specification can be practiced without the specific details, other than in the examples provided herein. In other instances, well-known methods, procedures, components, and circuits have not been described in detail since not to unnecessarily obscure aspects of the present specification.

[0068] The terminology used in one or more embodiments of the present specification is for the purpose of describing particular embodiments only and is not intended to be limiting of one or more embodiments of the present specification. As used in one or more embodiments of the present specification and the accompanying claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in one or more embodiments of the present specification, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0069] It will be understood that, although the terms first, second, etc. can be used herein to describe various information, these terms are not intended to denote a temporal or chronological order. Rather, these terms are used solely to distinguish one from another only. For example, without departing from the scope of one or more embodiments of the present specification, first can be termed second and, similarly, second can be termed first. Depending on the context, the word "if' as used herein can be interpreted to mean "when" or "in response to determining."

[0070] In the present specification, an image processing method is provided, and the present specification also relates to an image processing apparatus, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.

[0071] In practical applications, image black border removal processing is applied in different business scenarios, such as homework correction scenarios, contract backup scenarios, and certificate upload scenarios. After taking a picture of a target object, black border removal processing is needed to avoid the black border in the recognized image from causing downstream business to fail to proceed normally. For example, in a homework correction scenario, after a student takes a picture of a test paper and uploads it to a homework correction program, the test paper region needs to be positioned based on the identification information in the test paper, and then black border removal is performed according to the positioned region, so that the final test paper image does not contain black lines. However, in this process, if the test paper does not contain identification information, black border removal cannot be performed. Meanwhile, when the test paper image is cropped, if the position of the test paper in the image is not symmetrical due to the shooting angle, the answer content on the test paper may be cut off during cropping, thereby affecting the accuracy of the test paper review. Therefore, an effective solution is urgently needed to solve the above problems.

[0072] Referring to the schematic diagram shown in Figure 1 To improve image processing accuracy and not affect downstream business use, the image processing method provided by the embodiment can first determine a binary image corresponding to the to-be-processed image, so that subsequent processing can be performed on the basis of the binary image, and the interference of redundant features in the image can be reduced. After obtaining the binary image, the edge region in the binary image can be filled to obtain a first image containing a filled region. Then, the filled region in the first image is dilated to obtain a second image, and an object region is determined in the second image. The object region in the second image is then dilated to obtain a third image. At this time, the edge of the object in the image can be located according to the third image and the second image obtained by dilation. Then, a mask image is constructed on this basis, and the distribution information of the pixel points in the mask image is used to segment the to-be-processed image, so that the region outside the object in the to-be-processed image can be cut, and the content of the object region will not be affected, so that a target image is obtained. In the processing process from the to-be-processed image to the target image, the content in the image will not be modified, and the useful features will not be cropped, so that the downstream business can use a target image with higher quality.

[0073] Figure 2 A flowchart of an image processing method according to an embodiment of the present specification is shown, which specifically includes the following steps:

[0074] In step S202, a binary image corresponding to the to-be-processed image is determined, and the edge region in the binary image is filled to obtain a first image containing a filled region.

[0075] The image processing method provided in this embodiment can be applied to a test paper marking scene. In this scene, the test paper image can be segmented by the image processing method provided in this embodiment, so that the test paper content in the test paper image can be avoided from being cut. The image processing method provided in this embodiment can also be applied to a contract text data conversion scene. In this scene, the contract content can be avoided from being cut when the contract text is converted into data. The image processing method provided in this embodiment can also be applied to a certificate identification scene. In this scene, the certificate content can be avoided from being cut when the certificate is identified. This embodiment takes the test paper marking scene as an example to describe the image processing method. The same or similar contents in other scenes can be referred to the corresponding description in this embodiment, and will not be described in detail here.

[0076] Specifically, the to-be-processed image specifically refers to an image captured by a user for a target object. The image needs to be segmented before it can be used for downstream business, such as a test paper image, a contract image, or a certificate image. Correspondingly, the binary image specifically refers to an image obtained by performing binary processing on the to-be-processed image. The image can be used to process the image before segmentation, so as to avoid the influence of redundant features in the image on the segmentation accuracy. Correspondingly, the edge region specifically refers to a region in the binary image that needs to be filled according to a set strategy. The region is the photographed region before the target object. For example, the to-be-processed image is a test paper image. The image contains not only the test paper content but also the desktop content on which the test paper is placed when the image is captured. In the corresponding binary image, the edge region is the region corresponding to the desktop content in the binary image. By filling the region and performing subsequent processing, the influence on the segmentation accuracy can be avoided. Correspondingly, the first image specifically refers to an image obtained by filling the edge region.

[0077] Based on this, after obtaining the to-be-processed image, in order to accurately segment the to-be-processed image and avoid cutting the object features in the image, a binary image corresponding to the to-be-processed image can be generated first. Then, the non-object region in the binary image is determined as the edge region. The edge region is filled based on this, so that the first image containing the filled region is obtained. This facilitates subsequent segmentation processing based on the first image, so as to ensure the segmentation accuracy.

[0078] Further, in the process of determining the binary image corresponding to the to-be-processed image, in order to ensure that the binary image conversion is more accurate, the image can be first processed in grayscale and then binarized. In this embodiment, the specific implementation is as follows:

[0079] The to-be-processed image is obtained. The to-be-processed image is preprocessed to obtain an intermediate image. The intermediate image is converted into a grayscale image, and the grayscale image is binarized to obtain the binary image corresponding to the to-be-processed image.

[0080] Specifically, the preprocessing specifically refers to the processing of denoising and size adjustment of the to-be-processed image, which is used to realize the adjustment of the to-be-processed image to meet the subsequent use of the intermediate image; correspondingly, the gray image specifically refers to the image obtained after the gray processing of the intermediate image; correspondingly, the binary image specifically refers to the image obtained after the binary processing of the to-be-processed image.

[0081] Based on this, after obtaining the to-be-processed image, in order to be able to accurately segment the to-be-processed image later, a mask image with higher precision needs to be created before segmentation, and in order to ensure the creation precision of the mask image, the to-be-processed image can be preprocessed first, realizing the scale adjustment and denoising of the to-be-processed image to obtain an intermediate image; At this time, the intermediate image is converted into a gray image, and the gray image is binary processed to obtain a binary image corresponding to the to-be-processed image, which is convenient for subsequent use.

[0082] In actual application, in order to accelerate the image processing speed and avoid the influence of shooting light and other problems, the to-be-processed image can be preprocessed first, that is, the to-be-processed image is scaled and denoised, the to-be-processed image is first adjusted to a set size image, and then the set size image is denoised according to the median filter, so that an intermediate image can be obtained; wherein the value of ksize of the median filter can be set according to actual needs, such as 5.

[0083] After obtaining the intermediate image, the intermediate image can be grayed to obtain a gray image, and then the image is binaryzed to obtain a binary image for subsequent use. The threshold of binaryzation can be set according to actual needs, such as 196.

[0084] For example, user A completes the answer of a math test paper, in order to determine his score, the math test paper can be photographed and the photographed image can be uploaded to the test paper marking program for marking, at this time, the test paper image uploaded by user A will be obtained, as shown in Figure 3 (a).

[0085] Further, in order to accelerate the segmentation speed of the test paper image and avoid the influence of electronic noise caused by shooting, the test paper image can be first processed in size to obtain a test paper image of a set size, and then the image can be denoised by using a median filter with a set ksize, so that an intermediate test paper image can be obtained according to the denoising result.

[0086] Further, in order to avoid the interference of the redundant features in the test paper image and affect the segmentation accuracy, the intermediate test paper image can be further subjected to a grayscale processing, and then subjected to a binarization processing according to the binarization threshold 196, so that the binarization image corresponding to the test paper image can be obtained, to facilitate the segmentation of the test paper content in the test paper image based on the binarization image, and accurately correct the answer content in the test paper.

[0087] In summary, in order to improve the image processing efficiency and avoid the influence of noise points, the image to be processed can be preprocessed first, and then subjected to grayscale and binarization processing, so that subsequent operations can be completed based on the binarization image, thereby ensuring the image segmentation accuracy.

[0088] Further, when filling the edge region, the edge region needs to be accurately identified first and then processed to avoid the influence of the filling content on the objects in the image. In the embodiment, the specific implementation is as follows:

[0089] In the binarization image, an image region outside the target object is selected as the edge region; the pixel values of the pixel points in the edge region are adjusted, and the first image containing the filling region is obtained according to the adjustment result.

[0090] Specifically, the target object specifically refers to an object that needs to be contained after the image to be processed is segmented. For example, if the image to be processed is a test paper image, the target object is a test paper; or if the image to be processed is a contract image, the target object is a contract text; or if the image to be processed is a certificate image, the target image is a certificate.

[0091] Based on this, since the binarization image is obtained based on the image to be processed, the image features contained in the binarization image are the same as the image features contained in the image to be processed. In order to ensure that the region corresponding to the target object in the image to be processed can be accurately segmented, the image region outside the target object needs to be selected as the edge region in the binarization image first; then the pixel values of the pixel points in the edge region are adjusted, so that the image region outside the target object is adjusted, and the image region does not need to be adjusted, so that the first image containing the filling region can be obtained according to the adjustment result, and the inside and outside of the target object region can be accurately distinguished in the first image, to facilitate subsequent use.

[0092] In actual application, when determining the edge region, considering that most users will include the target object in the image when shooting, the upper, lower, left and right four regions of the image can be regarded as the edge region, and then padding is performed on the edge region, so that the pixel value of the pixel point in the padded edge region is 0, that is, black, to facilitate subsequent use of the image for region generation processing. That is, the padded edge region will be used as a seed point for region generation, which can be completed based on the seed point during region generation. The value of padding can be set according to actual needs, such as 5.

[0093] In the above example, after obtaining the binary image corresponding to the test paper image, the upper, lower, left and right four regions of the binary image can be padded with a padding value of 5, so that the pixel points of the regions outside the test paper region in the binary image are set to 0, that is, black, thereby obtaining a first test paper image containing the region corresponding to the seed point for region generation, facilitating subsequent use.

[0094] In summary, by selecting the edge region for padding processing, the region that does not affect the target object can be segmented out, and based on this, region dilation and erosion can be performed to divide the edge of the target object, facilitating subsequent use.

[0095] In step S204, the padded region in the first image is dilated to obtain a second image, and an object region is determined in the second image.

[0096] Specifically, after obtaining the first image containing the padded region, further, in order to locate the edge of the target object in the image and create a mask image for image segmentation based on this, the padded region in the first image can be dilated first to erode the target object region in the first image, and then the target object region is dilated to erode the non-target object region in the image, so that the edge corresponding to the target object can be divided to construct a mask image for use. Therefore, after obtaining the first image containing the padded region, the padded region in the first image can be dilated first, so that a second image is obtained according to the dilation result. At this time, the region corresponding to the target object in the second image is eroded by the padded region. In order to determine the edge corresponding to the target object, the object region corresponding to the target object in the second image can be determined for further processing.

[0097] Specifically, the second image refers to the image obtained after region generation of the padded region in the first image, and the region corresponding to the target object in the image is eroded by the padded region. Correspondingly, the object region specifically refers to the region corresponding to the target object in the second image.

[0098] Further, in the inflation process of the filled area in the image, it is actually a region inflation and erosion process, and in order to be able to distinguish the content inside and outside the edge of the object in the subsequent, the inflation process can be performed according to the set mode, and in the embodiment, the specific implementation mode is as follows:

[0099] According to the preset inflation strategy, the region growth degree parameter and the region growth frequency parameter are determined; based on the region growth degree parameter and the region growth frequency parameter, the region inflation task corresponding to the filled area is created; and the inflation process of the filled area in the first image is performed through the execution of the region inflation task, and the second image is obtained.

[0100] Specifically, the inflation strategy specifically refers to a strategy for recording region growth degree and region growth frequency, different strategies record different parameters, and are used for different degrees of inflation processing of the filled area. Correspondingly, the region growth degree parameter specifically refers to a parameter for controlling the inflation degree of the filled area, such as light growth, moderate growth or severe growth; correspondingly, the region growth frequency specifically refers to a parameter for controlling the inflation frequency of the filled area, which is used to control the region growth frequency; correspondingly, the region inflation task specifically refers to a task of inflation processing of the filled area.

[0101] Based on this, in order to be able to perform different degrees of inflation processing on different filled areas, the region growth degree parameter and the region growth frequency parameter corresponding to the filled area can be determined according to the preset inflation strategy; then based on the region growth degree parameter and the region growth frequency parameter, the region inflation task corresponding to the filled area is created; at this time, the inflation processing of the filled area in the first image can be realized by executing the region inflation task, and the second image meeting the subsequent use requirement is obtained.

[0102] In actual application, after obtaining the first image containing the black seed point region, the region growth can be performed on the black seed point region. In specific implementation, the growth process adopts a morphological inflation algorithm to perform inflation on the black region in the first image, that is, to perform erosion on the white region corresponding to the target object in the first image, so that the morphological erosion operator can be used to perform region growth by eroding the white region corresponding to the target object in the first image, that is: region_grow = erode(page) i Wherein, i represents the growth frequency. And the region growth degree can be set according to the generation frequency. For example, three growth degrees can be set as 'light':3,'middle':4,'high':5; wherein, the front of the colon represents the growth degree, and the rear of the colon is the growth frequency. Light represents light growth, middle represents moderate growth, and high represents severe growth.

[0103] As used in the above example, after obtaining the first test paper image, the region corresponding to the black seed point in the first test paper image can be subjected to region growing, that is, the white region corresponding to the test paper in the first test paper image is subjected to erosion, and the second test paper image shown in (b) of FIG. 10 is obtained according to the region generation result, so that the subsequent determination of the test paper edge can be combined with the second test paper image. Figure 3 As used in the above example, after obtaining the first test paper image, the region corresponding to the black seed point in the first test paper image can be subjected to region growing, that is, the white region corresponding to the test paper in the first test paper image is subjected to erosion, and the second test paper image shown in (b) of FIG. 10 is obtained according to the region generation result, so that the subsequent determination of the test paper edge can be combined with the second test paper image.

[0104] As used in the above example, after obtaining the first test paper image, the region corresponding to the black seed point in the first test paper image can be subjected to region growing, that is, the white region corresponding to the test paper in the first test paper image is subjected to erosion, and the second test paper image shown in (b) of FIG. 10 is obtained according to the region generation result, so that the subsequent determination of the test paper edge can be combined with the second test paper image.

[0105] Further, in the determination of the object region, the region to which the object belongs is identified and then used. In the embodiment, the specific implementation manner is as follows:

[0106] An edge detection algorithm is used to perform edge detection processing on the second image, at least one element region corresponding to the second image is determined according to the edge detection processing result, and a target element region is screened from the at least one element region as the object region.

[0107] Specifically, the edge detection algorithm refers to an algorithm for detecting all object edges in the second image. Correspondingly, the element region refers to a region framed by each edge line after edge detection. Correspondingly, the target element region refers to a region corresponding to the target object in the second image.

[0108] Therefore, in order to determine the edge of the target object in combination with the second image, a preset edge detection algorithm can be used to perform edge detection processing on the second image, at least one element region corresponding to the second image can be determined according to the edge detection processing result, and a target element region can be screened from the at least one element region as the object region. Since each element region corresponds to a different object, the target element region can be screened from the at least one element region as the object region. In practical applications, in the test paper marking scenario, since the region occupied by the test paper is the largest after the image is captured, the target element region can be selected as the element region with the largest area, which is used as the object region.

[0109] As described above, by using the edge detection algorithm to detect all edges in the image, it can be ensured that the detected result contains the edge information of all objects. Based on this, the edge of the target object is selected for subsequent mask image generation, which can achieve accurate segmentation of the image to be processed.

[0110] In step S206, the object region in the second image is subjected to dilation processing to obtain a third image, and a mask image is generated based on the third image and the second image.

[0111] Specifically, after determining the object region in the second image, further, in order to generate a mask image with higher precision, which can be used in the processing stage, the object region in the second image can be dilated first, so that the object region corresponding to the target object in the image is eroded from the object region corresponding to the non-target object, and a third image is obtained according to the dilated result. Then, the mask image can be generated according to the second image and the third image.

[0112] Specifically, the third image refers to the image obtained after dilating the object region in the second image, and the dilating processing of the object region can refer to the dilating processing of the filling region in the above-mentioned embodiments, which will not be described in detail in this embodiment. Correspondingly, the mask image refers to the image composed of the region corresponding to the target object and the region corresponding to the non-target object, which can be used as the basis for the segmentation processing of the image to be processed.

[0113] Further, when generating the mask image, considering that the mask image is the basis for cutting the image to be processed, it is necessary to ensure the generation accuracy of the mask image, so as to accurately segment the image to be processed. In this embodiment, the specific implementation is as follows:

[0114] Comparing the third image and the second image, determining an object edge region according to a comparison result. Generating the mask image based on the object edge region.

[0115] Specifically, the object edge region refers to the edge region corresponding to the target object, and the edge corresponding to the target object can be selected by calculating the connected component of the edge region, which is convenient for subsequent image segmentation processing.

[0116] Based on this, when creating the mask image, the third image and the second image can be compared to determine the object edge region according to the comparison result, and the mask image can be generated based on the object edge region.

[0117] When generating the mask image based on the object edge region, in order to accurately distinguish the internal region of the object and the external region of the object, so as to accurately segment the image to be processed, the method of calculating the connected component can be used. In this embodiment, the specific implementation is as follows:

[0118] Calculate the connected component corresponding to the object edge region, and determine the target object edge according to the maximum connected component; adjust the first image region inside the target object edge and the second image region outside the target object edge respectively, and generate the mask image according to the adjustment result.

[0119] Based on this, in order to accurately position the edge of the target object, so as to create a mask image, the connected components corresponding to the object edge region can be calculated first, and the target object edge corresponding to the target object can be determined according to the maximum connected component; At this time, the first image region in the target object edge and the second image region outside the target object edge are adjusted respectively to generate a mask image according to the adjustment result.

[0120] On this basis, when adjusting the image region, different regions are filled in different ways according to the set rules, so that mask images with different display effects in and out of the object region can be generated, so that the segmentation processing can be completed in combination with the pixel point information in the mask image in the segmentation stage. In the embodiment, the specific implementation is as follows:

[0121] The image region in the target object edge is selected as the first image region, and the image region outside the target object edge is selected as the second image region; The pixel points in the first image region are filled according to the first reference pixel value, and the pixel points in the second image region are filled according to the second reference pixel value; The mask image is generated according to the pixel point filling result.

[0122] Specifically, the first image region specifically refers to the image region in the target object edge in the third image, that is, the region corresponding to the target object; Correspondingly, the second image region specifically refers to the image region outside the target object edge in the third image, that is, the region corresponding to the non-target object. Correspondingly, the first reference pixel value and the second reference pixel value specifically refer to the values of adjusting the pixel values of the pixel points in the region, which are used to obtain the mask image according to the filling result.

[0123] Based on this, when creating a mask image, the image region in the target object edge can be selected as the first image region, and the image region outside the target object edge can be selected as the second image region; Then the pixel points in the first image region are filled according to the first reference pixel value, and the pixel points in the second image region are filled according to the second reference pixel value; To generate a mask image according to the pixel point filling result. The first reference pixel value and the second reference pixel value are different, which are used to distinguish different regions and facilitate image segmentation processing.

[0124] In actual application, after the region growing of the filled region in the first image, the second image is obtained. Thereafter, the edge of all objects in the second image can be determined by using the morphological edge algorithm; and then the object region in the second image is subjected to an inflation process. The inflation process can refer to the same or similar description as above, and will not be described in detail herein. According to the inflation process result, the third image is obtained. In the third image, the black region corresponding to the non-target object is eroded by the white region of the target object. At this time, the third image is subtracted from the second image, i.e., all_edge = dilate(page) - erode(page).

[0125] At this time, the auxiliary image composed of the black region and the white region can be obtained according to the image processing result. Since the auxiliary image only contains the black region and the white region, in order to complete the segmentation processing of the image to be processed based on the auxiliary image, the connected components of the edge corresponding to each object can be calculated after the edge of all objects is recognized. Since the target object occupies the largest area in the image to be processed, the edge corresponding to the largest connected component can be selected as the edge of the target object. Thereafter, the pixels in the auxiliary image are filled according to the edge of the target object, and the mask image can be obtained according to the filling result, so as to be used in the segmentation of the image to be processed.

[0126] Further, when the pixels in the auxiliary image are filled according to the edge of the target object, the purpose is to distinguish the region of the target object and the region of the non-target object. Therefore, the pixels inside the edge can be filled with 1, and the remaining pixels can be filled with 0, so as to obtain the mask according to the filling result, which is convenient for subsequent use.

[0127] In the above example, after the second test paper image as shown in (b) of FIG. 6 is obtained, the edge detection algorithm can be used to detect all objects contained in the second test paper image. According to the detection result, the edge corresponding to all objects is obtained, i.e., the effect as shown in (c) of FIG. 6. Since the test paper region needs to be segmented from the test paper image, the edge corresponding to the test paper region can be obtained by calculating the largest connected component. Thereafter, the pixel value of the pixel inside the largest connected component can be set to 1, and the pixel value of the other pixels can be set to 0. The mask image as shown in (a) of FIG. 7 can be obtained according to the setting result, and the mask image can be used for image segmentation processing subsequently. Figure 3 Figure 3 Figure 4

[0128] ​​​In summary, by creating a mask image by calculating the maximum connected component corresponding to the edge, the accuracy of the mask image creation can be ensured, and based on this, the segmentation processing of the to-be-processed image can be performed to accurately segment the image corresponding to the target object, thereby facilitating the use of downstream businesses.

[0129] In step S208, the to-be-processed image is segmented according to the distribution information of the pixels in the mask image, and a target image is obtained based on the segmentation result.

[0130] Specifically, after generating the mask image, further, in order to accurately segment the region corresponding to the target object in the to-be-processed image using the mask image, the to-be-processed image can be segmented according to the distribution information of the pixels in the mask image, the black edges in the to-be-processed image are removed, and a target image is obtained based on the segmentation result, thereby facilitating the use of downstream businesses.

[0131] Specifically, the distribution information refers to the distribution information of the black and white pixels in the mask image, wherein the white pixels correspond to the region corresponding to the target object, and the black pixels correspond to the region corresponding to the non-target object. Correspondingly, the target image specifically refers to the image obtained by cropping the region with black edges in the to-be-processed image.

[0132] Further, in order to ensure the segmentation accuracy, the mask image needs to be adjusted to have the same properties as the to-be-processed image before segmentation processing according to the distribution information of the pixels in the mask image. In this embodiment, the specific implementation is as follows:

[0133] The mask image is adjusted using the image property information of the to-be-processed image to obtain a target mask image, the image segmentation information corresponding to the to-be-processed image is determined according to the distribution information of the pixels in the target mask image, the to-be-processed image is segmented according to the image segmentation information, and the target image is obtained based on the segmentation result.

[0134] Specifically, the image property information specifically refers to the image size information of the to-be-processed image, etc. Correspondingly, the target mask image specifically refers to the image obtained by adjusting the mask image according to the image property information. The image has at least the same size as the to-be-processed image, and can also maintain the same properties as the to-be-processed image in other dimensions, such as clarity and resolution. Correspondingly, the image segmentation information specifically refers to the information for segmenting the to-be-processed image, which can be position comparison relationship information.

[0135] Based on this, during image segmentation, the mask image can be adjusted using the image attribute information of the image to be processed to obtain the target mask image. Then, based on the pixel distribution information in the target mask image, the image segmentation information corresponding to the image to be processed is determined. Finally, the image to be processed is segmented according to the image segmentation information, thus obtaining the target image based on the segmentation results. This facilitates use by downstream businesses.

[0136] In practical applications, when performing image segmentation, the mask image can first be restored to the same size as the image to be processed. Then, the image to be processed is segmented according to the pixel values ​​of the pixels in the mask image. That is, the original image pixels with a pixel value of 1 in the mask image are retained, while the original image pixels with a pixel value of 0 in the mask image are deleted to segment out the black border areas. Finally, the retained pixels are rendered by assigning a pixel value of 255, i.e., white, to obtain the target image corresponding to the image to be processed.

[0137] Continuing with the previous example, after obtaining... Figure 4 After obtaining the mask image shown in (a), the mask image can be restored to the same size as the test paper image (w*h). Then, the test paper image can be segmented based on the pixel values ​​of the pixels in the mask image. Specifically, pixels with a value of 1 in the mask image are retained, while pixels with a value of 0 in the mask image are deleted. This segmentation removes the black border areas from the test paper image. Finally, the retained pixels are rendered and assigned a value of 255, resulting in the image shown in (a). Figure 4 The target image shown in (b) facilitates subsequent grading of math exam questions based on this image. Furthermore, to enhance the grading process, the target image can be further beautified after acquisition.

[0138] The image processing method provided by the embodiment can improve the image processing accuracy and does not affect the use of downstream services. The binary image corresponding to the to-be-processed image is determined first, and subsequent processing is performed on the basis of the binary image, so that the interference of redundant features in the image is reduced. After obtaining the binary image, the edge region in the binary image is filled first to obtain a first image containing a filled region. Then, the filled region in the first image is dilated to obtain a second image, and an object region is determined in the second image. Then, the object region in the second image is dilated to obtain a third image. At this time, the edge of the object in the image can be located according to the third image and the second image obtained by dilation. Then, a mask image is constructed on the basis of this, and the distribution information of the pixel points in the mask image is used to segment the to-be-processed image, so that the region outside the object in the to-be-processed image is cut, and the content of the object region is not affected, so that a target image is obtained. In the processing process from the to-be-processed image to the target image, the content in the image is not modified, and the useful features are not cropped, so that the downstream service can use the target image with higher quality.

[0139] The following description is made with reference to the accompanying drawings. Figure 5 The image processing method provided by the embodiment is further described below with reference to the application of the image processing method in the test paper image segmentation scene. In the image processing method, Figure 5 FIG. 1 shows a processing flowchart of an image processing method provided by an embodiment of the present specification, which specifically includes the following steps:

[0140] In step S502, a to-be-processed image is obtained, and the to-be-processed image is preprocessed to obtain an intermediate image.

[0141] In step S504, the intermediate image is converted into a gray-scale image, and the gray-scale image is binarized to obtain a binary image corresponding to the to-be-processed image.

[0142] In step S506, an image region outside a target object in the binary image is selected as an edge region.

[0143] In step S508, the pixel value of a pixel point in the edge region is adjusted, and a first image containing a filled region is obtained according to the adjustment result.

[0144] In step S510, a region growth degree parameter and a region growth frequency parameter are determined according to a preset dilation strategy.

[0145] In step S512, a region dilation task corresponding to the filled region is created based on the region growth degree parameter and the region growth frequency parameter.

[0146] Step S514, performing region expansion on the filling region in the first image to obtain a second image.

[0147] Step S516, performing edge detection on the second image using a preset edge detection algorithm, and determining at least one element region corresponding to the second image according to the edge detection result.

[0148] Step S518, screening a target element region from the at least one element region as an object region, and performing region expansion on the object region in the second image to obtain a third image.

[0149] Step S520, comparing the third image with the second image, and determining an object edge region according to the comparison result.

[0150] Step S522, calculating connected components corresponding to the object edge region, and determining a target object edge according to a largest connected component.

[0151] Step S524, selecting an image region within the target object edge as a first image region, and selecting an image region outside the target object edge as a second image region.

[0152] Step S526, filling pixel points in the first image region according to a first reference pixel value, and filling pixel points in the second image region according to a second reference pixel value, and generating a mask image according to the filling result.

[0153] Step S528, adjusting the mask image using image attribute information of the image to be processed to obtain a target mask image.

[0154] Step S530, determining image segmentation information corresponding to the image to be processed according to distribution information of pixel points in the target mask image.

[0155] Step S532, performing segmentation processing on the image to be processed according to the image segmentation information, and obtaining a target image according to the segmentation processing result.

[0156] The image processing method provided by the embodiment can improve the image processing precision and does not affect the use of downstream services, can first determine a binary image corresponding to the to-be-processed image, and realize subsequent processing on the basis of the binary image, so as to reduce the interference of redundant features in the image. After obtaining the binary image, the edge region in the binary image can be filled first to obtain a first image containing a filled region. Then, the filled region in the first image is dilated to obtain a second image, and an object region is determined in the second image. Then, the object region in the second image is dilated to obtain a third image, and the edge of the object in the image can be located according to the third image and the second image obtained by dilating. Then, a mask image is constructed on the basis of this, and the target image is segmented by using the distribution information of the pixel points in the mask image, so that the region outside the object in the to-be-processed image can be cut, and the content of the object region is not affected, so that the target image is obtained. In the processing process from the to-be-processed image to the target image, the content in the image is not modified, and the useful features are not cropped, so that the downstream service can use the target image with higher quality.

[0157] Corresponding to the method embodiments, the specification also provides image processing device embodiments, Figure 6 The structure of an image processing device provided by an embodiment of the specification is shown. As shown in the figure, Figure 6 The device includes:

[0158] The image determining module 602 is configured to determine a binary image corresponding to the to-be-processed image, and fill the edge region in the binary image to obtain a first image containing a filled region.

[0159] The region determining module 604 is configured to dilate the filled region in the first image to obtain a second image, and determine an object region in the second image.

[0160] The image generating module 606 is configured to dilate the object region in the second image to obtain a third image, and generate a mask image based on the third image and the second image.

[0161] The segmentation processing module 608 is configured to segment the to-be-processed image according to the distribution information of the pixel points in the mask image, and obtain a target image according to the segmentation processing result.

[0162] In an optional embodiment, the image determining module 602 is further configured to:

[0163] Obtaining the to-be-processed image; preprocessing the to-be-processed image to obtain an intermediate image; converting the intermediate image into a gray-scale image, and performing binarization processing on the gray-scale image to obtain the binarization image corresponding to the to-be-processed image.

[0164] In an optional embodiment, the image determining module 602 is further configured to:

[0165] Selecting, in the binarization image, an image region outside the target object as the edge region; adjusting pixel values of pixel points in the edge region, and obtaining the first image containing the filling region according to an adjustment result.

[0166] In an optional embodiment, the region determining module 604 is further configured to:

[0167] Determining a region growth degree parameter and a region growth frequency parameter according to a preset expansion strategy; creating a region expansion task corresponding to the filling region based on the region growth degree parameter and the region growth frequency parameter; and performing expansion processing on the filling region in the first image by executing the region expansion task to obtain the second image.

[0168] In an optional embodiment, the region determining module 604 is further configured to:

[0169] Performing edge detection processing on the second image by using a preset edge detection algorithm; determining at least one element region corresponding to the second image according to an edge detection processing result; and selecting a target element region in the at least one element region as the object region.

[0170] In an optional embodiment, the image generating module 606 is further configured to:

[0171] Comparing the third image and the second image to determine an object edge region according to a comparison result; and generating the mask image based on the object edge region.

[0172] In an optional embodiment, the image generating module 606 is further configured to:

[0173] Calculating a connected component corresponding to the object edge region, and determining a target object edge according to a largest connected component; respectively adjusting a first image region in the target object edge and a second image region outside the target object edge according to an adjustment result to generate the mask image.

[0174] In an optional embodiment, the image generating module 606 is further configured to:

[0175] select an image region within the edge of the target object as the first image region and an image region outside the edge of the target object as the second image region; fill the pixel points in the first image region according to a first reference pixel value and fill the pixel points in the second image region according to a second reference pixel value; and generate the mask image according to the pixel point filling results.

[0176] In an optional embodiment, the segmentation processing module 608 is further configured to:

[0177] adjust the mask image according to the image attribute information of the image to be processed to obtain a target mask image; determine image segmentation information corresponding to the image to be processed according to the distribution information of the pixel points in the target mask image; and perform segmentation processing on the image to be processed according to the image segmentation information, and obtain the target image according to the segmentation processing result.

[0178] The image processing apparatus provided in this embodiment can improve the image processing precision and does not affect the use of downstream services. The binary image corresponding to the image to be processed is determined first, and subsequent processing is performed on the basis of the binary image, so that the interference of redundant features in the image is reduced. After the binary image is obtained, the edge region in the binary image is filled first to obtain a first image containing a filled region. Then, the filled region in the first image is dilated to obtain a second image, and an object region is determined in the second image. The object region in the second image is dilated again to obtain a third image. The edge of the object in the image is located according to the third image obtained by dilating and the second image. Then, the mask image is constructed on the basis of this, and the image to be processed is segmented according to the distribution information of the pixel points in the mask image. Thus, the region outside the object in the image to be processed is cut, and the content of the region corresponding to the object is not affected, so that the target image with higher quality is obtained. In the processing from the image to be processed to the target image, the content in the image is not modified, and the useful features are not cropped, so that the downstream services can use the target image with higher quality.

[0179] The above is a schematic scheme of the image processing apparatus in this embodiment. It should be noted that the technical scheme of the image processing apparatus belongs to the same concept as the technical scheme of the image processing method described above. The details of the technical scheme of the image processing apparatus that are not described in detail can be referred to the description of the technical scheme of the image processing method.

[0180] Corresponding to the method embodiments described above, the present specification also provides another image processing method embodiment, Figure 7 A flowchart of another image processing method provided in an embodiment of the present specification is shown. As shown in FIG. 8, the image processing method includes the following steps.Figure 7 As shown in the method includes:

[0181] In step S702, a binary image corresponding to the to-be-processed test paper image is determined, and an edge region of the test paper in the binary image is filled to obtain a first test paper image containing a filled region.

[0182] In step S704, the filled region in the first test paper image is dilated to obtain a second test paper image, and a test paper region is determined in the second test paper image.

[0183] In step S706, the test paper region in the second test paper image is dilated to obtain a third test paper image, and a test paper mask image is generated based on the third test paper image and the second test paper image.

[0184] In step S708, the to-be-processed test paper image is segmented according to the distribution information of the pixel points in the test paper mask image, and a target test paper image is obtained according to the segmentation result.

[0185] Corresponding to the method embodiment, the specification also provides another image processing device embodiment, Figure 8 The structure of another image processing device provided by an embodiment of the specification is shown. As shown in the figure, Figure 8 The device includes:

[0186] The image determining module 802 is configured to determine a binary image corresponding to the to-be-processed test paper image, and fill an edge region of the test paper in the binary image to obtain a first test paper image containing a filled region.

[0187] The region determining module 804 is configured to dilate the filled region in the first test paper image to obtain a second test paper image, and determine a test paper region in the second test paper image.

[0188] The image generating module 806 is configured to dilate the test paper region in the second test paper image to obtain a third test paper image, and generate a test paper mask image based on the third test paper image and the second test paper image.

[0189] The segmentation processing module 808 is configured to segment the to-be-processed test paper image according to the distribution information of the pixel points in the test paper mask image, and obtain a target test paper image according to the segmentation result.

[0190] The above is a schematic solution of another image processing apparatus of the embodiment. It should be noted that the technical solution of the image processing apparatus belongs to the same concept as the technical solution of the image processing method described above, and the details of the technical solution of the image processing apparatus that are not described in detail can be referred to the description of the technical solution of the image processing method.

[0191] Figure 9 A structural block diagram of a computing device 900 according to an embodiment of the present specification is shown. The components of the computing device 900 include, but are not limited to, a memory 910 and a processor 920. The processor 920 is connected to the memory 910 through a bus 930, and a database 950 is used to save data.

[0192] The computing device 900 also includes an access device 940, which enables the computing device 900 to communicate via one or more networks 960. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 940 can include one or more of any type of network interface (e.g., a network interface card (NIC)), wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and the like.

[0193] In an embodiment of the present application, the above-mentioned components of the computing device 900 and other components not shown in the Figure 9 may be connected to each other, for example, through a bus. It should be understood that Figure 9 The structural block diagram of the computing device shown is only for the purpose of example, and is not a limitation on the scope of the present application. Those skilled in the art can add or replace other components as needed.

[0194] The computing device 900 can be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 900 can also be a mobile or stationary server.

[0195] The processor 920 is configured to execute computer-executable instructions, including:

[0196] determine a binarization image corresponding to the to-be-processed image, and fill an edge region in the binarization image to obtain a first image containing a filled region;

[0197] perform dilation processing on the filled region in the first image to obtain a second image, and determine an object region in the second image;

[0198] perform dilation processing on the object region in the second image to obtain a third image, and generate a mask image based on the third image and the second image;

[0199] perform segmentation processing on the to-be-processed image according to distribution information of pixel points in the mask image, and obtain a target image according to a segmentation processing result. Alternatively,

[0200] determine a binarization image corresponding to the to-be-processed image, and fill an edge region in the binarization image to obtain a first image containing a filled region;

[0201] perform dilation processing on the filled region in the first image to obtain a second image, and determine a test paper region in the second image;

[0202] perform dilation processing on the test paper region in the second image to obtain a third image, and generate a test paper mask image based on the third image and the second image;

[0203] perform segmentation processing on the to-be-processed test paper image according to distribution information of pixel points in the test paper mask image, and obtain a target test paper image according to a segmentation processing result.

[0204] The above is a schematic scheme of the computing device of the embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the image processing method belong to the same concept, and the details of the technical scheme of the computing device that are not described in detail can be referred to the description of the technical scheme of the image processing method.

[0205] An embodiment of the present specification also provides a computer readable storage medium storing computer instructions, which are executed by a processor to:

[0206] determine a binarization image corresponding to the to-be-processed image, and fill an edge region in the binarization image to obtain a first image containing a filled region;

[0207] perform dilation processing on the filled region in the first image to obtain a second image, and determine an object region in the second image;

[0208] perform dilation processing on the object region in the second image to obtain a third image, and generate a mask image based on the third image and the second image;

[0209] perform segmentation processing on the to-be-processed image according to distribution information of pixel points in the mask image, and obtain a target image according to a segmentation processing result. Alternatively,

[0210] determine a binarization image corresponding to the to-be-processed test paper image, and fill a test paper edge region in the binarization image to obtain a first test paper image containing a filled region;

[0211] perform dilation processing on the filled region in the first test paper image to obtain a second test paper image, and determine a test paper region in the second test paper image;

[0212] perform dilation processing on the test paper region in the second test paper image to obtain a third test paper image, and generate a test paper mask image based on the third test paper image and the second test paper image;

[0213] perform segmentation processing on the to-be-processed test paper image according to distribution information of pixel points in the test paper mask image, and obtain a target test paper image according to a segmentation processing result.

[0214] The above is a schematic scheme of the computer readable storage medium of the embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the image processing method described above belong to the same concept, and the details of the technical scheme of the storage medium which are not described in detail can be referred to the description of the technical scheme of the image processing method.

[0215] The above describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the acts or steps recited in the claims can be performed in a different order than those in the embodiments and still achieve desirable results. In addition, the processes depicted in the figures do not necessarily require the particular order shown or sequential order to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous.

[0216] The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier signal, telecommunication signal, software distribution medium, etc. It should be noted that the computer readable medium can include appropriate contents according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.

[0217] It should be noted that, for the foregoing method embodiments, in order to facilitate description, each is described as a combination of a series of acts, but those skilled in the art should know that the present specification is not limited to the order of the acts described, because according to the present specification, certain steps can be performed in other orders or at the same time. Secondly, those skilled in the art should know that the embodiments described in the specification are all preferred embodiments, and the acts and modules involved are not necessarily all necessary for the present specification.

[0218] In the above embodiments, the description of each embodiment is focused on, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0219] The preferred embodiments of the present specification disclosed above are only used to help explain the present specification. The alternative embodiments do not describe all the details and limit the present invention to the specific embodiments described. Obviously, according to the content of the present specification, many modifications and changes can be made. The present specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present specification, so that those skilled in the art can well understand and use the present specification. The present specification is limited only by the claims and their full scope and equivalents.

Claims

1. An image processing method, characterized in that, include: Determine the binarized image corresponding to the image to be processed, and fill the edge regions in the binarized image to obtain a first image containing the filled regions; The filled region in the first image is dilated to obtain the second image, and the object region is determined in the second image; A third image is obtained by dilating the object region in the second image, and a mask image is generated based on the third image and the second image. The step of generating the mask image based on the third image and the second image includes: comparing the third image and the second image, determining the object edge region based on the comparison result, and generating the mask image based on the object edge region. The image to be processed is segmented according to the distribution information of pixels in the mask image, and the target image is obtained based on the segmentation results.

2. The method according to claim 1, characterized in that, Determining the binarized image corresponding to the image to be processed includes: Obtain the image to be processed; The image to be processed is preprocessed to obtain an intermediate image; The intermediate image is converted into a grayscale image, and the grayscale image is binarized to obtain the binarized image corresponding to the image to be processed.

3. The method according to claim 1, characterized in that, The step of filling the edge regions in the binarized image to obtain a first image containing the filled regions includes: In the binarized image, an image region outside the target object is selected as the edge region; The pixel values ​​of the pixels in the edge region are adjusted, and the first image containing the filled region is obtained based on the adjustment result.

4. The method according to claim 1, characterized in that, The step of dilating the filled region in the first image to obtain the second image includes: The parameters for the degree of regional growth and the number of regional growth cycles are determined based on a preset expansion strategy. Based on the region growth degree parameter and the region growth number parameter, a region expansion task corresponding to the filled region is created; The second image is obtained by performing the region dilation task to dilate the filled region in the first image.

5. The method according to claim 1, characterized in that, Determining the object region in the second image includes: The second image is processed by edge detection using a preset edge detection algorithm; Determine at least one element region corresponding to the second image based on the edge detection processing results; Filter the target element region from the at least one element region to obtain the object region.

6. The method according to claim 1, characterized in that, Generating the mask image based on the object edge region includes: Calculate the connected components corresponding to the edge region of the object, and determine the edge of the target object based on the maximum connected component; The first image region within the edge of the target object and the second image region outside the edge of the target object are adjusted respectively, and the mask image is generated according to the adjustment results, wherein the first image region is the image region within the edge of the target object, and the second image region is the image region outside the edge of the target object.

7. The method according to claim 6, characterized in that, The step of adjusting the first image region within the edge of the target object and the second image region outside the edge of the target object, and generating the mask image based on the adjustment results, includes: The pixels in the first image region are filled according to the first reference pixel value, and the pixels in the second image region are filled according to the second reference pixel value; The mask image is generated based on the pixel filling results.

8. The method according to any one of claims 1-7, characterized in that, The step of segmenting the image to be processed according to the distribution information of pixels in the mask image, and obtaining the target image based on the segmentation result, includes: The mask image is adjusted using the image attribute information of the image to be processed to obtain the target mask image; Based on the distribution information of pixels in the target mask image, determine the image segmentation information corresponding to the image to be processed; The image to be processed is segmented according to the image segmentation information, and the target image is obtained based on the segmentation results.

9. An image processing apparatus, characterized in that, include: The image determination module is configured to determine the binarized image corresponding to the image to be processed, and fill the edge regions in the binarized image to obtain a first image containing the filled regions; The region determination module is configured to perform dilation processing on the filled region in the first image to obtain a second image, and to determine the object region in the second image; An image generation module is configured to perform dilation processing on an object region in the second image to obtain a third image, and generate a mask image based on the third image and the second image, wherein generating the mask image based on the third image and the second image includes: comparing the third image and the second image, determining an object edge region based on the comparison result; and generating the mask image based on the object edge region. The segmentation processing module is configured to segment the image to be processed according to the distribution information of pixels in the mask image, and obtain the target image based on the segmentation processing result.

10. An image processing method, characterized in that, include: Determine the binarized image corresponding to the test paper image to be processed, and fill the edge region of the test paper in the binarized image to obtain a first test paper image containing the filled region; The filled area in the first test paper image is dilated to obtain the second test paper image, and the test paper area is determined in the second test paper image; The test paper region in the second test paper image is dilated to obtain the third test paper image, and a test paper mask image is generated based on the third test paper image and the second test paper image. The step of generating the test paper mask image based on the third test paper image and the second test paper image involves comparing the third test paper image and the second test paper image and determining the object edge region based on the comparison result. The test paper mask image is generated based on the edge region of the object; The test paper image to be processed is segmented according to the distribution information of pixels in the test paper mask image, and the target test paper image is obtained based on the segmentation result.

11. An image processing apparatus, characterized in that, include: The image determination module is configured to determine the binarized image corresponding to the test paper image to be processed, and fill the test paper edge region in the binarized image to obtain a first test paper image containing the filled region. The region determination module is configured to perform dilation processing on the filled region in the first test paper image to obtain a second test paper image, and to determine the test paper region in the second test paper image. An image generation module is configured to perform dilation processing on the test paper region in the second test paper image to obtain a third test paper image, and generate a test paper mask image based on the third test paper image and the second test paper image, wherein generating the test paper mask image based on the third test paper image and the second test paper image involves: comparing the third test paper image and the second test paper image, determining the object edge region based on the comparison result, and generating the test paper mask image based on the object edge region; The segmentation processing module is configured to segment the test paper image to be processed according to the distribution information of pixels in the test paper mask image, and obtain the target test paper image based on the segmentation processing result.

12. A computing device, characterized in that, It includes a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the method according to any one of claims 1 to 8 or 10.

13. A computer-readable storage medium storing computer instructions, characterized in that, When executed by a processor, this instruction implements the steps of the method according to any one of claims 1 to 8 or 10.

14. A computer program product, characterized in that, Includes computer instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 8 or 10.

Citation Information

Patent Citations

  • Method for removing black edge of image

    CN112634229A

  • Document image optimization method and medium

    CN115273114A