An image processing method, device and storage medium

By applying line detection and quadrilateral structure feature rules in image processing, combined with neural network training, the problem of low accuracy in calculating corner points by neural networks is solved, and high-precision recognition of the target object's position is achieved.

CN116051581BActive Publication Date: 2026-07-21ZHUHAI PANTUM ELECTRONICS CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHUHAI PANTUM ELECTRONICS CO LTD
Filing Date
2022-11-24
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

In existing technologies, the accuracy of directly calculating the corner points of a target object using neural networks is low, and there is a lack of handling for abnormal situations, resulting in low accuracy in identifying the position of the target object.

Method used

By acquiring the binary edge map of the image to be processed, line detection and repeated line merging are performed. The structural feature rules of quadrilaterals are used to determine the target intersection point combination. Combined with the target neural network model for training and optimization, anomalies are eliminated and the recognition accuracy is improved.

Benefits of technology

It improves the accuracy of target object location recognition, reduces the occurrence of anomalies, and enhances the precision of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116051581B_ABST
    Figure CN116051581B_ABST
Patent Text Reader

Abstract

The application provides an image processing method and device and a storage medium. The method comprises: acquiring a to-be-processed image, the to-be-processed image comprising a first processing region and a second processing region; outputting a binary edge graph of the to-be-processed image based on a target neural network model, wherein the target neural network is trained based on sample graphs synthesized based on the first processing region and the second processing region; performing straight line detection based on the binary edge graph to detect a straight line combination in the binary edge graph, performing repeated straight line merging on the straight line combination to output a target straight line combination in the binary edge graph; determining a first intersection point combination of any two straight lines in the target straight line combination in the binary edge graph, and determining a target intersection point combination in the first intersection point combination based on a structural feature rule of a quadrangle; determining a target region edge of the to-be-processed image based on the target intersection point combination, and returning a processing result. According to the embodiment of the application, the recognition accuracy of the target region edge can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing, and more particularly to an image processing method, apparatus, and storage medium for determining the edges of a target region. Background Technology

[0002] Currently, users often use their mobile phones to take pictures of cards or paper documents for archiving or printing. However, the images taken by mobile phones have many unwanted areas, and due to the complexity and diversity of the scenes, most algorithms are not accurate enough in recognizing the location of cards (or paper documents, etc.), and there will inevitably be some discrepancies with the ideal location. Improving the accuracy of target object location recognition is a challenging task.

[0003] Existing technologies typically use neural networks to improve the accuracy of target object position contour recognition. These neural networks directly calculate each corner point in an end-to-end manner. Therefore, the accuracy of corner point calculation by these neural networks is low, and they lack handling for abnormal cases, such as calculating fewer than four corner points. Summary of the Invention

[0004] This invention provides an image processing method, apparatus, and storage medium that can classify and process different abnormal situations, thereby improving the accuracy of image processing.

[0005] One embodiment of the present invention provides an image processing method, the method comprising:

[0006] Acquire an image to be processed, the image to be processed comprising a first processing region and a second processing region;

[0007] The target neural network model outputs a binary edge map of the image to be processed, wherein the target neural network is trained based on a sample map synthesized from the first processing region and the second processing region.

[0008] Line detection is performed based on the binary edge map to detect line combinations in the binary edge map, and repeated line merging is performed on the line combinations to output the target line combination in the binary edge map;

[0009] Determine the first intersection point combination of any two lines in the target line combination in the binary edge graph, and determine the target intersection point combination in the first intersection point combination based on the structural feature rules of quadrilaterals;

[0010] The target region edge of the image to be processed is determined based on the target intersection point combination, and the processing result is returned.

[0011] The method also includes:

[0012] Obtain the set of foreground images and the set of background images, and synthesize any foreground image from the set of foreground images and any background image from the set of background images to obtain training sample images.

[0013] The target neural network model is trained using the training sample images.

[0014] The method also includes:

[0015] The target neural network model is used to perform n operations on the image. The first n-1 operations include multiple convolutions and activations and one pooling operation. The nth operation includes multiple convolutions and activations. The input of the first operation is the image to be processed, and the input of the next operation is the output of the previous operation.

[0016] Extract a set of matrices obtained from the last convolution and activation in each operation;

[0017] Perform transpose convolution on each of the n sets of matrices, where the images corresponding to the n sets of matrices after transpose convolution have the same size;

[0018] The n sets of matrices after transpose and convolution are concatenated and then convolved to obtain the edge regions of the preset shape.

[0019] The method also includes:

[0020] The binary edge map is subjected to line detection, and the detected line combination is subjected to polar coordinate transformation to determine the difference in angle and the difference in radius between any two lines in the line combination.

[0021] Determine preset angle thresholds and radius thresholds, and merge any two lines in the line combination whose angle difference is less than or equal to the angle threshold, or whose radius difference is less than or equal to the radius threshold, into a single line.

[0022] Output the target line combination after repeating and merging the given line combination.

[0023] The binary edge map includes a third processing region and a fourth processing region, wherein the third processing region is the foreground image of the binary edge map, and the fourth processing region is the background image of the binary edge map. The method further includes:

[0024] Based on any two lines in the target line combination, a second intersection point combination is determined in the binary edge map, wherein the intersection points in the second intersection point combination are located in the third processing region and the fourth processing region in the binary edge map;

[0025] The intersection points in the first intersection point combination located in the fourth processing region of the binary edge map are excluded to determine the third intersection point combination of any two lines in the target line combination in the third processing region of the binary edge map.

[0026] Intersections in the third intersection point combination whose distance is less than or equal to a preset distance threshold are merged into one intersection point to determine the first intersection point combination of any two lines in the target line combination in the binary edge graph.

[0027] The method also includes:

[0028] Determine the number N of intersection points in the first intersection point combination, where N is a positive integer greater than or equal to 0;

[0029] When N is greater than or equal to 1, M suspicious quadrilateral intersection point combinations are determined based on the N intersection points in the first intersection point combination, where M is a positive integer greater than or equal to 0;

[0030] Based on the structural feature rules of quadrilaterals, reasonable values ​​are calculated for the suspected quadrilaterals identified in the M suspected quadrilateral intersection point combinations. The four intersection points of the quadrilateral with the highest reasonable value that is greater than the preset reasonable value threshold are determined as the target intersection point combination. The structural feature rules of quadrilaterals include the quadrilateral side length rules and the quadrilateral angle rules.

[0031] The method also includes:

[0032] When N equals 3, a target triangle is determined based on the N intersection points, and the first intersection point with the largest angle value is determined based on the target triangle;

[0033] Based on the first intersection point and the parallelogram rule, the second intersection point diagonally opposite the first intersection point is determined, and the three intersection points in the target triangle and the second intersection point are determined as the target intersection point combination.

[0034] The method also includes:

[0035] When N equals 2, the position of the center point of the binary edge map is determined;

[0036] The target edge segment is determined based on the N intersection points, and the fourth and fifth intersection points are determined based on the target edge segment and the center point position of the binary edge map.

[0037] Two of the N intersection points, along with the fourth and fifth intersection points, are determined as the target intersection point combination in the first intersection point combination.

[0038] The method also includes:

[0039] When N is less than or equal to 1, four default intersection points are determined based on the side length of the binary edge map and a preset ratio threshold, and the four default intersection points are determined as the target intersection point combination in the first intersection point combination.

[0040] Another aspect of the present invention provides an image processing apparatus, the apparatus comprising:

[0041] The acquisition module is used to acquire an image to be processed, the image to be processed including a first processing region and a second processing region;

[0042] The output module is used to output a binary edge map of the image to be processed based on the target neural network model, wherein the target neural network is trained based on a sample map synthesized from the first processing region and the second processing region;

[0043] The detection module is used to perform line detection based on the binary edge map to detect line combinations in the binary edge map, and to perform repeated line merging on the line combinations to output the target line combination in the binary edge map;

[0044] The first determining module is used to determine the first intersection point combination of any two lines in the target line combination in the binary edge graph, and to determine the target intersection point combination in the first intersection point combination based on the structural feature rules of quadrilaterals;

[0045] The second determining module is used to determine the edge of the target region of the image to be processed based on the combination of target intersection points, and return the processing result.

[0046] This invention also provides an electronic device, including: a memory, a processor, and a computer program;

[0047] The computer program is stored in the memory and configured to be executed by the processor to implement the method described in any of the above-described embodiments.

[0048] This invention provides a computer-readable storage medium storing a computer program thereon, characterized in that the program, when executed, implements the steps of any of the methods described above.

[0049] Through embodiments of the present invention, an image to be processed can be acquired, a binary edge map of the image to be processed can be output based on a target neural network model, and line detection can be performed on the binary edge map to detect line combinations in the binary edge map. Then, repeated line merging is performed on the line combinations to output target line combinations in the binary edge map. Next, the first intersection point combination of any two lines in the target line combination is determined in the binary edge map, and the target intersection point combination in the first intersection point combination is determined based on the structural feature rules of quadrilaterals. Finally, the target edge image of the image to be processed is determined based on the target intersection point combination, and the processing result is returned. It can be seen that in the process of determining the target edge image, line detection is performed on the binary edge map output by the target neural network model, and the target intersection point combination is determined based on specific quadrilateral structural feature rules. Here, the determination of the target intersection point combination considers specific quadrilateral structural feature rules, thus eliminating unreasonable quadrilateral cases, reducing the occurrence of anomalies, and thereby improving the recognition accuracy of the target edge image. Attached Figure Description

[0050] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0051] Figure 1a A network architecture example diagram provided for an embodiment of the present invention;

[0052] Figure 1b An example image of an image to be processed provided in an embodiment of the present invention;

[0053] Figure 1c An example image of a target edge provided in an embodiment of the present invention;

[0054] Figure 1d An example diagram of a binary edge map provided in an embodiment of the present invention;

[0055] Figure 1e An example diagram of a cropped target region determined based on a combination of target intersections, provided as an embodiment of the present invention;

[0056] Figure 2a This is a flowchart illustrating an image processing method provided in an embodiment of the present invention;

[0057] Figure 2b This is an example diagram of a binary edge map after line detection provided in an embodiment of the present invention;

[0058] Figure 3 This is a flowchart example of another image processing method provided in an embodiment of the present invention;

[0059] Figure 4 This is an example diagram illustrating the angular correspondence of a quadrilateral provided in an embodiment of the present invention;

[0060] Figure 5 This is an example diagram of the graphical location for calculating edge probability values ​​provided in an embodiment of the present invention;

[0061] Figure 6 This is a structural example diagram of an image processing device provided in an embodiment of the present invention;

[0062] Figure 7 This is a structural example diagram of another electronic device provided in an embodiment of the present invention. Detailed Implementation

[0063] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0064] Please see Figure 1a This is a schematic diagram of a network architecture provided by an embodiment of the present invention. The network architecture may include a server 200 and a terminal device 100. The server 200 can transmit data with the terminal device 100 via the network. The terminal device 100 may have an image processing application installed (to determine the edge of a target area in a photograph, facilitating printing and other operations using the determined target area). The server 200 can be the backend server corresponding to the image processing application; therefore, the terminal device 100 can transmit data with the server 200 through the client corresponding to the image processing application. Optionally, the server 200 can obtain data sent from the terminal device 100, such as... Figure 1bThe image to be processed shown can be a pre-captured image stored in the terminal device 100, an image received from the network or other terminal devices, or an image captured in real-time by the terminal device 100; no limitation is made here. As shown in Figure 1, after the server 200 acquires the image to be processed, it outputs a binary edge map of the image based on the target neural network model. Then, the server 200 performs line detection on the binary edge map to detect line combinations, and then performs repeated line merging on the line combinations to output the target line combination in the binary edge map. Next, the server 200 determines the first intersection point combination of any two lines in the target line combination in the binary edge map, and determines the target intersection point combination in the first intersection point combination based on the structural feature rules of quadrilaterals. Finally, the server 200 determines, based on the target intersection point combination, the following... Figure 1c The image shown includes the edges of the four vertices, and the above is as follows: Figure 1c The image shown is returned to terminal 100, where the user can view the processed image. Figure 1c The image shown includes the edge of the target region 111. The aforementioned terminal devices may include mobile phones, tablets, laptops, PDAs, mobile internet devices (MIDs), and wearable devices (such as smartwatches and smart bracelets).

[0065] Optionally, the method implemented by server 200 in this application can also be executed by terminal device 100. When this method is applied to a terminal device, due to the limited memory and running speed of the terminal, the neural network algorithm needs to be optimized. In an optional embodiment, since the target neural network algorithm is built on the TensorFlow framework (or other frameworks such as TensorFlow, PyTorch, and PaddlePaddle), and the target neural network model in this embodiment aims to achieve edge detection of the target region, modules not used by the neural network algorithm in the framework can be deleted, retaining only the modules used by the target neural network to achieve edge detection of the target region. This reduces the size of the target neural network model and the memory usage of the terminal device, thereby improving the running speed of the terminal device.

[0066] The above optimization can also be performed when the method is applied to server 200, and the embodiments of this application are not limited here.

[0067] Please see Figure 2a This is a schematic flowchart of an image processing method provided in an embodiment of the present invention. The method may include:

[0068] Step S101: Obtain the image to be processed, which includes a first processing area and a second processing area.

[0069] Specifically, when the image to be processed is an image received from a network or other terminal device, the image to be processed can be as follows: Figure 1b The image shown. (As shown) Figure 1b As shown, the image to be processed includes a first processing area 10a and a second processing area 10b. The first processing area 10a is the foreground image of the image to be processed, and the second processing area 10b is the background image of the image to be processed.

[0070] Step S102: Output the binary edge map of the image to be processed based on the target neural network model, wherein the target neural network is trained based on the sample map synthesized from the first processing region and the second processing region.

[0071] Specifically, the target neural network can be a VGG16 convolutional neural network. VGG consists of 5 convolutional layers, 3 fully connected layers, and a softmax output layer. Max-pooling separates the layers, and all hidden activation units use the ReLU function, with pooling layers serving as boundaries. The VGG16 convolutional neural network has 6 block structures. Each block structure has a side-output added after the last convolutional layer, and each structure has the same number of channels. Because both convolutional and fully connected layers have weights, they are also called weight layers. There are 13 convolutional layers, 3 fully connected layers, and pooling layers (which do not involve weights), resulting in a total of 16 layers. For the VGG16 convolutional neural network, its 13 convolutional layers and 5 pooling layers are responsible for feature extraction, while the last 3 fully connected layers are responsible for classification. In an optional embodiment of this application, the last pooling layer and the subsequent fully connected layers are removed, retaining the first 5 modules. Therefore, in the above five block structures, all 1x1x21 convolutional outputs in each module are element-wise summed to obtain a composite feature. By simultaneously training the five side outputs derived from the convolutional layers and the results of the five side outputs after passing through the fusion layer, and calculating six loss functions, the trained target neural network is obtained.

[0072] In optional embodiments of this application, different images are cropped along the edges of the target image to serve as foreground images (e.g., 10a), and different images are used as background images (e.g., 10b). The foreground image can be a first processing region of the image to be processed, and the background image can be a second processing region of the image to be processed. When training the target neural network model, a set of foreground images and a set of background images are obtained. Any foreground image from the set of foreground images is synthesized with any background image from the set of background images (perspective transformation can be performed to simulate a distorted scene) to obtain a training sample image. Simultaneously, the position of the foreground image in the background image is recorded, and a black-and-white annotation image containing the outline of the foreground image is generated. By synthesizing the training sample image using the foreground and background images, the problem of a large workload during manual annotation can be avoided since the edge region of the foreground image is known.

[0073] However, since the training sample sets obtained above are generated in large batches based on certain algorithms, they may differ from training sample sets in real-world scenarios. Therefore, to obtain more realistic training sample sets, the entire function is improved and batch tested. The test results are then manually selected, and accurate data is added to the training sample set. Here, accurate data is a dataset synthesized by combining the calculated accurate target intersection point combinations with the input training samples. In an optional embodiment of this application, a neural network model is built based on TensorFlow. The prepared training sample set is used as the model's input, and the neural network is trained for no less than 10,000 rounds to obtain a trained neural network model. After training, the target neural network model is tested. If sufficient accuracy is not achieved, training is performed again. During retraining, correct input data is selected as a new training sample set, and training is performed again. Here, the selected correct input data is a dataset synthesized by combining the calculated accurate target intersection point combinations with the input training samples. When creating a new training sample set, the calculation results (four intersection points) are drawn into a quadrilateral, which is used as the edge of the target region of the input training sample map, thus obtaining a sample data and adding it to the new sample training set.

[0074] In an optional embodiment of this application, after the target neural network is trained, the image to be processed (e.g., Figure 1b The input is fed into the target neural network, which performs n operations on it. The first n-1 operations include multiple convolutions and activations and one pooling operation. The nth operation includes multiple convolutions and activations. The input for the first operation is the image to be processed (e.g., Figure 1bThe input for the next operation is the output of the previous operation. Extract the matrix obtained from the last convolution and activation in each operation, and perform transpose convolution on each of the n matrices. The n transpose convolutioned matrices correspond to the same image size. Concatenate the n transpose convolutioned matrices and then perform convolution to output the image to be processed (e.g., ...). Figure 1b Binary edge maps (e.g.) Figure 1d Here, the value of n is equal to the number of operations performed by the selected neural network algorithm. Optionally, when the target neural network is a VGG network, the number of operations performed by the VGG network is 5, so n can be 5 here.

[0075] Step S103: Based on the above binary edge map, perform line detection to detect line combinations in the above binary edge map, and perform repeated line merging on the above line combinations to output the target line combination in the above binary edge map.

[0076] Optionally, line detection can be performed on the binary edge map output by the aforementioned target neural network. This line detection can be either Hough transform-based or LSD-based. LSD-based line detection involves analyzing local areas of the image to obtain the set of pixels representing lines, then verifying and solving the hypothesis parameters, merging the pixel set with the error control set, and adaptively controlling the number of false detections. Hough transform, on the other hand, is a feature extraction method widely used in image analysis and computer vision to identify features (such as lines) within objects. Its algorithm is roughly as follows: given a shape type to be identified, the algorithm performs a voting process in the parameter space to determine the object's shape, which is determined by local maxima in the accumulation space. Therefore, Hough transform transforms the line detection problem in image space into a point detection problem in parameter space, completing the line detection task by finding peaks in the parameter space, i.e., transforming the detection of global characteristics into the detection of local characteristics.

[0077] Specifically, when performing the Hough transform, all straight lines passing through a point in the image space are represented using polar coordinates. (in, The distance from the origin to the line is denoted as . The perpendicular line between the origin and the line The angle between the axes represents the line length, which, when mapped to the parameter space, becomes a sine curve. The more sine curves a point passes through in the parameter space, the more points lie on that line. Therefore, a threshold can be set; when the number exceeds a certain value, it indicates the existence of a corresponding line in the image space. For example, as the principle suggests, the number of sine curves a point passes through represents the intensity of that line; more curves indicate greater intensity. Therefore, to distinguish the range of a point, the coordinates can be discretized (e.g., angles of 0°, 1°, 2°..., or distances). Taking values ​​1, 2, 3..., after discretization, there are two parameters: angular resolution and distance resolution. The number of sine curves at a point in the parameter space reflects the intensity of the straight line. Based on a threshold accumulated for either the angular or distance parameters of the sine curves at that point, the corresponding straight line with values ​​higher than that threshold is determined. For example... Figure 2b As shown, Figure 2b To combine lines in the binary edge map after Hough transform, the more relaxed the threshold of the above parameters, the more lines will be obtained. Therefore, only the first few lines can be selected (for example, only the first 10 detected lines are used, and the multiple detected lines are sorted according to a certain probability, with the first line having the highest probability).

[0078] Optionally, after detecting line combinations in the binary edge image using the above line detection, repeated line merging can be performed on the above line combinations to output the target line combination in the binary edge image. Based on the expression after polar coordinate transformation of the above line combinations, the angle difference and radius difference between any two lines in the above line combination are determined, and preset angle thresholds and radius thresholds are determined. Lines whose angle difference is less than or equal to the angle threshold and whose radius difference is less than or equal to the radius threshold are merged into a single line. Specifically, due to the presence of noise and jagged edges in the image, the Hough line detection algorithm may detect multiple similar lines for the same entity line, all representing the same line, but with slight errors in angle and radius. Therefore, in polar coordinates, the angle can be considered as... and radius Lines that are very close to each other are considered to be the same straight line. Therefore, the difference in angle between two lines is defined as... The difference in radii is And given preset thresholds, the two straight lines whose angle difference and radius difference are within the preset thresholds are merged into a single straight line.

[0079] Step S104: Determine the first intersection point combination of any two lines in the above target line combination in the above binary edge graph, and determine the target intersection point combination in the above first intersection point combination based on the structural feature rules of quadrilaterals.

[0080] The specific implementation process of step S104 can be found in the following... Figure 3 The descriptions of steps S204-S207 in the corresponding embodiments will not be repeated here.

[0081] Step S105: Determine the edge of the target region of the image to be processed based on the above target intersection point combination, and return the processing result.

[0082] Specifically, a quadrilateral is determined based on the four intersection points in the above target intersection point combination. This quadrilateral region is then defined as the target region of the image to be processed. The edges of the quadrilateral are used as the edges of the target region. These target region edges are then returned to the user terminal, allowing the user to view the processed image on the terminal (e.g., ...). Figure 1c ).

[0083] Optionally, when the image to be processed is captured by the phone's camera, the captured image can be automatically stored. When the processed image needs to be returned, the phone's image processing application calls the edge recognition API (Application Programming Interface) (the input parameter of this interface is the storage path of the image to be processed). The image processing application obtains four intersection points from the determined target intersection point combination from the edge recognition interface, maps the four intersection points onto the phone's display screen using the actual pixel ratio of the image and the actual displayed pixel ratio. After user confirmation, the cropping API (the input parameters of this interface are the storage path of the image to be processed and the four intersection points of the target quadrilateral) is called to obtain the target area and display it on the terminal device. The displayed cropped image effect is as follows. Figure 1e As shown, this is the final cropped version displayed to the user. Figure 1e Without irrelevant non-target areas 112, users can accurately determine the target area 111, facilitating further printing or scanning to obtain the target image and achieve the most ideal printing, photographing, and scanning results.

[0084] In this application, the target neural network model is first used to output the edges of the target regions in the image to be processed. While this step can be achieved using the Canny algorithm in traditional methods, its performance is not as good as that achieved through a neural network. Furthermore, this application employs a training-and-testing strategy in the training part of the target neural network. To obtain a more realistic training sample set, batch testing is performed after the entire function is perfected, and the test results are manually selected, with accurate data added to the training sample set. Here, accurate data is a dataset synthesized by combining the calculated accurate target intersection point combinations with the input training samples. This strategy of manual testing, result selection, and secondary training effectively improves the model's performance and accuracy.

[0085] Please see Figure 3 This is a schematic diagram of another image processing method provided in an embodiment of the present invention. The method may include:

[0086] Step S201: Obtain the image to be processed, which includes a first processing area and a second processing area.

[0087] The specific implementation process of step S201 can be found in the above. Figure 2a The description of step S101 in the corresponding embodiments will not be repeated here.

[0088] Step S202: Output the binary edge map of the image to be processed based on the target neural network model, wherein the target neural network is trained based on the sample map synthesized from the first processing region and the second processing region.

[0089] The specific implementation process of step S202 can be found in the above. Figure 2a The description of step S102 in the corresponding embodiments will not be repeated here.

[0090] Step S203: Based on the above binary edge map, perform line detection to detect line combinations in the above binary edge map, and perform repeated line merging on the above line combinations to output the target line combination in the above binary edge map.

[0091] The specific implementation process of step S203 can be found in the above. Figure 2a The description of step S103 in the corresponding embodiments will not be repeated here.

[0092] Step S204: Determine the first intersection point combination of any two lines in the above target line combination in the above binary edge graph.

[0093] Specifically, based on any two lines in the aforementioned target line combination, a second intersection point combination is determined in the aforementioned binary edge map. The intersection points in this second intersection point combination are located in the third and fourth processing regions of the binary edge map. Here, the third processing region is the foreground image of the binary edge map, and the fourth processing region is the background image. The intersection points in the first intersection point combination located in the fourth processing region of the binary edge map are excluded to determine the third intersection point combination of any two lines in the target line combination within the third processing region of the binary edge map. Intersection points in the third intersection point combination whose distance is less than or equal to a preset distance threshold are merged into one intersection point to determine the first intersection point combination of any two lines in the target line combination in the binary edge map.

[0094] Step S205: Determine the number N of intersection points in the first intersection point combination, where N is a positive integer greater than or equal to 0; when N is greater than or equal to 1, determine M suspicious quadrilateral intersection point combinations based on the N intersection points in the first intersection point combination, where M is a positive integer greater than or equal to 0.

[0095] Specifically, after determining the first intersection point combination within the foreground region of the binary edge map, the number of intersection points in the first intersection point combination is then determined. Next, quadrilaterals are searched, with each quadrilateral consisting of four points. A total of M suspected quadrilaterals can be formed. These suspected quadrilaterals are not necessarily valid quadrilaterals. For example, if the number of intersection points N in the first intersection point combination is 3 or 2, no valid quadrilateral exists. Therefore, a suspected quadrilateral can be formed based on the N intersection points in the first intersection point combination, and its validity can be judged later. When N is greater than 4, a sorting algorithm can be used to generate M suspected quadrilaterals from the N intersection points. In this case, M is greater than or equal to 1, and the validity of these M suspected quadrilaterals is then judged.

[0096] Step S206: Based on the structural feature rules of quadrilaterals, calculate the reasonable value of the suspected quadrilaterals determined in the above M suspected quadrilateral intersection point combinations, and determine the 4 intersection points of the quadrilaterals with reasonable values ​​greater than the preset reasonable value threshold and the highest ranking as the target intersection point combination. The structural feature rules of quadrilaterals include the quadrilateral side length rules and the quadrilateral angle rules.

[0097] Specifically, when N is greater than or equal to 1, reasonable values ​​are calculated for the suspicious quadrilaterals determined from the M suspicious quadrilateral intersection point combinations formed by the above N intersection points based on the structural feature rules of quadrilaterals.

[0098] When N is greater than or equal to 4, every four points can be combined to form a quadrilateral, and the similarity of the quadrilateral's sides to a rectangle can be determined by using the rules governing the quadrilateral's side length and angles. For example... Figure 4 As shown, Figure 4 This is an example diagram illustrating the angular correspondence of a quadrilateral. When calculating angles or side lengths, the order of the four points cannot be determined, for example, when calculating... Figure 4 When calculating the angle corresponding to P1, it's necessary to consider whether to calculate ∠P2P1P3, ∠P2P1P4, or other cases. Therefore, the four points need to be sorted to ensure the accuracy of the calculated side lengths and angles. During the sorting process, it's important to consider that the four input points have... =24 possibilities, therefore, calculate the center coordinates P of the four input points (unordered) P={A,B,C,D}, establish a coordinate system at the center coordinates, and calculate the angle θ={θ_t} between each point and the origin. A θ B θ C θD} (where θ∈[0°,180°]), then sort them in ascending order to obtain an ordered sequence of angles θ′={θ A θ B θ C θ D Therefore, according to its corresponding points, we obtain the ordered points P′={A,B,C,D}. Here, points A, B, C, and D correspond to... Figure 4 Points P1, P2, P3, and P4 are given in the diagram.

[0099] Optionally, after sorting the four points of the quadrilateral, the plausibility of the suspected quadrilateral can be calculated according to relevant rules. Here, the side length rule refers to calculating the area of ​​the quadrilateral using its side lengths, and considering the ratio of the quadrilateral's area to the area of ​​the binary edge image. If this ratio is very small, it indicates that the suspected quadrilateral is very small, and even if there is an actual target region edge, it should be considered unreasonable and non-existent. Therefore, this method can be used to filter out plausible suspected quadrilaterals. Additionally, the angle rule refers to how closely a quadrilateral resembles a rectangle, and how closely the triangles formed within it resemble right triangles. Therefore, the plausibility of a suspected quadrilateral is judged by the angles of the triangles within the quadrilateral. Optionally, such as... Figure 4 As shown, first calculate the angle values ​​θ = {θ1, θ2, θ3, θ4} corresponding to each point, where θ1 corresponds to... Figure 4 The angle value corresponding to point P1 is calculated, and so on for the others. θ1 is calculated by connecting adjacent points P2 and P3 to P1, and then using the formula P1P2∙P3P4=|P1P2|∙|P1P3|∙cosθ1. The angle values ​​of the other angles are calculated using the same principle. Optionally, after calculating the angle of each angle, the probability value of that angle can also be calculated.

[0100]

[0101] Where i∈[1,4], and by the properties of quadrilaterals, θi∈[0°,180°], when there exists θ i When P approaches 0°, other angle values ​​also approach 0° or 180°. θ Approaching 0; when θ i Approaching 90°, P θ P approaches 1, therefore P θ ∈ (0,1). However, considering the angle, when θ i When the angle is greater than 120° or less than 60° (at which point P) θThe result is likely to be mostly (0, 0.666), which produces a poor visual effect, and the resulting quadrilaterals often do not meet the requirements. Therefore, P can be limited. θ It is considered reasonable within the range (0.3, 1], where 0.3 is determined empirically.

[0102] Optionally, when calculating the rationality of a quadrilateral using side length rules, first calculate as follows: Figure 4 The area S of the quadrilateral in P1,P2,P3,P4 The area of ​​the binary edge map, S = height * width, is calculated, and then the area probability value is calculated.

[0103]

[0104] This property determines the size of the quadrilateral, and therefore usually needs to be set empirically. Optionally, this area probability value P... s The reasonable range is [0.015625, 1), where 0.015625 is determined empirically (i.e., corresponds to 1 / 64). Optionally, for calculating S... P1,P2,P3,P4 The quadrilateral can be decomposed into two triangles. Since the four points obtained are ordered points after calculation and sorting, it is easy to divide it into two triangles, i.e., △ P1,P2,P4 and △ P1,P3,P4 Then, using Heron's formula, the area of ​​the triangle can be calculated, and thus the area of ​​the quadrilateral can be calculated. Based on these two rules, unreasonable quadrilaterals can be eliminated when N is greater than or equal to 4.

[0105] Specifically, after eliminating unreasonable quadrilaterals, the most reasonable quadrilateral will be selected based on the calculation of reasonable values, and the four intersection points of the quadrilateral with the highest reasonable value will be determined as the target intersection point combination.

[0106] The formula for calculating the reasonable value is as follows:

[0107] Among them, P θ P represents the angle probability value. s P represents the area probability value. A Let represent the marginal probability value, and the above three coefficients satisfy:

[0108]

[0109] Specifically, when P θ =0 or P s =0 or P A When =0, the above reasonable value P=0. Optionally, the above P... θ P s There is a certain reasonable range (P) θIn the interval (0.3, 1], P s The range is [0.015625, 1). If it is not within the reasonable range, then the reasonable value P is assigned to 0. Optionally, the reasonable value... Theoretically, the range of values ​​for is [0,1], but this depends on its coefficient, which is determined empirically and is usually taken as . =0.2, =0.3, =0.5.

[0110] The formulas for calculating the angle probability and area probability are the same as described above, while the edge probability is calculated as the proportion of the edge. This is because, in practical situations, when calculating the rationality of using angle and area probability values, such as... Figure 5 As shown, quadrilateral P0P1P4P3 has higher angle and area probability values, but the line it lies on differs significantly from the edge of the target region. Quadrilateral P2P4P5P3, corresponding to the edge of the target region, is the desired feature. Therefore, to quantify this situation, an edge probability value needs to be added. During the calculation, the algorithm counts the number of edge pixels. These edge pixels refer to the number of pixel values ​​that distinguish between edges and non-edges. For example, the white solid line in the above figure represents the edge calculated by the target neural network model; therefore, the number of pixels along the white solid line will be counted.

[0111] Specifically, such as Figure 5 As shown, the number of all edge pixels in a binary edge image is counted, let's call it... Next, count the number of edge pixels on each side of the quadrilateral, denoted as S; then, starting from a vertex of the quadrilateral, move clockwise or counterclockwise along one side, counting the number of edge pixels locally at fixed intervals, denoted as S. The length is set to 2r. Starting from point P0, gradually count the number of edge pixels within a radius of r along the direction P0 -> P1 -> P4 -> P3 -> P0 (note that this can also be counted within a perpendicular distance r from the line, in which case it is not a circle). Because the points counted in each step are different, meaning that the same point is only counted once, therefore That is, the formula for the marginal probability value is:

[0112]

[0113] The marginal probability value ranges from [0,1]. Typically, this probability value will not be 1 or 0 in most correct cases, but will be in the middle range in most cases. Therefore, the coefficient of this probability value needs to be relatively large.

[0114] Specifically, after calculating the reasonable quadrilaterals selected above, the angle probability value, area probability value, and edge probability value of the reasonable quadrilaterals are calculated. Then, the reasonable quadrilaterals are sorted by reasonable value, and the four intersection points of the quadrilateral with the highest reasonable value that is greater than the preset reasonable value threshold are determined as the target intersection point combination.

[0115] Optionally, when N equals 3, no reasonable quadrilateral will exist. Therefore, the fourth intersection point can be determined by finding a reasonable triangle. When N equals 3, a target triangle is determined based on three intersection points, and the first intersection point with the largest angle value is determined based on the target triangle. The second intersection point, diagonally opposite the first intersection point, is determined based on the first intersection point and the parallelogram rules. The three intersection points of the target triangle and the second intersection point are then used as the target intersection point combination. Alternatively, when N is greater than or equal to 4, if no reasonable quadrilateral exists after calculating reasonable values, a triangle can be formed between any three points to find a reasonable triangle. The fourth intersection point is then determined using this reasonable triangle, thus determining a new reasonable quadrilateral.

[0116] Specifically, if we form a triangle with any three points, and let the vertices be A, B, and C, then the corresponding angle is θ. A θ B θ C Here, we still follow the angle and area rules of quadrilaterals to find a reasonable triangle. The angle probability values ​​are as follows:

[0117]

[0118] in, ∈[60°,180°), when A triangle is considered standard when the angle is 90°, but note that this value is not centered at 90°. Cases exceeding 120° exist, and a few will correspond to real-world scenarios; these are optional and can be set based on experience. The range [60°, 150°] is considered a reasonable value. ∈[2 / 3,1].

[0119] Wherein, the area probability value at this time is:

[0120]

[0121] Where height*width is the area of ​​the binary edge map. Here, the area of ​​the triangle is doubled, and the area of ​​its corresponding parallelogram is calculated. Therefore, the probability value of this area is similar to the probability value of the area of ​​the quadrilateral mentioned earlier. Optionally, based on experience, the range of the area probability value here is set to [0.015625, 1).

[0122] Optionally, after selecting a reasonable triangle, it is also necessary to deduce the fourth point. Let the vertices be A(x0,y0), B(x1,y1), and C(x2,y2), and the point to be deduced be D(x3,y3). The fourth point can be deduced using vector rules and parallelogram rules, but the prerequisite is to first determine the point with the largest angle value. For example, when the angle value corresponding to point A is the largest, an equation can be established using vector AB=DC, and the corresponding point can be found. That is:

[0123]

[0124] Therefore, we can conclude that:

[0125]

[0126] Similarly:

[0127]

[0128] Therefore, once a reasonable triangle has been selected, the position of the fourth point can be deduced based on the positions of the three points in the determined triangle, and these four points can be identified as the target intersection combination.

[0129] Optionally, when N equals 2, the center point of the binary edge map is determined, the target edge segment is determined based on the N intersection points, and the fourth and fifth intersection points are determined based on the target edge segment and the center point of the binary edge map. Two intersection points out of the N intersection points, the fourth intersection point, and the fifth intersection point are determined as the target intersection point combination in the first intersection point combination.

[0130] Specifically, when N equals 2, the remaining two points forming the quadrilateral can be determined based on two points, since any two points can always form a rectangle. However, considering that in most cases, three straight lines intersect at two points in the image, and the lines containing these two points are usually the edges of the target region, and these two points are usually the vertices of the target region's edge, the line segment connecting these two points can be used as the edge, and the remaining two points can be calculated accordingly. Based on the determined two points, it can be inferred that the extension direction of the remaining two points should point towards the center of the binary edge map, so the center of the binary edge map needs to be determined first. In the calculation, let A(x0,y0), B(x1,y1), C(x2,y2), and D(x3,y3), that is, points A and B are known, and C and D are to be found. When finding point C, according to the properties of vectors:

[0131]

[0132]

[0133] Where L is a known quantity, i.e., a pre-defined extension length. Based on the above two properties, the following relationship is derived:

[0134]

[0135]

[0136] These two equations yield two sets of solutions, points C and C'. Similarly, two sets of solutions can be obtained when calculating D. Since the extension direction should point towards the center, it is necessary to exclude another solution, i.e., retain the solution closer to the center coordinates. For example, after obtaining two sets of solutions (C and C'), calculate the distance from each point to the center coordinates O(width / 2, height / 2) of the binary edge map, denoted as... and ,when > At this point, point C is the correct solution, and similarly, the correct solution for point D can be found using the same method. After determining the remaining two points, the four points at this point can be considered as the target intersection point combination.

[0137] Step S207: When N is less than or equal to 1, four default intersection points are determined based on the side length of the binary edge map and the preset ratio threshold, and the four default intersection points are determined as the target intersection point combination in the first intersection point combination.

[0138] Specifically, when the number of determined N values ​​is less than or equal to 1 (i.e., N equals 1 or 0), intersection point correction is required for the first intersection point combination. Although this situation is rare, it still needs to be considered. Optionally, based on the side length of the binary edge map and a preset scale threshold, four default intersection points are determined, and these four default intersection points are selected as the target intersection point combination in the first intersection point combination. During intersection point correction, default keypoints are directly provided, and the results are returned. For example, based on the side length of the binary edge map and the preset scale threshold, four intersection points (width*0.1, height*0.1), (width*0.9, height*0.1), (width*0.1, height*0.9), and (width*0.9, height*0.9) can be returned, and these four default intersection points can be selected as the target intersection point combination.

[0139] Optionally, the above target intersection point combination can also be determined based on Harris corner detection. In this case, it is not necessary to use line detection to detect lines and then determine the target intersection point combination through the intersection of the lines. This is because in some abnormal cases, if the target neural network model detects many broken parts at the edge of the target area, that is, the continuity of the line segments is not high, the lines obtained by line detection alone may be ineffective. Therefore, in this case, Harris corner detection can be used to determine the target intersection point combination.

[0140] Step S208: Determine the edge of the target region of the image to be processed based on the combination of target intersection points, and return the processing result.

[0141] The specific implementation process of step S208 can be found in the above. Figure 2a The description of step S105 in the corresponding embodiment will not be repeated here.

[0142] In this application, after outputting a binary edge map through a target neural network, target line combinations can be detected through line detection. The first intersection point combination is determined based on the intersection points of these target line combinations. Different processing methods are then determined based on the number of intersection points in the first intersection point combination. The problem of determining target intersection point combinations is solved using the structural feature rules of quadrilaterals, such as proposing the concepts of angle probability value, area probability value, and edge probability value. These methods are used to judge the rationality of quadrilaterals, selecting the optimal target intersection point combination, and thus determining the target region edge with higher accuracy. Furthermore, in handling abnormal cases, methods such as using default points and speculating on the third and fourth points are considered to correct the intersection points, which can improve the overall accuracy and visual effect of the solution.

[0143] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of an image processing device provided in an embodiment of the present invention, as shown below. Figure 6 As shown, the image processing device may include: an acquisition module 101, an output module 102, a detection module 103, a first determination module 104, and a second determination module 105;

[0144] The acquisition module 101 is used to acquire the image to be processed, which includes a first processing area and a second processing area.

[0145] Output module 102 is used to output a binary edge map of the image to be processed based on the target neural network model, wherein the target neural network is trained based on the sample map synthesized from the first processing region and the second processing region;

[0146] Detection module 103 is used to perform line detection based on binary edge map to detect line combinations in binary edge map, and to merge repeated lines in line combinations to output target line combinations in binary edge map;

[0147] The first determining module 104 is used to determine the first intersection point combination of any two lines in the target line combination in the binary edge map, and to determine the target intersection point combination in the first intersection point combination based on the structural feature rules of quadrilaterals.

[0148] The second determining module 105 is used to determine the edge of the target region of the image to be processed based on the combination of target intersection points and return the processing result.

[0149] For details on the specific functional implementation of the acquisition module 101, output module 102, detection module 103, first determination module 104, and second determination module 105, please refer to [link to relevant documentation]. Figure 2a Steps S101-S105 in the corresponding embodiments will not be described again here.

[0150] Please see Figure 7 This is a schematic diagram of the structure of another electronic device provided in an embodiment of the present invention. Figure 7 As shown, the electronic device 1000 may include a processor 1001, a network interface 1004, and a memory 1005. Furthermore, the electronic device 1000 may also include a user interface 1003 and at least one communication bus 1002. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as at least one disk storage device. Optionally, the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001. Figure 7 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a device control application program.

[0151] exist Figure 7 In the electronic device 1000 shown, the network interface 1004 provides network communication functions; the user interface 1003 is mainly used to provide an input interface for users; and the processor 1001 can be used to call the device control application stored in the memory 1005.

[0152] It should be understood that the electronic device 1000 described in the embodiments of the present invention can perform the foregoing text. Figure 2a , Figure 3 The description of the image processing method in any of the corresponding embodiments can also be performed as described above. Figure 6 The description of the image processing apparatus in the corresponding embodiments will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated.

[0153] Furthermore, it should be noted that this embodiment of the invention also provides a computer-readable storage medium storing a computer program executed by the aforementioned image processing apparatus, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the aforementioned... Figure 2a , Figure 3 The description of the data operation method in any corresponding embodiment is already provided, and therefore will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the embodiments of the computer storage medium involved in this invention, please refer to the description of the method embodiments of this invention.

[0154] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0155] The above description is merely a preferred embodiment of the present invention and should not be construed as limiting the scope of the invention. Therefore, any equivalent variations made in accordance with the claims of the present invention are still within the scope of the present invention.

Claims

1. An image processing method, characterized in that, include: Acquire an image to be processed, the image to be processed comprising a first processing region and a second processing region; The target neural network model outputs a binary edge map of the image to be processed, wherein the target neural network is trained based on a sample map synthesized from the first processing region and the second processing region; Line detection is performed on the binary edge map based on polar coordinate Hough transform to detect line combinations in the binary edge map, and repeated line merging is performed on the line combinations to output the target line combination in the binary edge map. Determine the first intersection point combination of any two lines in the target line combination in the binary edge graph, and determine the target intersection point combination in the first intersection point combination based on the structural feature rules of quadrilaterals; The target region edge of the image to be processed is determined based on the target intersection point combination, and the processing result is returned; The method for determining the target intersection combination in the first intersection combination based on the quadrilateral structural feature rule includes: Determine the number N of intersection points in the first intersection point combination, where N is a positive integer greater than or equal to 0; When N is greater than or equal to 1, M suspicious quadrilateral intersection point combinations are determined based on the N intersection points in the first intersection point combination, where M is a positive integer greater than or equal to 0; Based on the structural feature rules of quadrilaterals, reasonable values ​​are calculated for the suspected quadrilaterals identified in the M suspected quadrilateral intersection point combinations. The four intersection points of the quadrilateral with the highest reasonable value that is greater than the preset reasonable value threshold are determined as the target intersection point combination. The structural feature rules of quadrilaterals include the quadrilateral side length rules, the quadrilateral angle rules, and the quadrilateral edge rules. The formula for calculating the reasonable value is as follows: P=λ×P θ +αP s +βP A ; Among them, P θ P represents the angle probability value. s P represents the area probability value. A This represents the marginal probability value, and the above three coefficients satisfy: λ + α + β = 1; The quadrilateral-based structural feature rules calculate reasonable values ​​for the suspicious quadrilaterals identified in the M suspicious quadrilateral intersection point combinations. The four intersection points of the quadrilateral with the highest reasonable value (greater than a preset reasonable value threshold) are then identified as target intersection point combinations, including: When N equals 3, a target triangle is determined based on the N intersection points, and the first intersection point with the largest angle value is determined based on the target triangle; Based on the first intersection point and the parallelogram rule, the second intersection point diagonally opposite the first intersection point is determined, and the three intersection points in the target triangle and the second intersection point are determined as the target intersection point combination.

2. The image processing method according to claim 1, characterized in that, The first processing region is the foreground image in the image to be processed, the second processing region is the background image in the image to be processed, and before outputting the binary edge map of the image to be processed based on the target neural network model, the method further includes: Obtain the set of foreground images and the set of background images, and synthesize any foreground image from the set of foreground images and any background image from the set of background images to obtain training sample images. The target neural network model is trained using the training sample images.

3. The image processing method according to claim 1, characterized in that, The step of outputting the binary edge map of the image to be processed based on the target neural network model includes: The target neural network model is used to perform n operations on the image to be processed. The first n-1 operations include multiple convolutions and activations and one pooling operation. The nth operation includes multiple convolutions and activations. The input of the first operation is the image to be processed, and the input of the next operation is the output of the previous operation. Extract a set of matrices obtained from the last convolution and activation in each operation; Perform transpose convolution on each of the n sets of matrices, where the images corresponding to the n sets of matrices after transpose convolution have the same size; The n sets of matrices after transpose and convolution are concatenated and then convolved to output the binary edge map of the image to be processed.

4. The image processing method according to claim 1, characterized in that, The step of repeatedly merging the line combinations to output the target line combination in the binary edge map includes: After performing line detection on the binary edge map, the detected line combinations are subjected to polar coordinate Hough transform to determine the difference in angle and radius between any two lines in the line combination. Determine preset angle thresholds and radius thresholds, and merge any two lines in the line combination whose angle difference is less than or equal to the angle threshold, and merge any two lines in the line combination whose radius difference is less than or equal to the radius threshold into a single line. Output the target line combination after repeating and merging the given line combination.

5. The image processing method according to claim 1 or 2, characterized in that, The binary edge map includes a third processing region and a fourth processing region, wherein the third processing region is the foreground image of the binary edge map, and the fourth processing region is the background image of the binary edge map. Determining the first intersection point combination of any two lines in the target line combination within the binary edge map includes: Based on any two lines in the target line combination, a second intersection point combination is determined in the binary edge map, wherein the intersection points in the second intersection point combination are located in the third processing region and the fourth processing region in the binary edge map; The intersection points in the first intersection point combination located in the fourth processing region of the binary edge map are excluded to determine the third intersection point combination of any two lines in the target line combination in the third processing region of the binary edge map. Intersections in the third intersection point combination whose distance is less than or equal to a preset distance threshold are merged into one intersection point to determine the first intersection point combination of any two lines in the target line combination in the binary edge graph.

6. The method according to claim 1, characterized in that, The quadrilateral-based structural feature rules calculate reasonable values ​​for the suspicious quadrilaterals identified in the M suspicious quadrilateral intersection point combinations, and determine the four intersection points of the quadrilateral with the highest reasonable value (greater than a preset reasonable value threshold) as the target intersection point combinations. This also includes: When N equals 2, the position of the center point of the binary edge map is determined; The target edge segment is determined based on the N intersection points, and the fourth and fifth intersection points are determined based on the target edge segment and the center point position of the binary edge map. Two of the N intersection points, along with the fourth and fifth intersection points, are determined as the target intersection point combination in the first intersection point combination.

7. The method according to claim 1, characterized in that, The method for determining the target intersection point combination in the first intersection point combination based on the quadrilateral structural feature rules further includes: When N is less than or equal to 1, four default intersection points are determined based on the side length of the binary edge map and a preset ratio threshold, and the four default intersection points are determined as the target intersection point combination in the first intersection point combination.

8. An image processing apparatus, characterized in that, include: The acquisition module is used to acquire an image to be processed, the image to be processed including a first processing region and a second processing region; The output module is used to output a binary edge map of the image to be processed based on the target neural network model, wherein the target neural network is trained based on a sample map synthesized from the first processing region and the second processing region; The detection module is used to perform line detection on the binary edge map based on polar coordinate Hough transform to detect line combinations in the binary edge map, and to perform repeated line merging on the line combinations to output the target line combination in the binary edge map. The first determining module is used to determine the first intersection point combination of any two lines in the target line combination in the binary edge graph, and to determine the target intersection point combination in the first intersection point combination based on the structural feature rules of quadrilaterals; The second determining module is used to determine the edge of the target region of the image to be processed based on the combination of target intersection points, and return the processing result; The first determining module is specifically used for: Determine the number N of intersection points in the first intersection point combination, where N is a positive integer greater than or equal to 0; When N is greater than or equal to 1, M suspicious quadrilateral intersection point combinations are determined based on the N intersection points in the first intersection point combination, where M is a positive integer greater than or equal to 0; Based on the structural feature rules of quadrilaterals, reasonable values ​​are calculated for the suspected quadrilaterals identified in the M suspected quadrilateral intersection point combinations. The four intersection points of the quadrilateral with the highest reasonable value that is greater than the preset reasonable value threshold are determined as the target intersection point combination. The structural feature rules of quadrilaterals include the quadrilateral side length rules, the quadrilateral angle rules, and the quadrilateral edge rules. The formula for calculating the reasonable value is as follows: P=λ×P θ +αP s +βP A ; Among them, P θ P represents the angle probability value. s P represents the area probability value. A This represents the marginal probability value, and the above three coefficients satisfy: λ + α + β = 1; The quadrilateral-based structural feature rules calculate reasonable values ​​for the suspicious quadrilaterals identified in the M suspicious quadrilateral intersection point combinations. The four intersection points of the quadrilateral with the highest reasonable value (greater than a preset reasonable value threshold) are then identified as target intersection point combinations, including: When N equals 3, a target triangle is determined based on the N intersection points, and the first intersection point with the largest angle value is determined based on the target triangle; Based on the first intersection point and the parallelogram rule, the second intersection point diagonally opposite the first intersection point is determined, and the three intersection points in the target triangle and the second intersection point are determined as the target intersection point combination.

9. An electronic device, characterized in that, It includes a memory, a processor, and a computer program; wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor of the electronic device, the electronic device performs the steps of the method according to any one of claims 1-7.