Image processing method and device
By corroding and dilating the connected domain and using matching convolution kernels to segment the text adhesion areas, the problem of paragraph text adhesion in OCR technology is solved, and the segmentation performance and neatness of layout analysis are improved.
Patent Information
- Application Number
- CN202211426312.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-11-15
AI Technical Summary
Existing OCR technology has the problem of text adhesion between different paragraphs when analyzing layout, resulting in poor segmentation performance.
By determining whether the connected domain meets certain conditions, corroding and dilating the connected domain that meets the conditions, and using convolution kernels of matching sizes to split the connected domain, an independent second or third connected domain is obtained to solve the text adhesion problem.
It improves the segmentation performance and neatness of layout analysis, effectively solves the problem of text adhesion, and improves the segmentation effect of image processing.
Smart Images

Figure CN118097700B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an image processing method and device. Background Art
[0002] Computer text recognition, also known as optical character recognition (OCR), involves extracting text from images and converting it into text for easier reading. Currently, OCR technology involves layout analysis, which involves breaking text into paragraphs. However, due to the diversity and complexity of real-world documents, current OCR technology still suffers from the problem of text from different paragraphs clogging up when performing layout analysis. Summary of the Invention
[0003] The present application provides an image processing method and device, which can solve the problem of text adhesion between paragraphs in an image, thereby improving the segmentation performance of layout analysis.
[0004] In a first aspect, an image processing method is provided, comprising: determining whether a first connected domain satisfies a first condition, the first condition comprising at least one of the following: a size of the first connected domain is greater than or equal to a first threshold, a shortest side of a circumscribed rectangle of the first connected domain is greater than or equal to a second threshold, and the first connected domain is a connected domain corresponding to a text region in a first image; and when the first connected domain satisfies the first condition, sequentially performing a first erosion process and a first dilation process on the first connected domain to obtain a plurality of second connected domains. It can be seen that the first connected domain corresponding to the text region in the first image satisfies the first condition, indicating that the first connected domain has a text adhesion problem. In this case, by sequentially performing the first erosion process and the first dilation process on the first connected domain, a plurality of second connected domains can be obtained. In other words, the first connected domain with text adhesion is segmented into a plurality of independent second connected domains, thereby resolving the text adhesion problem between the plurality of second connected domains. This can also be understood as resolving the text adhesion problem between paragraphs in the first image, thereby improving the segmentation performance of layout analysis.
[0005] Optionally, in combination with the first aspect, a first erosion process and a first dilation process are sequentially performed on the first connected domain to obtain multiple second connected domains, including: using the size of the first convolution kernel, performing the first erosion process and the first dilation process sequentially on the first connected domain to obtain multiple second connected domains, and the size of the first convolution kernel is determined according to the shortest side of the circumscribed rectangle of the first connected domain. It can be seen that the size of the first convolution kernel is determined according to the shortest side of the circumscribed rectangle of the first connected domain, that is, the size of the convolution kernel matches the situation of the current connected domain, which makes it possible to better segment out multiple independent second connected domains when the size of the first convolution kernel is used to sequentially perform the first erosion process and the first dilation process on the first connected domain, thereby solving the problem of text adhesion between the multiple second connected domains and improving the segmentation performance of layout analysis.
[0006] Optionally, in combination with the first aspect, the size of the first convolution kernel is (M, N / M) or (N / M, M), where M is determined based on the pixel size occupied by the text in the text area in the first image, and N is the shortest side of the circumscribed rectangle of the first connected domain. It can be seen that the size of the first convolution kernel is (M, N / M) or (N / M, M), where M is determined based on the pixel size occupied by the text in the text area in the first image, and N is the shortest side of the circumscribed rectangle of the first connected domain. This allows for better segmentation of multiple independent second connected domains when the first convolution kernel size is used to perform the first corrosion processing and the first dilation processing on the first connected domain in sequence, thereby solving the problem of text adhesion between multiple second connected domains and improving the segmentation performance of layout analysis.
[0007] Optionally, in combination with the first aspect, the method further includes: determining whether there is a connected domain that satisfies a second condition among the multiple second connected domains, the second condition including at least one of the following: the size of the second connected domain is greater than or equal to the first threshold, and the shortest side of the circumscribed rectangle of the second connected domain is greater than or equal to the second threshold; when a connected domain that satisfies the second condition exists among the multiple second connected domains, sequentially performing a second erosion process and a second dilation process on the connected domains that satisfy the second condition among the multiple second connected domains to obtain multiple third connected domains. It can be seen that the presence of a connected domain that satisfies the second condition among the multiple second connected domains indicates that there are connected domains with text adhesion among the multiple second connected domains. At this time, by sequentially performing a second erosion process and a second dilation process on the connected domains that satisfy the second condition among the multiple second connected domains, multiple third connected domains can be obtained. In other words, the second connected domain with text adhesion is divided into multiple independent third connected domains, which solves the problem of text adhesion between the multiple third connected domains and improves the segmentation performance of layout analysis.
[0008] Optionally, in combination with the first aspect, a second erosion process and a second dilation process are sequentially performed on the connected domains that meet the second condition in the multiple second connected domains to obtain multiple third connected domains, including: using the size of the second convolution kernel, sequentially performing the second erosion process and the second dilation process on the connected domains that meet the second condition in the multiple second connected domains to obtain multiple third connected domains, and the size of the second convolution kernel is determined according to the shortest side of the circumscribed rectangle of the connected domain that meets the second condition in the multiple second connected domains. It can be seen that the size of the second convolution kernel is determined according to the shortest side of the circumscribed rectangle of the connected domain that meets the second condition in the multiple second connected domains, that is, the size of the convolution kernel matches the situation of the current connected domain, which makes it possible to better segment multiple independent third connected domains when using the size of the second convolution kernel to sequentially perform the second erosion process and the second dilation process on the connected domains that meet the second condition in the multiple second connected domains, thereby solving the problem of text adhesion between the multiple third connected domains and improving the segmentation performance of layout analysis.
[0009] Optionally, in combination with the first aspect, the size of the second convolution kernel is (K / M, M) or (M, K / M), the shortest side of the circumscribed rectangle of the connected domain that meets the second condition in the K multiple second connected domains, and M is determined according to the pixel size occupied by the text area in the first image. It can be seen that the size of the second convolution kernel is (K / M, M) or (M, K / M), and the shortest side of the circumscribed rectangle of the connected domain that meets the second condition in the K multiple second connected domains, and M is determined according to the pixel size occupied by the text area in the first image. This makes it possible to better segment out multiple independent third connected domains when the second convolution kernel size is used to perform the second corrosion process and the second dilation process on the connected domains that meet the second condition in the multiple second connected domains in sequence, thereby solving the problem of text adhesion between the multiple third connected domains and improving the segmentation performance of layout analysis.
[0010] Optionally, in combination with the first aspect, the method further includes: determining whether there is a connected domain satisfying a third condition among the multiple third connected domains, the third condition being that the size of the third connected domain is greater than or equal to a third threshold; when there is a connected domain satisfying the third condition among the multiple third connected domains, obtaining the position of the connected domain satisfying the third condition among the multiple third connected domains; determining whether the connected domain satisfying the third condition among the multiple third connected domains exceeds the boundary point of the first image based on the position of the connected domain satisfying the third condition among the multiple third connected domains; when the connected domain satisfying the third condition among the multiple third connected domains exceeds the boundary point of the first image, removing the area exceeding the boundary point of the first image for the connected domain satisfying the third condition among the multiple third connected domains. It can be seen that there are connected domains satisfying the third condition among the multiple third connected domains, which indicates that there are connected domains without text adhesion problems among the multiple third connected domains. At this time, through the positions of the connected domains satisfying the third condition among the multiple third connected domains, it can be determined whether the connected domains satisfying the third condition among the multiple third connected domains exceed the boundary points of the first image according to the positions of the connected domains satisfying the third condition among the multiple third connected domains. Furthermore, when the connected domains satisfying the third condition among the multiple third connected domains exceed the boundary points of the first image, the areas exceeding the boundary points of the first image can be removed for the connected domains satisfying the third condition among the multiple third connected domains. This can improve the segmentation neatness of the layout analysis.
[0011] Optionally, in combination with the first aspect, the method further includes: when no connected domain satisfies the second condition among the plurality of second connected domains, determining whether a connected domain satisfies a fourth condition among the plurality of second connected domains, the fourth condition being that the size of the second connected domain is greater than or equal to a third threshold; when a connected domain satisfies the fourth condition among the plurality of second connected domains, obtaining the position of the connected domain that satisfies the fourth condition among the plurality of second connected domains; determining whether the connected domain that satisfies the fourth condition among the plurality of second connected domains exceeds a boundary point of the first image based on the position of the connected domain that satisfies the fourth condition among the plurality of second connected domains; when a connected domain that satisfies the fourth condition among the plurality of second connected domains exceeds a boundary point of the first image, removing the area that exceeds the boundary point of the first image for the connected domain that satisfies the fourth condition among the plurality of second connected domains. It can be seen that when no connected domain satisfies the second condition among the plurality of second connected domains, it can be determined whether a connected domain that satisfies the fourth condition among the plurality of second connected domains exists. When a connected domain that satisfies the fourth condition among the plurality of second connected domains exists, this indicates that there is no text adhesion problem within these second connected domains. Furthermore, based on the position of the connected domain that meets the fourth condition in the multiple second connected domains, it can be determined whether the connected domain that meets the fourth condition in the multiple second connected domains exceeds the boundary point of the first image. Then, when the connected domain that meets the fourth condition in the multiple second connected domains exceeds the boundary point of the first image, the area that exceeds the boundary point of the first image can be removed for the connected domain that meets the fourth condition in the multiple second connected domains. This can improve the segmentation neatness of the layout analysis.
[0012] In a second aspect, an image processing apparatus is provided, the image processing apparatus comprising a module for executing the method as described in any one of the first aspects.
[0013] According to a third aspect, an image processing device is provided, comprising at least one processor and a communication interface, wherein the at least one processor is configured to call a computer program stored in at least one memory to execute a method as described in any one of the first aspects.
[0014] According to a fourth aspect, a communication system is provided, comprising an image processing device, wherein the image processing device is configured to implement the method as described in any one of the first aspects.
[0015] In a fifth aspect, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program runs on one or more processors, the method as described in any one of the first aspects is implemented.
[0016] According to a sixth aspect, a computer program product is provided. When the computer program product is run on one or more processors, it implements the method described in any one of the first aspects.
[0017] In the seventh aspect, a chip system is provided, comprising at least one processor, a memory and an interface circuit, wherein the interface circuit is used to provide information input / output for at least one processor, and a computer program is stored in the memory. When the computer program runs on one or more processors, the method described in any one of the first aspects is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The following is a brief introduction to the drawings required for describing the embodiments.
[0019] Figure 1 A flowchart of an image processing method provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of connected domains corresponding to various text regions in a first image provided in an embodiment of the present application;
[0021] Figure 3 A schematic diagram of performing corrosion processing on an image to be processed provided in an embodiment of the present application;
[0022] Figure 4 A schematic diagram of performing dilation processing on an image to be processed provided in an embodiment of the present application;
[0023] Figure 5 A schematic diagram of a transversely cut first connected domain provided in an embodiment of the present application;
[0024] Figure 6 A schematic diagram of a longitudinally cut first connected domain provided in an embodiment of the present application;
[0025] Figure 7 A schematic diagram of first cutting horizontally and then cutting vertically a connected domain provided in an embodiment of the present application;
[0026] Figure 8 A schematic diagram of first cutting vertically and then cutting horizontally a connected domain provided in an embodiment of the present application;
[0027] Figure 9 is a structural diagram of an image processing device 90 provided in an embodiment of the present application;
[0028] Figure 10 1 is a structural diagram of an image processing device 100 provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. In the embodiments of the present application, the terms "system" and "network" can be used interchangeably. Unless otherwise specified, " / " indicates that the objects associated before and after are in an "or" relationship. For example, A / B can represent A or B. "And / or" in this application is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, in the description of this application, unless otherwise specified, "multiple" refers to two or more than two. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be one or more. In addition, to facilitate a clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, terms such as "first" and "second" are used to distinguish between network elements and identical or similar items with substantially the same functions. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order, and terms such as "first" and "second" do not necessarily limit differences.
[0030] References to "one embodiment" or "some embodiments" in the embodiments of the present application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.
[0031] The following specific implementation methods further describe in detail the objectives, technical solutions and beneficial effects of the present application. It should be understood that the following are only specific implementation methods of the present application and are not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of the present application should be included in the scope of protection of the present application.
[0032] In the various embodiments of the present application, unless otherwise specified or there is a logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced by each other. The technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationships.
[0033] It should be understood that the image processing method provided in the embodiment of the present application can be applied to an image processing device, which can be, for example, a terminal device or a server, and is not limited here.
[0034] The terminal device may be, for example, a mobile phone, a tablet computer, a personal computer (PC), a laptop computer, a machine type communication (MTC) terminal, a handheld device with wireless communication capabilities, a computing device or other processing device connected to a wireless modem, an in-vehicle device, a wearable device (also referred to as a wearable smart device), a virtual reality (VR) terminal, an augmented reality (AR) terminal, etc. The terminal device may also be a wireless terminal used in self-driving, remote medical, smart grid, transportation safety, smart city, or smart home applications. The embodiments of the present application do not limit the specific device form of the terminal device.
[0035] The server mentioned in the embodiment of the present application can be a server or a server cluster composed of multiple servers. Specifically, the server can include a server that centrally stores state information, or a distributed server cluster that contains distributed storage state information. For example, a distributed server can be a server cluster composed of multiple servers, and the cluster can include cloud computing servers, content delivery network (CDN) servers, network time protocol (NTP), domain name resolution system (DNS) servers, etc. Among them, the various servers can coordinate with each other to jointly complete functions such as calculation, data storage, and communication. For the convenience of description, in the embodiment of the present application, a single server, a distributed server, and a server cluster are collectively referred to as a server.
[0036] The following uses the terminal device as an example to illustrate this solution. Figure 1 , Figure 1 A flowchart of an image processing method provided in an embodiment of the present application is provided, and the method includes but is not limited to the following steps:
[0037] 101. The terminal device determines whether a first connected domain satisfies a first condition, where the first condition includes at least one of the following: a size of the first connected domain is greater than or equal to a first threshold, a shortest side of a circumscribed rectangle of the first connected domain is greater than or equal to a second threshold, and the first connected domain is a connected domain corresponding to a text area in the first image.
[0038] In the present application, a connected domain refers to an image area composed of foreground pixels with the same pixel value and adjacent positions in the first image. Foreground pixels refer to pixels in the text area in the first image. The text area is composed of at least one row and / or at least one column of text, and the present application does not limit the specific form of the text. It should be noted that in the present application, the number of text areas in the first image can be, for example, one or more. When the number of text areas in the first image is one, the first connected domain is the connected domain corresponding to the text area; when the number of text areas in the first image is multiple, the first connected domain is the connected domain corresponding to any one of the multiple text areas. It should be understood that because there is a text adhesion problem between the connected domains corresponding to different text areas in the first image, the connected domain corresponding to at least one text area among the multiple text areas in the first image can be a connected domain. For example, see Figure 2 , Figure 2 This is a schematic diagram of a connected domain corresponding to each text area in a first image provided by an embodiment of the present application. Figure 2 As shown, the text regions in the first image 20 may include, for example, text regions 20a to 20g, and the connected domains corresponding to the text regions in the first image 20 may include, for example, connected domains 21a to 21e. Specifically, the connected domains corresponding to text regions 20a, 20b, and 20f are the same connected domain, namely, connected domain 21a. This indicates that there is a text adhesion problem between the connected domains corresponding to text region 20a, 20b, and 20f. The connected domains corresponding to text regions 20c to 20g are connected domain 21c, connected domain 21d, connected domain 21e, and connected domain 21b, respectively. In other words, the connected domains corresponding to these text regions are independent connected domains, indicating that there is no text adhesion problem between the connected domains corresponding to text regions 20c to 20g.
[0039] In one possible implementation, the connected domain corresponding to one or more text regions in the first image may be the connected domain after the terminal device sequentially performs the third erosion and third dilation processes. Alternatively, the connected domain corresponding to one or more text regions in the first image may be the connected domain after the terminal device sequentially performs the third erosion and third dilation processes using a third convolution kernel size. The size of the third convolution kernel may be predefined, for example, the size of the third convolution kernel may be (7,7).
[0040] In this application, erosion is a process of finding a local minimum. For example, when the image to be processed is convolved with a convolution kernel, in each convolution process, the minimum value in the area covered by the convolution kernel is assigned to the specified pixel point, and the effect is that the bright area of the image to be processed is reduced. The convolution kernel has a definable anchor point, which is usually the center point of the convolution kernel and also the specified pixel point. For example, see Figure 3 , Figure 3 This is a schematic diagram of an embodiment of the present application providing a method for performing corrosion processing on an image to be processed. Figure 3 As shown, in Figure 3 In the figure, A is the image to be processed, which consists of 5×5 pixels, where the shadow part represents the bright spot. Figure 3 The shaded area in B is the convolution kernel, which has 5 pixels in total. The anchor point is the center of these 5 pixels, which is the pixel in the second row and second column in B. C is the image after corrosion processing. Figure 3 The “*” in the figure indicates convolution. That is, the image to be processed is convolved with the convolution kernel to obtain the image after erosion.
[0041] In this application, dilation is a process of finding a local maximum. For example, when the image to be processed is convolved with a convolution kernel, in each convolution process, the maximum value in the area covered by the convolution kernel is assigned to a designated pixel, thereby making the brighter ones brighter. The result is that the bright area of the image to be processed is expanded. The convolution kernel has a definable anchor point, which is usually the center point of the kernel and also the designated pixel. For example, see Figure 4 , Figure 4 This is a schematic diagram of an embodiment of the present application providing a method for dilating an image to be processed. Figure 4 As shown, in Figure 4 In the figure, A is the image to be processed, which consists of 5×5 pixels, where the shadows represent bright spots. Figure 4 The shaded area in B is the convolution kernel, which has 5 pixels in total. The anchor point is the center of these 5 pixels, which is the pixel in the second row and second column in B. C is the image after dilation. Figure 4 The “*” in the figure indicates convolution. That is, the image to be processed is convolved with the convolution kernel to obtain the expanded image.
[0042] It should be noted that the dilation process and the erosion process are not mutually inverse. In addition, the convolution kernels used in the erosion process and the dilation process are of the same size. Optionally, in this application, the erosion process followed by the dilation process may be referred to as an opening operation.
[0043] Optionally, the first image may also include a table area and / or a picture area, the table area is composed of at least one row and / or at least one column of a table, and the picture area is composed of at least one picture. The resolution of the first image may be, for example, 960*960, and of course it may be other resolutions. The present application does not limit the size of the first image. It should be understood that the image resolution can be used to reflect the amount of information stored in the image, and refers to the total number of pixels in the image. The image resolution is usually expressed as the number of horizontal pixels * the number of vertical pixels. If the resolution of the first image is 960*960, that is, the number of horizontal pixels of the first image is 960, and the number of vertical pixels is also 960.
[0044] Optionally, the first image can be an image that meets the version analysis requirements. The version analysis requirements may include, for example, the image type, such as a book image or a paper image. In this application, image types do not include screenshot images. In one possible implementation, the terminal device may input the image to be classified into a scene classification model to obtain the first image that meets the version analysis requirements.
[0045] It should be noted that in the present application, the first threshold value may be, for example, predefined, or it may be a threshold value determined by the terminal device based on the resolution of the first image. For example, the first threshold value may be 10,000 pixels. Similarly, the second threshold value may be, for example, predefined, or it may be a threshold value determined by the terminal device based on the shortest side of the bounding rectangle of the connected domain corresponding to different text areas in the first image. Optionally, the second threshold value may be, for example, the average value, minimum value, maximum value or median of the shortest side of the bounding rectangle of the connected domain corresponding to different text areas in the first image, which is not limited here. For example, the second threshold value may be 100 pixels.
[0046] 102. When the first connected domain meets the first condition, the terminal device sequentially performs a first corrosion process and a first expansion process on the first connected domain to obtain a plurality of second connected domains.
[0047] Optionally, step 102 may include, for example: the terminal device uses the size of the first convolution kernel to perform a first corrosion process and a first dilation process on the first connected domain in sequence to obtain multiple second connected domains, and the size of the first convolution kernel is determined according to the shortest side of the circumscribed rectangle of the first connected domain. It can be seen that the size of the first convolution kernel is determined according to the shortest side of the circumscribed rectangle of the first connected domain, that is, the size of the convolution kernel matches the situation of the current connected domain, which makes it possible to better segment multiple independent second connected domains when the size of the first convolution kernel is used to perform the first corrosion process and the first dilation process on the first connected domain in sequence, thereby solving the problem of text adhesion between the multiple second connected domains and improving the segmentation performance of the layout analysis.
[0048] In the present application, the size of the first convolution kernel can be, for example, any of the following, and the specific one may depend on the solution implementation, protocol definition, etc.
[0049] The first type, the size of the first convolution kernel is (M, N / M). This indicates that the terminal device uses the size of the first convolution kernel to horizontally cut the first connected domain. For example, see Figure 5 , Figure 5 This is a schematic diagram of a transversely cut first connected domain provided in an embodiment of the present application. Figure 5 As shown, the first connected domain 50 is horizontally divided into a second connected domain 51 and a second connected domain 52, that is, the area selected by the dotted line in the first connected domain 50 is divided, so that the first connected domain 50 is divided into the second connected domain 51 and the second connected domain 52.
[0050] The second type is that the size of the first convolution kernel is (N / M, M). This indicates that the terminal device uses the size of the first convolution kernel to vertically cut the first connected domain. For example, see Figure 6 , Figure 6 This is a schematic diagram of a longitudinally cut first connected domain provided in an embodiment of the present application. Figure 6 As shown, the first connected domain 60 is longitudinally divided into a second connected domain 61 and a second connected domain 62 , that is, the area selected by the dotted line in the first connected domain 60 is divided, so that the first connected domain 60 is divided into the second connected domain 61 and the second connected domain 62 .
[0051] In the present application, M is determined based on the pixel size occupied by the text in the text area in the first image, and N is the shortest side of the circumscribed rectangle of the first connected domain. For example, M can be the average, minimum, maximum, or median of the pixel sizes of the text with the smallest pixel size across multiple text areas in the first image determined by the terminal device. For another example, M can be the pixel size of the text with the smallest pixel size across any text area in the first image determined by the terminal device.
[0052] It can be seen that the first connected domain corresponding to the text area in the first image meets the first condition, which indicates that there is a text adhesion problem in the first connected domain. At this time, by performing the first corrosion process and the first expansion process on the first connected domain in sequence, multiple second connected domains can be obtained. In other words, the first connected domain with text adhesion is divided into multiple independent second connected domains, which solves the text adhesion problem between multiple second connected domains. It can also be understood that the text adhesion problem between paragraphs in the first image is solved, thereby improving the segmentation performance of layout analysis.
[0053] Optionally, the method may further include: the terminal device determining whether there is a connected domain that satisfies a second condition among the multiple second connected domains, the second condition including at least one of the following: the size of the second connected domain is greater than or equal to the first threshold, and the shortest side of the circumscribed rectangle of the second connected domain is greater than or equal to the second threshold; when a connected domain that satisfies the second condition exists among the multiple second connected domains, the terminal device sequentially performs a second erosion process and a second dilation process on the connected domains that satisfy the second condition among the multiple second connected domains to obtain multiple third connected domains. It can be seen that the presence of a connected domain that satisfies the second condition among the multiple second connected domains indicates that there are connected domains with text adhesion among the multiple second connected domains. At this time, by sequentially performing the second erosion process and the second dilation process on the connected domains that satisfy the second condition among the multiple second connected domains, multiple third connected domains can be obtained. In other words, the second connected domain with text adhesion is divided into multiple independent third connected domains, which solves the problem of text adhesion between the multiple third connected domains and improves the segmentation performance of the layout analysis.
[0054] The terminal device sequentially performs a second erosion process and a second dilation process on the connected domains satisfying the second condition in the plurality of second connected domains to obtain a plurality of third connected domains. For example, the method may include: the terminal device sequentially performs a second erosion process and a second dilation process on the connected domains satisfying the second condition in the plurality of second connected domains using the size of the second convolution kernel to obtain the plurality of third connected domains, and the size of the second convolution kernel is determined according to the shortest side of the circumscribed rectangle of the connected domains satisfying the second condition in the plurality of second connected domains. It can be seen that the size of the second convolution kernel is determined according to the shortest side of the circumscribed rectangle of the connected domains satisfying the second condition in the plurality of second connected domains. In other words, the size of the convolution kernel matches the situation of the current connected domain. This enables, when the size of the second convolution kernel is used to sequentially perform a second erosion process and a second dilation process on the connected domains satisfying the second condition in the plurality of second connected domains, to better segment the plurality of independent third connected domains, thereby resolving the problem of text adhesion between the plurality of third connected domains and improving the segmentation performance of the layout analysis.
[0055] In the present application, the size of the second convolution kernel can be, for example, any of the following, and the specific one may depend on the solution implementation, protocol definition, etc.
[0056] The sizes of the first and second convolution kernels are (K / M, M). It should be noted that when the size of the first convolution kernel is (M, N / M), the size of the second convolution kernel is (K / M, M). This indicates that the terminal device uses the size of the first convolution kernel to first cut the first connected domain horizontally to obtain multiple second connected domains, and then uses the size of the second convolution kernel to cut the connected domains in the multiple second connected domains that meet the second condition vertically. For example, see Figure 7 , Figure 7This is a schematic diagram of a method of first cutting horizontally and then cutting vertically a connected domain according to an embodiment of the present application. Figure 7 As shown, the first connected domain 70 is divided horizontally into a second connected domain 71 and a second connected domain 72. That is, the area selected by the dotted line in the first connected domain 70 is divided, so that the first connected domain 70 is divided into the second connected domain 71 and the second connected domain 72. Furthermore, the connected domain that meets the second condition in the second connected domain 71 and the second connected domain 72 is the second connected domain 72, and the second connected domain 72 is divided vertically into a third connected domain 73 and a third connected domain 74. That is, the area selected by the dotted line in the second connected domain 72 is divided, so that the second connected domain 72 is divided into the third connected domain 73 and the third connected domain 74.
[0057] The second type is that the size of the second convolution kernel is (M, K / M). It should be noted that when the size of the first convolution kernel is (N / M, M), the size of the second convolution kernel is (M, K / M). This indicates that the terminal device uses the size of the first convolution kernel to first vertically cut the first connected domain to obtain multiple second connected domains, and then uses the size of the second convolution kernel to horizontally cut the connected domains in the multiple second connected domains that meet the second condition. For example, see Figure 8 , Figure 8 This is a schematic diagram of a method of first cutting vertically and then cutting horizontally a connected domain according to an embodiment of the present application. Figure 8 As shown, the first connected domain 80 is divided vertically into a second connected domain 81 and a second connected domain 82. That is, the area selected by the dotted line in the first connected domain 80 is divided, so that the first connected domain 80 is divided into the second connected domain 81 and the second connected domain 82. Furthermore, the connected domain that meets the second condition in the second connected domain 81 and the second connected domain 82 is the second connected domain 81, and the second connected domain 81 is divided horizontally into a third connected domain 83 and a third connected domain 84. That is, the area selected by the dotted line in the second connected domain 81 is divided, so that the second connected domain 81 is divided into the third connected domain 83 and the third connected domain 84.
[0058] Optionally, the method also includes: the terminal device determines whether there is a connected domain satisfying a third condition among the multiple third connected domains, and the third condition is that the size of the third connected domain is greater than or equal to a third threshold; when there is a connected domain satisfying the third condition among the multiple third connected domains, the terminal device obtains the position of the connected domain satisfying the third condition among the multiple third connected domains; the terminal device determines whether the connected domain satisfying the third condition among the multiple third connected domains exceeds the boundary point of the first image based on the position of the connected domain satisfying the third condition among the multiple third connected domains; when the connected domain satisfying the third condition among the multiple third connected domains exceeds the boundary point of the first image, the terminal device removes the area exceeding the boundary point of the first image for the connected domain satisfying the third condition among the multiple third connected domains. It can be seen that there are connected domains satisfying the third condition among the multiple third connected domains, which indicates that there are connected domains without text adhesion problems among the multiple third connected domains. At this time, through the positions of the connected domains satisfying the third condition among the multiple third connected domains, it can be determined whether the connected domains satisfying the third condition among the multiple third connected domains exceed the boundary points of the first image according to the positions of the connected domains satisfying the third condition among the multiple third connected domains. Furthermore, when the connected domains satisfying the third condition among the multiple third connected domains exceed the boundary points of the first image, the areas exceeding the boundary points of the first image can be removed for the connected domains satisfying the third condition among the multiple third connected domains. This can improve the segmentation neatness of the layout analysis.
[0059] It should be noted that, in the present application, the third threshold may be, for example, predefined, such as the third threshold may be, for example, 100 pixels.
[0060] The position of the connected domain that satisfies the third condition among the multiple third connected domains can be understood as one or more of the following: the coordinates of each vertex of the circumscribed rectangle of the connected domain that satisfies the third condition among the multiple third connected domains, or the coordinates of any pixel point on the side of the circumscribed rectangle, or the coordinates of the center point of the side of the circumscribed rectangle. The side of the circumscribed rectangle can be, for example, one or more of the left side, right side, top side, and bottom side of the circumscribed rectangle.
[0061] In a possible implementation, the method may further include: when no connected domain meets the third condition among the plurality of third connected domains, the terminal device discards the text regions corresponding to the plurality of third connected domains. This can remove connected domains that are too severely adhered.
[0062] Optionally, the method further includes: when no connected domain satisfies the second condition among the plurality of second connected domains, the terminal device determining whether a connected domain satisfies a fourth condition among the plurality of second connected domains, the fourth condition being that the size of the second connected domain is greater than or equal to a third threshold; when a connected domain satisfies the fourth condition among the plurality of second connected domains, the terminal device obtaining a location of the connected domain satisfying the fourth condition among the plurality of second connected domains; the terminal device determining whether the connected domain satisfying the fourth condition among the plurality of second connected domains exceeds a boundary point of the first image based on the location of the connected domain satisfying the fourth condition among the plurality of second connected domains; when a connected domain satisfying the fourth condition among the plurality of second connected domains exceeds a boundary point of the first image, the terminal device removes the area exceeding the boundary point of the first image for the connected domain satisfying the fourth condition among the plurality of second connected domains. It can be seen that when no connected domain satisfies the second condition among the plurality of second connected domains, it can be determined whether a connected domain satisfies the fourth condition among the plurality of second connected domains. When a connected domain satisfies the fourth condition among the plurality of second connected domains, this indicates that there is no text adhesion problem within these second connected domains. Furthermore, based on the position of the connected domain that meets the fourth condition in the multiple second connected domains, it can be determined whether the connected domain that meets the fourth condition in the multiple second connected domains exceeds the boundary point of the first image. Then, when the connected domain that meets the fourth condition in the multiple second connected domains exceeds the boundary point of the first image, the area that exceeds the boundary point of the first image can be removed for the connected domain that meets the fourth condition in the multiple second connected domains. This can improve the segmentation neatness of the layout analysis.
[0063] The position of the connected domain that satisfies the fourth condition among the plurality of second connected domains can be understood as, for example, one or more of the following: the coordinates of each vertex of the bounding rectangle of the connected domain that satisfies the fourth condition among the plurality of second connected domains, or the coordinates of any pixel point on the side of the bounding rectangle, or the coordinates of the center point on the side of the bounding rectangle. The side of the bounding rectangle can be, for example, one or more of the left side, right side, top side, and bottom side of the bounding rectangle.
[0064] In a possible implementation, the method may further include: when no connected domain meets the fourth condition among the plurality of second connected domains, the terminal device discards the text regions corresponding to the plurality of second connected domains. This can remove connected domains that are too severely congested.
[0065] It should be noted that, in one possible implementation, the image processing method provided in the embodiment of the present application can be implemented through a network model.
[0066] The above describes in detail the method of the embodiment of the present application, and the following provides an apparatus of the embodiment of the present application.
[0067] The embodiments of the present application also provide a device for implementing any of the above methods. For example, an image processing device is provided, which includes modules (or means) for implementing each step performed by the image processing device in any of the above methods.
[0068] For example, see Figure 9 , Figure 9 is a structural diagram of an image processing device 90 provided in an embodiment of the present application. The image processing device 90 includes a processing module 901, a sending module 902, and a receiving module 903. Figure 1 The method described in the embodiment shown.
[0069] It should be understood that the division of the modules in the above device is merely a division of logical functions. In actual implementation, they may be fully or partially integrated into a physical entity, or they may be physically separated. In addition, the modules in the device may be implemented in the form of a processor calling software; for example, the device includes a processor, the processor is connected to a memory, and the memory stores instructions. The processor calls the instructions stored in the memory to implement any of the above methods or to implement the functions of the modules of the device, wherein the processor is, for example, a general-purpose processor, such as a central processing unit (CPU) or a microprocessor, and the memory is a memory within the device or a memory outside the device. Alternatively, the modules in the device can be implemented in the form of hardware circuits, and the functions of some or all modules can be realized by designing the hardware circuits. The hardware circuit can be understood as one or more processors. For example, in one implementation, the hardware circuit is an application-specific integrated circuit (ASIC), which realizes the functions of some or all of the above modules by designing the logical relationship of the components in the circuit. For another example, in another implementation, the hardware circuit can be implemented by a programmable logic device (PLD). Taking a field programmable gate array (FPGA) as an example, it can include a large number of logic gate circuits, and the connection relationship between the logic gate circuits is configured by configuring the configuration file, thereby realizing the functions of some or all of the above modules. All modules of the above devices can be implemented in the form of software called by the processor, or in the form of hardware circuits, or in part by the form of software called by the processor, and the rest by hardware circuits.
[0070] In an embodiment of the present application, a processor is a circuit with a signal processing capability. In one implementation, the processor may be a circuit with instruction reading and execution capability, such as a central processing module, a microprocessor, a graphics processing unit (GPU) (which can be understood as a microprocessor), or a digital signal processor (DSP); in another implementation, the processor may implement certain functions through the logical relationship of a hardware circuit, and the logical relationship of the hardware circuit is fixed or reconfigurable, such as a hardware circuit implemented by an ASIC or PLD, such as an FPGA. In a reconfigurable hardware circuit, the process of the processor loading a configuration document and implementing the hardware circuit configuration can be understood as the process of the processor loading instructions to implement the functions of some or all of the above modules. In addition, it can also be a hardware circuit designed for artificial intelligence, which can be understood as an ASIC, such as a neural network processing unit (NPU), a tensor processing unit (TPU), a deep learning processing unit (DPU), etc.
[0071] It can be seen that each module in the above device can be one or more processors (or processing circuits) configured to implement the above method, such as: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.
[0072] In addition, the modules in the above device can be fully or partially integrated together, or can be implemented independently. In one implementation, these modules are integrated together and implemented in the form of a system-on-a-chip (SOC). The SOC may include at least one processor for implementing any of the above methods or implementing the functions of the modules of the device. The type of the at least one processor can be different, for example, including a CPU and FPGA, a CPU and an artificial intelligence processor, a CPU and a GPU, etc.
[0073] Regardless of whether these functional modules are subdivided or combined, the general process executed by the image processing device 90 is the same. For example, the receiving module 903 and the sending module 902 in the above-mentioned image processing device 90 can also be combined into a communication module. Usually, each module corresponds to its own program code (or program instruction). When the program code corresponding to each of these modules is run on the processor, the module executes the corresponding process to achieve the corresponding function. It should be noted that the implementation of each of the following modules can refer to Figure 1 The corresponding description of the illustrated embodiment.
[0074] In a possible implementation, the image processing device 90 may be Figure 1 The terminal device in the embodiment shown, or a module in the terminal device, such as a chip or an integrated circuit, includes a processing module 901 and a sending module 902, wherein each module is described as follows:
[0075] Processing module 901 is used to: determine whether a first connected domain meets a first condition, where the first condition includes at least one of the following: a size of the first connected domain is greater than or equal to a first threshold, the shortest side of a circumscribed rectangle of the first connected domain is greater than or equal to a second threshold, and the first connected domain is a connected domain corresponding to a text region in the first image; when the first connected domain meets the first condition, perform a first corrosion process and a first dilation process on the first connected domain in sequence to obtain a plurality of second connected domains.
[0076] Optionally, when the first connected domain is subjected to the first corrosion processing and the first dilation processing in sequence to obtain multiple second connected domains, the processing module 901 is used to use the size of the first convolution kernel to perform the first corrosion processing and the first dilation processing on the first connected domain in sequence to obtain multiple second connected domains, and the size of the first convolution kernel is determined according to the shortest side of the circumscribed rectangle of the first connected domain.
[0077] Optionally, the size of the first convolution kernel is (M, N / M) or (N / M, M), where M is determined according to the pixel size occupied by the text in the text area in the first image, and N is the shortest side of the circumscribed rectangle of the first connected domain.
[0078] Optionally, the processing module 901 is further used to: determine whether there is a connected domain that meets a second condition among the multiple second connected domains, where the second condition includes at least one of the following: the size of the second connected domain is greater than or equal to the first threshold, and the shortest side of the circumscribed rectangle of the second connected domain is greater than or equal to the second threshold; when there is a connected domain that meets the second condition among the multiple second connected domains, the connected domains that meet the second condition among the multiple second connected domains are sequentially subjected to a second corrosion process and a second expansion process to obtain multiple third connected domains.
[0079] Optionally, when performing the second corrosion process and the second dilation process in sequence on the connected domains that meet the second condition in multiple second connected domains to obtain multiple third connected domains, the processing module 901 is used to: use the size of the second convolution kernel to perform the second corrosion process and the second dilation process in sequence on the connected domains that meet the second condition in multiple second connected domains to obtain multiple third connected domains, and the size of the second convolution kernel is determined according to the shortest side of the circumscribed rectangle of the connected domain that meets the second condition in the multiple second connected domains.
[0080] Optionally, the size of the second convolution kernel is (K / M, M) or (M, K / M), where K is the shortest side of the circumscribed rectangle of the connected domain that meets the second condition in multiple second connected domains, and M is determined according to the pixel size occupied by the text area in the first image.
[0081] Optionally, the processing module 901 is further used to: determine whether there is a connected domain that meets a third condition among the multiple third connected domains, where the third condition is that the size of the third connected domain is greater than or equal to a third threshold; when there is a connected domain that meets the third condition among the multiple third connected domains, obtain the position of the connected domain that meets the third condition among the multiple third connected domains; determine whether the connected domain that meets the third condition among the multiple third connected domains exceeds the boundary point of the first image based on the position of the connected domain that meets the third condition among the multiple third connected domains; when the connected domain that meets the third condition among the multiple third connected domains exceeds the boundary point of the first image, remove the area that exceeds the boundary point of the first image for the connected domain that meets the third condition among the multiple third connected domains.
[0082] Optionally, the processing module 901 is further used to: when there is no connected domain satisfying the second condition among the multiple second connected domains, determine whether there is a connected domain satisfying the fourth condition among the multiple second connected domains, where the fourth condition is that the size of the second connected domain is greater than or equal to the third threshold; when there is a connected domain satisfying the fourth condition among the multiple second connected domains, obtain the position of the connected domain satisfying the fourth condition among the multiple second connected domains; determine whether the connected domain satisfying the fourth condition among the multiple second connected domains exceeds the boundary point of the first image based on the position of the connected domain satisfying the fourth condition among the multiple second connected domains; when the connected domain satisfying the fourth condition among the multiple second connected domains exceeds the boundary point of the first image, remove the area exceeding the boundary point of the first image for the connected domain satisfying the fourth condition among the multiple second connected domains.
[0083] See also Figure 10 , Figure 10 1 is a schematic diagram of the structure of an image processing device 100 provided in an embodiment of the present application. The image processing device 100 may include at least one memory 1001 and at least one processor 1002. Optionally, the device may also include a bus 1003. Further, the device may also optionally include a communication interface 1004. The memory 1001, the processor 1002, and the communication interface 1004 are connected via the bus 1003.
[0084] Memory 1001 is used to provide storage space for storing data such as an operating system and computer programs. Memory 1001 may be one or a combination of random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or compact disc read-only memory (CD-ROM).
[0085] The processor 1002 is a module that performs arithmetic operations and / or logical operations, and can specifically be one or a combination of processing modules such as a CPU, a GPU, a microprocessor unit (MPU), an ASIC, an FPGA, and a complex programmable logic device (CPLD).
[0086] The communication interface 1004 is used to receive data sent externally and / or send data externally, and can be a wired link interface such as an Ethernet cable, or a wireless link interface (Wi-Fi, Bluetooth, general wireless transmission, etc.). Optionally, the communication interface 1004 can also include a transmitter (such as a radio frequency transmitter, antenna, etc.) or a receiver coupled to the interface.
[0087] The processor 1002 in the image processing device 100 is used to read the computer program stored in the memory 1001 and to execute the aforementioned image processing method, for example Figure 1 The method described in the illustrated embodiment.
[0088] In some possible implementations, the image processing apparatus 100 may be Figure 1 The terminal device in the embodiment shown, or a module in the terminal device, such as a chip or an integrated circuit, etc. The processor 1002 in the image processing apparatus 100 is configured to read the computer program stored in the memory 1001 to perform the following operations:
[0089] Determine whether the first connected domain satisfies a first condition, where the first condition includes at least one of the following: a size of the first connected domain is greater than or equal to a first threshold, a shortest side of a circumscribed rectangle of the first connected domain is greater than or equal to a second threshold, and the first connected domain is a connected domain corresponding to a text region in the first image; when the first connected domain satisfies the first condition, perform a first erosion process and a first dilation process on the first connected domain in sequence to obtain a plurality of second connected domains.
[0090] Optionally, when performing the first erosion process and the first dilation process on the first connected domain in sequence to obtain multiple second connected domains, the processor 1002 is further used to perform the following operations: using the size of the first convolution kernel, performing the first erosion process and the first dilation process on the first connected domain in sequence to obtain multiple second connected domains, and the size of the first convolution kernel is determined according to the shortest side of the circumscribed rectangle of the first connected domain.
[0091] Optionally, the size of the first convolution kernel is (M, N / M) or (N / M, M), where M is determined according to the pixel size occupied by the text in the text area in the first image, and N is the shortest side of the circumscribed rectangle of the first connected domain.
[0092] Optionally, the processor 1002 is further used to perform the following operations: determine whether there is a connected domain that meets a second condition among the multiple second connected domains, where the second condition includes at least one of the following: the size of the second connected domain is greater than or equal to the first threshold, and the shortest side of the circumscribed rectangle of the second connected domain is greater than or equal to the second threshold; when there is a connected domain that meets the second condition among the multiple second connected domains, perform a second corrosion process and a second expansion process on the connected domains that meet the second condition among the multiple second connected domains in sequence to obtain multiple third connected domains.
[0093] Optionally, when performing the second corrosion process and the second dilation process in sequence on the connected domains that meet the second condition in multiple second connected domains to obtain multiple third connected domains, the processor 1002 is used to perform the following operations: using the size of the second convolution kernel, performing the second corrosion process and the second dilation process in sequence on the connected domains that meet the second condition in multiple second connected domains to obtain multiple third connected domains, and the size of the second convolution kernel is determined according to the shortest side of the circumscribed rectangle of the connected domain that meets the second condition in the multiple second connected domains.
[0094] Optionally, the size of the second convolution kernel is (K / M, M) or (M, K / M), where K is the shortest side of the circumscribed rectangle of the connected domain that meets the second condition in multiple second connected domains, and M is determined according to the pixel size occupied by the text area in the first image.
[0095] Optionally, the processor 1002 is further used to perform the following operations: determine whether there is a connected domain satisfying a third condition among the multiple third connected domains, where the third condition is that the size of the third connected domain is greater than or equal to a third threshold; when there is a connected domain satisfying the third condition among the multiple third connected domains, obtain the position of the connected domain satisfying the third condition among the multiple third connected domains; determine whether the connected domain satisfying the third condition among the multiple third connected domains exceeds the boundary point of the first image based on the position of the connected domain satisfying the third condition among the multiple third connected domains; when the connected domain satisfying the third condition among the multiple third connected domains exceeds the boundary point of the first image, remove the area exceeding the boundary point of the first image for the connected domain satisfying the third condition among the multiple third connected domains.
[0096] Optionally, the processor 1002 is further used to perform the following operations: when there is no connected domain satisfying the second condition among the multiple second connected domains, determine whether there is a connected domain satisfying the fourth condition among the multiple second connected domains, where the fourth condition is that the size of the second connected domain is greater than or equal to the third threshold; when there is a connected domain satisfying the fourth condition among the multiple second connected domains, obtain the position of the connected domain satisfying the fourth condition among the multiple second connected domains; based on the position of the connected domain satisfying the fourth condition among the multiple second connected domains, determine whether the connected domain satisfying the fourth condition among the multiple second connected domains exceeds the boundary point of the first image; when the connected domain satisfying the fourth condition among the multiple second connected domains exceeds the boundary point of the first image, remove the area exceeding the boundary point of the first image for the connected domain satisfying the fourth condition among the multiple second connected domains.
[0097] The embodiment of the present application provides a computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium. When the computer program is executed on one or more processors, the following is implemented: Figure 1 The method of any one of the embodiments shown.
[0098] The embodiment of the present application provides a computer program product, which, when running on one or more processors, implements the following Figure 1 The method of any one of the embodiments shown.
[0099] The embodiment of the present application provides a chip system, which includes at least one processor, a memory and an interface circuit. The interface circuit is used to provide information input / output for at least one processor. The memory stores a computer program. When the computer program is run on one or more processors, the following is implemented: Figure 1 The method of any one of the embodiments shown.
[0100] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the embodiments of the present application. In addition, the network element units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware or in the form of software network element units.
[0101] If the above-mentioned integrated unit is implemented in the form of a software network element unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the part that essentially contributes to the technical solution of the present application, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, an image processing device, a cloud server, or a network device, etc.) to perform all or part of the steps of the above-mentioned methods in each embodiment of the present application. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk. The above is only a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection of the claims.
Claims
1. An image processing method, characterized in that: include: determining whether the first connected domain satisfies a first condition, the first condition comprising at least one of the following: a size of the first connected domain is greater than or equal to a first threshold, a shortest side of a circumscribed rectangle of the first connected domain is greater than or equal to a second threshold, and the first connected domain is a connected domain corresponding to a text region in the first image; When the first connected domain satisfies the first condition, performing a first corrosion process and a first expansion process on the first connected domain in sequence to obtain a plurality of second connected domains; The first connected domain is subjected to a first corrosion process and a first expansion process in sequence to obtain a plurality of second connected domains, including: performing the first erosion process and the first dilation process on the first connected domain in sequence using the size of the first convolution kernel to obtain the plurality of second connected domains, wherein the size of the first convolution kernel is determined according to the shortest side of a circumscribed rectangle of the first connected domain; The size of the first convolution kernel is (M, N / M) or (N / M, M), where M is determined according to the pixel size occupied by the text in the text area in the first image, and N is the shortest side of the circumscribed rectangle of the first connected domain.
2. The method according to claim 1, characterized in that The method further comprises: determining whether there is a connected domain among the plurality of second connected domains that satisfies a second condition, where the second condition includes at least one of the following: a size of the second connected domain is greater than or equal to the first threshold, and a shortest side of a circumscribed rectangle of the second connected domain is greater than or equal to the second threshold; When there is a connected domain that meets the second condition among the plurality of second connected domains, the connected domains that meet the second condition among the plurality of second connected domains are sequentially subjected to a second corrosion process and a second expansion process to obtain a plurality of third connected domains.
3. The method according to claim 2, characterized in that The step of sequentially performing a second corrosion process and a second expansion process on the connected domains satisfying the second condition in the plurality of second connected domains to obtain a plurality of third connected domains comprises: Using the size of the second convolution kernel, the second erosion process and the second dilation process are sequentially performed on the connected domains that meet the second condition among the multiple second connected domains to obtain the multiple third connected domains. The size of the second convolution kernel is determined according to the shortest side of the circumscribed rectangle of the connected domain that meets the second condition among the multiple second connected domains.
4. The method according to claim 3, characterized in that The size of the second convolution kernel is (K / M, M) or (M, K / M), where K is the shortest side of the circumscribed rectangle of the connected domain among the multiple second connected domains that meets the second condition, and M is determined based on the pixel size occupied by the text area in the first image.
5. The method according to claim 2, characterized in that The method further comprises: determining whether there is a connected domain among the plurality of third connected domains that satisfies a third condition, wherein the third condition is that a size of the third connected domain is greater than or equal to a third threshold; When a connected domain that satisfies the third condition exists among the plurality of third connected domains, obtaining a position of the connected domain that satisfies the third condition among the plurality of third connected domains; determining, according to a position of a connected domain satisfying the third condition among the plurality of third connected domains, whether the connected domain satisfying the third condition among the plurality of third connected domains exceeds a boundary point of the first image; When a connected domain satisfying the third condition among the plurality of third connected domains exceeds a boundary point of the first image, for the connected domain satisfying the third condition among the plurality of third connected domains, an area exceeding the boundary point of the first image is removed.
6. The method according to claim 2, characterized in that The method further comprises: When no connected domain satisfies the second condition among the plurality of second connected domains, determining whether there is a connected domain satisfying a fourth condition among the plurality of second connected domains, the fourth condition being that a size of the second connected domain is greater than or equal to a third threshold; When a connected domain that satisfies the fourth condition exists among the plurality of second connected domains, obtaining a position of the connected domain that satisfies the fourth condition among the plurality of second connected domains; determining, according to a position of the connected domain that satisfies the fourth condition among the plurality of second connected domains, whether the connected domain that satisfies the fourth condition among the plurality of second connected domains exceeds a boundary point of the first image; When a connected domain satisfying the fourth condition among the plurality of second connected domains exceeds a boundary point of the first image, for the connected domain satisfying the fourth condition among the plurality of second connected domains, an area exceeding the boundary point of the first image is removed.
7. An image processing device, characterized in that: The image processing apparatus comprises a module for executing the method according to any one of claims 1 to 6.
8. An image processing device, characterized in that: The apparatus comprises at least one processor and a communication interface, wherein the at least one processor is configured to call a computer program stored in at least one memory to execute the method according to any one of claims 1 to 6.
9. A communication system, characterized in that: The apparatus comprises an image processing device, wherein the image processing device is configured to implement the method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is run on one or more processors, the method according to any one of claims 1 to 6 is implemented.
11. A computer program product, characterized in that When the computer program product is run on one or more processors, the computer program product implements the method according to any one of claims 1 to 6.
12. A chip system, characterized in that: The method comprises at least one processor, a memory and an interface circuit, wherein the interface circuit is used to provide information input / output for the at least one processor, and the memory stores a computer program, which implements the method according to any one of claims 1 to 6 when the computer program is executed on one or more processors.
Citation Information
Patent Citations
Statistical method, apparatus and system for the quantity of people
CN105844649A
Cotton detection, segmentation and counting method and system
CN113298768A
Text line segmentation method and device and computer readable storage medium
CN114842477A