Image detection method, device and storage medium based on spatial distribution
By acquiring the contour information of the image to determine the distribution of the limit eight-grayscale nine-window signal image, and setting a two-level condition to filter out non-limit images, the problem of low detection accuracy in the existing technology is solved, and efficient and accurate image detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN SKYWORTH RGB ELECTRONICS CO LTD
- Filing Date
- 2022-12-21
- Publication Date
- 2026-06-16
AI Technical Summary
Existing technologies have low detection accuracy for extreme eight-grayscale nine-window signal images. Conventional methods cannot accurately determine the number of color pixels in the image, resulting in a high false positive rate.
By acquiring the contour information of the image to be detected, it is determined whether there is a nine-window signal image with equal proportions. Based on the contour information, it is determined whether the limit eight-grayscale signal image meets the preset image distribution standard. Secondary conditions are set to screen out non-limit eight-grayscale signal images, thereby improving the detection accuracy.
It achieves accurate and rapid detection of extreme eight-grayscale nine-window signal images, improves detection accuracy, reduces false positives, and enhances image detection efficiency.
Smart Images

Figure CN115861270B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image detection method, device and storage medium based on spatial distribution. Background Technology
[0002] With the increasing demand for televisions, they have become one of the major energy-consuming home appliances today and in the future. Assessing the energy efficiency limits and energy efficiency ratings of televisions before they leave the factory is a crucial indicator for evaluating them. According to the new standard GB24850-2020 "Energy Efficiency Limits and Energy Efficiency Ratings for Flat Panel Televisions and Set-Top Boxes" issued by the State Administration for Market Regulation, televisions must undergo strict energy efficiency limit and energy efficiency rating assessments before leaving the factory. The extreme eight-grayscale nine-window signal image is the test image used for television testing and evaluation. Therefore, it is necessary to determine whether the test image is an extreme eight-grayscale nine-window signal image. The conventional method is to determine this through the color histogram of the image, but this method only determines the number of colored pixels in the test image, resulting in low accuracy in detecting extreme eight-grayscale nine-window signal images.
[0003] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main objective of this application is to provide an image detection method, device, and storage medium based on spatial distribution, aiming to solve the technical problem of low accuracy in the detection of extreme eight-grayscale nine-window signal images in the prior art.
[0005] To achieve the above objectives, this application provides an image detection method based on spatial distribution, the image detection method based on spatial distribution comprising:
[0006] Acquire the image to be detected, and determine the contour information of each object in the image to be detected according to a preset contour algorithm;
[0007] Based on the contour information, determine whether there is a proportionally distributed nine-window signal image in the image to be detected;
[0008] If it exists, then the limit eight grayscale signal image in the image to be detected is determined according to the contour information, and it is determined whether the limit eight grayscale signal image meets the preset image distribution standard.
[0009] If the conditions are met, the image to be detected is determined to be a limit eight-grayscale nine-window signal image.
[0010] Optionally, the step of acquiring the image to be detected and determining the contour information of each object in the image to be detected according to a preset contour algorithm includes:
[0011] The image to be detected is compressed to obtain a compressed image, and the compressed image is then converted to grayscale to obtain a grayscale compressed image.
[0012] The gray compressed image is binarized to obtain a black and white image according to a preset binarization threshold, and the contour information of each object in the black and white image is determined according to a preset contour algorithm.
[0013] Optionally, the step of determining the contour information of each object in the image to be detected according to a preset contour algorithm further includes:
[0014] Based on a preset contour algorithm, the contours of each object in the image to be detected are extracted;
[0015] Each of the contours is fitted to obtain the rectangular boundary and contour points corresponding to each contour, and the rectangular boundary and the contour points are used as the contour information, wherein the contour point is any vertex on the rectangular boundary corresponding to the contour.
[0016] Optionally, the contour information includes contour points, and the step of determining whether a proportionally distributed nine-window signal image exists in the image to be detected based on the contour information includes:
[0017] Based on the coordinates corresponding to each contour point, determine the maximum and minimum contour points among the contour points, and draw straight lines with the maximum and minimum contour points as initial points respectively to obtain a set of straight lines;
[0018] Determine whether the number of first contour points passed by each line in the set of lines is greater than or equal to a preset threshold for the number of contour points, wherein the first contour point is a contour point whose distance relative to any line in the set of lines is less than a preset threshold for the distance between points and lines.
[0019] If so, then it is determined that the image to be detected contains a nine-window signal image;
[0020] Based on the distance between the first contour points passed by each line in the set of lines, determine whether the nine-window signal image is a nine-window signal image with equal proportions.
[0021] Optionally, the step of drawing straight lines with the maximum contour point and the minimum contour point as initial points respectively to obtain a set of straight lines includes:
[0022] A first straight line is drawn with the maximum contour point as the initial point and the first coordinate point as the ending point. The first coordinate point is a coordinate point with the same x-coordinate value as the maximum contour point and a y-coordinate value of zero, and a coordinate point with the same y-coordinate value as the maximum contour point and a x-coordinate value of zero.
[0023] A second straight line is drawn with the minimum contour point as the initial point and the second coordinate point as the ending point. The second coordinate point is a coordinate point with the same x-coordinate value as the minimum contour point and the same y-coordinate value as the width of the image to be detected, and a coordinate point with the same y-coordinate value as the minimum contour point and the same x-coordinate value as the length of the image to be detected.
[0024] A third straight line is drawn with the maximum contour point as the initial point and the third coordinate point as the ending point, wherein the third coordinate point is the origin of the coordinate system in the image to be detected.
[0025] A fourth straight line is drawn with the minimum contour point as the initial point and the fourth coordinate point as the ending point, wherein the fourth coordinate point is the maximum coordinate point in the image to be detected;
[0026] The set of lines includes the first line, the second line, the third line, and the fourth line.
[0027] Optionally, the step of determining whether the nine-window signal image is a proportionally distributed nine-window signal image based on the distance between the first contour points traversed by each line in the set of lines includes:
[0028] Obtain the distance set corresponding to each line in the set of lines, wherein the distance set includes the first distance between each first contour point passed by the line and the initial point of the line;
[0029] Determine whether each first distance in each of the distance sets satisfies a preset multiple relationship;
[0030] If the condition is met, then the nine-window signal image is determined to be a nine-window signal image with equal proportions.
[0031] Optionally, the contour information includes a rectangular boundary, and the step of determining the extreme eight-grayscale signal image in the image to be detected based on the contour information includes:
[0032] Obtain the aspect ratio corresponding to the boundary of each rectangle;
[0033] The rectangular boundary whose aspect ratio is within the preset aspect ratio threshold range is used as the extreme eight-grayscale signal image.
[0034] Optionally, the step of determining whether the extreme eight-grayscale signal image meets the preset image distribution standard includes:
[0035] Obtain the second contour point corresponding to the extreme eight-grayscale signal image, and draw the fifth straight line based on the second contour point, wherein the second contour point is the contour point corresponding to the rectangular boundary in the extreme eight-grayscale signal image;
[0036] Determine whether the intersection point of the fifth line with respect to the third line and the fourth line meets the preset intersection point standard;
[0037] If satisfied, the extreme eight-grayscale signal image is determined to satisfy the image distribution standard.
[0038] This application also provides an image detection device, the image detection device comprising: a memory, a processor, and an image detection program stored in the memory and executable on the processor, the image detection program being configured to implement the steps of the spatial distribution-based image detection method described above.
[0039] This application also provides a storage medium, which is a computer-readable storage medium, on which an image detection program is stored. The image detection program is executed by a processor to implement the steps of the spatial distribution-based image detection method described above.
[0040] This application discloses an image detection method, device, and storage medium based on spatial distribution. It acquires an image to be detected and determines the contour information of each object in the image according to a preset contour algorithm, achieving accurate identification of the contour information corresponding to each object in the image. Then, based on the contour information, it determines whether a proportionally distributed nine-window signal image exists in the image. If it does, it determines a limit eight-grayscale signal image in the image based on the contour information and determines whether the limit eight-grayscale signal image meets a preset image distribution standard. If it does, it determines that the image to be detected is a limit eight-grayscale nine-window signal image. Through accurate identification of the contour information corresponding to each object in the image, it achieves accurate determination of the positional distribution of each contour in the image. The method employs a two-tiered approach to filter out images that do not meet the limit eight-grayscale nine-window signal criteria. Only images meeting all the criteria are identified as limit eight-grayscale nine-window signal images, thus improving image detection accuracy. Compared to conventional histogram detection methods that misclassify limit eight-grayscale images or images with the same color but different color window distributions, this application uses a two-tiered approach. The first tier filters out images lacking nine-window signals or those whose nine-window signals are not proportionally distributed. The second tier filters out images lacking limit eight-grayscale signals or those whose limit eight-grayscale signals do not meet the image distribution standards. This achieves accurate and rapid detection of the images under test, improving both detection efficiency and accuracy. Attached Figure Description
[0041] Figure 1 This is a schematic diagram of the structure of the image detection device in the hardware operating environment involved in the embodiments of this application;
[0042] Figure 2 This is a flowchart illustrating the first embodiment of the spatial distribution-based image detection method of this application.
[0043] Figure 3 This is a schematic diagram of a scene from the second embodiment of the spatial distribution-based image detection method of this application;
[0044] Figure 4 This is a schematic diagram of a scene from the third embodiment of the spatial distribution-based image detection method of this application;
[0045] Figure 5 This is a scene diagram of the fourth embodiment of the image detection method based on spatial distribution of this application;
[0046] Figure 6 This is a flowchart illustrating the fifth embodiment of the spatial distribution-based image detection method of this application.
[0047] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0048] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0049] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of an image detection device in the hardware operating environment involved in the embodiments of this application.
[0050] like Figure 1 As shown, the image detection device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0051] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the image detection device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0052] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a data storage module, a network communication module, a user interface module, and an image detection program.
[0053] exist Figure 1 In the image detection device shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and memory 1005 in the image detection device of this application can be set in the image detection device, and the image detection device calls the image detection program stored in the memory 1005 through the processor 1001 and performs the following operations:
[0054] Acquire the image to be detected, and determine the contour information of each object in the image to be detected according to a preset contour algorithm;
[0055] Based on the contour information, determine whether there is a proportionally distributed nine-window signal image in the image to be detected;
[0056] If it exists, then the limit eight grayscale signal image in the image to be detected is determined according to the contour information, and it is determined whether the limit eight grayscale signal image meets the preset image distribution standard.
[0057] If the conditions are met, the image to be detected is determined to be a limit eight-grayscale nine-window signal image.
[0058] Furthermore, the step of acquiring the image to be detected and determining the contour information of each object in the image to be detected according to a preset contour algorithm includes:
[0059] The image to be detected is compressed to obtain a compressed image, and the compressed image is then converted to grayscale to obtain a grayscale compressed image.
[0060] The gray compressed image is binarized to obtain a black and white image according to a preset binarization threshold, and the contour information of each object in the black and white image is determined according to a preset contour algorithm.
[0061] Furthermore, the step of determining the contour information of each object in the image to be detected according to a preset contour algorithm further includes:
[0062] Based on a preset contour algorithm, the contours of each object in the image to be detected are extracted;
[0063] Each of the contours is fitted to obtain the rectangular boundary and contour points corresponding to each contour, and the rectangular boundary and the contour points are used as the contour information, wherein the contour point is any vertex on the rectangular boundary corresponding to the contour.
[0064] Further, the contour information includes contour points, and the step of determining whether a proportionally distributed nine-window signal image exists in the image to be detected based on the contour information includes:
[0065] Based on the coordinates corresponding to each contour point, determine the maximum and minimum contour points among the contour points, and draw straight lines with the maximum and minimum contour points as initial points respectively to obtain a set of straight lines;
[0066] Determine whether the number of first contour points passed by each line in the set of lines is greater than or equal to a preset threshold for the number of contour points, wherein the first contour point is a contour point whose distance relative to any line in the set of lines is less than a preset threshold for the distance between points and lines.
[0067] If so, then it is determined that the image to be detected contains a nine-window signal image;
[0068] Based on the distance between the first contour points passed by each line in the set of lines, determine whether the nine-window signal image is a nine-window signal image with equal proportions.
[0069] Further, the step of drawing straight lines using the maximum contour point and the minimum contour point as initial points respectively to obtain a set of straight lines includes:
[0070] A first straight line is drawn with the maximum contour point as the initial point and the first coordinate point as the ending point. The first coordinate point is a coordinate point with the same x-coordinate value as the maximum contour point and a y-coordinate value of zero, and a coordinate point with the same y-coordinate value as the maximum contour point and a x-coordinate value of zero.
[0071] A second straight line is drawn with the minimum contour point as the initial point and the second coordinate point as the ending point. The second coordinate point is a coordinate point with the same x-coordinate value as the minimum contour point and the same y-coordinate value as the width of the image to be detected, and a coordinate point with the same y-coordinate value as the minimum contour point and the same x-coordinate value as the length of the image to be detected.
[0072] A third straight line is drawn with the maximum contour point as the initial point and the third coordinate point as the ending point, wherein the third coordinate point is the origin of the coordinate system in the image to be detected.
[0073] A fourth straight line is drawn with the minimum contour point as the initial point and the fourth coordinate point as the ending point, wherein the fourth coordinate point is the maximum coordinate point in the image to be detected;
[0074] The set of lines includes the first line, the second line, the third line, and the fourth line.
[0075] Further, the step of determining whether the nine-window signal image is a proportionally distributed nine-window signal image based on the distance between the first contour points traversed by each line in the set of lines includes:
[0076] Obtain the distance set corresponding to each line in the set of lines, wherein the distance set includes the first distance between each first contour point passed by the line and the initial point of the line;
[0077] Determine whether each first distance in each of the distance sets satisfies a preset multiple relationship;
[0078] If the condition is met, then the nine-window signal image is determined to be a nine-window signal image with equal proportions.
[0079] Further, the contour information includes a rectangular boundary, and the step of determining the extreme eight-grayscale signal image in the image to be detected based on the contour information includes:
[0080] Obtain the aspect ratio corresponding to the boundary of each rectangle;
[0081] The rectangular boundary whose aspect ratio is within the preset aspect ratio threshold range is used as the extreme eight-grayscale signal image.
[0082] Furthermore, the step of determining whether the extreme eight-grayscale signal image meets the preset image distribution standard includes:
[0083] Obtain the second contour point corresponding to the extreme eight-grayscale signal image, and draw the fifth straight line based on the second contour point, wherein the second contour point is the contour point corresponding to the rectangular boundary in the extreme eight-grayscale signal image;
[0084] Determine whether the intersection point of the fifth line with respect to the third line and the fourth line meets the preset intersection point standard;
[0085] If satisfied, the extreme eight-grayscale signal image is determined to satisfy the image distribution standard.
[0086] Based on the above structure, various embodiments of the spatial distribution-based image detection method are proposed.
[0087] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the spatial distribution-based image detection method of this application.
[0088] In this embodiment, the executing entity of the spatially distributed image detection method can be an image detection device. Image detection can be a local device, a network device, etc., and no limitation is made in this embodiment. For ease of description, the executing entity is omitted from the description of each embodiment below. In this embodiment, the spatially distributed image detection method includes:
[0089] Step S10: Obtain the image to be detected, and determine the contour information of each object in the image to be detected according to a preset contour algorithm;
[0090] The process involves acquiring the image to be detected, preprocessing the image, identifying objects in the image using a preset contour algorithm, extracting the contour regions corresponding to each object, and then determining the contour information corresponding to each contour region.
[0091] The image to be tested is the test image used to evaluate the energy efficiency limit and energy efficiency level of the device before it leaves the factory. Only when the image to be tested is an extreme eight-grayscale nine-window signal image can the energy efficiency limit and energy efficiency level of the device be tested be valid. The device to be tested is a device that needs to be evaluated for energy efficiency, such as a flat-screen TV.
[0092] Preprocessing is an image processing procedure performed to reduce computational load and improve the accuracy and speed of image detection. For example, preprocessing includes reducing the resolution of the image to be detected to reduce computational load, and / or converting the image to be detected into a grayscale or black-and-white image through grayscale or binarization processing to facilitate the extraction of the contours of each object in the image to be detected. Contour algorithms refer to methods that can identify contour regions and fit contours of each object in an image, including contour discovery and contour shape fitting.
[0093] In one feasible implementation, the contour information of each object in the image to be detected is stored in a preset dictionary, each object's contour is assigned a unique contour number, and the contour number is used as the key in the preset dictionary, while the contour information of each object is used as the value in the preset dictionary.
[0094] An object refers to a visible object or graphic that makes up an image, or a data array that stores the color of each pixel in a coordinate system; the contour region is the outer contour or edge of each object in the image to be detected; the contour information is the attribute information corresponding to each object in the image to be detected, including contour, rectangular boundary, boundary length, boundary width, contour points, contour point coordinates, and color within the contour.
[0095] In another feasible implementation, the bitstream signal corresponding to the video or image to be detected is obtained, the bitstream signal is converted into video data or image data, and then the video data is read frame by frame and converted into a single image to be detected.
[0096] Step S20: Based on the contour information, determine whether there is a nine-window signal image with equal proportions in the image to be detected;
[0097] The contour information corresponding to each object in the acquired image to be detected is compared with a preset nine-window signal image standard to determine whether the contour information meets the preset nine-window signal image standard. If it does, it is determined that there are proportionally distributed nine-window signal images in the image to be detected; if it does not, it is determined that there are no proportionally distributed nine-window signal images in the image to be detected, and thus it is determined that the image to be detected is not a limit eight-grayscale nine-window signal image. The nine-window signal image standard is an image judgment standard formulated based on the arrangement position, distribution, and color information of the nine-window signal images in the limit eight-grayscale nine-window signal image. Only when the image to be detected fully meets the arrangement position, distribution, and color standard of the nine-window signal images does a nine-window signal image exist in the image to be detected.
[0098] The nine-window signal image is composed of three white window signals and six color window signals arranged in equal proportions. The six color windows are two red windows, two green windows, and two blue windows, and are used to test the screen brightness of the device under test.
[0099] Step S30: If it exists, determine the limit eight grayscale signal image in the image to be detected based on the contour information, and determine whether the limit eight grayscale signal image meets the preset image distribution standard.
[0100] If a nine-window signal image exists in the image to be detected, then the limit eight-grayscale signal image in the image to be detected is obtained based on the contour information; if it is not obtained, then the limit eight-grayscale signal image does not exist in the image to be detected, and it is determined that the image to be detected is not a limit eight-grayscale nine-window signal image; if it is obtained, then it is determined whether the limit eight-grayscale signal image in the image to be detected meets the preset image distribution standard.
[0101] The extreme eight grayscale signal image is an image composed of two rows of signals with different gray levels. The first row of gray levels is 0%, 5%, 10%, and 15%, and the second row of gray levels is 85%, 90%, 95%, and 100%. The extreme eight grayscale signal image is used for the standard state of the device under test.
[0102] The image distribution standard is an image judgment standard formulated based on the arrangement and distribution of the nine-window signal image and the extreme eight-grayscale signal image in the extreme eight-grayscale nine-window signal image. Only when the image to be detected contains both the nine-window signal image and the extreme eight-grayscale signal image in equal proportions and meets the image distribution standard can the image to be detected be an extreme eight-grayscale nine-window signal image.
[0103] Step S40: If the condition is met, the image to be detected is determined to be a limit eight-grayscale nine-window signal image.
[0104] If the image to be tested contains both a nine-window signal image and a limit eight-grayscale signal image that are distributed in equal proportions, and also meets the image distribution standard, then the image to be tested is determined to be a limit eight-grayscale nine-window signal image, and the energy efficiency limit value and energy efficiency level measured by the device under test through the image to be tested are determined to be effective values.
[0105] In this embodiment, by accurately identifying the contour information corresponding to each object in the image to be detected, the positional distribution of each contour in the image to be detected is accurately determined. Furthermore, by setting secondary conditions, non-limit eight-grayscale nine-window signal images in the image to be detected are accurately and quickly screened out. Only when all conditions are met can an image be judged as a limit eight-grayscale nine-window signal image, thereby improving the accuracy of image detection. Compared with the conventional histogram detection method, which misjudges limit eight-grayscale images or images with the same color but different color window distributions, this application sets secondary conditions. The first-level condition filters out images that do not have nine-window signals or images where the nine-window signals are not distributed proportionally. The second-level condition filters out images that do not have limit eight-grayscale signals or images where the limit eight-grayscale signals do not meet the image distribution standard. This achieves accurate and fast detection of the image to be detected, improving both the efficiency and accuracy of image detection.
[0106] Furthermore, based on the first embodiment described above, a second embodiment of the image detection method based on spatial distribution of this application is proposed. In this embodiment, step S10 includes:
[0107] Step S11: Compress the image to be detected to obtain a compressed image, and perform grayscale processing on the compressed image to obtain a grayscale compressed image;
[0108] After acquiring the image to be detected, the images of different resolutions are compressed to obtain a low-resolution compressed image. For example, the initial resolution of the image to be detected is 720P, 2K, 4K or 8K, and the resolution of the image to be detected is compressed to 480P to reduce the amount of computation. Then, the compressed image is converted from a color image to a grayscale compressed image through grayscale processing. Grayscale processing is a method to convert a color image into a grayscale image.
[0109] Step S12: According to a preset binarization threshold, the gray compressed image is binarized to obtain a black and white image, and the contour information of each object in the black and white image is determined according to a preset contour algorithm.
[0110] After converting the image to be detected into a grayscale compressed image, the grayscale compressed image is binarized according to a preset binarization threshold and binarization function to obtain a black and white image. Then, the approximate contours of each object in the black and white image and the corresponding contour information are extracted according to a preset contour algorithm. For example, according to the preset binarization threshold [0, 125], the grayscale compressed image is converted into a black and white image using the binarization function cv2.THRESH_BINARY.
[0111] A black and white image is a type of binary image, meaning that the image has only two gray levels. The gray value of any pixel in the image is either 0 or 255, representing black and white, respectively. Binarization processes set the gray values of pixels above a certain threshold as the maximum gray value and the gray values of pixels below this threshold as the minimum gray value, thus achieving binarization.
[0112] In this embodiment, the image to be detected is compressed to obtain a compressed image, thereby reducing the computational load in the image detection process. The compressed image is then converted to grayscale to obtain a grayscale compressed image, facilitating binarization of the image to be detected. Furthermore, based on a preset binarization threshold, the grayscale compressed image is binarized to obtain a black and white image, and the contour information of the black and white image is determined according to the contour algorithm. By performing preprocessing such as compression, grayscale conversion, and binarization on the image to be detected, it is transformed into a compressed black and white image, facilitating the extraction of contours of each object in the image and the identification of corresponding contour information, further improving the accuracy of contour recognition in the image to be detected, and thus increasing the accuracy of image detection.
[0113] In one feasible implementation, step S10, the step of determining the contour information of each object in the image to be detected according to a preset contour algorithm, further includes:
[0114] Step S13: Extract the contours of each object in the image to be detected according to a preset contour algorithm;
[0115] Step S14: Fit each of the contours to obtain the rectangular boundary and contour points corresponding to each contour, and use the rectangular boundary and the contour points as the contour information, wherein the contour point is any vertex on the rectangular boundary corresponding to the contour.
[0116] According to a preset contour algorithm, the contour regions of each object in the image to be detected are extracted; for example, the preset contour algorithm is a contour discovery algorithm; each contour is fitted to obtain the rectangular boundary corresponding to each contour, that is, the outer contour boundary of the rectangle; then, based on the rectangular boundary corresponding to each contour, the contour points corresponding to each contour and the color in each contour are determined, wherein the contour point is any vertex on the rectangular boundary corresponding to each contour; for example, the upper left vertex on the rectangular boundary corresponding to each contour is taken as the contour point; then, the length, width and other attribute information corresponding to each rectangular boundary, as well as the coordinates of each contour point are obtained, wherein the coordinates of each contour point can be determined with any vertex of the image to be detected as the origin, and this embodiment does not limit this; the rectangular boundary, boundary length, boundary width, contour point, contour point coordinates and color in the obtained detection image are taken as contour information.
[0117] To aid in understanding the above technical solutions, the following is a scene illustration of a second embodiment of a specific spatial distribution-based image detection method, with reference to... Figure 3 , Figure 3 The image in the image is the image to be detected. Each rectangle in the image to be detected is the contour corresponding to the object in the image to be detected. The black boundary of each contour is the boundary of each rectangle. Then, the upper left vertex (black dot) of each rectangle boundary is taken as the contour point, and the color (green, red, white and blue) in each contour is extracted. The attribute information such as rectangle boundary, boundary length, boundary width, contour point, contour point coordinates and color in the contour is taken as contour information.
[0118] In this embodiment, a preset contour algorithm is used to accurately identify the contours and contour information of each object in the image to be detected. This allows for the accurate identification of the distribution of each contour in the image, the color information within the contour, and the positional relationship between the contours. This enables the determination of whether each contour in the image satisfies the special window signal distribution arrangement of the limit eight-grayscale nine-window signal image, thereby achieving accurate judgment of the image to be detected and further improving the accuracy of image detection.
[0119] Furthermore, based on the first and / or second embodiments described above, a third embodiment of the spatial distribution-based image detection method of this application is proposed. In this embodiment, step S20 includes:
[0120] Step S21: Based on the coordinates corresponding to each contour point, determine the maximum and minimum contour points among the contour points, and draw straight lines with the maximum and minimum contour points as initial points respectively to obtain a set of straight lines.
[0121] Based on the contour information, the coordinates of each contour point in the image to be detected are determined. Then, based on the coordinates, the maximum and minimum contour points are selected from the contour points. The maximum contour point is the contour point with the largest sum of horizontal and vertical coordinate values in the image to be detected. The minimum contour point is the contour point with the smallest sum of horizontal and vertical coordinate values in the image to be detected. Then, straight lines are drawn in the horizontal, vertical, and diagonal directions with the maximum and minimum contour points as initial points to obtain a set of straight lines.
[0122] In one feasible implementation, the contour information is stored in a preset dictionary, and each contour information corresponds to a contour number. In each contour point in the preset dictionary, starting from any contour point, the horizontal and vertical coordinates are traversed. For example, if the maximum contour point is obtained, contour point 1 is taken as the initial point and designated as the maximum contour point. Based on the contour number, the traversal continues to contour point 2 of the next contour number. It is determined whether the horizontal coordinate of contour point 2 is greater than that of contour point 1. If it is, contour point 2 is designated as the maximum contour point, and the traversal continues to contour point 3 of the next contour number, until all contour points are traversed. After determining the contour point with the largest horizontal coordinate, the vertical coordinates of each contour point are traversed using the same method to determine the maximum contour point. The maximum and minimum contour points and their corresponding attribute information are then stored in the preset dictionary.
[0123] In another feasible implementation, before drawing straight lines and determining the positional distribution between contours in the image to be detected, the contour information of the image to be detected is used to determine the color within the contour of each contour in the image to be detected, and then it is determined whether the color corresponding to each contour meets the preset color standard; wherein, the preset color standard is the color corresponding to the nine-window signal image in the extreme eight-grayscale nine-window signal image, that is, including: three white windows, two red windows, two green windows and two blue windows; if the color within the contour of each contour in the image to be detected meets the preset color standard, it indicates that the image to be detected meets the color corresponding to the nine-window signal image in the extreme eight-grayscale nine-window signal image, then step S21 is executed, otherwise, it is directly determined that the image is not an extreme eight-grayscale nine-window signal image.
[0124] Optionally, the step of drawing straight lines with the maximum contour point and the minimum contour point as initial points respectively to obtain a set of straight lines includes:
[0125] Step S211: Draw a first straight line with the maximum contour point as the initial point and the first coordinate point as the ending point. The first coordinate point is a coordinate point with the same x-coordinate value as the maximum contour point and a y-coordinate value of zero, and a coordinate point with the same y-coordinate value as the maximum contour point and a x-coordinate value of zero.
[0126] To aid in understanding the above technical solutions, the following is a scene illustration of a third embodiment of a specific spatial distribution-based image detection method, for further explanation. Figure 4 , Figure 4 The image in the image is the image to be detected. Each rectangle in the image represents the contour of the object in the image. The black dots represent the contour points and coordinates (including the first, second, third, and fourth coordinate points). The thick black lines represent the lines in the set of lines. A coordinate system is established with the top-left corner of the image as the origin, and the largest contour point is Q. A The minimum contour point is Q. B ; with the maximum contour point Q A Let Q be the initial point and the first coordinate point. C and Q D Draw two first straight lines L to the termination point. AC and L AD Where, the first coordinate point Q C It is the point with the largest contour Q A The first coordinate point Q is a point with the same ordinate value and a x-coordinate value of zero. D It is the point with the largest contour Q A The points with the same x-coordinate and a y-coordinate of zero are the points on the first line L. AC It is the maximum contour point Q A The first line L is a straight line drawn horizontally from the initial point. AD It is the maximum contour point Q A A straight line drawn vertically from the initial point.
[0127] Step S212: Draw a second straight line with the minimum contour point as the initial point and the second coordinate point as the ending point. The second coordinate point is a coordinate point with the same x-coordinate value as the minimum contour point and the same y-coordinate value as the width of the image to be detected, and a coordinate point with the same y-coordinate value as the minimum contour point and the same x-coordinate value as the length of the image to be detected.
[0128] For example, refer to Figure 4 With the smallest contour point Q B Let Q be the initial point and the second coordinate point. E and Q F Draw two second straight lines L, with the endpoint as the endpoint. BE and L BF Where, the second coordinate point Q E It is the minimum contour point Q B The coordinates of the points with the same ordinate value and an abscissa value equal to the length of the image to be detected are the second coordinate point Q. F It is the minimum contour point Q BThe coordinates of the points with the same x-coordinate value and y-coordinate value equal to the width of the image to be detected are the coordinates of the second line L. BE It is the smallest contour point Q B A straight line drawn horizontally from the initial point, the second straight line L BF It is the smallest contour point Q B A straight line drawn vertically from the initial point.
[0129] Step S213: Draw a third straight line with the maximum contour point as the initial point and the third coordinate point as the ending point, wherein the third coordinate point is the origin of the coordinate system in the image to be detected;
[0130] For example, refer to Figure 4 With the maximum contour point Q A Let Q be the initial point and the third coordinate point. G Draw the third straight line L as the endpoint. AG Among them, the third coordinate point Q G It is the origin of the coordinate system in the image to be detected, i.e., the third line L. AG For the maximum contour point Q A A straight line drawn diagonally from the initial point.
[0131] Step S214: Draw a fourth straight line with the minimum contour point as the initial point and the fourth coordinate point as the ending point, wherein the fourth coordinate point is the maximum coordinate point in the image to be detected;
[0132] For example, refer to Figure 4 With the smallest contour point Q B Let Q be the initial point and the fourth coordinate point. H Draw the fourth line L to the termination point. BH Among them, the fourth coordinate point Q H It is the maximum coordinate point in the image to be detected (the horizontal coordinate equals the length of the image to be detected, and the vertical coordinate equals the width of the image to be detected), which is the fourth line L. BH For the minimum contour point Q B A straight line drawn diagonally from the initial point.
[0133] Step S215, the set of lines includes the first line, the second line, the third line and the fourth line.
[0134] The first, second, third, and fourth lines are merged to generate a set of lines. For example, refer to... Figure 4 The line to be drawn: L AC L AD L BE L BF L AG and L BHMerge them to obtain a set of lines.
[0135] In this embodiment, straight lines are drawn vertically, horizontally, and diagonally with the maximum and minimum contour points as initial points, respectively. Then, the drawn straight lines are used to determine whether each contour in the image to be detected satisfies the special window signal distribution arrangement of the limit eight-grayscale nine-window signal image, thereby achieving accurate judgment of the image to be detected and further improving the accuracy of image detection.
[0136] Step S22: Determine whether the number of first contour points passed by each line in the set of lines is greater than or equal to a preset threshold for the number of contour points, wherein the first contour point is a contour point whose distance relative to any line in the set of lines is less than a preset threshold for the distance between points and lines.
[0137] Step S23: If yes, then determine that the image to be detected contains a nine-window signal image;
[0138] After obtaining the set of lines, the number of first contour points passed by each line in the set is counted. Contour points whose distance from any line in the set is less than a preset point-to-line distance threshold are the first contour points passed by each line in the set. Then, it is determined whether the number of first contour points passed by each line in the set is greater than or equal to the preset contour point number threshold. If yes, it means that the horizontal, vertical, and diagonal lines drawn with the maximum and minimum contour points respectively pass through contour points that are at least greater than or equal to the contour point number threshold, and each contour point corresponds to a contour. In this case, the image to be detected is determined to meet the requirements of a nine-window signal image, i.e., a nine-window signal image exists. If no, it means that the number of contours in a certain direction in the image to be detected is less than the requirements of a nine-window signal image. In this case, the image to be detected does not have a nine-window signal image, and thus it is determined that the image to be detected is not a limit eight-grayscale nine-window signal image.
[0139] For example, refer to Figure 4 The preset threshold for the number of contour points is 3, the preset threshold for the distance between points and lines is 1, and the first straight line L AC For the maximum contour point Q A A straight line is drawn horizontally from the initial point; then, the contour points are obtained relative to the first straight line L. AC The distance is used to determine the first straight line L. AC The corresponding first contour point; through calculation, the maximum contour point Q A Contour point Q I and contour point Q J Compared to the first straight line L AC If the distance between the contour points and the points is less than the preset point-to-line distance threshold, then the first straight line L is determined. AC The first contour points are: the largest contour point QA Contour point Q I and contour point Q J Thus, the first straight line L is determined. AC The number of the first contour points is 3, which is equal to the preset contour point number threshold.
[0140] The point-to-line distance threshold is the critical value for determining whether a line passes through a certain contour point. If the point-to-line distance from a certain contour point to the line is greater than the point-to-line distance threshold, it is determined that the line has not passed through that point. If the point-to-line distance from a certain contour point to the line is less than or equal to the point-to-line distance threshold, it is determined that the line passes through that point, that is, that point is the first contour point passed by the line. The contour point number threshold is the critical value for the number of first contour points passed by each line in the nine-window signal image.
[0141] In one feasible implementation, three integer variables are defined to count the number of first contour points passed by each line. The keys and values in the preset dictionary are traversed. If a contour point passes by a line, the variable is incremented by 1, thereby counting the number of first coordinate points corresponding to each line.
[0142] In another feasible implementation, contour points other than the maximum and minimum contour points in the preset dictionary are used as coordinate points to be detected; any coordinate point to be detected is selected from the preset dictionary, and it is determined whether the slope of the line connecting the coordinate point to be detected with respect to the maximum contour point and / or the minimum contour point is less than a preset slope threshold; if it is less than, it indicates that the slope of the line connecting the coordinate point to be detected with respect to the maximum contour point and / or the minimum contour point is close to zero, and the coordinate point to be detected is determined to be the first contour point passed by the straight line drawn in the horizontal direction with the maximum contour point and / or the minimum contour point as the initial point;
[0143] Optionally, any coordinate point to be detected is selected from the preset dictionary. It is determined whether the difference between the x-coordinate of the coordinate point to be detected and the x-coordinate of the maximum contour point and / or the minimum contour point is less than the preset x-coordinate difference threshold. If so, it indicates that the x-coordinate of the coordinate point to be detected is almost equal to that of the maximum contour point and / or the minimum contour point. Then, the coordinate point to be detected is determined to be the first contour point passed by the straight line drawn in the vertical direction with the maximum contour point and / or the minimum contour point as the initial point.
[0144] Optionally, any coordinate point to be detected is selected from a preset dictionary. The first slope of the line connecting the coordinate point to be detected to the maximum contour point and / or the minimum contour point is calculated, as well as the second slope of the straight line drawn in the oblique direction with the maximum contour point and / or the minimum contour point as the initial point. It is determined whether the slope difference between the first slope and the second slope is less than a preset slope threshold. If it is less, it indicates that the first slope and the second slope are almost equal, that is, the corresponding straight lines are almost parallel. Then, it is determined that the coordinate point to be detected is the first contour point passed by the straight line drawn in the oblique direction with the maximum contour point and / or the minimum contour point as the initial point.
[0145] In another feasible implementation, the threshold for the number of contour points is 3. If the number of first contour points passed by each line in the set of lines is 3, it means that the lines drawn with the maximum contour point and the minimum contour point respectively in the horizontal, vertical and diagonal directions all pass through 3 contour points. That is to say, regardless of whether the maximum contour point or the minimum contour point is the initial point, there are 3 contours in the three directions of the image to be detected. That is, the image to be detected has 9 contour regions. Since the nine-window signal image contains 9 window signals, it is determined that the image to be detected meets the requirements of the nine-window signal image, that is, the nine-window signal image exists.
[0146] Step S24: Based on the distance between the first contour points passed by each line in the set of lines, determine whether the nine-window signal image is a nine-window signal image with equal proportions.
[0147] Calculate the first distance between the first contour point passed by each line in the set of lines and the initial point of the corresponding line. Based on the proportional relationship between the first distances, determine the distribution and arrangement relationship between the nine-window signal images in the image to be detected. Then, determine whether the nine-window signal images in the image to be detected are proportionally distributed. If yes, it means that there are proportionally distributed nine-window signal images in the image to be detected. If no, it means that there are no proportionally distributed nine-window signal images in the image to be detected. Therefore, it is determined that the image to be detected is not a limit eight-grayscale nine-window signal image.
[0148] In this embodiment, by drawing straight lines in the horizontal, vertical, and diagonal directions with the maximum and minimum contour points as initial points respectively, a set of straight lines is obtained. Then, the number of first contour points passed by each straight line in the set of straight lines is obtained, thereby accurately identifying the distribution of each contour in the image to be detected. Based on the distribution, it is determined whether each contour in the image to be detected satisfies the special window signal distribution arrangement of the limit eight-grayscale nine-window signal image. At the same time, the color within the contour in the image to be detected is judged, thereby achieving accurate judgment of the image to be detected and further improving the accuracy of image detection.
[0149] Optionally, the step of determining whether the nine-window signal image is a proportionally distributed nine-window signal image based on the distance between the first contour points traversed by each line in the set of lines includes:
[0150] Step S241: Obtain the distance set corresponding to each line in the set of lines, wherein the distance set includes the first distance between each first contour point passed by the line and the initial point of the line;
[0151] Step S242: Determine whether each first distance in each distance set satisfies a preset multiple relationship;
[0152] Step S243: If yes, then determine that the nine-window signal image is a nine-window signal image with equal proportions.
[0153] Each line in the set of lines has at least one first contour point it passes through. The distance set corresponding to each line in the set of lines is calculated, where the distance set includes the first distance between each first contour point passed by the line and the initial point of the line. Then, the ratio between the first distances corresponding to each distance set is obtained, and it is determined whether the ratio between the first distances satisfies a preset multiple relationship. If it satisfies, it indicates that the first contour points passed by the corresponding line and their corresponding rectangular boundaries (contours) are arranged proportionally, and the nine-window signal image in the image to be detected is determined to be a proportionally distributed nine-window signal image. If it does not satisfy, it indicates that the first contour points passed by the corresponding line and their corresponding rectangular boundaries (contours) are not arranged proportionally, and the nine-window signal image in the image to be detected is determined to be a non-proportionally distributed nine-window signal image, thus determining that the image to be detected is not a limit eight-grayscale nine-window signal image.
[0154] In one feasible implementation, the distance (first distance) between each first contour point and the initial point of the corresponding straight line can be calculated using a distance formula. The initial point coordinates are (x1, y1), and the first contour point coordinates are (x2, y2).
[0155] For example, refer to Figure 4 The preset distance ratio threshold range is 1.8-2.3, meaning the ratio between the first distances is approximately twofold. The first straight line L... AC For the maximum contour point Q A Let L be a straight line drawn horizontally from the initial point, and let L be the first straight line. AC The corresponding first contour point includes: the maximum contour point Q A Contour point Q I and contour point Q J ; Calculate the first straight line L AC The corresponding first contour point relative to the first straight line L AC The initial point (maximum profile point Q) A The first distance, i.e., L AI and L AJ The length of L AI and L AJ The length combination is used as the first straight line L. AC The corresponding distance set is used to calculate L. AI and L AJ The ratio between the lengths is 2, and the ratio 2 is within the preset distance ratio threshold range of 1.8-2.3, indicating that the contour point Q... I Contour point Q J and the maximum contour point QA The corresponding rectangular boundaries are distributed proportionally; then, in the same way, it is calculated whether other lines in the image to be detected satisfy the condition. If all of them satisfy the condition, then the nine-window signal image is determined to be a nine-window signal image with a proportional distribution.
[0156] In this embodiment, by obtaining the first distance between the first contour point traversed by each straight line in the image to be detected and the corresponding initial point, the positional distribution and arrangement of the nine-window signal images in the image to be detected are accurately identified, thereby determining whether the nine-window signals in the image to be detected are proportionally distributed. If so, there are proportionally distributed nine-window signal images in the image to be detected, which meets part of the standard of the limit eight-grayscale nine-window signal image. If not, there are no proportionally distributed nine-window signal images in the image to be detected, which does not meet part of the standard of the limit eight-grayscale nine-window signal image. This achieves efficient and accurate judgment of the image to be detected, further improving the accuracy and efficiency of image detection.
[0157] Furthermore, based on the first, second, and / or third embodiments described above, a fourth embodiment of the spatial distribution-based image detection method of this application is proposed. In this embodiment, step S30 includes:
[0158] Step S31: Obtain the aspect ratio corresponding to the boundary of each rectangle;
[0159] Step S32: The rectangular boundary whose aspect ratio is within the preset aspect ratio threshold range is taken as the extreme eight-grayscale signal image.
[0160] Based on the contour information, the boundary length and boundary width of each rectangle are obtained, and the aspect ratio of each rectangle is calculated. The boundary length and boundary width of each rectangle can be obtained by traversing the coordinates of each contour point in a preset dictionary, which is not limited in this embodiment. Then, the aspect ratio is compared with a preset aspect ratio threshold range to filter out the rectangles whose aspect ratio is within the preset aspect ratio threshold range, which is the extreme eight-grayscale signal image.
[0161] The preset aspect ratio threshold range is set according to the aspect ratio of the eight-grayscale signal image in the extreme eight-grayscale nine-window signal image. Within the aspect ratio threshold range, the eight-grayscale signal image standard is met; otherwise, it is not. The preset aspect ratio threshold range can be a threshold range close to 3 or close to 4.
[0162] In this embodiment, by obtaining the aspect ratio of each rectangle boundary in the image to be detected, the precise identification of the limit eight grayscale signal image is achieved. Furthermore, if the limit eight grayscale signal image is not obtained, it can be quickly determined that the limit eight grayscale signal image does not exist in the image to be detected, thereby determining that the image to be detected is not a limit eight grayscale nine window signal image, further improving the accuracy and efficiency of the detection of the image to be detected.
[0163] Step S33: Obtain the second contour point corresponding to the extreme eight-grayscale signal image, and draw the fifth straight line according to the second contour point, wherein the second contour point is the contour point corresponding to the rectangular boundary in the extreme eight-grayscale signal image;
[0164] The extreme eight-grayscale signal image includes multiple rectangular boundaries. For example, the extreme eight-grayscale signal image includes two rectangular boundaries. The contour points corresponding to the rectangular boundaries in the extreme eight-grayscale signal image are used as the second contour points, and then the fifth straight line is drawn with each of the second contour points as the initial point and the final point, respectively.
[0165] Step S34: Determine whether the intersection point of the fifth line with respect to the third line and the fourth line meets the preset intersection point standard.
[0166] Step S35: If satisfied, then determine that the extreme eight-grayscale signal image satisfies the image distribution standard.
[0167] The intersection points of the fifth line with the third and fourth lines are obtained respectively, and it is determined whether the intersection points meet the preset intersection point criteria. The preset intersection point criteria are that there is one and only one intersection point, and the intersection point is within the image to be detected, that is, the x-coordinate value of the intersection point is less than or equal to the length of the image to be detected, and the y-coordinate value of the intersection point is less than or equal to the width of the image to be detected. If the intersection points of the fifth line with the third and fourth lines all meet the preset intersection point criteria, it indicates that there is a rectangular boundary of a limit eight grayscale signal image in the middle of the first and second rows and the middle of the second and third rows of the nine-window signal image of the image to be detected. That is, the limit eight grayscale signal image of the image to be detected meets the preset image distribution criteria; therefore, the image to be detected is determined to be a limit eight grayscale nine-window signal image. If the image to be detected does not meet any of the above criteria, it is determined that the image to be detected is not a limit eight grayscale nine-window signal image.
[0168] The third straight line is drawn with the maximum contour point as the initial point and the origin of the coordinate system in the image to be detected as the ending point; the fourth straight line is drawn with the minimum contour point as the initial point and the maximum coordinate point in the image to be detected as the ending point.
[0169] The image distribution standard is the distribution standard that the extreme eight-grayscale image should meet, that is, there is a rectangular boundary of the extreme eight-grayscale signal image in the middle of the first and second rows and in the middle of the second and third rows of the nine-window signal image.
[0170] To aid in understanding the above technical solutions, the following is a scene illustration of a specific fourth embodiment of an image detection method based on spatial distribution, for further explanation. Figure 5 The aspect ratios of rectangular boundaries 1 and 2 are both within the preset aspect ratio threshold range, representing the extreme eight-grayscale signal images in the image to be detected; the third straight line L AG For the maximum contour point Q A A straight line drawn from the initial point in the diagonal direction; the fourth line L BH For the minimum contour point Q B The line drawn diagonally from the initial point; the contour points of rectangle boundary 1 and rectangle boundary 2 are the second contour points, including the second contour point Q. L Second contour point Q K ; Set the second contour point Q L Second contour point Q K Connect to draw the fifth line L. LK Then, the fifth line L is obtained respectively. LK and the third line L AG and the fourth line L BH The intersection point; the fifth line L LK and the third line L AG and the fourth line L BH Each line has one and only one intersection point, and all intersection points are within the image to be detected, i.e., the fifth line L. LK Compared to the third line L AG and the fourth line L BH The intersection points satisfy the preset intersection point standard; thus, it is determined that the limit eight grayscale signal image satisfies the image distribution standard.
[0171] In this embodiment, a fifth straight line is drawn by connecting the second contour points of the extreme eight-grayscale signal image in the image to be detected, thereby determining the relationship between the fifth straight line and the third and fourth straight lines of the nine-window signal image. If there is one and only one intersection point between the fifth straight line, the third straight line, and the fourth straight line within the image to be detected, it indicates that there is a rectangular boundary of the extreme eight-grayscale signal image in the middle of the first and second rows and the middle of the second and third rows of the nine-window signal image in the image to be detected. Then, the image to be detected is determined to be an extreme eight-grayscale nine-window signal image. If none of the criteria are met, the image to be detected is determined to be an extreme eight-grayscale nine-window signal image. This achieves efficient and accurate judgment of the image to be detected, further improving the accuracy and efficiency of image detection.
[0172] Furthermore, based on the first, second, third, and / or fourth embodiments described above, a fifth embodiment of the image detection method based on spatial distribution to be detected in this application is proposed, referring to... Figure 6 This is a flowchart illustrating the process of this embodiment. In this embodiment, the image or video stream data to be detected from the device to be detected is read, and then the image to be detected is scaled down to standard definition pixels to reduce the computational load of detecting the image to be detected. The compressed image to be detected is then subjected to grayscale and binarization processing, so that the contour region in the image to be detected can be extracted quickly and accurately through the contour discovery algorithm. After extracting the contour region, the rectangular boundary of the contour region, as well as the coordinates of the upper left corner of the rectangular boundary and the length and width of the boundary, are obtained. Then, the upper left corner coordinates of each rectangular boundary and the attribute information such as the length and width of the boundary are stored in a preset dictionary. The maximum and minimum coordinate points are obtained by traversing all rectangular boundaries, and the above coordinate information is stored in the dictionary by defining a dictionary. Then, the first and second coordinate points are drawn in the horizontal, vertical and diagonal directions respectively, using the maximum and minimum coordinate points as base points. A straight line is drawn, and the number of coordinate points stored in the dictionary that each first straight line passes through is counted. If the number of coordinate points is three, it indicates that the image to be detected has three rectangular boundaries in the horizontal, vertical, and diagonal directions. Then, the ratio between the distance of each coordinate point passed by the first straight line and the distance to the base point of each straight line is calculated, and it is determined whether the ratio is close to a two-fold relationship. If so, it is determined that there is a nine-window signal image with equal proportions in the image to be detected. Then, by traversing each coordinate point in the dictionary, the aspect ratio of each rectangular boundary is obtained. If the aspect ratio is close to 3 or close to 4, it is determined that the rectangular boundary is a limit eight-grayscale signal image. Then, the upper left corner coordinate points of the limit eight-grayscale signal image in the image to be detected are connected to draw a second straight line. It is determined whether there is one and only one intersection point between the second straight line and the two straight lines in the diagonal direction. If so, it is determined that the image to be detected is a limit eight-grayscale nine-window signal image.
[0173] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0174] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0175] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. An image detection method based on spatial distribution, characterized in that, The spatial distribution-based image detection method includes the following steps: The image to be detected is acquired, and the contour information of each object in the image to be detected is determined according to a preset contour algorithm, wherein the contour information includes contour points; Based on the coordinates corresponding to each contour point, the maximum and minimum contour points among the contour points are determined, and straight lines are drawn with the maximum and minimum contour points as initial points to obtain a set of straight lines. The maximum contour point is the contour point with the largest sum of horizontal and vertical coordinate values in the image to be detected; the minimum contour point is the contour point with the smallest sum of horizontal and vertical coordinate values in the image to be detected. Determine whether the number of first contour points passed by each line in the set of lines is greater than or equal to a preset threshold for the number of contour points, wherein the first contour point is a contour point whose distance relative to any line in the set of lines is less than a preset threshold for the distance between points and lines. If so, it is determined that a nine-window signal image exists in the image to be detected; Based on the distance between the first contour points passed by each line in the set of lines, determine whether the nine-window signal image is a nine-window signal image with equal proportions. If so, the limit eight-grayscale signal image in the image to be detected is determined based on the contour information, and it is determined whether the limit eight-grayscale signal image meets the preset image distribution standard. If the conditions are met, the image to be detected is determined to be a limit eight-grayscale nine-window signal image.
2. The image detection method based on spatial distribution as described in claim 1, characterized in that, The step of determining the contour information of each object in the image to be detected according to a preset contour algorithm includes: The image to be detected is compressed to obtain a compressed image, and the compressed image is then converted to grayscale to obtain a grayscale compressed image. The gray compressed image is binarized to obtain a black and white image according to a preset binarization threshold, and the contour information of each object in the black and white image is determined according to a preset contour algorithm.
3. The image detection method based on spatial distribution as described in claim 1, characterized in that, The step of determining the contour information of each object in the image to be detected according to a preset contour algorithm further includes: Based on a preset contour algorithm, the contours of each object in the image to be detected are extracted; Each of the contours is fitted to obtain the rectangular boundary and contour points corresponding to each contour, and the rectangular boundary and the contour points are used as the contour information, wherein the contour point is any vertex on the rectangular boundary corresponding to the contour.
4. The image detection method based on spatial distribution as described in claim 1, characterized in that, The step of drawing straight lines with the largest contour point and the smallest contour point as initial points respectively to obtain a set of straight lines includes: A first straight line is drawn with the maximum contour point as the initial point and the first coordinate point as the ending point. The first coordinate point is a coordinate point with the same x-coordinate value as the maximum contour point and a y-coordinate value of zero, and a coordinate point with the same y-coordinate value as the maximum contour point and a x-coordinate value of zero. A second straight line is drawn with the minimum contour point as the initial point and the second coordinate point as the ending point. The second coordinate point is a coordinate point with the same x-coordinate value as the minimum contour point and the same y-coordinate value as the width of the image to be detected, and a coordinate point with the same y-coordinate value as the minimum contour point and the same x-coordinate value as the length of the image to be detected. A third straight line is drawn with the maximum contour point as the initial point and the third coordinate point as the ending point, wherein the third coordinate point is the origin of the coordinate system in the image to be detected. A fourth straight line is drawn with the minimum contour point as the initial point and the fourth coordinate point as the ending point, wherein the fourth coordinate point is the maximum coordinate point in the image to be detected; The set of lines includes the first line, the second line, the third line, and the fourth line.
5. The image detection method based on spatial distribution as described in claim 1, characterized in that, The step of determining whether the nine-window signal image is a proportionally distributed nine-window signal image based on the distance between the first contour points passed by each line in the set of lines includes: Obtain the distance set corresponding to each line in the set of lines, wherein the distance set includes the first distance between each first contour point passed by the line and the initial point of the line; Determine whether each first distance in each of the distance sets satisfies a preset multiple relationship; If the condition is met, then the nine-window signal image is determined to be a nine-window signal image with equal proportions.
6. The image detection method based on spatial distribution as described in claim 1, characterized in that, The contour information includes a rectangular boundary, and the step of determining the extreme eight-grayscale signal image in the image to be detected based on the contour information includes: Obtain the aspect ratio corresponding to the boundary of each rectangle; The rectangular boundary whose aspect ratio is within the preset aspect ratio threshold range is used as the extreme eight-grayscale signal image.
7. The image detection method based on spatial distribution as described in claim 4, characterized in that, The step of determining whether the extreme eight-grayscale signal image meets the preset image distribution standard includes: Obtain the second contour point corresponding to the extreme eight-grayscale signal image, and draw the fifth straight line based on the second contour point, wherein the second contour point is the contour point corresponding to the rectangular boundary in the extreme eight-grayscale signal image; Determine whether the intersection point of the fifth line with respect to the third line and the fourth line meets the preset intersection point standard; If satisfied, the extreme eight-grayscale signal image is determined to meet the preset image distribution standard.
8. An image detection device, characterized in that, The device includes: a memory, a processor, and an image detection program stored in the memory and executable on the processor, the image detection program being configured to implement the steps of the spatial distribution-based image detection method as described in any one of claims 1 to 7.
9. A storage medium, characterized in that, The storage medium stores an image detection program, which, when executed by a processor, implements the steps of the spatial distribution-based image detection method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Intelligent terminal panel visual fault detection system
CN110070524A
Card number identification method and device, storage medium and electronic device
CN110197179A