CN114022449A - Image processing method and system in billiard game - Google Patents
Image processing method and system in billiard game Download PDFInfo
- Publication number
- CN114022449A CN114022449A CN202111307322.7A CN202111307322A CN114022449A CN 114022449 A CN114022449 A CN 114022449A CN 202111307322 A CN202111307322 A CN 202111307322A CN 114022449 A CN114022449 A CN 114022449A
- Authority
- CN
- China
- Prior art keywords
- pixel
- image
- edge
- target
- grid
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 7
- 238000000605 extraction Methods 0.000 claims abstract description 39
- 238000000034 method Methods 0.000 claims description 22
- 238000012216 screening Methods 0.000 claims description 12
- 238000003708 edge detection Methods 0.000 claims description 3
- 230000009286 beneficial effect Effects 0.000 description 11
- 238000004364 calculation method Methods 0.000 description 10
- 239000011159 matrix material Substances 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000005457 optimization Methods 0.000 description 2
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/70—Denoising; Smoothing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/181—Segmentation; Edge detection involving edge growing; involving edge linking
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/70—Determining position or orientation of objects or cameras
- G06T7/73—Determining position or orientation of objects or cameras using feature-based methods
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Quality & Reliability (AREA)
- Image Analysis (AREA)
Abstract
The invention discloses an image processing method and system in a billiards game, which comprises the following steps: acquiring a plurality of original images including a billiard table surface; respectively carrying out edge extraction processing to obtain a plurality of edge images; selecting one edge image as a first target edge image, calculating pixel values of pixel points in other edge images and pixel values of corresponding pixel points in the target edge image respectively to obtain a pixel difference value, judging whether the pixel difference value is greater than a preset pixel difference value, and taking the pixel point with the pixel difference value greater than the preset pixel difference value as a target pixel point; calculating to obtain an average pixel value of the target pixel point at the same position according to the pixel values of the target pixel points at the same position in other edge images, and replacing the pixel points in the first target edge image at the corresponding position based on the average pixel value to obtain a second target edge image; determining and displaying billiard information. The accuracy of determining the billiard information is improved.
Description
Technical Field
The invention relates to the technical field of image processing, in particular to an image processing method and system in a billiard game.
Background
Machine vision has recently begun to be applied to billiard games for determining billiard information. In the prior art, images including a billiard table surface are obtained for image recognition, and billiard information is determined. The obtained images including the billiard table surface have larger image noise, the calculated amount is large, the determined billiard information is inaccurate, and therefore fairness of billiard games is not guaranteed.
Disclosure of Invention
The present invention is directed to solving, at least to some extent, one of the technical problems in the art described above. Therefore, the first objective of the present invention is to provide an image processing method in a billiard game, which is convenient for reducing image noise, reducing the calculation amount based on edge images, improving the calculation rate, ensuring more accurate billiard information, and ensuring the fairness of the billiard game.
A second object of the invention is to provide an image processing system in a billiards game.
In order to achieve the above object, a first aspect of the present invention provides an image processing method in a billiards game, including:
acquiring a plurality of original images including a billiard table surface;
respectively carrying out edge extraction processing on the plurality of original images to obtain a plurality of edge images;
selecting one edge image as a first target edge image, calculating pixel values of pixel points in other edge images except the target edge image in the plurality of edge images and pixel values of corresponding pixel points in the target edge image respectively to obtain a pixel difference value, judging whether the pixel difference value is greater than a preset pixel difference value or not, and taking the pixel point with the pixel difference value greater than the preset pixel difference value as a target pixel point;
calculating to obtain an average pixel value of the target pixel point at the same position according to the pixel values of the target pixel points at the same position in other edge images, and replacing the pixel points in the first target edge image at the corresponding position based on the average pixel value to obtain a second target edge image;
and carrying out image recognition on the second target edge image, determining billiard information and displaying.
According to some embodiments of the invention, performing an edge extraction process on an original image comprises:
carrying out graying processing on the original image to obtain a grayscale image;
determining a transverse gray gradient amplitude and a longitudinal gray gradient amplitude of each pixel point in the gray image, calculating to obtain a gray gradient amplitude of the pixel point according to the transverse gray gradient amplitude and the longitudinal gray gradient amplitude, judging whether the gray gradient amplitude is greater than a preset gray gradient amplitude, and taking the pixel point with the gray gradient amplitude greater than the preset gray gradient amplitude as an edge pixel point;
acquiring the position relation of each edge pixel point and the change relation of the gray gradient amplitude value of each edge pixel point, determining a plurality of pixel point sets, and connecting the pixel points in each pixel point set to form an edge contour line;
and obtaining an edge image according to the plurality of edge contour lines.
According to some embodiments of the invention, performing an edge extraction process on an original image comprises:
and carrying out edge detection based on a Canny algorithm to obtain an edge image.
According to some embodiments of the invention, further comprising: and carrying out image enhancement processing on a plurality of edge contour lines in the edge image.
According to some embodiments of the present invention, before calculating the pixel values of the pixel points in the edge images except the target edge image among the plurality of edge images and the pixel values of the pixel points in the target edge image, the method further includes: and determining interference pixel points in the first target edge image and marking.
According to some embodiments of the invention, performing an edge extraction process on an original image comprises:
acquiring pixel points of the original image, and constructing a grid coordinate system;
determining the grid direction of each grid in a grid coordinate system, and taking the angle formed by the grid direction and the transverse axis of the grid as the characteristic angle of the grid;
calculating a difference value between a pixel value of each current grid and a pixel value of a next grid at a characteristic angle of the current grid based on a grid coordinate system, and marking the current grid when the difference value is determined to be larger than a preset difference value;
determining the incidence relation between the marked grids on the characteristic angle, determining a plurality of types of grid sets according to the incidence relation, and connecting the pixel points corresponding to the grids in each type of grid set to obtain the edge image.
According to some embodiments of the invention, before performing the image recognition on the second target edge image, the method further comprises:
carrying out graying processing on the second target edge image;
acquiring gray values of pixel points in the second target edge image subjected to graying processing, screening the pixel points of the second target edge image from top to bottom, and taking the pixel points corresponding to the non-zero gray values appearing for the first time as first pixel points;
drawing a straight line perpendicular to the X axis and passing through a point (X1,0) to divide the second target edge image into a left image and a right image; x1 is the abscissa of the first pixel point;
counting the number of pixel points corresponding to non-zero gray values in the left image as a first number;
counting the number of pixel points corresponding to non-zero gray values in the right image as a second number;
when the first quantity is larger than the second quantity, screening pixel points of the second target edge image from left to right, and taking pixel points corresponding to non-zero gray values appearing for the first time as second pixel points; when the first quantity is smaller than the second quantity, screening pixel points of the second target edge image from right to left, and taking pixel points corresponding to non-zero gray values appearing for the first time as second pixel points;
calculating a target angle for optimizing the second target edge image according to the first pixel points and the second pixel points;
and optimizing the second target edge image according to the target angle.
In order to achieve the above object, a second aspect of the present invention provides an image processing system in a billiards game, including:
the acquisition module is used for acquiring a plurality of original images including the billiard table surface;
the extraction module is used for respectively carrying out edge extraction processing on the plurality of original images to obtain a plurality of edge images;
the first determining module is used for selecting one edge image as a first target edge image, calculating pixel values of pixel points in other edge images except the target edge image in the plurality of edge images and pixel values of corresponding pixel points in the target edge image respectively to obtain a pixel difference value, judging whether the pixel difference value is greater than a preset pixel difference value or not, and taking the pixel point with the pixel difference value greater than the preset pixel difference value as a target pixel point;
the replacing module is used for calculating the average pixel value of the target pixel point at the same position according to the pixel values of the target pixel points at the same position in other edge images, and replacing the pixel points in the first target edge image at the corresponding position based on the average pixel value to obtain a second target edge image;
and the second determining module is used for carrying out image recognition on the second target edge image, determining billiard information and displaying the billiard information.
According to some embodiments of the invention, the extraction module performs an edge extraction process on the original image, and performs the following steps:
carrying out graying processing on the original image to obtain a grayscale image;
determining a transverse gray gradient amplitude and a longitudinal gray gradient amplitude of each pixel point in the gray image, calculating to obtain a gray gradient amplitude of the pixel point according to the transverse gray gradient amplitude and the longitudinal gray gradient amplitude, judging whether the gray gradient amplitude is greater than a preset gray gradient amplitude, and taking the pixel point with the gray gradient amplitude greater than the preset gray gradient amplitude as an edge pixel point;
acquiring the position relation of each edge pixel point and the change relation of the gray gradient amplitude value of each edge pixel point, determining a plurality of pixel point sets, and connecting the pixel points in each pixel point set to form an edge contour line;
and obtaining an edge image according to the plurality of edge contour lines.
According to some embodiments of the invention, the extraction module performs an edge extraction process on the original image, and performs the following steps:
acquiring pixel points of the original image, and constructing a grid coordinate system;
determining the grid direction of each grid in a grid coordinate system, and taking the angle formed by the grid direction and the transverse axis of the grid as the characteristic angle of the grid;
calculating a difference value between a pixel value of each current grid and a pixel value of a next grid at a characteristic angle of the current grid based on a grid coordinate system, and marking the current grid when the difference value is determined to be larger than a preset difference value;
determining the incidence relation between the marked grids on the characteristic angle, determining a plurality of types of grid sets according to the incidence relation, and connecting the pixel points corresponding to the grids in each type of grid set to obtain the edge image.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and drawings.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention. In the drawings:
FIG. 1 is a flow diagram of a method of image processing in a billiards game, according to one embodiment of the present invention;
FIG. 2 is a flow diagram of a method of edge extraction processing of an original image according to one embodiment of the invention;
FIG. 3 is a block diagram of an image processing system in a pool game according to one embodiment of the invention.
Detailed Description
The preferred embodiments of the present invention will be described in conjunction with the accompanying drawings, and it will be understood that they are described herein for the purpose of illustration and explanation and not limitation.
As shown in fig. 1, an embodiment of the first aspect of the present invention provides a method for processing images in a billiards game, including steps S1-S5:
s1, acquiring a plurality of original images including the billiard table surface;
s2, respectively carrying out edge extraction processing on the plurality of original images to obtain a plurality of edge images;
s3, selecting one edge image as a first target edge image, calculating pixel values of pixel points in other edge images except the target edge image in the plurality of edge images and pixel values of corresponding pixel points in the target edge image respectively to obtain pixel difference values, judging whether the pixel difference values are greater than preset pixel difference values or not, and taking the pixel points with the pixel difference values greater than the preset pixel difference values as target pixel points;
s4, calculating to obtain an average pixel value of a target pixel point at the same position according to pixel values of target pixel points at the same position in other edge images, and replacing the pixel points in the first target edge image at the corresponding position based on the average pixel value to obtain a second target edge image;
and S5, performing image recognition on the second target edge image, determining billiard information and displaying.
The working principle of the technical scheme is as follows: acquiring a plurality of original images including a billiard table surface; the original image includes the desktop image and other images outside the desktop, which may be the floor. Respectively carrying out edge extraction processing on the plurality of original images to obtain a plurality of edge images; the edge image is an image including only a desktop. I.e. the image of the top of the billiard table. Selecting one edge image as a first target edge image, calculating pixel values of pixel points in other edge images except the target edge image in the plurality of edge images and pixel values of corresponding pixel points in the target edge image respectively to obtain a pixel difference value, judging whether the pixel difference value is greater than a preset pixel difference value or not, and taking the pixel point with the pixel difference value greater than the preset pixel difference value as a target pixel point; calculating to obtain an average pixel value of the target pixel point at the same position according to the pixel values of the target pixel points at the same position in other edge images, and replacing the pixel points in the first target edge image at the corresponding position based on the average pixel value to obtain a second target edge image; the influence of noise in the first target edge image can be reduced, and the signal-to-noise ratio of the second target edge image is ensured. And carrying out image recognition on the second target edge image, determining billiard information and displaying. The billiard information includes trajectory information, collision information, and the like of cue balls and other balls.
The beneficial effects of the above technical scheme are that: the method has the advantages that the image noise is reduced conveniently, the calculated amount is reduced based on the edge image, the calculation rate is improved, the influence of noise points in the edge image of the first target can be reduced, the signal to noise ratio of the edge image of the second target is ensured, the determined billiard information is more accurate, and the fairness of billiard games is ensured conveniently.
As shown in FIG. 2, according to some embodiments of the present invention, the edge extraction process is performed on the original image, including steps S21-S24:
s21, carrying out graying processing on the original image to obtain a grayscale image;
s22, determining a transverse gray gradient amplitude and a longitudinal gray gradient amplitude of each pixel point in the gray image, calculating to obtain a gray gradient amplitude of the pixel point according to the transverse gray gradient amplitude and the longitudinal gray gradient amplitude, judging whether the gray gradient amplitude is greater than a preset gray gradient amplitude, and taking the pixel point with the gray gradient amplitude greater than the preset gray gradient amplitude as an edge pixel point;
s23, obtaining the position relation of each edge pixel and the change relation of the gray gradient amplitude of each edge pixel, determining a plurality of pixel sets, and connecting the pixels in each pixel set to form an edge contour line;
and S24, obtaining an edge image according to the edge contour lines.
The working principle of the technical scheme is as follows: carrying out graying processing on the original image to obtain a grayscale image; determining a transverse gray gradient amplitude and a longitudinal gray gradient amplitude of each pixel point in the gray image, calculating to obtain a gray gradient amplitude of the pixel point according to the transverse gray gradient amplitude and the longitudinal gray gradient amplitude, judging whether the gray gradient amplitude is greater than a preset gray gradient amplitude, and taking the pixel point with the gray gradient amplitude greater than the preset gray gradient amplitude as an edge pixel point; acquiring the position relation of each edge pixel point and the change relation of the gray gradient amplitude value of each edge pixel point, determining a plurality of pixel point sets, and connecting the pixel points in each pixel point set to form an edge contour line; and obtaining an edge image according to the plurality of edge contour lines.
The beneficial effects of the above technical scheme are that: whether the pixel points are edge pixel points is accurately judged based on the gray gradient amplitude values of the pixel points, the position relation of each edge pixel point and the change relation of the gray gradient amplitude values of each edge pixel point are obtained, a plurality of edge contour lines are determined, and then the edge image is accurately determined.
According to some embodiments of the invention, performing an edge extraction process on an original image comprises:
and carrying out edge detection based on a Canny algorithm to obtain an edge image.
According to some embodiments of the invention, further comprising: and carrying out image enhancement processing on a plurality of edge contour lines in the edge image.
The beneficial effects of the above technical scheme are that: the method is more obvious based on a plurality of edge contour lines in the edge image, and is convenient for extracting image features.
According to some embodiments of the present invention, before calculating the pixel values of the pixel points in the edge images except the target edge image among the plurality of edge images and the pixel values of the pixel points in the target edge image, the method further includes: and determining interference pixel points in the first target edge image and marking.
The working principle of the technical scheme is as follows: before calculating the pixel values of the pixel points in the other edge images except the target edge image in the plurality of edge images and the pixel values of the pixel points in the target edge image, the method further comprises the following steps: and determining interference pixel points in the first target edge image and marking.
The beneficial effects of the above technical scheme are that: the method and the device are convenient for reducing the calculation process of the interference pixel points, reduce the calculation amount, avoid the influence of the interference pixel points on the image identification, and improve the accuracy of the image identification.
According to some embodiments of the invention, performing an edge extraction process on an original image comprises:
acquiring pixel points of the original image, and constructing a grid coordinate system;
determining the grid direction of each grid in a grid coordinate system, and taking the angle formed by the grid direction and the transverse axis of the grid as the characteristic angle of the grid;
calculating a difference value between a pixel value of each current grid and a pixel value of a next grid at a characteristic angle of the current grid based on a grid coordinate system, and marking the current grid when the difference value is determined to be larger than a preset difference value;
determining the incidence relation between the marked grids on the characteristic angle, determining a plurality of types of grid sets according to the incidence relation, and connecting the pixel points corresponding to the grids in each type of grid set to obtain the edge image.
The working principle of the technical scheme is as follows: acquiring pixel points of the original image, and constructing a grid coordinate system; the grid coordinate system divides the pixel points of the original image into a pixel point matrix of N x M, wherein N is the length of the original image; m is the width of the original image. Determining the grid direction of each grid in a grid coordinate system, and taking the angle formed by the grid direction and the transverse axis of the grid as the characteristic angle of the grid; when extracting the edge image, the edge change of each grid has a direction, the direction of a ray drawn towards the direction by taking the grid as a vertex is the grid direction, and the angle formed by the grid direction and the transverse axis of the grid is taken as the characteristic angle of the grid. Calculating a difference value between a pixel value of each current grid and a pixel value of a next grid at a characteristic angle of the current grid based on a grid coordinate system, and marking the current grid when the difference value is determined to be larger than a preset difference value; determining the incidence relation between the marked grids on the characteristic angle, determining a plurality of types of grid sets according to the incidence relation, and connecting the pixel points corresponding to the grids in each type of grid set to obtain the edge image.
The beneficial effects of the above technical scheme are that: the edge extraction processing is carried out on the original image, so that invalid images are reduced conveniently, the calculation amount is reduced, and the image identification is simpler. And meanwhile, whether the pixel point corresponding to the current grid is an edge pixel point is accurately determined based on the difference value between the pixel value of each current grid and the pixel value of the next grid at the characteristic angle of the current grid. And determining the incidence relation between the marked grids on the characteristic angle, determining a plurality of types of grid sets according to the incidence relation, and connecting the pixel points corresponding to the grids in each type of grid set to obtain the edge image, so that the accuracy of determining the edge image is improved.
According to some embodiments of the invention, before performing the image recognition on the second target edge image, the method further comprises:
carrying out graying processing on the second target edge image;
acquiring gray values of pixel points in the second target edge image subjected to graying processing, screening the pixel points of the second target edge image from top to bottom, and taking the pixel points corresponding to the non-zero gray values appearing for the first time as first pixel points;
drawing a straight line perpendicular to the X axis and passing through a point (X1,0) to divide the second target edge image into a left image and a right image; x1 is the abscissa of the first pixel point;
counting the number of pixel points corresponding to non-zero gray values in the left image as a first number;
counting the number of pixel points corresponding to non-zero gray values in the right image as a second number;
when the first quantity is larger than the second quantity, screening pixel points of the second target edge image from left to right, and taking pixel points corresponding to non-zero gray values appearing for the first time as second pixel points; when the first quantity is smaller than the second quantity, screening pixel points of the second target edge image from right to left, and taking pixel points corresponding to non-zero gray values appearing for the first time as second pixel points;
calculating a target angle for optimizing the second target edge image according to the first pixel points and the second pixel points;
and optimizing the second target edge image according to the target angle.
The working principle of the technical scheme is as follows: carrying out graying processing on the second target edge image; acquiring gray values of pixel points in the second target edge image subjected to graying processing, screening the pixel points of the second target edge image from top to bottom, and taking the pixel points corresponding to the non-zero gray values appearing for the first time as first pixel points; drawing a straight line perpendicular to the X axis and passing through a point (X1,0) to divide the second target edge image into a left image and a right image; x1 is the abscissa of the first pixel point; counting the number of pixel points corresponding to non-zero gray values in the left image as a first number; counting the number of pixel points corresponding to non-zero gray values in the right image as a second number; when the first quantity is larger than the second quantity, screening pixel points of the second target edge image from left to right, and taking pixel points corresponding to non-zero gray values appearing for the first time as second pixel points; when the first quantity is smaller than the second quantity, screening pixel points of the second target edge image from right to left, and taking pixel points corresponding to non-zero gray values appearing for the first time as second pixel points; calculating a target angle for optimizing the second target edge image according to the first pixel points and the second pixel points; and optimizing the second target edge image according to the target angle.
The beneficial effects of the above technical scheme are that: and optimizing the second target edge image according to the target angle, so that the image recognition result is prevented from being influenced by the angle of the second target edge image, and the accuracy of image recognition on the second target edge image is improved.
In an embodiment, calculating a target angle for performing optimization processing on the second target edge image according to the first pixel point and the second pixel point includes:
wherein, (x1, y1) is the coordinate of the first pixel point; (x2, y2) is the coordinates of the second pixel point; delta is a target angle; arcsin is an inverse trigonometric sine function.
Based on the formula, the target angle, namely the angle of the second target edge image needing to be deflected optimally, is accurately calculated, and the optimization processing is carried out according to the target angle, so that the accuracy of determining the key features in the second target edge image is improved.
As shown in fig. 3, a second embodiment of the present invention provides an image processing system in a billiards game, including:
the acquisition module is used for acquiring a plurality of original images including the billiard table surface;
the extraction module is used for respectively carrying out edge extraction processing on the plurality of original images to obtain a plurality of edge images;
the first determining module is used for selecting one edge image as a first target edge image, calculating pixel values of pixel points in other edge images except the target edge image in the plurality of edge images and pixel values of corresponding pixel points in the target edge image respectively to obtain a pixel difference value, judging whether the pixel difference value is greater than a preset pixel difference value or not, and taking the pixel point with the pixel difference value greater than the preset pixel difference value as a target pixel point;
the replacing module is used for calculating the average pixel value of the target pixel point at the same position according to the pixel values of the target pixel points at the same position in other edge images, and replacing the pixel points in the first target edge image at the corresponding position based on the average pixel value to obtain a second target edge image;
and the second determining module is used for carrying out image recognition on the second target edge image, determining billiard information and displaying the billiard information.
The working principle of the technical scheme is as follows: the acquisition module acquires a plurality of original images including a billiard table surface; the original image includes the desktop image and other images outside the desktop, which may be the floor. The extraction module respectively carries out edge extraction processing on the plurality of original images to obtain a plurality of edge images; the edge image is an image including only a desktop. I.e. the image of the top of the billiard table. The first determining module selects one edge image as a first target edge image, calculates pixel values of pixel points in other edge images except the target edge image in the plurality of edge images and pixel values of corresponding pixel points in the target edge image respectively to obtain a pixel difference value, judges whether the pixel difference value is greater than a preset pixel difference value or not, and takes the pixel point with the pixel difference value greater than the preset pixel difference value as a target pixel point; the replacement module calculates to obtain an average pixel value of a target pixel point at the same position according to pixel values of target pixel points at the same position in other edge images, and replaces the pixel points in the first target edge image at the corresponding position based on the average pixel value to obtain a second target edge image; the influence of noise in the first target edge image can be reduced, and the signal-to-noise ratio of the second target edge image is ensured. And the second determining module performs image recognition on the second target edge image, determines billiard information and displays the billiard information. The billiard information includes trajectory information, collision information, and the like of cue balls and other balls.
The beneficial effects of the above technical scheme are that: the method has the advantages that the image noise is reduced conveniently, the calculated amount is reduced based on the edge image, the calculation rate is improved, the influence of noise points in the edge image of the first target can be reduced, the signal to noise ratio of the edge image of the second target is ensured, the determined billiard information is more accurate, and the fairness of billiard games is ensured conveniently.
According to some embodiments of the invention, the extraction module performs an edge extraction process on the original image, and performs the following steps:
carrying out graying processing on the original image to obtain a grayscale image;
determining a transverse gray gradient amplitude and a longitudinal gray gradient amplitude of each pixel point in the gray image, calculating to obtain a gray gradient amplitude of the pixel point according to the transverse gray gradient amplitude and the longitudinal gray gradient amplitude, judging whether the gray gradient amplitude is greater than a preset gray gradient amplitude, and taking the pixel point with the gray gradient amplitude greater than the preset gray gradient amplitude as an edge pixel point;
acquiring the position relation of each edge pixel point and the change relation of the gray gradient amplitude value of each edge pixel point, determining a plurality of pixel point sets, and connecting the pixel points in each pixel point set to form an edge contour line;
and obtaining an edge image according to the plurality of edge contour lines.
The working principle of the technical scheme is as follows: the extraction module performs graying processing on the original image to obtain a grayscale image; determining a transverse gray gradient amplitude and a longitudinal gray gradient amplitude of each pixel point in the gray image, calculating to obtain a gray gradient amplitude of the pixel point according to the transverse gray gradient amplitude and the longitudinal gray gradient amplitude, judging whether the gray gradient amplitude is greater than a preset gray gradient amplitude, and taking the pixel point with the gray gradient amplitude greater than the preset gray gradient amplitude as an edge pixel point; acquiring the position relation of each edge pixel point and the change relation of the gray gradient amplitude value of each edge pixel point, determining a plurality of pixel point sets, and connecting the pixel points in each pixel point set to form an edge contour line; and obtaining an edge image according to the plurality of edge contour lines.
The beneficial effects of the above technical scheme are that: whether the pixel points are edge pixel points is accurately judged based on the gray gradient amplitude values of the pixel points, the position relation of each edge pixel point and the change relation of the gray gradient amplitude values of each edge pixel point are obtained, a plurality of edge contour lines are determined, and then the edge image is accurately determined.
According to some embodiments of the invention, further comprising: the third determining module is configured to, before calculating pixel values of pixel points in other edge images except the target edge image in the plurality of edge images and pixel values of pixel points in the target edge image, further include: and determining interference pixel points in the first target edge image and marking.
The working principle of the technical scheme is as follows: before calculating the pixel values of the pixel points in the edge images except the target edge image among the plurality of edge images and the pixel values of the pixel points in the target edge image, the third determining module further includes: and determining interference pixel points in the first target edge image and marking.
The beneficial effects of the above technical scheme are that: the method and the device are convenient for reducing the calculation process of the interference pixel points, reduce the calculation amount, avoid the influence of the interference pixel points on the image identification, and improve the accuracy of the image identification.
According to some embodiments of the invention, the extraction module performs an edge extraction process on the original image, and performs the following steps:
acquiring pixel points of the original image, and constructing a grid coordinate system;
determining the grid direction of each grid in a grid coordinate system, and taking the angle formed by the grid direction and the transverse axis of the grid as the characteristic angle of the grid;
calculating a difference value between a pixel value of each current grid and a pixel value of a next grid at a characteristic angle of the current grid based on a grid coordinate system, and marking the current grid when the difference value is determined to be larger than a preset difference value;
determining the incidence relation between the marked grids on the characteristic angle, determining a plurality of types of grid sets according to the incidence relation, and connecting the pixel points corresponding to the grids in each type of grid set to obtain the edge image.
The working principle of the technical scheme is as follows: an extraction module acquires pixel points of the original image and constructs a grid coordinate system; the grid coordinate system divides the pixel points of the original image into a pixel point matrix of N x M, wherein N is the length of the original image; m is the width of the original image. Determining the grid direction of each grid in a grid coordinate system, and taking the angle formed by the grid direction and the transverse axis of the grid as the characteristic angle of the grid; when extracting the edge image, the edge change of each grid has a direction, the direction of a ray drawn towards the direction by taking the grid as a vertex is the grid direction, and the angle formed by the grid direction and the transverse axis of the grid is taken as the characteristic angle of the grid. Calculating a difference value between a pixel value of each current grid and a pixel value of a next grid at a characteristic angle of the current grid based on a grid coordinate system, and marking the current grid when the difference value is determined to be larger than a preset difference value; determining the incidence relation between the marked grids on the characteristic angle, determining a plurality of types of grid sets according to the incidence relation, and connecting the pixel points corresponding to the grids in each type of grid set to obtain the edge image.
The beneficial effects of the above technical scheme are that: the edge extraction processing is carried out on the original image, so that invalid images are reduced conveniently, the calculation amount is reduced, and the image identification is simpler. And meanwhile, whether the pixel point corresponding to the current grid is an edge pixel point is accurately determined based on the difference value between the pixel value of each current grid and the pixel value of the next grid at the characteristic angle of the current grid. And determining the incidence relation between the marked grids on the characteristic angle, determining a plurality of types of grid sets according to the incidence relation, and connecting the pixel points corresponding to the grids in each type of grid set to obtain the edge image, so that the accuracy of determining the edge image is improved.
In one embodiment, determining a grid direction of each grid in a grid coordinate system, and taking an angle formed by the grid direction and a transverse axis of the grid as a characteristic angle of the grid comprises:
calculate the gaussian coefficient for each grid:
wherein f (x, y) is a Gaussian coefficient of a grid located at (x, y) in the grid coordinate system; e is a natural constant;
calculating the characteristic angle of each grid:
wherein theta is the characteristic angle of the grid,is a partial derivative of x for f (x, y),the y is biased for f (x, y).
The working principle and the beneficial effects of the technical scheme are as follows: the grid coordinate system displays the pixel points based on the pixel point matrix, and specifically can divide the pixel points of the original image into an N x N pixel point matrix. The coordinate values of the pixel points represent the position of the grid. Based on the formula, the characteristic angle of each grid is accurately calculated, so that the difference value between the pixel value of each current grid and the pixel value of the next grid at the characteristic angle of the current grid can be accurately calculated, and the edge pixel point can be accurately determined.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.
Claims (10)
1. An image processing method in a billiard game is characterized by comprising the following steps:
acquiring a plurality of original images including a billiard table surface;
respectively carrying out edge extraction processing on the plurality of original images to obtain a plurality of edge images;
selecting one edge image as a first target edge image, calculating pixel values of pixel points in other edge images except the target edge image in the plurality of edge images and pixel values of corresponding pixel points in the target edge image respectively to obtain a pixel difference value, judging whether the pixel difference value is greater than a preset pixel difference value or not, and taking the pixel point with the pixel difference value greater than the preset pixel difference value as a target pixel point;
calculating to obtain an average pixel value of the target pixel point at the same position according to the pixel values of the target pixel points at the same position in other edge images, and replacing the pixel points in the first target edge image at the corresponding position based on the average pixel value to obtain a second target edge image;
and carrying out image recognition on the second target edge image, determining billiard information and displaying.
2. The method of image processing in a billiards game of claim 1, wherein the edge extraction processing of the original image includes:
carrying out graying processing on the original image to obtain a grayscale image;
determining a transverse gray gradient amplitude and a longitudinal gray gradient amplitude of each pixel point in the gray image, calculating to obtain a gray gradient amplitude of the pixel point according to the transverse gray gradient amplitude and the longitudinal gray gradient amplitude, judging whether the gray gradient amplitude is greater than a preset gray gradient amplitude, and taking the pixel point with the gray gradient amplitude greater than the preset gray gradient amplitude as an edge pixel point;
acquiring the position relation of each edge pixel point and the change relation of the gray gradient amplitude value of each edge pixel point, determining a plurality of pixel point sets, and connecting the pixel points in each pixel point set to form an edge contour line;
and obtaining an edge image according to the plurality of edge contour lines.
3. The method of image processing in a billiards game of claim 1, wherein the edge extraction processing of the original image includes:
and carrying out edge detection based on a Canny algorithm to obtain an edge image.
4. The method of image processing in a billiards game of claim 2, further comprising: and carrying out image enhancement processing on a plurality of edge contour lines in the edge image.
5. The method of processing images in a billiards game as recited in claim 1, wherein before calculating the pixel values of the pixel points in the edge images except the target edge image among the plurality of edge images and the pixel values of the pixel points in the target edge image, the method further comprises: and determining interference pixel points in the first target edge image and marking.
6. The method of image processing in a billiards game of claim 1, wherein the edge extraction processing of the original image includes:
acquiring pixel points of the original image, and constructing a grid coordinate system;
determining the grid direction of each grid in a grid coordinate system, and taking the angle formed by the grid direction and the transverse axis of the grid as the characteristic angle of the grid;
calculating a difference value between a pixel value of each current grid and a pixel value of a next grid at a characteristic angle of the current grid based on a grid coordinate system, and marking the current grid when the difference value is determined to be larger than a preset difference value;
determining the incidence relation between the marked grids on the characteristic angle, determining a plurality of types of grid sets according to the incidence relation, and connecting the pixel points corresponding to the grids in each type of grid set to obtain the edge image.
7. The method of image processing in a billiard game of claim 1, wherein prior to image recognition of the second target edge image, further comprising:
carrying out graying processing on the second target edge image;
acquiring gray values of pixel points in the second target edge image subjected to graying processing, screening the pixel points of the second target edge image from top to bottom, and taking the pixel points corresponding to the non-zero gray values appearing for the first time as first pixel points;
drawing a straight line perpendicular to the X axis and passing through a point (X1,0) to divide the second target edge image into a left image and a right image; x1 is the abscissa of the first pixel point;
counting the number of pixel points corresponding to non-zero gray values in the left image as a first number;
counting the number of pixel points corresponding to non-zero gray values in the right image as a second number;
when the first quantity is larger than the second quantity, screening pixel points of the second target edge image from left to right, and taking pixel points corresponding to non-zero gray values appearing for the first time as second pixel points; when the first quantity is smaller than the second quantity, screening pixel points of the second target edge image from right to left, and taking pixel points corresponding to non-zero gray values appearing for the first time as second pixel points;
calculating a target angle for optimizing the second target edge image according to the first pixel points and the second pixel points;
and optimizing the second target edge image according to the target angle.
8. An image processing system in a billiard game, comprising:
the acquisition module is used for acquiring a plurality of original images including the billiard table surface;
the extraction module is used for respectively carrying out edge extraction processing on the plurality of original images to obtain a plurality of edge images;
the first determining module is used for selecting one edge image as a first target edge image, calculating pixel values of pixel points in other edge images except the target edge image in the plurality of edge images and pixel values of corresponding pixel points in the target edge image respectively to obtain a pixel difference value, judging whether the pixel difference value is greater than a preset pixel difference value or not, and taking the pixel point with the pixel difference value greater than the preset pixel difference value as a target pixel point;
the replacing module is used for calculating the average pixel value of the target pixel point at the same position according to the pixel values of the target pixel points at the same position in other edge images, and replacing the pixel points in the first target edge image at the corresponding position based on the average pixel value to obtain a second target edge image;
and the second determining module is used for carrying out image recognition on the second target edge image, determining billiard information and displaying the billiard information.
9. The image processing system in a billiards game of claim 8, wherein said extraction module performs edge extraction processing on the original image by performing the following steps:
carrying out graying processing on the original image to obtain a grayscale image;
determining a transverse gray gradient amplitude and a longitudinal gray gradient amplitude of each pixel point in the gray image, calculating to obtain a gray gradient amplitude of the pixel point according to the transverse gray gradient amplitude and the longitudinal gray gradient amplitude, judging whether the gray gradient amplitude is greater than a preset gray gradient amplitude, and taking the pixel point with the gray gradient amplitude greater than the preset gray gradient amplitude as an edge pixel point;
acquiring the position relation of each edge pixel point and the change relation of the gray gradient amplitude value of each edge pixel point, determining a plurality of pixel point sets, and connecting the pixel points in each pixel point set to form an edge contour line;
and obtaining an edge image according to the plurality of edge contour lines.
10. The image processing system in a billiards game of claim 8, wherein said extraction module performs edge extraction processing on the original image by performing the following steps:
acquiring pixel points of the original image, and constructing a grid coordinate system;
determining the grid direction of each grid in a grid coordinate system, and taking the angle formed by the grid direction and the transverse axis of the grid as the characteristic angle of the grid;
calculating a difference value between a pixel value of each current grid and a pixel value of a next grid at a characteristic angle of the current grid based on a grid coordinate system, and marking the current grid when the difference value is determined to be larger than a preset difference value;
determining the incidence relation between the marked grids on the characteristic angle, determining a plurality of types of grid sets according to the incidence relation, and connecting the pixel points corresponding to the grids in each type of grid set to obtain the edge image.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111307322.7A CN114022449A (en) | 2021-11-05 | 2021-11-05 | Image processing method and system in billiard game |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111307322.7A CN114022449A (en) | 2021-11-05 | 2021-11-05 | Image processing method and system in billiard game |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114022449A true CN114022449A (en) | 2022-02-08 |
Family
ID=80061754
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111307322.7A Pending CN114022449A (en) | 2021-11-05 | 2021-11-05 | Image processing method and system in billiard game |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114022449A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115802005A (en) * | 2022-11-08 | 2023-03-14 | 苏州迈创信息技术有限公司 | Security monitoring video storage method for residential houses |
-
2021
- 2021-11-05 CN CN202111307322.7A patent/CN114022449A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115802005A (en) * | 2022-11-08 | 2023-03-14 | 苏州迈创信息技术有限公司 | Security monitoring video storage method for residential houses |
CN115802005B (en) * | 2022-11-08 | 2023-09-19 | 苏州迈创信息技术有限公司 | Security monitoring video storage method for residential building |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110866924B (en) | Line structured light center line extraction method and storage medium | |
CN108629775B (en) | Thermal state high-speed wire rod surface image processing method | |
CN115170669B (en) | Identification and positioning method and system based on edge feature point set registration and storage medium | |
CN109540925B (en) | Complex ceramic tile surface defect detection method based on difference method and local variance measurement operator | |
CN113724193B (en) | PCBA part size and clearance high-precision visual measurement method | |
CN113421296A (en) | Laser spot centroid extraction method based on gray threshold | |
CN104966348B (en) | A kind of bill images key element integrality detection method and system | |
CN109409290A (en) | A kind of thermometer calibrating reading automatic recognition system and method | |
CN104331695A (en) | Robust round identifier shape quality detection method | |
CN104574312A (en) | Method and device of calculating center of circle for target image | |
CN107545259A (en) | A kind of Quick Response Code reconstructing method based on Da-Jin algorithm | |
CN114022449A (en) | Image processing method and system in billiard game | |
CN114677340B (en) | Concrete surface roughness detection method based on image edge | |
CN112361977A (en) | Linear distance measuring method based on weight distribution | |
CN113160223A (en) | Contour determination method, contour determination device, detection device and storage medium | |
CN114862765A (en) | Cell layered image processing method | |
CN109141829B (en) | Target line definition calculation and industrial camera rear intercept detection method | |
CN106951902B (en) | Image binarization processing method and device | |
CN109978916A (en) | Vibe moving target detecting method based on gray level image characteristic matching | |
CN117853510A (en) | Canny edge detection method based on bilateral filtering and self-adaptive threshold | |
CN112734779A (en) | Dot calibration plate edge sub-pixel detection method | |
CN112597868A (en) | Test paper identification and correction method based on no positioning point | |
CN116863463A (en) | Egg assembly line rapid identification and counting method | |
CN108256475B (en) | Bill image inversion detection method | |
CN113112546B (en) | Space target detection identification and pose tracking method based on three-X combined marker |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |