An image gray scale estimation method, system, computer device and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NORTHWEST A & F UNIV
- Filing Date
- 2025-01-25
- Publication Date
- 2026-07-03
Smart Images

Figure CN119941832B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, specifically relating to an image grayscale estimation method, system, computer device, and storage medium. Background Technology
[0002] For industrial products such as seamless steel pipes, rails, and PVC pipes, key dimensions are mostly recorded manually using handheld measuring instruments during production, and surface defects are identified by visual inspection or traditional non-destructive testing. Manual inspection suffers from low efficiency, susceptibility to subjective factors, and poor accuracy.
[0003] To address the demand for efficient and rapid inspection in industrial production, various image-based defect detection methods have emerged in recent years. Structured light sensors, based on the principle of triangulation, can acquire distance information of targets illuminated by structured light within a certain range. They also offer advantages such as high sampling rate and high accuracy, and have been widely applied in industrial measurement. However, in structured light 3D scanning technology, after imaging modulated light stripes, a common problem is that the grayscale value of a bright stripe on one side is lower than that of a dark stripe on the other side, which poses difficulties for stripe extraction and matching. To thoroughly solve this problem, it is necessary to perform simulation calculations on the structured light illumination and the object as a whole to estimate the grayscale characteristics in the image.
[0004] In grayscale estimation during structured light 3D scanning, adaptive thresholding, linear filtering, and histogram equalization are commonly used to improve image quality and optimize stripe extraction. Adaptive thresholding analyzes local regions of the image and dynamically adjusts the threshold based on the grayscale distribution of each region, adapting to areas with varying brightness. Linear filtering uses convolutional kernels to filter the image, altering pixel grayscale values. This method is often used for noise reduction and image smoothing to improve image quality. Histogram equalization redistributes pixel grayscale values across the entire grayscale range, resulting in a more uniform distribution and enhanced image contrast.
[0005] While adaptive thresholding, linear filtering, and histogram equalization are widely used in image processing and grayscale estimation, they also have some limitations. Adaptive thresholding, although flexible in handling local illumination variations, can still lead to misjudgments under complex lighting and noise conditions, especially in cases of uneven surface reflection or strong light sources, making it difficult to accurately extract fringe information. Linear filtering, while effective at removing noise, can blur the stripes in detailed structured light images, particularly in edge regions, potentially losing crucial information and affecting the accuracy of 3D reconstruction. Histogram equalization enhances image contrast, but in structured light scanning, it may over-amplify noise or high-frequency components, especially under uneven illumination, causing the grayscale distribution to no longer match the actual object surface features, thus affecting the accuracy of fringe extraction.
[0006] Therefore, traditional image processing methods struggle to accurately address the complex reflective properties and uneven illumination of surfaces such as seamless steel pipes, leading to grayscale estimation errors and affecting the effectiveness of defect detection. Summary of the Invention
[0007] To address the problem that traditional image processing methods struggle to accurately handle the complex reflective properties and uneven illumination of surfaces such as seamless steel pipes, leading to grayscale estimation errors and affecting defect detection results, this invention provides an image grayscale estimation method.
[0008] To achieve the above objectives, the present invention provides the following technical solution:
[0009] An image grayscale estimation method, comprising:
[0010] The light stripes are projected onto the plane plate on which the calibration plate is located to form a light plane, and the center point of the light stripe projection on the light plane is determined.
[0011] Define an image plane of an illusion, project points on the imaging plane onto the image plane of the illusion, connect the center point of each column of light stripes to the origin of the camera coordinate system to form a ray, construct a system of equations using the coordinates of the intersection points of multiple rays with the light plane and the image plane of the illusion, as well as the intrinsic and extrinsic parameters of the camera, and fit the system of equations using the least squares method to obtain the equation of the light plane.
[0012] The tubular object to be tested is placed on the plane plate where the calibration plate is located. Multiple structured beams are projected onto the surface of the tubular object and reflected onto the imaging plane. The image coordinates and three-dimensional coordinates of the multiple structured beams are obtained. The image coordinates, three-dimensional coordinates and camera coordinates are input into the light plane equation to calculate the geometric parameters of the multiple structured beams on the imaging plane.
[0013] Multiple reflection coefficients of the tubular surface are obtained by solving the actual gray value of the surface of the tested tubular object and the geometric parameters of multiple structured beams on the imaging plane. The average value of the multiple reflection coefficients is taken, and the theoretical gray value of the surface of the tested tubular object is calculated based on the average value of the multiple reflection coefficients.
[0014] Preferably, an image plane of the illusion is defined, points on the imaging plane are projected onto the image plane of the illusion, the center point of each column of light stripes is connected to the origin of the camera coordinate system to form a ray, and a system of equations is constructed using the coordinates of the intersection points of multiple rays with the light plane and the image plane of the illusion, as well as the intrinsic and extrinsic parameters of the camera. The equation of the light plane is obtained by fitting the system of equations using the least squares method. Specifically:
[0015] Define an imaginary image plane, with the origin of the camera coordinate system at point O. c The points on the imaging plane are projected onto the normalized plane; let P′(x1, y1, f) on the imaging plane correspond to P″(x2, y2, 1) on the normalized plane, and normalization is achieved by fixing the Z coordinate to 1; at this time, according to the line O C The point P is obtained by finding the intersection of -P″ and the plane containing the calibration plate, and the straight line O is obtained by finding the intersection of the line O″ and the plane containing the calibration plate. C The expression for -P″ is shown in formula (1):
[0016]
[0017] Where (x, y, z) are the coordinates of point P in the camera coordinate system;
[0018] The coordinates of the imaging plane are normalized to the camera coordinate system as shown in formula (2), and the coordinates of point P″ are substituted into formula (3):
[0019]
[0020]
[0021] Substituting formula (3) into the plane equation of the calibration plate, Ax + By - z + c = 0, where A, B, and C are obtained through camera calibration, the coordinates (x, y, z) of point P in the camera coordinate system are obtained as shown in formula (4):
[0022]
[0023] The above calculation is performed on the center point of each light fringe in each image to obtain the camera coordinates of the center point of the light fringe, which are then substituted into equation (5):
[0024]
[0025] Among them, (x ci y ci , zci The coordinates of the center point of the light fringe are obtained by formula (4), A. c B c C c These are the coefficients of the equation for the light plane:
[0026] The equations for the light plane are obtained by fitting the system of equations using the least squares method.
[0027] Preferably, the camera is calibrated using a calibration plate to obtain the camera's intrinsic and extrinsic parameters, specifically as follows:
[0028] A flat plate of the same material as the tubular object being measured is placed in the illuminated area. A calibration plate of negligible thickness is attached to its left side. Multiple images from different perspectives are taken and the coordinates of feature points are extracted. The homography matrix of each image is determined based on the coordinates of the feature points and the geometric model of the camera imaging. The equations of the constraint relationship are obtained by rotating the homography matrix and solving the equations to obtain the intrinsic and extrinsic parameters of the camera.
[0029] Preferably, determining the center point of the light stripe projection on the light plane specifically involves:
[0030] The left and right boundaries of the light stripes are determined by setting a threshold, the ordinate of the gray-scale centroid of each column of light stripes within the left and right boundaries is calculated, and the center point of the light stripes is determined based on the ordinate of the gray-scale centroid of the light stripes.
[0031] Preferably, the ordinate of the gray-level centroid of each column of light stripes is determined by the gray-level centroid method, specifically as follows:
[0032] Scan the planar image row by row, calculate the light stripes column by column, determine the left and right boundaries of the light stripes by setting a threshold, calculate the ordinate of the gray-scale centroid of each row of light stripes within the left and right boundaries according to the formula, and determine the position of the center point of the light stripes according to the ordinate of the gray-scale centroid of the light stripes.
[0033] The specific formula for the ordinate of the grayscale centroid of the light stripe is as follows:
[0034]
[0035] Where j is the position of each column of pixels; T is the set of pixels involved in the calculation; g(*) is the gray value of the pixel; y center The vertical coordinate is the centroid of the grayscale of the light stripe.
[0036] Preferably, the planar plate is made of the same material as the tubular object being tested.
[0037] This invention also proposes an image grayscale estimation system, comprising:
[0038] The center point acquisition module is used to project light stripes onto the plane plate where the calibration plate is located to form a light plane and determine the center point of the light stripe projection on the light plane.
[0039] The equation construction module is used to define an image plane of an illusion, project points on the imaging plane onto the image plane of the illusion, connect the center point of each column of light stripes to the origin of the camera coordinate system to form a ray, construct a set of equations using the coordinates of the intersection points of multiple rays with the light plane and the image plane of the illusion, as well as the intrinsic and extrinsic parameters of the camera, and fit the set of equations using the least squares method to obtain the equation of the light plane.
[0040] The parameter acquisition module is used to place the tubular object under test on the plane plate where the calibration plate is located, project multiple structured lights onto the surface of the tubular object under test and reflect them onto the imaging plane, acquire the image coordinates and three-dimensional coordinates of the multiple structured lights, input the image coordinates, three-dimensional coordinates and camera coordinates into the light plane equation, and calculate the geometric parameters of the multiple structured lights on the imaging plane.
[0041] The grayscale estimation module is used to solve for multiple reflection coefficients of the surface of the tubular object under test based on the actual grayscale value of the surface and the geometric parameters of multiple structured beams on the imaging plane. The average value of the multiple reflection coefficients is taken, and the theoretical grayscale value of the surface of the tubular object under test is calculated based on the average value of the multiple reflection coefficients.
[0042] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement any of the steps in the image grayscale estimation method.
[0043] The present invention also provides a computer-readable storage medium storing a computer program that, when loaded by a processor, can execute any of the steps in the image grayscale estimation method.
[0044] The image grayscale estimation method provided by this invention has the following beneficial effects:
[0045] Grayscale optimization can simulate the grayscale value of a flawless object surface. Comparing this with the actual grayscale value can help infer the shape of the object surface and more accurately determine the location of defects.
[0046] This invention establishes an artificial image plane and connects the center point of each column of light stripes to the origin of the camera coordinate system to form rays. A system of equations is constructed using the coordinates of the intersections of multiple rays with the light plane and the artificial image plane, as well as the camera's intrinsic and extrinsic parameters. The light plane equation is obtained by fitting the equations using the least squares method. The construction of the light plane equation transforms light from lines into a continuous surface, solving the problem of uneven illumination. Simultaneously, the geometric parameters of multiple structured beams projected onto the tested tubular object on the imaging plane can be calculated using the light plane equation. The calculation of these parameters is unaffected by image noise or high-frequency components. Finally, multiple reflectance coefficients of the tested tubular object surface are obtained by solving for the geometric parameters. The average value of these reflectance coefficients is then taken, and the theoretical grayscale value of the tested tubular object surface is calculated based on this average value. This solves the problem of uneven grayscale in structured light stripes in 3D scanning, providing more reliable data support for defect detection of industrial products such as steel pipes. Attached Figure Description
[0047] To more clearly illustrate the embodiments and design schemes of the present invention, the accompanying drawings required for this embodiment will be briefly described below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 This is a flowchart of the image grayscale estimation method in Embodiment 1 of the present invention;
[0049] Figure 2 This is a flowchart of measuring tubular objects using the image grayscale estimation method of Embodiment 1 of the present invention;
[0050] Figure 3 This is a schematic diagram of a line structured light sensor measurement system.
[0051] Figure 4 This is a schematic diagram of the grayscale centroid method;
[0052] Figure 5 Schematic diagram of optical plane calibration;
[0053] Figure 6 This is a schematic diagram of light plane normalization;
[0054] Figure 7 This is a schematic diagram of the light propagation process;
[0055] Figure 8 Comparison of steel pipe surface grayscale before and after optimization;
[0056] Figure 9 This is a point cloud map of the steel pipe surface. Detailed Implementation
[0057] To enable those skilled in the art to better understand and implement the technical solutions of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and should not be construed as limiting the scope of protection of the present invention.
[0058] Example 1
[0059] This invention proposes a grayscale estimation method based on a physical model and using radiance as the fundamental basis. Utilizing optical simulation, it can accurately estimate the grayscale distribution of an object's surface under specific lighting conditions, better simulating and optimizing the influence of factors such as illumination and reflection on image grayscale. This provides more reliable data support for defect detection in industrial products such as steel pipes, improving the accuracy and robustness of structured light 3D scanning. The core idea is as follows: Light stripes are projected onto a plane plate containing the calibration plate to form a light plane; the center point of the projected light stripes on the light plane is determined; an artificial image plane is set, and points on the imaging plane are projected onto the artificial image plane; the center point of each column of light stripes is connected to the origin of the camera coordinate system to form a ray; a system of equations is constructed using the coordinates of the intersections of multiple rays with the light plane and the artificial image plane, as well as the camera's intrinsic and extrinsic parameters; the light plane equation is obtained by fitting the system of equations using the least squares method; the tubular object to be tested is placed on the plane plate containing the calibration plate. The system projects multiple structured beams onto the surface of the tubular object under test, which are then reflected onto the imaging plane. The image coordinates and 3D coordinates of these structured beams are acquired. These coordinates, along with the camera coordinates, are input into the light plane equation to calculate the geometric parameters of the structured beams on the imaging plane. Based on the actual grayscale value of the tubular object's surface and the geometric parameters of the structured beams on the imaging plane, multiple reflection coefficients of the surface are obtained. The average of these reflection coefficients is then used to calculate the theoretical grayscale value of the tubular object's surface. Specifically, the 3D coordinates are used by constructing a straight line equation in 3D space connecting the camera origin to the center point. This straight line equation is then substituted into the light plane equation to calculate the geometric parameters.
[0060] Specifically, Figure 1 and Figure 2 As shown, the image grayscale estimation method proposed in this invention includes the following steps:
[0061] Step 1: Perform camera calibration on the flat-panel calibration target to obtain the camera's internal and external parameters.
[0062] like Figure 3As shown, the multi-line structured light monocular vision measurement system mainly consists of three parts: an optical projector (generally a laser or projector), an image acquisition unit (a camera in this embodiment), and a computer. This embodiment uses the optical projector of the multi-line structured light monocular vision measurement system to project multiple structured lights onto the tubular object being measured. The camera calibration method adopts Zhang Zhengyou's planar template calibration method. The basic principle of this method is to use a planar calibration plate, move the calibration plate several times within the camera's field of view, capture images from multiple different perspectives, extract feature points, and calculate the homography matrix of each image. This allows for the calculation of the camera's intrinsic parameters (focal length, principal point position, etc.) and extrinsic parameters (position and attitude). By utilizing nonlinear optimization parameters, the projection error is minimized. This calibration method is convenient to use and highly applicable.
[0063] In use, the optical projector projects multiple structured beams, which form a set of light planes and are projected onto the surface of the tubular object being measured. When the relative positions of the optical projector and the camera are fixed, a camera imaging model can be constructed, the transformation formulas between various coordinate systems can be calculated, and the camera parameters obtained through calibration can be substituted to obtain the geometric relationship between two-dimensional pixels and three-dimensional points.
[0064] During camera calibration, a flat plate of the same material as the tubular object being measured is placed in the illuminated area, and a calibration plate of negligible thickness is attached to its left side. Multiple images from different perspectives are taken and the coordinates of feature points are extracted. The homography matrix of each image is determined based on the geometric model of camera imaging, and the system of equations of constraint relationship is obtained through the orthogonality of the rotation matrix, thereby solving the intrinsic and extrinsic parameters of the camera.
[0065] The specific formula for the basic geometric model of camera imaging is as follows:
[0066]
[0067] In the formula, (x w ,y w ,z w (x) is the world coordinate of the object, (x) c y c , z c () represents the camera coordinates, (u,v) represents the object's coordinates in the image coordinate system, corresponding to the pixel positions on the image, and f represents the position of the object. x f y It is the camera's focal length, (c x ,c y R is the coordinate of the origin of the image coordinate system in the pixel coordinate system, T is the translation vector, and z is the position of the pixel coordinates. c This represents the depth value (i.e., the distance from the object to the camera).
[0068] When the Zhang Zhengyou planar template calibration method is used for camera calibration, the code logic is implemented by means of the methods in the OpenCv library. Multiple captured images are saved in a folder and read into the program using the imread() function. Then, the findCirclesGrid() function is used to extract the center point data of each image. The plane where the calibration board is located is set as z = 0, and the world coordinates of the first center point are set as (0, 0) to initialize the world coordinates of each calibration point. Substituting the pixel coordinates and world coordinates of the calibration points obtained above into the calibrateCamera() function, the internal parameter matrix and distortion matrix of the camera, as well as the rotation matrix and translation vector of each image, can be obtained.
[0069] Step 2: Extract the center of the light stripe.
[0070] Furthermore, as Figure 4 shown, in Step 2, the gray-level centroid method is used to extract the center point of the light stripe on the plane where the calibration board is located. The basic principle of the gray-level centroid method is to regard the gray value of the target area as "mass distribution" and determine the exact position by calculating the centroid of the gray distribution in this area. The main idea is to scan the image row by row, calculate each column of the light stripe, determine the left and right boundaries of the light stripe through the set threshold, and calculate the vertical coordinate of the gray-level centroid of each row of the light stripe according to the formula. All pixel points whose gray values exceed the set threshold are involved in the calculation process.
[0071] The specific formula of the gray-level centroid method is as follows:
[0072]
[0073] where h is the position of each column of pixel points (a < j < b), a and b are the vertical coordinates of the boundaries of the light stripe; H is the set of pixel points participating in the calculation; g(*) is the gray value of the pixel point; y center is the vertical coordinate of the obtained gray-level centroid point.
[0074] Specifically, after determining the left and right boundaries of the light stripe, calculate the vertical coordinate of the gray-level centroid to obtain the exact center position of the light stripe. Since there are multiple light stripes to be extracted in the image, after calculating one light stripe each time, the boundary flag bit needs to be reset to continue processing the next light stripe. Therefore, after calculating the vertical coordinate, the flag bits indicating whether the left and right boundaries have been obtained should be set to false to continue scanning the gray-level centroid of the next light stripe. If the number of light stripes collected in this row is complete, the center points can be classified into the corresponding light stripe sets according to the extraction order.
[0075] Step 3: Calibrate the plane equation where each light stripe is located.
[0076] Furthermore, step three employs the principle of line-plane intersection. By constructing a system of equations using the intersection points of rays and the light plane in the camera coordinate system, the orientation and position of the light plane can be determined. The equation of the light plane is then obtained by fitting the equation using the least squares method. For the calibration of the light plane of a single light fringe, the point set in a single image is collinear, making it impossible to directly fit a light plane. Therefore, it is necessary to acquire two or more images from different viewpoints to calibrate the corresponding light plane.
[0077] Specifically, such as Figure 5 As shown, the principle of line-plane intersection is used for light plane calibration. The light stripes are projected onto the plane where the calibration plate is located, with the origin O of the image coordinate system and the origin O of the camera coordinate system both defined. c The distance is f, P′ is the center point of the light fringe on the imaging plane, and the straight line O c The intersection point P of -P′ and the plane is the corresponding point of the center point P′ of the light stripe on the imaging plane in the actual three-dimensional space. The equation of the light plane can be obtained by fitting the least squares method.
[0078] Step one yielded the camera's intrinsic parameter matrix, as shown in matrix A. Since camera calibration only provides f... x f y These values, corresponding to scaling factors in the x and y directions respectively, do not directly reflect the actual physical distance. To obtain the actual focal length, the physical dimensions of the camera sensor are needed, which leads to additional calculations and lookups, making the operation more complex.
[0079]
[0080] This invention considers normalizing the imaging plane, such as... Figure 6 As shown, an imaginary image plane is defined, which is the normalization plane. Points on the imaging plane are projected onto this imaginary normalization plane. Let P′(x1, y1, f) on the imaging plane correspond to P″(x2, y2, 1) on the normalization plane. Normalization is achieved by fixing the Z coordinate to 1. At this point, according to the line O... C Point P can be found by finding the intersection of -P″ and the plane containing the calibration plate, and the straight line O. C The expression for -P″ is shown in formula (1).
[0081]
[0082] Where (x, y, z) are the coordinates of point P in the camera coordinate system.
[0083] The coordinates of the imaging plane are normalized to the form of the camera coordinate system as shown in formula (2), and the coordinates of point P″ are substituted into formula (3).
[0084]
[0085]
[0086] Substituting formula (3) into the calibration plate plane equation Ax + By - z + c = 0, where A, B, and C are obtained through camera calibration, the coordinates (x, y, z) of point P in the camera coordinate system are obtained as shown in formula (4). x f y c x c y The value is obtained from step one.
[0087]
[0088] The above calculation is performed on the center point of each light fringe in each image to obtain the camera coordinates of the center point of the light fringe, which are then substituted into formula (5).
[0089]
[0090] Among them, (x ci y ci , z ci The coordinates of the center point of the light fringe are obtained by formula (4), A. c B c C c These are the coefficients of the equation for the light plane.
[0091] The equation of the light plane is obtained by fitting the system of equations using the least squares method. That is, the best function match of a set of data is found by minimizing the sum of squares of the errors, and the equation of the light plane can be obtained.
[0092] Step 4: Based on the actual gray value of the surface of the tubular object under test and the geometric parameters of multiple structured beams on the imaging plane, solve for multiple reflection coefficients of the surface of the tubular object under test, take the average value of multiple reflection coefficients, and calculate the theoretical gray value of the surface of the tubular object under test based on the average value of multiple reflection coefficients.
[0093] Specifically, according to the physical process, the propagation of light energy can be broken down into two stages. The first stage is the reflection stage after light emitted from a (point) light source strikes the surface of an object; the second stage is the imaging stage where the reflected light enters the camera. Light follows the principles of energy conservation and rectilinear propagation throughout its entire propagation process. Figure 7 As shown, C represents the observation camera, L represents the light source, P represents the imaging plane, S represents the illuminated area of the observed object's surface, A represents a pixel, and A′ represents the tiny area on the object's surface corresponding to A. Light is emitted from L, reflected by S, and then enters the camera C.
[0094] In the first stage, let the radiant energy of the light source be Q, and the power be... It is certain that the electro-optical conversion rate of the light source is α, and its luminous flux is... After being modulated by a lens, the light source radiates uniformly outward in a hemispherical wave shape with a sphericity of 2π. Then the emitted light intensity is... When the area of the micro-city A' is S A' The distance from the light source is R. A' The angle between A' and the light source is θ, and the luminous flux at A' is... Corresponding illuminance Let the reflectivity of the surface at point A' be β, then the intensity of the reflected light is: The reflected illuminance is
[0095] In the second stage, the light rays from A' reach the pixel corresponding to image point A and are converted into electrical signals, which are recorded as grayscale values. Let R be the distance between A' and the center point of the camera lens. C The image distance is f, and the pixel area is S. A The angle between the face and the face facing the solid angle is At that time, by Therefore, the luminous flux at point A is Corresponding illuminance
[0096] The specific calculation of the theoretical grayscale value is as follows:
[0097] If γ represents the photoelectric conversion coefficient of a pixel (characterized by the sensitivity curve of a CCD / CMOS sensor), then G A for:
[0098]
[0099] When the angle between A' and the corresponding pixel plane of A is ψ, and R C When f > f, the following relation is satisfied:
[0100]
[0101] Substituting formula (7) into formula (6), we get:
[0102]
[0103] In the above formula in, α is the radiant power of the light source, and α is the electro-optical conversion efficiency of the light source. When the light source is determined, both are constants; γ, f, and S A These are camera parameters; β is the surface reflectivity of the object, which is a constant when the surface material is determined; R C R A' ,θ, ψ and ψ are geometric variables, representing parameters such as the relative position and angle between the camera and the object surface, and the light source, respectively.
[0104] When the system consisting of the light source and camera is determined, k is only related to the reflectivity of the surface of the tubular object being measured. After observing and obtaining the gray value of pixel A and calculating the above parameter values, the relative value of k for this system can be calculated by substituting them into formula (8). By calibrating the steel pipe, its axis equation, pose, and radius can be obtained, and based on this, the approximate normal vector at the micro-surface element A' can be determined. By performing similar calculations on all pixels corresponding to all light stripe regions in the image, the relative value of the reflectivity k of the steel pipe surface can be estimated.
[0105] Step 5: Apply the reflection estimation coefficients to the entire image, optimize the image grayscale, and obtain the point cloud image of the object under test.
[0106] Furthermore, step five, by estimating the surface reflectance coefficient of the object in step four, obtains the surface reflectance coefficient value of the object's surface, and thus the theoretical grayscale value of the tested tubular surface. Applying the surface reflectance coefficient to the image pixels corrects the grayscale value of the light stripes, improving the accuracy of light stripe extraction. A comparison of the grayscale values of the steel pipe surface before and after optimization is shown below. Figure 8 As shown in the image. After image optimization, combined with the plane equation calibration and 3D coordinate calculation in the previous steps, a 3D scanning model is established. The 3D point cloud data of the steel pipe surface can be obtained from the grayscale value of each pixel and the optimized image. In the actual measurement process, the defective steel pipe is scanned using a fixed projector and camera, and the generated point cloud results are shown in the image. Figure 9 As shown.
[0107] Based on the same inventive concept, the present invention also provides an image grayscale estimation system, comprising:
[0108] The center point acquisition module is used to project light stripes onto the plane plate where the calibration plate is located to form a light plane and determine the center point of the light stripe projection on the light plane.
[0109] The equation construction module is used to define an image plane of an illusion, project points on the imaging plane onto the image plane of the illusion, connect the center point of each column of light stripes to the origin of the camera coordinate system to form a ray, construct a set of equations using the coordinates of the intersection points of multiple rays with the light plane and the image plane of the illusion, as well as the intrinsic and extrinsic parameters of the camera, and fit the set of equations using the least squares method to obtain the equation of the light plane.
[0110] The parameter acquisition module is used to place the tubular object under test on the plane plate where the calibration plate is located, project multiple structured lights onto the surface of the tubular object under test and reflect them onto the imaging plane, acquire the image coordinates and three-dimensional coordinates of the multiple structured lights, input the image coordinates, three-dimensional coordinates and camera coordinates into the light plane equation, and calculate the geometric parameters of the multiple structured lights on the imaging plane.
[0111] The grayscale estimation module is used to solve for multiple reflection coefficients of the surface of the tubular object under test based on the actual grayscale value of the surface and the geometric parameters of multiple structured beams on the imaging plane. The average value of the multiple reflection coefficients is taken, and the theoretical grayscale value of the surface of the tubular object under test is calculated based on the average value of the multiple reflection coefficients.
[0112] The modules in the aforementioned image grayscale estimation system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the computer device's memory as software, so that the processor can call and execute the corresponding operations of each module.
[0113] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps in the image grayscale estimation method embodiment. Specific implementation methods can be found in the method embodiment, and will not be repeated here.
[0114] Furthermore, the present invention also provides a non-transitory computer-readable storage medium containing instructions, on which a computer program is stored. For example, a memory containing instructions that can be executed by a processor of a computer device to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc. When the computer program is executed by the processor, it can implement the steps in the image grayscale estimation method embodiments. Specific implementation methods can be found in the method embodiments, which will not be repeated here.
[0115] Those skilled in the art will understand that embodiments of the present invention can provide methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0116] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0117] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0118] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0119] It should be noted that the specific embodiments described above enable those skilled in the art to more fully understand the present invention, but do not limit the present invention in any way. Therefore, although the present invention has been described in detail in this specification and embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the present invention; and all technical solutions and improvements that do not depart from the spirit and scope of the present invention are covered within the protection scope of the present invention patent. No reference numerals in the claims should be construed as limiting the scope of the claims. Any simple variations or equivalent substitutions of technical solutions that can be readily obtained by those skilled in the art within the scope of the technology disclosed in the present invention are within the protection scope of the present invention.
Claims
1. A method of estimating image gray scale, characterized by, include: The light stripes are projected onto the plane plate on which the calibration plate is located to form a light plane, and the center point of the light stripe projection on the light plane is determined. Define an image plane of an illusion, project points on the imaging plane onto the image plane of the illusion, connect the center point of each column of light stripes to the origin of the camera coordinate system to form a ray, construct a system of equations using the coordinates of the intersection points of multiple rays with the light plane and the image plane of the illusion, as well as the intrinsic and extrinsic parameters of the camera, and fit the system of equations using the least squares method to obtain the equation of the light plane. The tubular object to be tested is placed on the plane plate where the calibration plate is located. Multiple structured beams are projected onto the surface of the tubular object and reflected onto the imaging plane. The image coordinates and three-dimensional coordinates of the multiple structured beams are obtained. The image coordinates, three-dimensional coordinates and camera coordinates are input into the light plane equation to calculate the geometric parameters of the multiple structured beams on the imaging plane. Multiple reflection coefficients of the tubular surface are obtained by solving the actual gray value of the surface of the tested tubular object and the geometric parameters of multiple structured beams on the imaging plane. The average value of the multiple reflection coefficients is taken, and the theoretical gray value of the surface of the tested tubular object is calculated based on the average value of the multiple reflection coefficients.
2. The image grayscale estimation method according to claim 1, characterized in that, The process involves defining an image plane for an illusion, projecting points from the imaging plane onto this image plane, connecting the center point of each column of light fringes to the origin of the camera coordinate system to form a ray, and constructing a system of equations using the coordinates of the intersections of multiple rays with the light plane and the image plane of the illusion, as well as the camera's intrinsic and extrinsic parameters. The light plane equation is then obtained by fitting the system of equations using the least squares method. Specifically: Define an imaginary image plane, with the origin of the camera coordinate system as... O c The points on the imaging plane are projected onto the image plane of the artifact; let the points on the imaging plane be... The coordinates corresponding to the image plane of the artifact are Normalization is achieved by fixing the Z-coordinate to 1; at this point, based on the straight line... The point is obtained by finding the intersection of the plane with the calibration plate. ,straight line The expression is shown in formula (1): (1) in, It is a point in the camera coordinate system The coordinates; The coordinates of the imaging plane are normalized to the camera coordinate system as shown in formula (2), and the points are... Substituting the coordinates into formula (3) shows: (2) (3) Substitute formula (3) into the plane equation of the calibration plate. ,in The points in the camera coordinate system are obtained through camera calibration. coordinates As shown in formula (4): (4) The above calculation is performed on the center point of each light fringe in each image to obtain the camera coordinates of the center point of the light fringe, which are then substituted into the system of equations (5): (5) in, The coordinates of the center point of the light stripe are obtained through formula (4). , , These are the coefficients of the equation for the light plane: The equations for the light plane are obtained by fitting the system of equations using the least squares method.
3. The image grayscale estimation method according to claim 1, characterized in that, The camera is calibrated using a calibration board to obtain its intrinsic and extrinsic parameters, specifically: A flat plate of the same material as the tubular object being measured is placed in the illuminated area. A calibration plate of negligible thickness is attached to its left side. Multiple images from different perspectives are taken and the coordinates of feature points are extracted. The homography matrix of each image is determined based on the coordinates of the feature points and the geometric model of the camera imaging. The equations of the constraint relationship are obtained by rotating the homography matrix and solving the equations to obtain the intrinsic and extrinsic parameters of the camera.
4. The image grayscale estimation method according to claim 1, characterized in that, The determination of the center point of the light stripe projection on the light plane specifically involves: The left and right boundaries of the light stripes are determined by setting a threshold, the ordinate of the gray-scale centroid of each column of light stripes within the left and right boundaries is calculated, and the center point of the light stripes is determined based on the ordinate of the gray-scale centroid of the light stripes.
5. The image grayscale estimation method according to claim 4, characterized in that, The ordinate of the gray-level centroid of each column of light stripes is determined using the gray-level centroid method, specifically as follows: Scan the planar image row by row, calculate the light stripes column by column, determine the left and right boundaries of the light stripes by setting a threshold, calculate the ordinate of the gray-scale centroid of each row of light stripes within the left and right boundaries according to the formula, and determine the position of the center point of the light stripes according to the ordinate of the gray-scale centroid of the light stripes. The specific formula for the ordinate of the grayscale centroid of the light stripe is as follows: in, The position of each column of pixels; The set of pixels used in the calculation; The grayscale value of a pixel; The vertical coordinate is the centroid of the grayscale of the light stripe.
6. The image grayscale estimation method according to claim 1, characterized in that, The flat plate is made of the same material as the tubular object being tested.
7. An image grayscale estimation system, characterized in that, include: The center point acquisition module is used to project light stripes onto the plane plate where the calibration plate is located to form a light plane and determine the center point of the light stripe projection on the light plane. The equation construction module is used to define an image plane of an illusion, project points on the imaging plane onto the image plane of the illusion, connect the center point of each column of light stripes to the origin of the camera coordinate system to form a ray, construct a set of equations using the coordinates of the intersection points of multiple rays with the light plane and the image plane of the illusion, as well as the intrinsic and extrinsic parameters of the camera, and fit the set of equations using the least squares method to obtain the equation of the light plane. The parameter acquisition module is used to place the tubular object under test on the plane plate where the calibration plate is located, project multiple structured lights onto the surface of the tubular object under test and reflect them onto the imaging plane, acquire the image coordinates and three-dimensional coordinates of the multiple structured lights, input the image coordinates, three-dimensional coordinates and camera coordinates into the light plane equation, and calculate the geometric parameters of the multiple structured lights on the imaging plane. The grayscale estimation module is used to solve for multiple reflection coefficients of the surface of the tubular object under test based on the actual grayscale value of the surface and the geometric parameters of multiple structured beams on the imaging plane. The average value of the multiple reflection coefficients is taken, and the theoretical grayscale value of the surface of the tubular object under test is calculated based on the average value of the multiple reflection coefficients.
8. A computer device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is loaded by the processor, it is able to perform the steps of the method according to any one of claims 1 to 6.