Method, system, detection device and storage medium for detecting red waterline of bills

By calculating the ratio of red and black pixels in the red waterline detection image, the average value of white line penetration and horizontal projection histogram analysis, the problem of red waterline detection being easily affected by background interference is solved, and the detection accuracy is improved.

CN113255680BActive Publication Date: 2025-10-14SHENZHEN YIHUA COMP +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011508090.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-18
Publication Date
2025-10-14
Estimated Expiration
2040-12-18

AI Technical Summary

Technical Problem

The red waterline detection algorithm in the existing technology is easily affected by background interference, resulting in missed detection or missing red waterline.

Method used

The presence of a red waterline is determined by calculating the ratio of red and black pixels in the target detection image, obtaining the average value of white line penetration in the binary image, and analyzing the histogram of the horizontal projection.

Benefits of technology

The accuracy of red waterline detection is improved and the probability of missed detection is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113255680B_ABST
    Figure CN113255680B_ABST
Patent Text Reader

Abstract

The application discloses a method for detecting a red water line of a bill, comprising the following steps: acquiring a target detection image of a target detection area of a target bill to be detected, acquiring a first quantity of red pixel points and a second quantity of black pixel points in the target detection image, and calculating a first ratio of a sum of the first quantity and the second quantity to a total quantity of pixels of the target detection image; determining whether the first ratio is less than a preset first threshold value, and if not, acquiring a binary image of the target detection image; acquiring a first number of white line penetrations of at least one column in the binary image, and calculating a first average value of the first number; determining whether the first average value is less than a preset second threshold value, and if not, acquiring a projection histogram of a horizontal direction projection of the binary image; determining whether the projection histogram meets a preset image requirement, and if the projection histogram meets the preset image requirement, determining that the target detection area has a red water line. The application further discloses a system for detecting a red water line of a bill, a detection device and a storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image detection, in particular to a method and system for detecting a red water line of a bill, a detection device and a storage medium. BACKGROUND

[0002] The current red water line detection algorithm only counts the average number of red water lines from a one-dimensional perspective. Specifically, the number of times each column of the image penetrates the white line is obtained, and the average penetration number of the image is obtained. Once the average penetration number is less than the preset number of red water line, it is considered that the condition is not met, and the red water line is missing. Moreover, the penetration number is only counted from a one-dimensional perspective, which is easily disturbed by the background. Once the background is not clean, the penetration number of each column can reach a number close to the preset threshold, thereby affecting the algorithm judgment and leading to the problem of missing red water line. SUMMARY

[0003] The present application provides a method and system for detecting a red water line of a bill, a detection device and a storage medium, which are used to solve the problem of missing red water line caused by the one-dimensional penetration statistics being easily disturbed and affecting the judgment.

[0004] A method for detecting a red water line of a bill, comprising: obtaining a target detection image of a target detection region of a target bill to be detected, obtaining a first number of red pixel points and a second number of black pixel points in the target detection image, calculating a first ratio of the sum of the first number and the second number to the total number of pixels of the target detection image; determining whether the first ratio is less than a preset first threshold value, if the first ratio is greater than or equal to the preset first threshold value, obtaining a binary image of the target detection image; obtaining a first number of white line penetrations of at least one column in the binary image, calculating a first average value of the first number; determining whether the first average value is less than a preset second threshold value, if the first average value is greater than or equal to the preset second threshold value, obtaining a projection histogram of a horizontal direction projection of the binary image; determining whether the projection histogram meets a preset image requirement, if the projection histogram meets the preset image requirement, determining that the target detection region has a red water line.

[0005] The system for detecting red water line of a bill comprises a ratio module, a binary module, a mean module and a judging module.

[0006] A detection device comprises a memory and a processor, the memory stores a computer program, and the computer program is executed by the processor to make the processor execute the steps of the method.

[0007] A storage medium stores a computer program, and the computer program is executed by a processor to make the processor execute the steps of the method.

[0008] The embodiments of the present application have the following beneficial effects:

[0009] According to the first ratio of the sum of the first quantity of red pixel points and the second quantity of black pixel points in the target detection image to the total quantity of pixels in the target detection image, the existence of the red water line in the target detection image is preliminarily judged according to the minimum proportion of the red water line, the existence of the interval line segment in the target detection image is further judged according to the average value of the first quantity of white line penetration in at least one column of the binary image of the target detection image, and whether the parallel equidistant straight line exists is judged according to the projection histogram of the horizontal direction projection of the binary image, so that the accuracy of the judgment is improved, and the probability of missing the red water line is reduced. BRIEF DESCRIPTION OF DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.

[0011] Wherein:

[0012] Figure 1 is a flowchart of a first embodiment of the method for detecting red waterlines of a bill provided by the present application;

[0013] Figure 2 is a schematic diagram of a target detection image of a target detection area with red waterlines provided by the present application;

[0014] Figure 3 is a schematic diagram of a target detection image of a target detection area without red waterlines provided by the present application;

[0015] Figure 4 is a schematic diagram of a projection histogram of a target detection area with red waterlines provided by the present application;

[0016] Figure 5 is a schematic diagram of a projection histogram of a target detection area without red waterlines provided by the present application;

[0017] Figure 6 is a flowchart of a second embodiment of the method for detecting red waterlines of a bill provided by the present application;

[0018] Figure 7 is a schematic diagram of a de-interference image of a target detection area with red waterlines provided by the present application;

[0019] Figure 8 is a schematic diagram of a de-interference image of a target detection area without red waterlines provided by the present application;

[0020] Figure 9 is a schematic diagram of a binarization image of a target detection area with red waterlines provided by the present application;

[0021] Figure 10 is a schematic diagram of a binarization image of a target detection area without red waterlines provided by the present application;

[0022] Figure 11 is a schematic diagram of a de-noising image of a target detection area with red waterlines provided by the present application;

[0023] Figure 12 is a schematic diagram of a de-noising image of a target detection area without red waterlines provided by the present application;

[0024] Figure 13 is a flowchart of a third embodiment of the method for detecting red waterlines of a bill provided by the present application;

[0025] Figure 14 is a structural schematic diagram of an embodiment of the system for detecting red waterlines of a bill provided by the present application. DETAILED DESCRIPTION

[0026] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0027] See also Figure 1 , Figure 1 1 is a flow chart of a first embodiment of a method for detecting red waterline on bills provided by the present invention, comprising the following steps:

[0028] S101: Obtain a target detection image of a target detection area of ​​a target detection ticket, obtain a first number of red pixels and a second number of black pixels in the target detection image, and calculate a first ratio of the sum of the first number and the second number to the total number of pixels in the target detection image.

[0029] In a specific implementation scenario, a target detection image of the target detection area of ​​a target detection bill is obtained. The red waterline of the bill is generally at a fixed position. Therefore, there is no need to perform global detection to detect whether there is a red waterline in the target detection bill. It is only necessary to zoom in a certain proportion (to avoid omission) according to the fixed position of the red waterline to obtain the target detection area. You can first obtain the bill image of the target detection bill, and then take a screenshot of the bill image according to the position information of the target detection area to obtain the target detection image. The target detection image is in RGB mode, and the target detection image is converted into a target conversion image of the HSV color model, such as Figure 2 The target detection image shown is the target detection area with a red waterline, as shown in Figure 3 Shown is the target detection image of the target detection area without the red waterline.

[0030] Converting the target detection image in the RGB model to a target conversion image in the HSV color model can be performed using an existing conversion formula or algorithm, which will not be described in detail here. A first number of red pixels and a second number of black pixels in the target conversion image in the HSV color model are obtained. The first number and the second number are added to obtain a first ratio of the number of pixels to the total number of pixels in the target detection image.

[0031] In other implementation scenarios, the first number of red pixels and the second number of black pixels may be directly obtained based on the acquired target detection image, and the first number and the second number are added to obtain a first ratio of the number of pixels to the total number of pixels in the target detection image.

[0032] S102: Determine whether the first ratio is less than a preset first threshold, if not, execute step S103. If yes, execute step S109.

[0033] In one specific implementation scenario, the target detection region where the red waterline is located includes the red waterline and the black text, and if the proportion of the area occupied by the red pixel points of the red waterline and the black pixel points of the black text is too low, it indicates that the target detection region does not have a red waterline. In this implementation scenario, the first threshold value is 0.4, and if the first ratio is greater than or equal to 0.4, the target detection region may have a red waterline.

[0034] S103: Obtain a binary image of the target detection image.

[0035] In one specific implementation scenario, if the first ratio is greater than or equal to a preset first threshold value, the target detection region may have a red waterline, and subsequent operations are performed to further determine whether there is a red waterline. The binary image of the target detection image is obtained, for example, a binary threshold value can be set, the target detection image is subjected to a binary operation, and the binary image is obtained.

[0036] S104: Obtain a first number of white line penetrations in at least one column of the binary image, and calculate a first average value of the first number.

[0037] In one specific implementation scenario, the first number of white line penetrations in at least one column of the binary image is obtained. Specifically, the number of white line penetrations in each column of the binary image can be obtained as the first number, the number of white line penetrations can also be obtained at intervals of at least one column as the first number, or the number of white line penetrations in a specified column can be obtained as the first number. The adjacent color difference of each column of pixels of the binary image can be obtained, and when the adjacent color difference is greater than a preset color difference threshold value, it is recorded. The number of white line penetrations in each column is obtained according to the number of records. The number of consecutive preset number (for example, 20, 30, 50) of pixel values of each column of pixels greater than a preset value (for example, 230, 240, 250) can also be obtained, and the first number is obtained according to the number.

[0038] After obtaining at least one first number, a first average value of the at least one first number is calculated, and the first average value can be any one of an arithmetic average value, a geometric average value, a square average value, a harmonic average value, and a weighted average value.

[0039] S105: Determine whether the first average value is less than a preset second threshold value, and if not, perform step S106. If yes, perform step S109.

[0040] In a specific implementation scenario, it is determined whether the first average value is less than a preset second threshold value. The preset second threshold value is set to 8, and ideally should be set to 9. However, this is to prevent the algorithm from misdetecting the target detection area due to incomplete interception of the red waterline area. If the first average value is greater than or equal to the preset second threshold value, it indicates that the target detection area may contain a red waterline, and subsequent operations are performed for further determination. If the first average value is less than the preset second threshold value, it indicates that the number of penetrations of at least one column of white lines is too small, and the target detection area does not contain a red waterline.

[0041] S106: Obtain a projection histogram of the horizontal projection of the binarized image.

[0042] In a specific implementation scenario, if the first average value is greater than or equal to the preset second threshold value, it indicates that there may be a red waterline in the target detection area, and a projection histogram of the horizontal projection of the binary image can be obtained. Specifically, the sum of the pixel values ​​of each row of the binary image can be obtained, and a projection histogram can be obtained based on the sum of the pixel values. For example, a projection histogram is drawn with the number of rows as the x-axis and the sum of the pixel values ​​as the y-axis. In order to better understand the projection histogram, as shown in FIG. Figure 4 The projection histogram of the target detection area with red waterline is shown. Figure 5 Shown is the projection histogram of the target detection area without the red waterline.

[0043] S107: Determine whether the projection histogram meets the preset image requirements. If so, execute step S108; if not, execute step S109.

[0044] In a specific implementation scenario, according to Figure 4 and Figure 5 It can be seen that Figure 5 There are multiple red arcs in the corresponding target detection area, so Figure 5 The first mean value of the corresponding target detection area may be greater than the preset second threshold, but the red waterline is a plurality of parallel horizontal lines, so Figure 4 The projection histogram of is a regular wave shape, and Figure 5 The projection histogram is an irregular curve. Therefore, image recognition or image processing can be performed on the projection histogram to determine whether it meets preset image requirements. The preset image requirements may include at least one of limiting the number of peaks and / or troughs of the wavy lines in the projection histogram, limiting the difference between each peak and / or trough, and limiting the distance between each peak and / or trough.

[0045] S108: Determine whether a red waterline exists in the target detection area.

[0046] In a specific implementation scenario, if the projection histogram meets preset image requirements, it is determined that a red watermark exists in the target detection area. Information about the presence of the red watermark in the target detection area can be output to the user, or the authenticity of the target detection bill can be determined based on the information about the presence of the red watermark in the target detection area.

[0047] S109: Feedback to the user that there is no red waterline in the target detection area.

[0048] In a specific implementation scenario, if the projection histogram does not meet the preset image requirements, it is determined that there is no red waterline in the target detection area. Information indicating that there is no red waterline in the target detection area can be output to the user.

[0049] From the above description, it can be seen that in this embodiment, according to the first ratio of the sum of the first number of red pixels and the second number of black pixels in the target detection image to the total number of pixels of the target detection image, a preliminary judgment is made as to whether there is a red waterline in the target detection image according to the minimum proportion of the red waterline, and according to the average value of the first number of white lines penetrating at least one column of the binary image of the target detection image, it is further judged whether there are spaced line segments in the target detection image, and then according to the projection histogram of the horizontal projection of the binary image, it is judged whether there are parallel and equally spaced straight lines, thereby improving the accuracy of the judgment and reducing the probability of missing or missing red waterlines.

[0050] See also Figure 6 , Figure 6 1 is a flow chart of a second embodiment of the method for detecting the red waterline of a bill provided by the present invention, comprising the following steps:

[0051] S201: Acquire a target detection image of a target detection area of ​​a target detection ticket, and convert the target detection image into a target conversion image of an HSV color model, where the target conversion image includes a red HSV model image and a black HSV model image.

[0052] In a specific implementation scenario, the HSV color model algorithm may choose to retain only one color, such as red, black, etc. The target conversion image includes a red HSV model image retaining only red and a black HSV model image retaining only black.

[0053] S202: Obtain a first number of red pixels in the red HSV model image and a second number of black pixels in the black HSV model image, and calculate a first ratio of the sum of the first number and the second number to the total number of pixels in the target detection image.

[0054] In a specific implementation scenario, a first number of red pixels in a red HSV model image is obtained, a second number of black pixels in a black HSV model image is obtained, and the first number and the second number are added to obtain a first ratio of the number of pixels to the total number of pixels in the target detection image. Separately obtaining the first number of red pixels in the red HSV model image and the second number of black pixels in the black HSV model image can improve the accuracy of the first number and the second number.

[0055] S203: Determine whether the first ratio is less than a preset first threshold. If so, execute step S204; if not, execute step S211.

[0056] In a specific implementation scenario, step S203 is basically the same as step S102 in the first embodiment of the method for detecting the red waterline of a bill of the present invention, and will not be described in detail here.

[0057] S204: Obtain a first color image of a first color channel of the target detection image and a second color image of a second color channel of the target detection image, and subtract the first color image from the second color image to obtain a de-interferenced image.

[0058] In a specific implementation scenario, a first color image of a first color channel of a target detection image and a second color image of a second color channel of the target detection image are obtained, where the first color and the second color are different, and the first color image and the second color image are subtracted to remove unnecessary noise interference, thereby obtaining a de-interferenced image, such as unnecessary interference from black text.

[0059] Please refer to Figure 7 and Figure 8 , Figure 7 : is a schematic diagram of a de-interferenced image of a target detection area with a red waterline provided by the present invention, Figure 8 It is a schematic diagram of a de-interferenced image of a target detection area without a red waterline provided by the present invention.

[0060] S205: Performing horizontal Sobel edge detection on the interference-removed image to obtain an edge detection image, and binarizing the edge detection image to obtain a binarized image.

[0061] In a specific implementation scenario, horizontal Sobel edge detection is performed on the de-interferenced image to make horizontal straight lines more prominent, thereby obtaining an edge detection image. The edge detection image is then binarized using a binarization method to obtain a binary image. The binarization method can be fixed threshold binarization, where pixel values ​​in the edge detection image that are less than the threshold are set to white, and pixels that are greater than the threshold are set to black. Please refer to Figure 9 and Figure 10 , Figure 9is a schematic diagram of a binary image of a target detection area with a red waterline provided by the present invention, Figure 10 It is a schematic diagram of a binary image of a target detection area without a red waterline provided by the present invention.

[0062] S206: Denoising the upper and lower edges of the binary image to obtain a denoised image, obtaining the first number of white line penetrations in each column of the denoised image, and calculating a first average value of the first number.

[0063] In a specific implementation scenario, such as Figure 9 and Figure 10 As shown in , due to the Sobel edge detection, there are some extra white dots on the upper and lower edges of the binary image. Therefore, the upper and lower edges of the binary image are denoised to obtain the white areas composed of continuous white pixels on the upper and lower edges. The number of white pixels in each white area is obtained. If the number is less than the preset continuous threshold, the white pixels in the white area are replaced with black pixels to obtain the denoised image, as shown in Figure 11 Shown is the denoised image of the target detection area with a red waterline, as shown Figure 12 Shown is the denoised image of the target detection area without the red waterline.

[0064] The steps for obtaining the first number and the first average are basically the same as those described above and will not be described again here.

[0065] S207: Determine whether the first average value is less than a preset second threshold value. If so, execute step S208; if not, execute step S211.

[0066] S208: Obtain a projection histogram of the horizontal projection of the binarized image.

[0067] S209: Determine whether the projection histogram meets the preset image requirements. If so, execute step S210; if not, execute step S211.

[0068] In a specific implementation scenario, steps S207-S211 are basically the same as steps S105-109 in the first embodiment of the method for detecting the red waterline of a bill provided by the present invention, and will not be described in detail here.

[0069] From the above description, it can be seen that in this embodiment, the first color image of the first color channel of the target detection image and the second color image of the second color channel of the target detection image are subtracted to obtain a denoised image, which can remove interference factors in the target detection image. Performing horizontal Sobel edge detection on the denoised image can make the horizontal straight line more prominent. Performing denoising on the upper and lower edges of the binary image can remove the white spots caused by the Sobel edge detection, thereby improving the accuracy of the judgment and reducing the probability of missing or missing red waterlines.

[0070] See also Figure 13 , Figure 13 1 is a flow chart of a third embodiment of the method for detecting the red waterline of a bill provided by the present invention, comprising the following steps:

[0071] S301: Obtain a target detection image of a target detection area of ​​a target detection ticket, obtain a first number of red pixels and a second number of black pixels in the target detection image, and calculate a first ratio of the sum of the first number and the second number to the total number of pixels in the target detection image.

[0072] S302: Determine whether the first ratio is less than a preset first threshold, if not, execute step S303. If yes, execute step S310.

[0073] S303: Obtain a binary image of the target detection image.

[0074] S304: Obtain a first number of white line penetrations in at least one column of the binary image, and calculate a first average value of the first number.

[0075] S305: Determine whether the first average value is less than a preset second threshold value, if not, execute step S306. If yes, execute step S310.

[0076] In a specific implementation scenario, steps S301-S305 are basically the same as steps S101-105 in the first embodiment of the method for detecting the red waterline of a bill provided by the present invention, and will not be described in detail here.

[0077] S306: Obtain the sum of pixel values ​​of each row of the binary image, obtain the projection value of each row according to the sum of the pixel values ​​of each row, and draw a histogram according to the projection values.

[0078] In a specific implementation scenario, the sum of the pixel values ​​of each row of the binary image is obtained. A row is selected from the binary image as the current row, and the sum of the pixel values ​​of the current row and the n adjacent rows is added to obtain the projection value of the current row. For example, when n = 2, if the current row is row 1, the sum of the pixel values ​​of rows 1, 2, and 3 is added to obtain the projection value of row 1. If the current row is row m, the sum of the pixel values ​​of rows m, m+1, and m+2 is added to obtain the projection value of row m. A projection histogram is drawn based on the projection values ​​of each row of the binary image.

[0079] The value of n is preferably smaller than the spacing between red waterline lines, as too large a value will cause the projections of multiple red waterline lines to overlap. The purpose of taking n rows is that the red waterline may be slightly tilted, and taking only one row to calculate the row sum may not make the peak obvious.

[0080] S307: Obtain extreme points of the projection histogram.

[0081] In a specific implementation scenario, any row in the binary image is selected as the current row, and the projection value of the current row is subtracted from the projection value of the adjacent row to obtain the pixel difference value of the current row. For example, if the current row is row 1, the projection value of row 2 is subtracted from the projection value of row 1 to obtain the pixel difference value of row 1. For example, if the current row is row m, the projection value of row m+1 is subtracted from the projection value of row m to obtain the pixel difference value of row m.

[0082] Replace the pixel difference in the current row to obtain the replacement value of the current row. If the pixel difference is greater than 0, the replacement value is 1. If the pixel difference is less than 0, the replacement value is -1. If the pixel difference is 0, no replacement is performed. For example, if the pixel difference in row m is 12, it is replaced with 1. If the pixel difference in row m+1 is -3, it is replaced with -1.

[0083] Subtract the replacement value of the current row from the replacement value of the adjacent row to obtain the target value for the current row. For example, the target value for row m is the replacement value of row m+1 minus the replacement value of row m, which is -1. If the target value for the current row is -2, it means that the projected value before the current row is increasing, while the projected value after the current row is decreasing. Therefore, the position corresponding to the current row in the projection histogram is an extreme point.

[0084] S308: Determine whether the extreme point meets the preset extreme point requirements. If yes, execute step S309; ​​if not, execute step S310.

[0085] In a specific implementation scenario, it is determined whether the obtained extreme value points meet the preset extreme value point requirements. The preset extreme value point requirements include quantity requirements and spacing requirements. The number of extreme value points in the projection histogram is obtained. The number of extreme value points corresponds to the number of red waterlines in the target detection image. It is determined whether the number is greater than or equal to a preset third threshold. The preset third threshold is 8 in this embodiment. If the number is less than the preset third threshold, it indicates that the target detection image does not include the red waterline. If the number is greater than or equal to the preset third threshold, it indicates that the target detection area may include the red waterline. It is further determined whether the extreme value points meet the spacing requirements.

[0086] Obtain the coordinates of each extreme point in the projection histogram, calculate the coordinate difference between every two adjacent extreme points, specifically, obtain the horizontal coordinate of each extreme point in the projection histogram, calculate the difference between the horizontal coordinates of any two adjacent extreme points as the coordinate difference, calculate the average of all coordinate differences in the projection histogram as the second average, and determine whether the second average meets the interval requirement, for example, determine whether the difference between the second average and the preset interval value is less than a fourth threshold, that is, determine whether the second average is within a preset interval range, the preset interval range = preset interval value + / - fourth threshold. The fourth threshold is 1. If the target detection area includes a red waterline, the difference between the second average and the preset spacing value should be less than or equal to 1.

[0087] In other implementation scenarios, it is also possible to determine whether the number of extreme points meets the quantity requirement, whether the spacing between extreme points meets the spacing requirement, or whether the spacing between extreme points meets the spacing requirement first, and then determine whether the number of extreme points meets the quantity requirement.

[0088] S309: Determine whether a red waterline exists in the target detection area.

[0089] S310: Feedback to the user that there is no red waterline in the target detection area.

[0090] In a specific implementation scenario, step S309 and step S310 are basically the same as steps S108 and S109 in the first embodiment of the method for detecting the red waterline of a bill provided by the present invention, and will not be repeated here.

[0091] From the above description, it can be seen that in this embodiment, the extreme points of the projection histogram are obtained, and it is judged whether the extreme points meet the preset extreme point requirements. The extreme points are judged from the two aspects of number and interval according to the distribution characteristics of the red water line, which can further improve the accuracy of the judgment and reduce the probability of missing or missing red water lines.

[0092] See also Figure 14 , Figure 14 It is a structural diagram of an embodiment of the system for detecting the red waterline of bills provided by the present invention. The system 10 for detecting the red waterline of bills includes a ratio module 11, a binary module 12, an average module 13, a projection module 14 and a judgment module 15.

[0093] The ratio module 11 is used to obtain a target detection image of the target detection area of ​​the target detection ticket, obtain a first number of red pixels and a second number of black pixels in the target detection image, and calculate a first ratio of the sum of the first and second numbers to the total number of pixels in the target detection image. The binary module 12 is used to determine whether the first ratio is less than a preset first threshold. If the first ratio is greater than or equal to the preset first threshold, a binary image of the target detection image is obtained. The average module 13 is used to obtain the first number of white line penetrations in each column of the binary image and calculate a first average of the first number. The projection module 14 is used to determine whether the first average is less than a preset second threshold. If the first average is greater than or equal to the preset second threshold, a histogram of the horizontal projection of the binary image is obtained. The judgment module 15 is used to determine whether the projection histogram meets preset image requirements. If the projection histogram meets the preset image requirements, it is determined that a red waterline exists in the target detection area.

[0094] The judgment module 15 is further configured to obtain an extreme point of the projection histogram and judge whether the extreme point meets a preset extreme point requirement. If the extreme point meets the preset extreme point requirement, it is determined that a red waterline exists in the target detection area.

[0095] The projection module 14 is also used to obtain the sum of the pixel values ​​of the pixel points in each row of the binary image, select any row from the binary image as the current row, add the sum of the pixel values ​​of the current row and the n rows adjacent to the current row, and obtain the projection value of the current row, where n is greater than or equal to 1; and draw a projection histogram according to the projection value of each row of the binary image.

[0096] The judgment module 15 is also used to subtract the projection value of the current row from the projection value of the adjacent row of the current row to obtain the pixel difference value of the current row; replace the pixel difference value of the current row to obtain the replacement value of the current row, if the pixel difference value is greater than 0, the replacement value is 1, if the pixel difference value is less than 0, the replacement value is -1; subtract the replacement value of the current row from the replacement value of the adjacent row of the current row to obtain the target value of the current row, if the target value of the current row is -2, then the corresponding position of the current row in the projection histogram is the extreme point.

[0097] The judgment module 15 is also used to obtain the number of extreme points in the projection histogram, determine whether the number is greater than or equal to a preset third threshold, and if the number is less than the preset third threshold, determine that the target detection image does not include the red waterline; if the number is greater than or equal to the third threshold, obtain the coordinates of each extreme point in the projection histogram, calculate the coordinate difference between every two adjacent extreme points, and calculate the second average value of the coordinate difference in the projection histogram; determine whether the difference between the second average value and the preset interval value is less than a preset fourth threshold, and if the difference is less than the fourth threshold, determine that the target detection image includes the red waterline.

[0098] The binary module 12 is also used to obtain a first color image of a first color channel of the target detection image and a second color image of a second color channel of the target detection image, subtract the first color image and the second color image to obtain a de-interferenced image, wherein the first color and the second color are different; perform horizontal Sobel edge detection on the de-interferenced image to obtain an edge detection image, and binarize the edge detection image to obtain a binarized image.

[0099] The mean value module 13 is further configured to perform denoising on the upper and lower edges of the binary image to obtain a denoised image, and obtain the first number of white line penetrations in each column of the denoised image.

[0100] The ratio module 11 is also used to convert the target detection image into a target conversion image of the HSV color model, where the target conversion image includes a red HSV model image and a black HSV model image; and obtain a first number of red pixels in the red HSV model image and a second number of black pixels in the black HSV model image.

[0101] From the above description, it can be seen that in this embodiment, the system for detecting the red waterline of the bill preliminarily determines whether there is a red waterline in the target detection image based on the first ratio of the sum of the first number of red pixels and the second number of black pixels in the target detection image to the total number of pixels of the target detection image, and according to the minimum proportion of the red waterline, further determines whether there are spaced line segments in the target detection image based on the average value of the first number of white lines penetrating at least one column of the binary image of the target detection image, and then determines whether there are parallel and equally spaced straight lines based on the projection histogram of the horizontal projection of the binary image, thereby improving the accuracy of the judgment and reducing the probability of missing or missing red waterlines.

[0102] The present invention also provides a detection device, which includes a processor and a memory. The processor is coupled to the memory. The memory stores a computer program, and the processor executes the computer program when working to achieve the following Figure 1 、 Figure 6 and Figure 13 The detailed method can be found in the above, which will not be described here.

[0103] From the above description, it can be seen that in this embodiment, the detection device preliminarily determines whether there is a red waterline in the target detection image based on the first ratio of the sum of the first number of red pixels and the second number of black pixels in the target detection image to the total number of pixels of the target detection image, and according to the minimum proportion of the red waterline, further determines whether there are spaced line segments in the target detection image based on the average value of the first number of white lines penetrating at least one column of the binary image of the target detection image, and then determines whether there are parallel and equally spaced straight lines based on the projection histogram of the horizontal projection of the binary image, thereby improving the accuracy of the judgment and reducing the probability of missing the red waterline.

[0104] The present invention also provides a storage medium. The storage medium stores at least one computer program, which is used to be executed by a processor to implement the following Figure 1 、 Figure 6 and Figure 13 In one embodiment, the storage medium may be a storage chip, a hard disk, a mobile hard disk, a USB flash drive, an optical disk, or other readable and writable storage tools in the terminal, or a server, etc.

[0105] From the above description, it can be seen that the computer program in the storage medium in this embodiment can be used to preliminarily judge whether there is a red waterline in the target detection image according to the first ratio of the sum of the first number of red pixels and the second number of black pixels in the target detection image to the total number of pixels of the target detection image, and according to the minimum proportion of the red waterline, and further judge whether there are spaced line segments in the target detection image according to the average value of the first number of white lines penetrating at least one column of the binary image of the target detection image, and then judge whether there are parallel and equally spaced straight lines according to the projection histogram of the horizontal projection of the binary image, thereby improving the accuracy of the judgment and reducing the probability of missing or missing red waterlines.

[0106] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0107] Any combination of the technical features in the above embodiments can be made, and for the sake of brevity, not all possible combinations are described, however, any combination of the technical features is deemed to be within the scope of the present disclosure as long as there is no inconsistency.

[0108] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be pointed out that for ordinary skilled persons in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.

Claims

1. A method for detecting the red waterline of a bill, characterized in that: include: Obtaining a target detection image of a target detection area of ​​the target detection ticket, obtaining a first number of red pixels and a second number of black pixels in the target detection image, and calculating a first ratio of a sum of the first number and the second number to a total number of pixels in the target detection image; determining whether the first ratio is less than a preset first threshold, and if the first ratio is greater than or equal to the preset first threshold, obtaining a binarized image of the target detection image; Obtaining a first number of white line penetrations in at least one column of the binary image, and calculating a first average value of the first number; determining whether the first average value is less than a preset second threshold value, and if the first average value is greater than or equal to the preset second threshold value, obtaining a projection histogram of a horizontal projection of the binarized image; Determining whether the projection histogram meets the preset image requirements, and if the projection histogram meets the preset image requirements, determining that a red waterline exists in the target detection area; The step of determining whether the projection histogram meets the preset image requirements includes: Obtaining an extreme point of the projection histogram, determining whether the extreme point meets a preset extreme point requirement, and if the extreme point meets the preset extreme point requirement, determining that a red waterline exists in the target detection area; The step of obtaining the extreme points of the projection histogram includes: Selecting any row from the binary image as a current row, subtracting the projection value of the current row from the projection value of the adjacent row of the current row to obtain a pixel difference value of the current row; Replacing the pixel difference value of the current row to obtain a replacement value of the current row, if the pixel difference value is greater than 0, the replacement value is 1, if the pixel difference value is less than 0, the replacement value is -1; Subtract the replacement value of the current row from the replacement value of the adjacent row of the current row to obtain the target value of the current row. If the target value of the current row is -2, the position corresponding to the current row in the projection histogram is the extreme value point; The step of determining whether the extreme point meets the preset extreme point requirements includes: Obtaining the number of extreme value points in the projection histogram, determining whether the number is greater than or equal to a preset third threshold, and if the number is less than the preset third threshold, determining that the target detection image does not include the red waterline; If the number is greater than or equal to the third threshold, obtaining the coordinates of each extreme point in the projection histogram, calculating the coordinate difference between every two adjacent extreme points, and calculating a second average value of the coordinate differences in the projection histogram; determining whether a difference between the second average value and a preset interval value is less than a preset fourth threshold, and if the difference is less than the fourth threshold, determining that the target detection image includes a red waterline; The step of obtaining the first number of white line penetrations in each column of the binary image includes: Denoising is performed on the upper and lower edges of the binary image to obtain a denoised image, and the first number of white line penetrations in each column of the denoised image is obtained.

2. The method for detecting the red waterline of a bill according to claim 1, characterized in that: The step of obtaining a projection histogram of the horizontal projection of the binary image comprises: Obtaining the sum of pixel values ​​of pixels in each row of the binary image, adding the sum of pixel values ​​of the current row and n rows adjacent to the current row to obtain a projection value of the current row, where n is greater than or equal to 1; The projection histogram is drawn according to the projection value of each row of the binary image.

3. The method for detecting the red waterline of a bill according to claim 1, characterized in that: The step of obtaining a binary image of the target detection image includes: Obtaining a first color image of a first color channel of the target detection image and a second color image of a second color channel of the target detection image, and subtracting the first color image from the second color image to obtain a de-interferenced image, wherein the first color and the second color are different; Performing horizontal Sobel edge detection on the interference-removed image to obtain an edge detection image, and binarizing the edge detection image to obtain the binarized image.

4. The method for detecting the red waterline of a bill according to claim 1, characterized in that: The step of obtaining a first number of red pixels and a second number of black pixels in the target detection image includes: Converting the target detection image into a target conversion image of an HSV color model, wherein the target conversion image includes a red HSV model image and a black HSV model image; A first number of red pixels in the red HSV model image and a second number of black pixels in the black HSV model image are obtained.

5. A system for detecting the red waterline of bills, characterized in that: include: a ratio module, configured to obtain a target detection image of a target detection area of ​​the target detection ticket, obtain a first number of red pixels and a second number of black pixels in the target detection image, and calculate a first ratio of a sum of the first number and the second number to a total number of pixels in the target detection image; a binary module, configured to determine whether the first ratio is less than a preset first threshold, and if the first ratio is greater than or equal to the preset first threshold, obtain a binary image of the target detection image; an average module, configured to obtain a first number of white line penetrations in each column of the binary image and calculate a first average value of the first number; wherein the step of obtaining the first number of white line penetrations in each column of the binary image comprises: performing denoising on upper and lower edges of the binary image to obtain a denoised image, and obtaining the first number of white line penetrations in each column of the denoised image; a projection module, configured to determine whether the first average value is less than a preset second threshold value, and if the first average value is greater than or equal to the preset second threshold value, obtain a histogram of a horizontal projection of the binarized image; a judgment module, configured to judge whether the projection histogram meets the preset image requirements, and if the projection histogram meets the preset image requirements, judge whether a red waterline exists in the target detection area; The step of determining whether the projection histogram meets the preset image requirements includes: obtaining an extreme point of the projection histogram, determining whether the extreme point meets the preset extreme point requirements, and if the extreme point meets the preset extreme point requirements, determining that a red waterline exists in the target detection area; Wherein, the step of obtaining the extreme point of the projection histogram includes: selecting any row from the binary image as the current row, subtracting the projection value of the current row from the projection value of the adjacent row of the current row to obtain the pixel difference value of the current row; replacing the pixel difference value of the current row to obtain a replacement value of the current row, if the pixel difference value is greater than 0, the replacement value is 1, if the pixel difference value is less than 0, the replacement value is -1; subtracting the replacement value of the current row from the replacement value of the adjacent row of the current row to obtain a target value of the current row, if the target value of the current row is -2, then the corresponding position of the current row in the projection histogram is the extreme point; Among them, the step of judging whether the extreme point meets the preset extreme point requirements includes: obtaining the number of extreme points in the projection histogram, judging whether the number is greater than or equal to a preset third threshold, if the number is less than the preset third threshold, judging that the target detection image does not include the red waterline; if the number is greater than or equal to the third threshold, obtaining the coordinates of each extreme point in the projection histogram, calculating the coordinate difference between each two adjacent extreme points, and calculating the second average value of the coordinate difference in the projection histogram; judging whether the difference between the second average value and the preset interval value is less than a preset fourth threshold, if the difference is less than the fourth threshold, judging that the target detection image includes the red waterline.

6. A detection device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 4.

7. A storage medium, characterized in that: A computer program is stored, and when the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Real-time dynamic traffic light detection identification method based on unmanned driving

    CN103489324A

  • Image detection method and device, and bill identification instrument

    CN109410420A