Binarization threshold window calculation method, device, terminal equipment and medium

By binarizing the window image and analyzing the number of pixels in the white and black areas, a suitable binarization threshold window size is calculated, which solves the binarization distortion problem caused by inappropriate window size in the prior art, and improves the image binarization effect.

CN114170243BActive Publication Date: 2025-04-15KUNSHAN QIUTI PHOTOELECTRIC TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111402598.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-24
Publication Date
2025-04-15
Estimated Expiration
2041-11-24

AI Technical Summary

Technical Problem

In the prior art, when artificially defining a binarized threshold window, the window is prone to problems such that the window is too large or too small, resulting in distortion of the image binarization or poor effect.

Method used

By obtaining the window image, performing binarization processing to obtain the window binarization image, determining the number of pixels in the white and black areas, and calculating the size of the binarization threshold window to automatically determine the appropriate binarization window threshold.

Benefits of technology

Automatic determination and convenient calculation of binarization threshold windows are realized, which solves the problem of binarization distortion caused by inappropriate window size and improves the image binarization effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114170243B_ABST
    Figure CN114170243B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, terminal equipment and medium for calculating a binarization threshold window, wherein the method comprises: obtaining a window image; binarizing the window image to obtain a window binarization image, wherein the window binarization image comprises m white areas and n black areas; determining the number of pixels of each of the m white areas and the number of pixels of each of the n black areas; and calculating the size of the binarization threshold window according to the number of pixels of each of the m white areas and the number of pixels of each of the n black areas. The present invention can solve the technical problem of the window being too large or too small when the binarization threshold window is artificially defined in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a method, device, terminal equipment and medium for calculating a binary threshold window. Background Art

[0002] Image binarization refers to the process of setting the grayscale value of each pixel on the image to 0 or 255, that is, making the entire image appear in obvious black and white. When performing image binarization, the effect of image binarization mainly depends on the binarization threshold. The better the binarization threshold is selected, the more obvious the black and white effect of the image will be.

[0003] In the existing image binarization scheme, an adaptive binarization threshold is used to perform image binarization. Specifically, the average brightness of pixels within the window N*N is calculated with each pixel in the image as the center, and the center pixel is binarized with the average brightness as the binarization threshold. In practice, it is found that the size of the window N*N is manually defined, and there is a high possibility that the window is too large or too small. And if the window is too large, the binarization distortion is more serious; if the window is too small, the calculated binarization threshold of the center pixel is very close to the pixel value of the center pixel, and the black block of the image may become white block during the binarization process, and the image binarization effect is not good.

[0004] Therefore, it is urgent to propose a better calculation scheme for the binarization threshold window. Summary of the invention

[0005] The embodiment of the present invention provides a method for calculating a binarization threshold window, thereby solving the technical problem in the prior art that when a binarization threshold window is manually defined, the window is too large or too small.

[0006] On the one hand, the present invention provides a method for calculating a binarization threshold window through an embodiment of the present invention, the method comprising:

[0007] Get the window image;

[0008] Binarization is performed on the window image to obtain a window binary image, wherein the window binary image includes m white areas and n black areas, where m and n are both positive integers;

[0009] Determine the number of pixels in each of the m white areas and the number of pixels in each of the n black areas;

[0010] Calculating the size of the binarization threshold window according to the number of pixels in each of the m white areas and the number of pixels in each of the n black areas;

[0011] The binarization threshold window is used to determine the binarization window threshold corresponding to the binarization threshold window, so as to use the binarization window threshold to perform binarization processing on the original image where the window image is located.

[0012] Optionally, calculating the size of the binarization threshold window according to the number of pixels of each of the m white areas and the number of pixels of each of the n black areas comprises:

[0013] Sorting the number of pixels in each of the m white areas and the number of pixels in each of the n black areas to obtain a sorting result;

[0014] Calculating the number of b target pixels in the sorting result to obtain the size of the binarization threshold window;

[0015] Among them, the sorting result includes a number of pixel points, where a is the sum of m and n; the b number of target pixel points is the number of b pixel points located at a preset middle sorting position in the sorting result, where b is a positive integer less than a.

[0016] Optionally, the method further comprises:

[0017] Taking each pixel point in the original image as the center, using the binarization threshold window to perform sliding calculation on the original image, to obtain a binarization window threshold value for each pixel point in the original image;

[0018] According to the binarization window threshold of each pixel in the original image, binarization processing is performed on each pixel in the original image to obtain a corresponding original binarized image;

[0019] The binary window threshold of the pixel point is obtained by averaging the pixel values ​​of all the pixel points in the original image that are located in the binary threshold window.

[0020] Optionally, the window image is a region image located in a specified region of the original image.

[0021] Optionally, the binarizing the window image to obtain a window binarized image includes:

[0022] Taking each pixel point in the window image as the center, a preset threshold window is used to perform sliding calculation on the window image to obtain a binarization window threshold value for each pixel point in the window image;

[0023] According to the binarization window threshold of each pixel in the window image, binarization processing is performed on each pixel in the window image to obtain the window binarization image.

[0024] On the other hand, the present invention provides a device for calculating a binarization threshold window through an embodiment of the present invention, the device comprising: an acquisition module, a processing module, a determination module and a calculation module, wherein:

[0025] The acquisition module is used to acquire the window image;

[0026] The processing module is used to perform binarization processing on the window image to obtain a window binary image, wherein the window binary image includes m white areas and n black areas, where m and n are both positive integers;

[0027] The determination module is used to determine the number of pixels in each of the m white areas and the number of pixels in each of the n black areas;

[0028] The calculation module is used to calculate the size of the binarization threshold window according to the number of pixels in each of the m white areas and the number of pixels in each of the n black areas;

[0029] The binarization threshold window is used to determine the binarization window threshold corresponding to the binarization threshold window, so as to use the binarization window threshold to perform binarization processing on the original image where the window image is located.

[0030] For the contents not introduced or described in the embodiments of the present invention, please refer to the relevant introduction in the aforementioned method embodiments, which will not be repeated here.

[0031] On the other hand, the present invention provides a terminal device through an embodiment of the present invention, and the terminal device includes: a processor, a memory, a communication interface and a bus; the processor, the memory and the communication interface are connected through the bus and communicate with each other; the memory stores executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the calculation method of the binary threshold window as described above.

[0032] On the other hand, the present invention provides a computer-readable storage medium through an embodiment of the present invention, wherein the computer-readable storage medium stores a program, and when the program is run on a terminal device, the method for calculating the binarization threshold window as described above is executed.

[0033] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages: the present invention obtains a window image, performs binarization processing on the window image to obtain a window binarization image, then determines the number of pixels of each of the m white areas and the number of pixels of each of the n black areas, and finally calculates the size of the binarization threshold window according to the number of pixels of each of the m white areas and the number of pixels of each of the n black areas. According to the present invention, by binarizing the window image in the original image, and then analyzing and calculating the obtained window binarization image, the size of the binarization threshold window suitable for the binarization of the original image is obtained, which not only realizes the automatic determination and convenient calculation of the binarization threshold window, but also solves the technical problem of the window being too large or too small when the binarization threshold window is manually defined in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0035] Figure 1-Figure 2 It is a schematic diagram of two images after binarization processing provided in the prior art.

[0036] Figure 3 It is a flowchart of a method for calculating a binarization threshold window provided by an embodiment of the present invention.

[0037] Figure 4 It is a schematic diagram of selecting a window image from an original image provided by an embodiment of the present invention.

[0038] Figure 5 It is a schematic diagram of a possible window binarization image provided by an embodiment of the present invention.

[0039] Figure 6 It is a schematic diagram of a binarization threshold window provided by an embodiment of the present invention.

[0040] Figure 7 It is a schematic diagram of an original binary image provided by an embodiment of the present invention.

[0041] Figure 8 It is a structural schematic diagram of a binary threshold window calculation device provided by an embodiment of the present invention.

[0042] Fig. 9 It is a structural diagram of a terminal device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0043] In the process of proposing the present invention, the applicant also found that the prior art generally adopts the following two solutions for image binarization:

[0044] The first type is that grayscale images usually have brightness levels from 0 to 255. Image binarization is to use one or more thresholds (such as 127) to set the pixel brightness values ​​(i.e. the pixel value) less than the threshold to 0, and the pixel values ​​greater than or equal to the threshold to 255. In this way, you can get an image with two brightness values ​​of 0 or 255, that is, the image after binarization (referred to as the binary image). For example, take the image as a checkerboard image, see Figure 1 This is an example of an image after binarization processing provided by the prior art.

[0045] However, in practice, it is found that this image binarization scheme uses a fixed threshold and is only applicable to images within a certain brightness range with uniform brightness distribution in the center and around, and its versatility is poor. In addition, due to the dark corners of the image, the black block in the middle of the binary image will be smaller, and the black blocks around it will be larger.

[0046] The second method is to use adaptive thresholding to binarize the image. The working principle of the adaptive thresholding is to take each pixel as the center, calculate the average brightness of the pixels within the N*N window range, and use the average brightness as the threshold to binarize the central pixel.

[0047] However, in practice, it is found that the N*N window range is difficult to determine. If N is too small, the N*N window range of the pixels near the center of the black block is full of black dots. In this way, only the black dots can be used to calculate the threshold of the center pixel. The threshold and the pixel value of the center pixel are very close, which may cause the center of the black block to turn white. If N is too large, distortion will occur. The larger N is, the more it tends to use a fixed threshold for image binarization, and the binarization speed is slower. For example, see Figure 2 is another example of an image after binarization provided by the prior art. Figure 2 It can be seen that due to the small size of the N*N window, the black blocks of the image become white blocks after binarization, and the binarization effect is not good.

[0048] The embodiment of the present invention provides a method for calculating a binarization threshold window, thereby solving the technical problem in the prior art that when a binarization threshold window is manually defined, the window is too large or too small.

[0049] The technical solution of the embodiment of the present invention is to solve the above-mentioned technical problems, and the overall idea is as follows: obtain a window image; binarize the window image to obtain a window binarized image, wherein the window binarized image includes m white areas and n black areas, and m and n are both positive integers; determine the number of pixels in each of the m white areas and the number of pixels in each of the n black areas; calculate the size of the binarization threshold window according to the number of pixels in each of the m white areas and the number of pixels in each of the n black areas; wherein the binarization threshold window is used to determine the binarization window threshold corresponding to the binarization threshold window, so as to use the binarization window threshold to binarize the original image where the window image is located.

[0050] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0051] First of all, the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0052] See also Figure 3 , is a flow chart of a method for calculating a binarization threshold window provided by an embodiment of the present invention. Figure 3 The method shown includes the following implementation steps:

[0053] S301, obtaining a window image.

[0054] The window image of the present invention is a regional image located in a specified area of ​​the original image, and the specified area is an image area customized by a user or a system in the original image, such as an image area specified according to actual system requirements, or an image area specified according to a user's personal preferences, etc. In practical applications, the position of the specified area in the original image and the size of the specified area are not limited by the present invention, and can be set according to actual requirements. The original image includes but is not limited to a checkerboard image, or other customized images, etc. Preferably, the original image of the present invention is a checkerboard image.

[0055] In a specific embodiment, the original image corresponds to two symmetric center lines, and the designated area is an area intercepted in the original image along two sides with equal spacing, taking any one of the two symmetric center lines as a reference line. In other words, the designated area is a central area intercepted in the original image along the length direction or the width direction.

[0056] For example, see Figure 4 FIG. 1 is a schematic diagram of a possible window image provided by an embodiment of the present invention. Figure 4 In the present invention, a horizontal line area passing through the center point of the original image and having a width of one pixel is selected as the window image, specifically as follows Figure 4 The horizontal line area image shown is the window image. It should be noted that Figure 4 The window image shown is the window image shown in the optimal embodiment of the present application, which includes all pixel information in the entire length direction of the original image and has a larger span. Compared with the local selection box (i.e., the local selection window image), its binarization processing effect is better.

[0057] S302 , binarizing the window image to obtain a window binarized image, wherein the window binarized image includes m white areas and n black areas, where m and n are both positive integers.

[0058] In a specific embodiment, the present invention uses a preset threshold window N1×N1 to perform binarization processing on the window image, wherein N1 is a value set by the system, and is usually 1 / 4 of the length of the window image. Specifically, the present invention takes each pixel in the window image as the center, and uses a preset threshold window to perform sliding calculation on the window image for each central pixel to obtain a binarization window threshold for each pixel in the window image. Specifically, the binarization window threshold of each pixel is a value obtained by averaging the pixel values ​​of all pixels in the window image within the preset threshold window. Then, based on the binarization window threshold of each pixel in the window image, binarization processing is performed on each pixel in the window image to obtain the final window binarization image. Specifically, if the pixel value of a pixel is greater than the binarization window threshold of the pixel, the pixel value of the pixel is set to 255; otherwise, it is set to 0. The window binarization image of the present invention is composed of m white areas and n black areas cross-distributed, and m and n are both positive integers, and their values ​​are not limited.

[0059] For example, citing the above Figure 4 In the example shown, this application Figure 4 The window image shown is subjected to adaptive binarization processing to obtain a binarized line (i.e., a window binarized image). For details, see Figure 5 shown. Figure 5 The line shown is composed of many black line segments (ie, black areas) and white line segments (ie, white areas).

[0060] S303: Determine the number of pixels in each of the m white areas and the number of pixels in each of the n black areas.

[0061] After obtaining the window binary image, the present invention can count and determine the number of pixels in each white area and the number of pixels in each black area in the window binary image, in other words, determine the number of pixels in each of the m white areas and the number of pixels in each of the n black areas.

[0062] For example, citing Figure 5 In the example shown, after the window image is binarized, the present invention can obtain a window binarized image composed of multiple black and white line segments. Further, the present invention can count the number of pixels of each black and white line segment to form a list. For example, it is assumed that the number of pixels of each black and white line segment in this example is as follows: 32, 158, 147, 151, 150, 150, 151, 147, 9, 141, 150, 148, 150, 147, 149, 148, 150, 119, 29, 149, 149, 151, 147 and 156.

[0063] S304: Calculate the size of the binarization threshold window according to the number of pixels in each of the m white areas and the number of pixels in each of the n black areas, wherein the binarization threshold window is used to determine the binarization window threshold corresponding to the binarization threshold window, so as to perform binarization processing on the original image where the window image is located by using the binarization window threshold.

[0064] In a specific embodiment, the present invention can sort the number of pixels of each of the m white areas and the number of pixels of each of the n black areas, for example, by sorting from large to small according to the number of pixels, etc., to obtain a corresponding sorting result. Further, the present invention can calculate the number of b target pixels in the sorting result to obtain the size N2×N2 of the binary threshold window. Specifically, the average value of the number of b target pixels can be calculated first, and then multiplied by 2 to obtain N2. Among them, the sorting result includes a number of pixels, and a is equal to the sum of m and n. The number of b target pixels is the number of b pixels located at a preset middle sorting position in the sorting result, that is, the number of b pixels excluding the front or rear end positions in the sorting result, and b is a positive integer less than a.

[0065] For example, citing the example of step S303, the present invention can first sort the list to obtain the sorting results, specifically: 9, 29, 32, 119, 141, 147, 147, 148, 148, 149, 149, 149, 150, 150, 150, 150, 150, 151, 151, 151, 156 and 158. Further, the present invention can remove the data at the beginning and end of the sorting result, leaving only the data in the middle half of the sorting result, that is, the number of b target pixels is: 147, 147, 147, 147, 148, 148, 149, 149, 150, 150, 150 and 150 respectively.

[0066] Furthermore, the present invention can calculate the average value of the above b target pixel numbers to obtain the width of the black block in the checkerboard image. The width N2 of the binary threshold window is the brightness of the black block width. This value can ensure that the black and white pixels are evenly distributed within the N2×N2 window range under any circumstances. For example, see Figure 6 A schematic diagram of a possible binarization threshold window is shown in FIG. Figure 6 The black frame in the figure is the binarization threshold window.

[0067] In an optional embodiment, after calculating the binarization window threshold of the original image corresponding to the window image, the present invention can use each pixel in the original image as the center and perform sliding calculation on the original image using the binarization window threshold to obtain the binarization window threshold of each pixel in the original image. Specifically, the binarization window threshold of each pixel is the average pixel value obtained by averaging the pixel values ​​of all pixels in the original image located in the binarization threshold window with the pixel as the center. Further, the present invention can perform binarization processing on each pixel in the original image according to the binarization window threshold of each pixel in the original image to obtain the corresponding original binary image. Specifically, for example, when the pixel value of any pixel in the original image is greater than the binarization window threshold of the pixel, the pixel value of the pixel is set to 255, otherwise it is set to 0.

[0068] For example, see Figure 7 A schematic diagram showing a possible original binary image. Figure 7 It can be seen that by using the binarization threshold window calculated by this scheme to perform binarization processing on the original image, an original binarized image with a better binarization effect can be obtained.

[0069] By implementing the present invention, the present invention obtains a window image, performs binarization processing on the window image to obtain a window binarization image, then determines the number of pixels of each of the m white areas and the number of pixels of each of the n black areas, and finally calculates the size of the binarization threshold window according to the number of pixels of each of the m white areas and the number of pixels of each of the n black areas. By adopting the present invention, the window image in the original image is binarized, and then the processed window binarization image is analyzed and calculated to obtain the size of the binarization threshold window suitable for the binarization of the original image, so that the automatic determination and convenient calculation of the binarization threshold window are realized, and the technical problem of the window being too large or too small when the binarization threshold window is manually defined in the prior art is solved.

[0070] Based on the same inventive concept, another embodiment of the present invention provides a device and an electronic device corresponding to the method for calculating the binarization threshold window described in the embodiment of the present invention.

[0071] See also Figure 8 , is a schematic diagram of a structure of a computing device for a binary threshold window provided in an embodiment of the present application. Figure 8 The device 70 shown includes: an acquisition module 701, a processing module 702, a determination module 703 and a calculation module 704, wherein:

[0072] The acquisition module 701 is used to acquire the window image;

[0073] The processing module 702 is used to perform binarization processing on the window image to obtain a window binary image, wherein the window binary image includes m white areas and n black areas, where m and n are both positive integers;

[0074] The determination module 703 is used to determine the number of pixels in each of the m white areas and the number of pixels in each of the n black areas;

[0075] The calculation module 704 is used to calculate the size of the binarization threshold window according to the number of pixels in each of the m white areas and the number of pixels in each of the n black areas;

[0076] The binarization threshold window is used to determine the binarization window threshold corresponding to the binarization threshold window, so as to use the binarization window threshold to perform binarization processing on the original image where the window image is located.

[0077] Optionally, the calculation module 704 is specifically used for:

[0078] Sorting the number of pixels in each of the m white areas and the number of pixels in each of the n black areas to obtain a sorting result;

[0079] Calculating the number of b target pixels in the sorting result to obtain the size of the binarization threshold window;

[0080] Among them, the sorting result includes a number of pixel points, where a is the sum of m and n; the b number of target pixel points is the number of b pixel points located at a preset middle sorting position in the sorting result, where b is a positive integer less than a.

[0081] Optionally, the calculation module 704 is further used to perform sliding calculation on the original image using the binarization threshold window with each pixel in the original image as the center, so as to obtain a binarization window threshold of each pixel in the original image;

[0082] The processing module 702 is further configured to perform binarization processing on each pixel in the original image according to a binarization window threshold of each pixel in the original image to obtain a corresponding original binarized image;

[0083] The binary window threshold of the pixel point is obtained by averaging the pixel values ​​of all the pixel points in the original image that are located in the binary threshold window.

[0084] Optionally, the window image is a region image located in a specified region of the original image.

[0085] Optionally, the calculation module 704 is specifically used to perform sliding calculation on the window image using a preset threshold window with each pixel in the window image as the center, so as to obtain a binarization window threshold of each pixel in the window image;

[0086] The processing module 702 is specifically configured to perform binarization processing on each pixel in the window image according to a binarization window threshold of each pixel in the window image to obtain the window binarized image.

[0087] Please refer to 9, which is a schematic diagram of the structure of a terminal device provided by an embodiment of the present invention. Fig. 9 The terminal device 80 shown includes: at least one processor 801, a communication interface 802, a user interface 803 and a memory 804. The processor 801, the communication interface 802, the user interface 803 and the memory 804 can be connected via a bus or other means. The embodiment of the present invention takes the connection via a bus 805 as an example.

[0088] The processor 801 may be a general-purpose processor, such as a central processing unit (CPU).

[0089] The communication interface 802 may be a wired interface (eg, an Ethernet interface) or a wireless interface (eg, a cellular network interface or a wireless LAN interface) for communicating with other terminals or websites. In the embodiment of the present invention, the communication interface 802 is specifically used to obtain a window image or an original image.

[0090] The user interface 803 may be a touch panel, including a touch screen and a touch screen, for detecting operation instructions on the touch panel, or a physical button or a mouse. The user interface 803 may also be a display screen for outputting and displaying images or data.

[0091] The memory 804 may include a volatile memory, such as a random access memory (RAM); the memory may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); the memory 804 may also include a combination of the above-mentioned types of memory. The memory 804 is used to store a set of program codes, and the processor 801 is used to call the program codes stored in the memory 804 to perform the following operations:

[0092] Get the window image;

[0093] Binarization is performed on the window image to obtain a window binary image, wherein the window binary image includes m white areas and n black areas, where m and n are both positive integers;

[0094] Determine the number of pixels in each of the m white areas and the number of pixels in each of the n black areas;

[0095] Calculating the size of the binarization threshold window according to the number of pixels in each of the m white areas and the number of pixels in each of the n black areas;

[0096] The binarization threshold window is used to determine the binarization window threshold corresponding to the binarization threshold window, so as to use the binarization window threshold to perform binarization processing on the original image where the window image is located.

[0097] Optionally, calculating the size of the binarization threshold window according to the number of pixels of each of the m white areas and the number of pixels of each of the n black areas comprises:

[0098] Sorting the number of pixels in each of the m white areas and the number of pixels in each of the n black areas to obtain a sorting result;

[0099] Calculating the number of b target pixels in the sorting result to obtain the size of the binarization threshold window;

[0100] Among them, the sorting result includes a number of pixel points, where a is the sum of m and n; the b number of target pixel points is the number of b pixel points located at a preset middle sorting position in the sorting result, where b is a positive integer less than a.

[0101] Optionally, the processor 801 is further configured to:

[0102] Taking each pixel point in the original image as the center, using the binarization threshold window to perform sliding calculation on the original image, to obtain a binarization window threshold value for each pixel point in the original image;

[0103] According to the binarization window threshold of each pixel in the original image, binarization processing is performed on each pixel in the original image to obtain a corresponding original binarized image;

[0104] The binary window threshold of the pixel point is obtained by averaging the pixel values ​​of all the pixel points in the original image that are located in the binary threshold window.

[0105] Optionally, the window image is a region image located in a specified region of the original image.

[0106] Optionally, the binarizing the window image to obtain a window binarized image includes:

[0107] Taking each pixel point in the window image as the center, a preset threshold window is used to perform sliding calculation on the window image to obtain a binarization window threshold value for each pixel point in the window image;

[0108] According to the binarization window threshold of each pixel in the window image, binarization processing is performed on each pixel in the window image to obtain the window binarization image.

[0109] Since the electronic device introduced in this embodiment is an electronic device used to implement the calculation method of the binarization threshold window in the embodiment of the present invention, based on the calculation method of the binarization threshold window introduced in the embodiment of the present invention, a person skilled in the art can understand the specific implementation of the electronic device of the present embodiment and its various variations, so how the electronic device implements the method in the embodiment of the present invention is not described in detail here. As long as the electronic device used by a person skilled in the art to implement the information processing method in the embodiment of the present invention, it belongs to the scope of protection of the present invention.

[0110] The technical solution in the above-mentioned embodiment of the present invention has at least the following technical effects or advantages: the present invention obtains a window image, performs binarization processing on the window image to obtain a window binarization image, then determines the number of pixels of each of the m white areas and the number of pixels of each of the n black areas, and finally calculates the size of the binarization threshold window according to the number of pixels of each of the m white areas and the number of pixels of each of the n black areas. According to the present invention, by binarizing the window image in the original image, and then analyzing and calculating the obtained window binarization image, the size of the binarization threshold window suitable for the binarization of the original image is obtained, which not only realizes the automatic determination and convenient calculation of the binarization threshold window, but also solves the technical problem of the window being too large or too small when the binarization threshold window is manually defined in the prior art.

[0111] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0112] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0113] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0114] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0115] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0116] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for calculating a binary threshold window, characterized in that: The method comprises: Acquire a window image; the window image is a regional image located in a specified area of ​​the original image, and the specified area is an area intercepted in the original image along two sides with equal spacing, taking any one of the two symmetry center lines of the original image as a reference line; Binarization is performed on the window image to obtain a window binary image, wherein the window binary image includes m white areas and n black areas, where m and n are both positive integers; Determine the number of pixels in each of the m white areas and the number of pixels in each of the n black areas; Calculating the size of the binarization threshold window according to the number of pixels in each of the m white areas and the number of pixels in each of the n black areas; The binarization threshold window is used to determine the binarization window threshold corresponding to the binarization threshold window, so as to use the binarization window threshold to perform binarization processing on the original image where the window image is located; Calculating the size of the binarization threshold window according to the number of pixels in each of the m white areas and the number of pixels in each of the n black areas comprises: Sorting the number of pixels in each of the m white areas and the number of pixels in each of the n black areas to obtain a sorting result; Calculating the number of b target pixels in the sorting result to obtain the size of the binarization threshold window; Among them, the sorting result includes a number of pixel points, where a is the sum of m and n; the b number of target pixel points is the number of b pixel points located at a preset middle sorting position in the sorting result, where b is a positive integer less than a.

2. The method according to claim 1, characterized in that The method further comprises: Taking each pixel point in the original image as the center, using the binarization threshold window to perform sliding calculation on the original image, to obtain a binarization window threshold value for each pixel point in the original image; According to the binarization window threshold of each pixel in the original image, binarization processing is performed on each pixel in the original image to obtain a corresponding original binarized image; The binary window threshold of the pixel point is obtained by averaging the pixel values ​​of all the pixel points in the original image that are located in the binary threshold window.

3. The method according to claim 1, characterized in that The window image is a region image located in a designated region of the original image.

4. The method according to claim 1, characterized in that: The binarization of the window image to obtain a window binarization image comprises: Taking each pixel point in the window image as the center, a preset threshold window is used to perform sliding calculation on the window image to obtain a binarization window threshold value for each pixel point in the window image; According to the binarization window threshold of each pixel in the window image, binarization processing is performed on each pixel in the window image to obtain the window binarization image.

5. A device for calculating a binarization threshold window, characterized in that: The device comprises: an acquisition module, a processing module, a determination module and a calculation module, wherein: The acquisition module is used to acquire a window image; the window image is a regional image located in a specified area of ​​the original image, and the specified area is an area intercepted in the original image along two sides with equal intervals, taking any one of the two symmetry center lines of the original image as a reference line; The processing module is used to perform binarization processing on the window image to obtain a window binary image, wherein the window binary image includes m white areas and n black areas, where m and n are both positive integers; The determination module is used to determine the number of pixels in each of the m white areas and the number of pixels in each of the n black areas; The calculation module is used to calculate the size of the binarization threshold window according to the number of pixels in each of the m white areas and the number of pixels in each of the n black areas; The calculation module is specifically used for: Sorting the number of pixels in each of the m white areas and the number of pixels in each of the n black areas to obtain a sorting result; Calculating the number of b target pixels in the sorting result to obtain the size of the binarization threshold window; The sorting result includes a number of pixels, where a is the sum of m and n; the b number of target pixels is the number of b pixels located at a preset middle sorting position in the sorting result, where b is a positive integer less than a; The binarization threshold window is used to determine the binarization window threshold corresponding to the binarization threshold window, so as to use the binarization window threshold to perform binarization processing on the original image where the window image is located.

6. The device according to claim 5, characterized in that The calculation module is further used to perform sliding calculation on the original image using the binarization threshold window with each pixel in the original image as the center, so as to obtain the binarization window threshold of each pixel in the original image; The processing module is further used to perform binarization processing on each pixel in the original image according to the binarization window threshold of each pixel in the original image to obtain a corresponding original binary image; The binary window threshold of the pixel point is obtained by averaging the pixel values ​​of all the pixel points in the original image that are located in the binary threshold window.

7. A terminal device, characterized in that: The terminal device includes: a processor, a memory, a communication interface and a bus; the processor, the memory and the communication interface are connected through the bus and communicate with each other; the memory stores executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the calculation method of the binary threshold window as described in any one of claims 1 to 4.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program, and when the program is run on a terminal device, the method for calculating a binarization threshold window as described in any one of claims 1 to 4 is executed.

Citation Information

Patent Citations

  • Image binarization method and device, storage medium and computer equipment

    CN113255393A