Text region detection method and device

By performing edge detection and smoothing on image frames, candidate text regions are identified and verified, solving the problem of slow detection speed in existing technologies and achieving faster text region detection.

CN112801090BActive Publication Date: 2026-03-31XIAN WANXIANG ELECTRONICS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-26
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

In existing technologies, the detection speed of text regions in video images is relatively low, mainly because OCR detection of the entire video image is required, resulting in a large amount of data and reduced detection speed.

Method used

Edge detection is performed on the image frame to be processed to obtain the edge value of each pixel, and smoothing is performed to determine the candidate text region. Finally, the candidate text region is verified to obtain the text region.

Benefits of technology

By simplifying the detection process, first performing a rough screening of candidate text regions and then conducting a detailed detection, the detection speed and performance are significantly improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112801090B_ABST
    Figure CN112801090B_ABST
Patent Text Reader

Abstract

The present disclosure provides a text region detection method and device, and relates to the technical field of images. The method comprises: acquiring a to-be-processed image frame; performing edge detection on the to-be-processed image frame to obtain an edge value of each pixel point; performing smoothing processing on the edge value of each pixel point to obtain an edge image; determining a candidate text region from the edge image; and verifying the candidate text region to obtain a text region. The present disclosure first performs simple detection such as edge detection and smoothing processing on the entire to-be-processed image frame to obtain a candidate text region, and then performs detection on the candidate text region to obtain a text region. Since the area of the candidate text region is smaller than that of the to-be-processed image, the time spent in detecting the text region from the candidate text region is less than that in the prior art. Moreover, the detection from the to-be-processed image frame to the candidate text region is relatively simple, and the processing speed is fast, so that the time of the entire detection process is shortened, and the detection speed is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of image processing technology, and in particular to a method and apparatus for text region detection. Background Technology

[0002] With the rapid development of internet application technology and the widespread use of electronic products, people are becoming increasingly reliant on the internet. A vast amount of video information is disseminated online, and the internet is the primary channel through which people obtain information. Users of electronic products and the internet include both adults and minors, but minors have weaker resistance to electronic products and a weaker ability to discern online information. Therefore, recognizing the text content in online videos and then judging its appropriateness is particularly important. The process of video text recognition typically involves detecting the brightness and darkness of the text to determine the text region; then comparing the text in the region with a character database to output the correct text. The recognized text result is then compared with a corresponding monitoring word database to identify sensitive words, which are then removed from the video to purify the online space.

[0003] In related technologies, text region detection usually requires OCR (Optical Character Recognition) detection algorithms to perform text recognition on the entire video image. However, the large amount of data in the video stream leads to a decrease in detection speed. Summary of the Invention

[0004] This disclosure provides a method and apparatus for text region detection, which can solve the problem of reduced detection speed in the prior art. The technical solution is as follows:

[0005] According to a first aspect of the present disclosure, a text region detection method is provided, the method comprising:

[0006] Obtain the image frame to be processed;

[0007] Edge detection is performed on the image frame to be processed to obtain the edge value of each pixel;

[0008] The edge values ​​of each pixel are smoothed to obtain an edge image;

[0009] Candidate text regions are determined from the edge image;

[0010] The candidate text regions are verified to obtain the text regions.

[0011] This disclosure provides a text region detection method. Upon acquiring an image frame to be processed, edge detection is first performed on the image frame to obtain the edge value of each pixel. Then, the edge values ​​of each pixel are smoothed to obtain an edge image. Candidate text regions are then determined from the edge image. Finally, the candidate text regions are verified to obtain the text region. It can be seen that this disclosure first performs simple detections such as edge detection and smoothing on the entire image frame to obtain candidate text regions, and then detects each pixel within the candidate text regions to obtain the text region. Since the candidate text region is smaller than the area of ​​the image to be processed, the time spent detecting the text region from the candidate text region is less than that of existing technologies. Moreover, the detection from the image frame to the candidate text region is relatively simple, resulting in faster processing speed, thereby shortening the overall detection time and improving the detection speed.

[0012] In one embodiment, smoothing the edge values ​​of each pixel includes:

[0013] Divide all pixels into a first preset number of first target regions;

[0014] Determine the average edge value of all pixels within each of the first target regions.

[0015] In one embodiment, determining the candidate text region from the edge image includes:

[0016] The edge value of each pixel in the edge image is compared with a first preset threshold and a second preset threshold; the first preset threshold is greater than the second preset threshold.

[0017] The pixel values ​​of pixels with edge values ​​greater than the first preset threshold are set to 255, the pixel values ​​of pixels with edge values ​​greater than the second preset threshold and less than the first preset threshold are set to 128, and the pixel values ​​of pixels with edge values ​​less than the second preset threshold are set to 0, thus obtaining a black and white image.

[0018] The candidate text regions are obtained by filtering out pixels in the non-character regions of the grayscale image.

[0019] In one embodiment, the pixels used to filter non-character regions in the grayscale image include:

[0020] For each first target pixel in the black-and-white image, determine whether the pixel value of the first target pixel is equal to zero;

[0021] When it is determined that the pixel value of the first target pixel is not zero, the first first pixel with a pixel value of zero in the first direction is determined, the first second pixel with a pixel value of zero in the second direction is determined, the first third pixel with a pixel value of zero in the third direction is determined, and the first fourth pixel with a pixel value of zero in the fourth direction is determined, with the first direction being opposite to the second direction, the third direction being opposite to the fourth direction, and the first direction being perpendicular to the third direction.

[0022] When it is determined that the distance between the first pixel and the second pixel is less than a first preset value, or the distance between the third pixel and the fourth pixel is less than a second preset value, or the distance between the first pixel and the second pixel is less than the distance between the third pixel and the fourth pixel, the pixel value of the first target pixel is set to zero.

[0023] In one embodiment, verifying the candidate text regions to obtain the text regions includes:

[0024] Obtain a preprocessed image; the preprocessed image is an image obtained based on the candidate text regions;

[0025] The preprocessed image is binarized to obtain a black and white image;

[0026] Segment the black and white image;

[0027] The text region is obtained by filtering out pixels in the non-character regions of the segmented image.

[0028] In one embodiment, obtaining the preprocessed image includes:

[0029] Obtain the height of the candidate text region;

[0030] When the height is determined to be greater than the preset height, the image of the candidate text region is converted into a grayscale image, and the grayscale edge value of the grayscale image is calculated to obtain the preprocessed image;

[0031] When the height is determined to be less than the preset height, the candidate text region is enlarged to obtain the preprocessed image.

[0032] In one embodiment, segmenting the black and white image includes:

[0033] The black and white image is divided into a second preset number of second target regions;

[0034] The average edge value of all pixels within each second target region is determined to obtain the first smoothed image.

[0035] In one embodiment, it also includes:

[0036] The image after the first smoothing process is divided into a third preset number of third target regions;

[0037] The average edge value of all pixels within each of the third target regions is determined to obtain the second smoothed image.

[0038] In one embodiment, it also includes:

[0039] The image after the second smoothing process is divided into a fourth preset number of fourth target regions;

[0040] The average edge value of all pixels within each of the fourth target regions is determined to obtain the third smoothed image.

[0041] In one embodiment, filtering the pixels of non-character regions in the segmented image to obtain the text region includes:

[0042] For each second target pixel in the filtered and segmented image, determine whether the pixel value of the second target pixel is equal to zero;

[0043] When it is determined that the pixel value of the second target pixel is not zero, the first fifth pixel with a pixel value of zero in the first direction is determined, the first sixth pixel with a pixel value of zero in the second direction is determined, the first seventh pixel with a pixel value of zero in the third direction is determined, and the first eighth pixel with a pixel value of zero in the fourth direction is determined, using the second target pixel as the base point.

[0044] When it is determined that the distance between the fifth pixel and the sixth pixel is less than a third preset value, or the distance between the seventh pixel and the eighth pixel is less than a fourth preset value, or the distance between the first pixel and the second pixel is less than the distance between the third pixel and the fourth pixel, the pixel value of the second target pixel is set to zero to obtain the text region.

[0045] According to a second aspect of the present disclosure, a text region detection apparatus is provided, the apparatus comprising:

[0046] The acquisition module is used to acquire the image frames to be processed;

[0047] The detection module is used to perform edge detection on the image frame to be processed and obtain the edge value of each pixel.

[0048] The processing module is used to smooth the edge values ​​of each pixel to obtain an edge image;

[0049] The determination module is used to determine candidate text regions from the edge image;

[0050] The verification module is used to verify the candidate text regions to obtain the text regions.

[0051] This disclosure provides a text region detection device. When an image frame to be processed is acquired, edge detection is first performed on the image frame to obtain the edge value of each pixel. Then, the edge values ​​of each pixel are smoothed to obtain an edge image. Candidate text regions are then determined from the edge image. Finally, the candidate text regions are verified to obtain the text region. It can be seen that this disclosure first performs simple detections such as edge detection and smoothing on the entire image frame to obtain candidate text regions, and then detects each pixel in the candidate text regions to obtain the text region. Since the candidate text region is smaller than the area of ​​the image to be processed, the time spent detecting the text region from the candidate text region is less than that of the prior art. Moreover, the detection from the image frame to the candidate text region is relatively simple, resulting in faster processing speed, thereby shortening the overall detection time and improving the detection speed.

[0052] In one embodiment, the processing module includes a division submodule and a determination submodule;

[0053] The division submodule is used to divide all pixels into a first preset number of first target regions;

[0054] The determining submodule is used to determine the average value of the edge values ​​of all pixels within each first target region.

[0055] In one embodiment, the determining module includes a comparison submodule, a setting submodule, and a first filtering submodule;

[0056] The comparison submodule is used to compare the edge value of each pixel in the edge image with a first preset threshold value and a second preset threshold value respectively; the first preset threshold value is greater than the second preset threshold value;

[0057] The setting submodule is used to set the pixel value of pixels with an edge value greater than the first preset threshold value to 255, set the pixel value of pixels with an edge value greater than the second preset threshold value and less than the first preset threshold value to 128, and set the pixel value of pixels with an edge value less than the second preset threshold value to 0, so as to obtain a black and white image.

[0058] The first filtering submodule is used to filter pixels in non-character regions of the black-and-white image to obtain the candidate text regions.

[0059] In one embodiment, the first filtering submodule includes a first determining unit, a second determining unit, and a first setting unit;

[0060] The first determining unit is configured to determine whether the pixel value of each first target pixel in the black-and-white image is equal to zero.

[0061] The second determining unit is configured to, when determining that the pixel value of the first target pixel is not zero, use the first target pixel as a base point to determine the first first pixel with a pixel value of zero in a first direction, the first second pixel with a pixel value of zero in a second direction, the first third pixel with a pixel value of zero in a third direction, and the first fourth pixel with a pixel value of zero in a fourth direction; wherein the first direction is opposite to the second direction, the third direction is opposite to the fourth direction, and the first direction is perpendicular to the third direction;

[0062] The first setting unit is configured to set the pixel value of the first target pixel to zero when it is determined that the distance between the first pixel and the second pixel is less than a first preset value, or the distance between the third pixel and the fourth pixel is less than a second preset value, or the distance between the first pixel and the second pixel is less than the distance between the third pixel and the fourth pixel.

[0063] In one embodiment, the verification module includes an acquisition submodule, a processing submodule, a segmentation submodule, and a second filtering submodule;

[0064] The acquisition submodule is used to acquire a preprocessed image; the preprocessed image is an image obtained based on the candidate text region;

[0065] The processing submodule is used to perform binarization processing on the preprocessed image to obtain a black and white image;

[0066] The segmentation submodule is used to segment the black and white image;

[0067] The second filtering submodule is used to filter pixels in non-character regions of the segmented image to obtain the text region.

[0068] In one embodiment, the acquisition submodule includes an acquisition unit, a calculation unit, and an amplification unit;

[0069] The acquisition unit is used to acquire the height of the candidate text region;

[0070] The calculation unit is used to convert the image of the candidate text region into a grayscale image when it is determined that the height is greater than a preset height, and to calculate the grayscale edge value of the grayscale image to obtain the preprocessed image;

[0071] The magnification unit is used to magnify the candidate text region when the height is determined to be less than the preset height, so as to obtain the preprocessed image.

[0072] In one embodiment, the segmentation submodule includes a first segmentation unit and a third determination unit;

[0073] The first division unit is used to divide the black and white image into a second preset number of second target regions;

[0074] The third determining unit is used to determine the average value of the edge values ​​of all pixels in each of the second target regions to obtain the first smoothed image.

[0075] In one embodiment, the segmentation submodule further includes a second segmentation unit and a fourth determination unit;

[0076] The second division unit is used to divide the first smoothed image into a third preset number of third target regions;

[0077] The fourth determining unit is used to determine the average value of the edge values ​​of all pixels in each of the third target regions to obtain the second smoothed image.

[0078] In one embodiment, the segmentation submodule further includes a third segmentation unit and a fifth determination unit;

[0079] The third division unit is used to divide the second smoothing image into a fourth preset number of fourth target regions;

[0080] The fifth determining unit is used to determine the average value of the edge values ​​of all pixels in each of the fourth target regions to obtain the third smoothing image.

[0081] In one embodiment, the second filtering submodule includes a sixth determining unit, a seventh determining unit, and a second setting unit;

[0082] The sixth determining unit is used to determine whether the pixel value of the second target pixel is equal to zero for each second target pixel in the filtered and segmented image;

[0083] The seventh determining unit is used to determine, with the second target pixel as the base point, the first fifth pixel with a pixel value of zero in the first direction, the first sixth pixel with a pixel value of zero in the second direction, the first seventh pixel with a pixel value of zero in the third direction, and the first eighth pixel with a pixel value of zero in the fourth direction when the pixel value of the second target pixel is determined to be not zero.

[0084] The second setting unit is used to set the pixel value of the second target pixel to zero when it is determined that the distance between the fifth pixel and the sixth pixel is less than a third preset value, or the distance between the seventh pixel and the eighth pixel is less than a fourth preset value, or the distance between the first pixel and the second pixel is less than the distance between the third pixel and the fourth pixel, thereby obtaining the text region.

[0085] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0086] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0087] Figure 1 This is a flowchart of a text region detection method provided in an embodiment of this disclosure;

[0088] Figure 2a This is a schematic diagram of the structure of a text region detection device provided in an embodiment of this disclosure;

[0089] Figure 2b This is a schematic diagram of the structure of a text region detection device provided in an embodiment of this disclosure;

[0090] Figure 2c This is a schematic diagram of the structure of a text region detection device provided in an embodiment of this disclosure;

[0091] Figure 2d This is a schematic diagram of the structure of a text region detection device provided in an embodiment of this disclosure;

[0092] Figure 2e This is a schematic diagram of the structure of a text region detection device provided in an embodiment of this disclosure;

[0093] Figure 2f This is a schematic diagram of the structure of a text region detection device provided in an embodiment of this disclosure;

[0094] Figure 2gThis is a schematic diagram of the structure of a text region detection device provided in an embodiment of this disclosure;

[0095] Figure 2h This is a schematic diagram of the structure of a text region detection device provided in an embodiment of this disclosure;

[0096] Figure 2i This is a schematic diagram of the structure of a text region detection device provided in an embodiment of this disclosure;

[0097] Figure 2j This is a schematic diagram of the structure of a text region detection device provided in an embodiment of this disclosure. Detailed Implementation

[0098] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0099] This disclosure provides a method for detecting text regions, such as... Figure 1 As shown, the method includes the following steps:

[0100] Step 101: Obtain the image frame to be processed.

[0101] For example, when a text region detection command is received from the user or when the user is detected to have enabled the text region detection function, the current image frame is captured to obtain the image frame to be processed.

[0102] Step 102: Perform edge detection on the image frame to be processed to obtain the edge value of each pixel.

[0103] For example, the acquired image frame to be processed includes multiple pixels. Edge detection involves obtaining the grayscale difference between neighboring pixels in the image frame. Specifically, the grayscale difference can be calculated as follows: for each pixel, calculate the difference in pixel values ​​between two pixels horizontally separated by a preset number of pixels, thus obtaining the edge value of each pixel. For instance, if the preset number of pixels is set to 6 pixels, then calculate the difference between the pixel value of the current pixel and the pixel value of the seventh pixel, where the current pixel and the seventh pixel are in the same horizontal direction.

[0104] It should be noted that for images with a uniform background, the stroke boundaries of characters differ greatly from the background. The edge value of each pixel can be obtained by calculating the difference between two adjacent pixels.

[0105] Step 103: Smooth the edge values ​​of each pixel to obtain an edge image.

[0106] Optionally, all pixels are divided into a first preset number of first target regions; the average edge value of all pixels in each first target region is determined.

[0107] For example, when obtaining the edge value of each pixel, it is necessary to smooth the edge value of each pixel. The specific processing method is as follows: divide the region of all pixels into a first preset number of first target regions, then sum and average the edge values ​​of all pixels in each first target region to obtain the average edge value of each first target region, and finally determine the image composed of the average edge values ​​of each first target region as the edge image.

[0108] It should be noted that each first target region can be divided by rows or columns. For example, M rows of pixels constitute one first target region, and N columns of pixels constitute another. Preferably, the region can be divided by a combination of rows and columns. For example, each first target region includes M*N pixels, where all pixels in the region are relatively close together, resulting in more accurate calculations. Alternatively, M=N can be chosen.

[0109] It should be noted that smoothing avoids instability caused by some pixels having higher edge values ​​and others having lower edge values ​​when they are close together. The edge values ​​obtained in the above steps are higher at the boundary between the stroke and the background, and lower in the middle of the stroke. Since the characters in the text line are arranged close together and there are many stroke edges, averaging the edge values ​​in a horizontal area can produce a smoother region.

[0110] Step 104: Determine candidate text regions from the edge image.

[0111] Optionally, the edge value of each pixel in the edge image is compared with a first preset threshold and a second preset threshold respectively; the pixel value of pixels with an edge value greater than the first preset threshold is set to 255, the pixel value of pixels with an edge value greater than the second preset threshold and less than the first preset threshold is set to 128, and the pixel value of pixels with an edge value less than the second preset threshold is set to 0, to obtain a grayscale image; the pixels of non-character regions in the grayscale image are filtered to obtain the candidate text region.

[0112] Wherein, the first preset threshold value is greater than the second preset threshold value. The specific size of the first preset threshold value and the second preset threshold value can be set according to the actual situation, and this disclosure does not limit it.

[0113] For example, a first preset threshold and a second preset threshold can be set to detect strong and weak edges. This involves comparing the edge value of each pixel in the edge image with the first and second preset thresholds respectively. Pixels with edge values ​​greater than the first preset threshold are set to 255, resulting in white pixels; pixels with edge values ​​greater than the second preset threshold but less than the first preset threshold are set to 128, resulting in gray pixels; and pixels with edge values ​​less than the second preset threshold are set to 0, resulting in black pixels. This produces a black-and-white image. Finally, pixels in non-character regions of the black-and-white image are filtered out to obtain candidate text regions. Here, 255 corresponds to a high edge value, 128 to a low edge value, and 0 to a non-edge pixel.

[0114] It should be noted that a threshold value T can also be chosen, and the edge value of each pixel in the edge image can be compared with the threshold value T. Pixels with edge values ​​greater than the threshold value T are identified as text regions, and pixels with edge values ​​less than the threshold value T are identified as non-text regions. However, because the brightness and contrast of different video images vary greatly, and the brightness and contrast of different text lines in the same image also vary greatly, the edge value of one text may be very strong, while the edge value of another text may be very weak. Therefore, it is difficult to use a single threshold value to determine whether a pixel belongs to a text region or a non-text region. Therefore, the two threshold value determination methods mentioned above are usually used.

[0115] Furthermore, filtering pixels in non-character regions of the grayscale image can be achieved in the following way:

[0116] For each first target pixel in the grayscale image, determine whether the pixel value of the first target pixel is equal to zero; if the pixel value of the first target pixel is not zero, using the first target pixel as a base point, determine the first first pixel with a pixel value of zero in the first direction, the first second pixel with a pixel value of zero in the second direction, the first third pixel with a pixel value of zero in the third direction, and the first fourth pixel with a pixel value of zero in the fourth direction; if the distance between the first pixel and the second pixel is less than a first preset value, or the distance between the third pixel and the fourth pixel is less than a second preset value, or the distance between the first pixel and the second pixel is less than the distance between the third pixel and the fourth pixel, set the pixel value of the first target pixel to zero.

[0117] Wherein, the first direction is opposite to the second direction, the third direction is opposite to the fourth direction, and the first direction is perpendicular to the third direction.

[0118] For example, suppose the first direction is to the left of the first target pixel, the second direction is to the right of the first target pixel, the third direction is above the first target pixel, and the fourth direction is below the first target pixel. When obtaining a grayscale image, for each first target pixel in the grayscale image, first determine whether the pixel value of the first target pixel is equal to zero. If the pixel value of the first target pixel is determined to be equal to zero, continue to judge the pixel values ​​of other pixels. If the pixel value of the first target pixel is determined to be not equal to zero, then start searching from the left of the first target pixel until the first first pixel with a pixel value equal to zero is found; then start searching from the right of the first target pixel until the first second pixel with a pixel value equal to zero is found; then start searching from above the first target pixel until the first third pixel with a pixel value equal to zero is found; then start searching from the top of ... The search begins below each pixel and continues until the first fourth pixel with a value of zero is found. Then, the horizontal distance between the second pixel to the right and the first pixel to the left is compared to a first preset value. The vertical distance between the fourth pixel below and the third pixel above is also compared to a second preset value. Furthermore, the distances between the first and second pixels and between the third and fourth pixels are compared. If the distance between the first and second pixels is less than the first preset value, or the distance between the third and fourth pixels is less than the second preset value, or the distance between the first and second pixels is less than the distance between the third and fourth pixels, the pixel value of the first target pixel is set to zero. After performing this algorithm on each pixel, pixels with high edge values ​​that do not belong to the character region are filtered out.

[0119] It should be noted that the first preset value is a threshold set for erasing the horizontal run, and the second preset value is a threshold set for erasing the vertical run. The specific values ​​can be set according to actual needs, and this disclosure does not limit them.

[0120] Step 105: Verify the candidate text regions to obtain the text regions.

[0121] Optionally, a preprocessed image is obtained; the preprocessed image is binarized to obtain a black and white image; the black and white image is segmented; and pixels in non-character regions of the segmented image are filtered to obtain the text region.

[0122] The preprocessed image is an image obtained based on the candidate text regions.

[0123] For example, among the candidate text regions found, some regions are not text regions, but because their edge features and geometric dimensions are similar to those of text lines, they are also detected as text regions. Therefore, the non-text regions in the candidate text regions need to be deleted after verification to obtain the final text regions.

[0124] Furthermore, obtaining the preprocessed image can be achieved in the following ways:

[0125] Obtain the height of the candidate text region; when the height is greater than a preset height, convert the image of the candidate text region into a grayscale image and calculate the grayscale edge value of the grayscale image to obtain the preprocessed image; when the height is less than the preset height, enlarge the candidate text region to obtain the preprocessed image.

[0126] For example, when a candidate text region is obtained, its height is acquired and compared with a preset height. If the height of the candidate text region is greater than the preset height (e.g., the preset height is 20 pixels), the image of the candidate text region is converted into a grayscale image. Specific conversion methods can include existing technologies such as the averaging method, the maximum-minimum averaging method, and the weighted averaging method, which will not be elaborated here. When the grayscale image is obtained, the grayscale edge values ​​are calculated to obtain the preprocessed image. The calculation of the grayscale edge values ​​can refer to the edge value calculation method for each pixel mentioned above. If the height of the candidate text region is less than the preset height, the image of the candidate text region is enlarged using bilinear interpolation to widen the characters, thus obtaining the preprocessed image.

[0127] Furthermore, the segmentation of the black and white image can be achieved in the following ways:

[0128] The black and white image is divided into a second preset number of second target regions; the average value of the edge values ​​of all pixels in each second target region is determined to obtain the first smoothed image.

[0129] For example, when the preprocessed image is obtained, it is binarized to obtain a black and white image. Then, the black and white image is smoothed. The specific smoothing method is as follows: the region of all pixels in the black and white image is divided into a second preset number of second target regions. Then, the edge values ​​of all pixels in each second target region are summed and averaged to obtain the average edge value of each second target region. Finally, the image composed of the average edge values ​​of each second target region is determined as the first smoothed image.

[0130] It should be noted that during binarization, the binarization threshold can be determined by the edge values ​​of the top 30% of the black and white image. To prevent the binarization threshold from being too small, the minimum value of the binarization threshold can be set to 75.

[0131] Furthermore, the first smoothed image is divided into a third preset number of third target regions; the average edge value of all pixels in each third target region is determined to obtain the second smoothed image.

[0132] For example, when the first smoothed image is obtained, the first smoothed image is smoothed. The specific smoothing method is as follows: the region of all pixels in the first smoothed image is divided into a third preset number of third target regions. Then, the edge values ​​of all pixels in each third target region are summed and averaged to obtain the average edge value of each third target region. Finally, the image composed of the average edge values ​​of each third target region is determined as the second smoothed image.

[0133] Furthermore, the second smoothed image is divided into a fourth preset number of fourth target regions; the average edge value of all pixels in each fourth target region is determined to obtain the third smoothed image, thus achieving the initial segmentation of the image.

[0134] For example, when the second smoothed image is obtained, the second smoothed image is smoothed. The specific smoothing method is as follows: the region of all pixels in the second smoothed image is divided into a fourth preset number of fourth target regions. Then, the edge values ​​of all pixels in each fourth target region are summed and averaged to obtain the average edge value of each fourth target region. Finally, the image composed of the average edge values ​​of each fourth target region is determined as the third smoothed image, thus realizing the re-segmentation of the image.

[0135] It should be noted that after the image is segmented, there may be multiple connected regions. The area of ​​each connected region is compared with the preset area. When the area of ​​a connected region is determined to be less than the preset area, it is considered an interference region and is deleted. Finally, only connected regions with an area greater than the preset area are retained.

[0136] Furthermore, the text region can be obtained by filtering out non-character pixels in the segmented image in the following way:

[0137] For each second target pixel in the filtered and segmented image, determine whether the pixel value of the second target pixel is equal to zero;

[0138] When it is determined that the pixel value of the second target pixel is not zero, the first fifth pixel with a pixel value of zero in the first direction is determined, the first sixth pixel with a pixel value of zero in the second direction is determined, the first seventh pixel with a pixel value of zero in the third direction is determined, and the first eighth pixel with a pixel value of zero in the fourth direction is determined, using the second target pixel as the base point; when it is determined that the distance between the fifth pixel and the sixth pixel is less than a third preset value, or the distance between the seventh pixel and the eighth pixel is less than a fourth preset value, or the distance between the first pixel and the second pixel is less than the distance between the third pixel and the fourth pixel, the pixel value of the second target pixel is set to zero, thus obtaining the text area.

[0139] For example, when obtaining the segmented image, for each second target pixel in the segmented image, first determine whether the pixel value of the second target pixel is equal to zero. If the pixel value of the second target pixel is determined to be equal to zero, continue to judge the pixel values ​​of other pixels; if the pixel value of the second target pixel is determined to be not equal to zero, then start searching from the left of the second target pixel until the first fifth pixel with a pixel value of zero is found; then start searching from the right of the second target pixel until the first sixth pixel with a pixel value of zero is found; then start searching from above the second target pixel until the first seventh pixel with a pixel value of zero is found; then start searching from below the second target pixel until the first eighth pixel with a pixel value of zero is found; then... The horizontal distance between the sixth pixel and the fifth pixel to its left is compared with a third preset value. The vertical distance between the eighth pixel below and the seventh pixel above is compared with a fourth preset value. The distances between the sixth and fifth pixels and between the seventh and eighth pixels are also compared. If the distance between the sixth and fifth pixels is less than the third preset value, or the distance between the eighth and seventh pixels is less than the fourth preset value, or the distance between the sixth and fifth pixels is less than the distance between the eighth and seventh pixels, the pixel value of the second target pixel is set to zero. After detecting and calculating each pixel according to this algorithm, pixels in the segmented image that do not belong to the character region are filtered out, and the text region is finally obtained.

[0140] It should be noted that the third preset value is a threshold set for erasing the horizontal run, and the fourth preset value is a threshold set for erasing the vertical run. The specific values ​​can be set according to actual needs, and this disclosure does not limit them.

[0141] This disclosure provides a text region detection method. Upon acquiring an image frame to be processed, edge detection is first performed on the image frame to obtain the edge value of each pixel. Then, the edge values ​​of each pixel are smoothed to obtain an edge image. Candidate text regions are then determined from the edge image. Finally, the candidate text regions are verified to obtain the text region. It can be seen that this disclosure first performs simple detections such as edge detection and smoothing on the entire image frame to obtain candidate text regions, and then detects each pixel within the candidate text regions to obtain the text region. Since the candidate text region is smaller than the area of ​​the image to be processed, the time spent detecting the text region from the candidate text region using complex algorithms is less than that of existing technologies. Moreover, the detection method from the image frame to the candidate text region is relatively simple, resulting in faster processing speed. Overall, it adopts a method of first performing a rough screening to obtain candidate text regions, and then performing detailed detection on the candidate text regions, thereby shortening the overall detection process time, improving detection speed, and enhancing detection performance.

[0142] Based on the text region detection method described in the above embodiments, the following are device embodiments of this disclosure, which can be used to execute the method embodiments of this disclosure.

[0143] This disclosure provides a text region detection device, such as... Figure 2a As shown, the text region detection device 20 includes: an acquisition module 201, a detection module 202, a processing module 203, a determination module 204, and a verification module 205.

[0144] The acquisition module 201 is used to acquire the image frame to be processed.

[0145] The detection module 202 is used to perform edge detection on the image frame to be processed and obtain the edge value of each pixel.

[0146] The processing module 203 is used to smooth the edge values ​​of each pixel to obtain an edge image.

[0147] The determination module 204 is used to determine candidate text regions from the edge image.

[0148] The verification module 205 is used to verify the candidate text region to obtain the text region.

[0149] In one embodiment, such as Figure 2b As shown, the processing module 203 includes a division submodule 2031 and a determination submodule 2032.

[0150] The segmentation submodule 2031 is used to divide all pixels into a first preset number of first target regions.

[0151] The determining submodule 2032 is used to determine the average value of the edge values ​​of all pixels in each of the first target regions.

[0152] In one embodiment, such as Figure 2c As shown, the determining module 204 includes a comparison submodule 2041, a setting submodule 2042, and a first filtering submodule 2043.

[0153] The comparison submodule 2041 is used to compare the edge value of each pixel in the edge image with a first preset threshold value and a second preset threshold value respectively; the first preset threshold value is greater than the second preset threshold value.

[0154] The setting submodule 2042 is used to set the pixel value of pixels with an edge value greater than the first preset threshold value to 255, set the pixel value of pixels with an edge value greater than the second preset threshold value and less than the first preset threshold value to 128, and set the pixel value of pixels with an edge value less than the second preset threshold value to 0, so as to obtain a black and white image.

[0155] The first filtering submodule 2043 is used to filter pixels in non-character regions of the black and white image to obtain the candidate text regions.

[0156] In one embodiment, such as Figure 2d As shown, the first filtering submodule 2043 includes a first determining unit 20431, a second determining unit 20432, and a first setting unit 20433.

[0157] The first determining unit 20431 is used to determine whether the pixel value of each first target pixel in the black-and-white image is equal to zero.

[0158] The second determining unit 20432 is used to determine, with the first target pixel as the base point, the first first pixel with a pixel value of zero in the first direction, the first second pixel with a pixel value of zero in the second direction, the first third pixel with a pixel value of zero in the third direction, and the first fourth pixel with a pixel value of zero in the fourth direction when the pixel value of the first target pixel is determined to be not zero. The first direction is opposite to the second direction, the third direction is opposite to the fourth direction, and the first direction is perpendicular to the third direction.

[0159] The first setting unit 20433 is configured to set the pixel value of the first target pixel to zero when it is determined that the distance between the first pixel and the second pixel is less than a first preset value, or the distance between the third pixel and the fourth pixel is less than a second preset value, or the distance between the first pixel and the second pixel is less than the distance between the third pixel and the fourth pixel.

[0160] In one embodiment, such as Figure 2e As shown, the verification module 205 includes an acquisition submodule 2051, a processing submodule 2052, a segmentation submodule 2053, and a second filtering submodule 2054.

[0161] The acquisition submodule 2051 is used to acquire a preprocessed image; the preprocessed image is an image obtained based on the candidate text region.

[0162] The processing submodule 2052 is used to perform binarization processing on the preprocessed image to obtain a black and white image.

[0163] The segmentation submodule 2053 is used to segment the black and white image.

[0164] The second filtering submodule 2054 is used to filter pixels in non-character regions of the segmented image to obtain the text region.

[0165] In one embodiment, such as Figure 2f As shown, the acquisition submodule 2051 includes an acquisition unit 20511, a calculation unit 20512, and an amplification unit 20513.

[0166] The acquisition unit 20511 is used to acquire the height of the candidate text region.

[0167] The calculation unit 20512 is used to convert the image of the candidate text region into a grayscale image when it is determined that the height is greater than a preset height, and to calculate the grayscale edge value of the grayscale image to obtain the preprocessed image.

[0168] The magnification unit 20513 is used to magnify the candidate text region when it is determined that the height is less than the preset height, so as to obtain the preprocessed image.

[0169] In one embodiment, such as Figure 2g As shown, the segmentation submodule 2053 includes a first segmentation unit 20531 and a third determination unit 20532.

[0170] The first division unit 20531 is used to divide the black and white image into a second preset number of second target regions.

[0171] The third determining unit 20532 is used to determine the average value of the edge values ​​of all pixels in each second target region to obtain the first smoothed image.

[0172] In one embodiment, such as Figure 2h As shown, the segmentation submodule 2053 further includes a second segmentation unit 20533 and a fourth determination unit 20534.

[0173] The second division unit 20533 is used to divide the first smoothing image into a third preset number of third target regions.

[0174] The fourth determining unit 20534 is used to determine the average value of the edge values ​​of all pixels in each of the third target regions to obtain the second smoothed image.

[0175] In one embodiment, such as Figure 2i As shown, the segmentation submodule 2053 further includes a third segmentation unit 20535 and a fifth determination unit 20536.

[0176] The third division unit 20535 is used to divide the second smoothing image into a fourth preset number of fourth target regions.

[0177] The fifth determining unit 20536 is used to determine the average value of the edge values ​​of all pixels in each of the fourth target regions to obtain the third smoothing image.

[0178] In one embodiment, such as Figure 2j As shown, the second filtering submodule 2054 includes a sixth determining unit 20541, a seventh determining unit 20542, and a second setting unit 20543.

[0179] The sixth determining unit 20541 is used to determine whether the pixel value of the second target pixel is equal to zero for each second target pixel in the filtered and segmented image.

[0180] The seventh determining unit 20542 is used to determine, with the second target pixel as the base point, the first fifth pixel with a pixel value of zero in the first direction, the first sixth pixel with a pixel value of zero in the second direction, the first seventh pixel with a pixel value of zero in the third direction, and the first eighth pixel with a pixel value of zero in the fourth direction when the pixel value of the second target pixel is determined to be not zero.

[0181] The second setting unit 20543 is used to set the pixel value of the second target pixel to zero when it is determined that the distance between the fifth pixel and the sixth pixel is less than a third preset value, or the distance between the seventh pixel and the eighth pixel is less than a fourth preset value, or the distance between the first pixel and the second pixel is less than the distance between the third pixel and the fourth pixel, thereby obtaining the text region.

[0182] This disclosure provides a text region detection device. When an image frame to be processed is acquired, edge detection is first performed on the image frame to obtain the edge value of each pixel. Then, the edge values ​​of each pixel are smoothed to obtain an edge image. Candidate text regions are then determined from the edge image. Finally, the candidate text regions are verified to obtain the text region. It can be seen that this disclosure first performs simple detections such as edge detection and smoothing on the entire image frame to obtain candidate text regions, and then detects each pixel in the candidate text regions to obtain the text region. Since the candidate text region is smaller than the area of ​​the image to be processed, the time spent detecting the text region from the candidate text region is less than that of the prior art. Moreover, the detection from the image frame to the candidate text region is relatively simple, resulting in faster processing speed, thereby shortening the overall detection time and improving the detection speed.

[0183] Based on the above Figure 1 In addition to the text region detection method described in the corresponding embodiments, this disclosure also provides a computer-readable storage medium. For example, a non-transitory computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, magnetic tape, a floppy disk, or an optical data storage device. This storage medium stores computer instructions for executing the above-described... Figure 1 The text region detection method described in the corresponding embodiments will not be repeated here.

[0184] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0185] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

Claims

1. A character region detection method characterized by comprising: The method comprises: acquiring a to-be-processed image frame; performing edge detection on the to-be-processed image frame to obtain an edge value of each pixel point; performing smoothing processing on the edge value of each pixel point to obtain an edge image; determining a candidate character region from the edge image; verifying the candidate character region to obtain a character region; the determining of the candidate character region from the edge image comprises: comparing the edge value of each pixel point in the edge image with a first preset threshold value and a second preset threshold value respectively; the first preset threshold value is greater than the second preset threshold value; setting the pixel value of a pixel point with an edge value greater than the first preset threshold value as 255, setting the pixel value of a pixel point with an edge value greater than the second preset threshold value and less than the first preset threshold value as 128, and setting the pixel value of a pixel point with an edge value less than the second preset threshold value as 0 to obtain a black-and-white-and-gray image; filtering the pixels of a non-character region in the black-and-white-and-gray image to obtain the candidate character region; the filtering of the pixels of the non-character region in the black-and-white-and-gray image comprises: determining whether the pixel value of each first target pixel point in the black-and-white-and-gray image is equal to zero; when it is determined that the pixel value of the first target pixel point is not equal to zero, determining a first first pixel point with a pixel value equal to zero in a first direction, a first second pixel point with a pixel value equal to zero in a second direction, a first third pixel point with a pixel value equal to zero in a third direction, and a first fourth pixel point with a pixel value equal to zero in a fourth direction, taking the first target pixel point as a base point; the first direction and the second direction are opposite directions, the third direction and the fourth direction are opposite directions, and the first direction is perpendicular to the third direction; when it is determined that the distance between the first pixel point and the second pixel point is less than a first preset value, or the distance between the third pixel point and the fourth pixel point is less than a second preset value, or the distance between the first pixel point and the second pixel point is less than the distance between the third pixel point and the fourth pixel point, setting the pixel value of the first target pixel point as zero.

2. The method of claim 1, wherein, the smoothing processing of the edge value of each pixel point comprises: dividing all pixel points into a first preset number of first target regions; determining the average value of the edge values of all pixel points in each first target region.

3. The method of claim 1, wherein, the verifying of the candidate character region to obtain a character region comprises: acquiring a pre-processed image; the pre-processed image is an image obtained according to the candidate character region; performing binaryzation processing on the pre-processed image to obtain a black-and-white image; segmenting the black-and-white image; filtering the pixels of a non-character region in the segmented image to obtain the character region.

4. The method of claim 3, wherein, the acquiring of the pre-processed image comprises: acquiring the height of the candidate character region; when it is determined that the height is greater than a preset height, converting the image of the candidate character region into a gray-scale image, calculating the gray-scale edge value of the gray-scale image, and obtaining the pre-processed image; When it is determined that the height is less than the preset height, the candidate character region is enlarged to obtain the preprocessed image.

5. The method of claim 3, wherein, The segmenting the black-and-white image comprises: dividing the black-and-white image into a second preset number of second target regions; determining an average value of edge values of all pixel points in each of the second target regions to obtain a first smoothed image.

6. The method of claim 5, wherein, Further comprising: dividing the first smoothed image into a third preset number of third target regions; determining an average value of edge values of all pixel points in each of the third target regions to obtain a second smoothed image.

7. The method of claim 6, wherein, Further comprising: dividing the second smoothed image into a fourth preset number of fourth target regions; determining an average value of edge values of all pixel points in each of the fourth target regions to obtain a third smoothed image.

8. The method of claim 3, wherein, The filtering of the non-character region pixels in the segmented image comprises: for each second target pixel point in the segmented image, determining whether the pixel value of the second target pixel point is equal to zero; when it is determined that the pixel value of the second target pixel point is not equal to zero, determining a first fifth pixel point in a first direction whose pixel value is equal to zero, a first sixth pixel point in a second direction whose pixel value is equal to zero, a first seventh pixel point in a third direction whose pixel value is equal to zero, and a first eighth pixel point in a fourth direction whose pixel value is equal to zero, based on the second target pixel point as a base point; when it is determined that the distance between the fifth pixel point and the sixth pixel point is less than a third preset value, or the distance between the seventh pixel point and the eighth pixel point is less than a fourth preset value, or the distance between the first pixel point and the second pixel point is less than the distance between the third pixel point and the fourth pixel point, setting the pixel value of the second target pixel point to zero to obtain the character region.

9. A character region detection apparatus characterized by comprising: comprising: an acquisition module configured to acquire an image frame to be processed; a detection module configured to perform edge detection on the image frame to be processed to obtain an edge value of each pixel point; a processing module configured to perform smoothing processing on the edge value of each pixel point to obtain an edge image; a determination module configured to determine a candidate character region from the edge image; a verification module configured to verify the candidate character region to obtain a character region; the determination module comprises a comparison submodule, a setting submodule, and a first filtering submodule; the comparison submodule is configured to compare the edge value of each pixel point in the edge image with a first preset threshold value and a second preset threshold value respectively; the first preset threshold value is greater than the second preset threshold value; the setting submodule is configured to set the pixel value of a pixel point with an edge value greater than the first preset threshold value to 255, set the pixel value of a pixel point with an edge value greater than the second preset threshold value and less than the first preset threshold value to 128, and set the pixel value of a pixel point with an edge value less than the second preset threshold value to 0 to obtain a black-and-white-and-gray image; The first filtering submodule is configured to filter pixels of non-character regions in the black-and-white image to obtain the candidate text region. The first filtering submodule comprises a first determining unit, a second determining unit and a first setting unit. The first determining unit is configured to determine, for each first target pixel point in the black-and-white image, whether a pixel value of the first target pixel point is equal to zero. The second determining unit is configured to, when determining that the pixel value of the first target pixel point is not equal to zero, determine, with the first target pixel point as a base point, a first first pixel point in a first direction whose pixel value is equal to zero, a first second pixel point in a second direction whose pixel value is equal to zero, a first third pixel point in a third direction whose pixel value is equal to zero, and a first fourth pixel point in a fourth direction whose pixel value is equal to zero; the first direction and the second direction are opposite directions, the third direction and the fourth direction are opposite directions, and the first direction is perpendicular to the third direction. The first setting unit is configured to, when determining that a distance between the first pixel point and the second pixel point is less than a first preset value, or a distance between the third pixel point and the fourth pixel point is less than a second preset value, or the distance between the first pixel point and the second pixel point is less than the distance between the third pixel point and the fourth pixel point, set the pixel value of the first target pixel point to zero.

Citation Information

Patent Citations

  • Picture processing method and apparatus

    CN105260428A

  • License plate image binaryzation method based on Laplacian extension operator

    CN107909075A