A multi-camera illumination compensation method for tunnels
By selecting a small number of reference images from images acquired by multiple cameras in the tunnel to calculate the illumination compensation template and coefficients, the problem of uneven brightness and brightness difference in tunnel images is solved, achieving efficient illumination compensation, which is suitable for large data volume scenarios.
Patent Information
- Application Number
- CN202311106075.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-08-30
AI Technical Summary
Existing illumination compensation methods cannot effectively solve the problems of uneven brightness in images from the same camera and brightness differences between images from different cameras when collecting tunnel appearance data by a track vehicle. They are particularly computationally intensive and difficult to apply when dealing with large amounts of data.
By selecting a small number of reference images, we calculate the illumination compensation template and illumination compensation coefficients. Using these parameters, we perform illumination compensation on the images from each camera. This includes setting up n cameras, selecting m images, sorting them according to the grayscale standard deviation, stacking them into a matrix to calculate the mean matrix, calculating the grayscale mean in blocks, obtaining the illumination compensation template and coefficients, and performing simple calculations to achieve illumination compensation.
It effectively solves the problems of uneven brightness and brightness difference in images acquired by multiple cameras in tunnels, requires less computation, is suitable for large data scenarios, and improves the efficiency of illumination compensation.
Smart Images

Figure CN117354630B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of illumination compensation technology, and in particular to a multi-camera illumination compensation method for tunnels. Background Technology
[0002] Currently, tunnel defect detection mainly relies on manual inspection, which is inefficient. However, automated acquisition of tunnel surface images using a railcar, image stitching to generate a map, and automatic defect identification to create a defect distribution map can significantly improve detection efficiency. Railcars typically carry multiple fixed-mount line-scan cameras and use lasers for illumination to acquire tunnel surface images. Due to varying ambient lighting conditions and differences in the illumination effects of different lasers, images acquired by the same camera may exhibit uneven brightness, and images from different cameras may show significant brightness differences.
[0003] The commonly used illumination compensation methods are as follows: the first method is to select some images as templates, then calculate the gray-level mean, and then linearly stretch the gray levels of other images based on the gray-level mean; the second method is to perform gray-level histogram equalization on the template images, and then perform histogram matching on other images based on the gray-level histogram of the template images.
[0004] The above-mentioned illumination compensation methods are not applicable to tunnel appearance data collected by the track vehicle. First, the brightness of images from the same camera is uneven, often showing a clear distinction between the bright and dark areas on the left and right sides of the image. After linear stretching of grayscale, the bright areas will become too bright, so they are only suitable for images with uniform brightness. Second, although histogram equalization and histogram matching can achieve better results, they involve a large amount of computation and are difficult to apply to projects with large amounts of data. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide a multi-camera illumination compensation method for tunnels.
[0006] The objective of this invention is achieved through the following technical solution: a multi-camera illumination compensation method for tunnels, comprising the following steps:
[0007] S1: Set up n cameras, select m images, sort them according to the grayscale standard deviation, and select the first k images as reference images;
[0008] S2: Stack k reference images into a matrix M with k channels. s Calculate M s The mean matrix M is obtained by taking the mean values of pixels at the same location across different channels. m ;
[0009] S3: Calculate the grayscale mean value by dividing the mean matrix into blocks to obtain the illumination compensation template;
[0010] S4: Calculate the mean of all illumination compensation templates to obtain the illumination compensation coefficient;
[0011] S5: Perform illumination compensation on the images of each camera based on the illumination compensation template and illumination compensation coefficient.
[0012] Preferably, step S1 further includes the following step:
[0013] S11: Given n cameras, for the image captured by the i-th (i = 1, 2, ..., n) camera, the width and height of the image are both (w, h). Select m images and calculate the grayscale standard deviation σ of the j-th (j = 1, 2, ..., m) image. j ,
[0014]
[0015] in, Let μ be the pixel value of the j-th image. j The average pixel value;
[0016] S12: Sort in ascending order based on grayscale standard deviation.
[0017] Preferably, in step S11, if the number of images captured by a single camera is less than m, then all images are selected.
[0018] Preferably, in step S2, M s Given a matrix of dimension (k, w, h), obtain the mean matrix M of dimension (w, h). m Calculate M m Medium pixel value p (x,y) ,
[0019]
[0020] in, For M s The pixel value with coordinates (x, y) in the l-th (l = 1, 2, ..., k) channel.
[0021] Preferably, step S3 further includes the following step:
[0022] S31: Let the block size be b = 256, and the creation size be (w b ,h b The block mean matrix of ) Where w b =ceil(w / b),h b =ceil(h / b), in the mean matrix M mCalculate the average grayscale value by dividing the data into blocks, and enter the average value of each block. Calculate at the corresponding position Medium pixel value
[0023]
[0024] Where mean is the mean operation on the matrix, M' m For M m Block matrices in a matrix;
[0025] S32: When in In the diagram, the coordinates (x', y') correspond to M. m The range of the matrix is:
[0026]
[0027] S33: Divide the block mean matrix By (w b ,h b Upsampled to size (w,h), the illumination compensation template for this camera image is obtained.
[0028] Preferably, in step S4, the average value is calculated by summing the average values of all illumination compensation templates as the illumination compensation coefficient β between different cameras. The calculation formula is as follows:
[0029]
[0030] Where, mean is the operation of calculating the average of a matrix. Let n be the illumination compensation template for the i-th camera, and n be the number of cameras.
[0031] Preferably, in step S5, the formula for calculating illumination compensation for each camera's image based on the illumination compensation template and illumination compensation coefficient is as follows:
[0032]
[0033] Among them, I i For the image from the i-th camera, I' i This is the image after illumination compensation.
[0034] The present invention has the following advantages: In the scenario of multiple cameras acquiring apparent images in a tunnel, compared with commonly used illumination compensation methods, the present invention calculates the illumination compensation template and illumination compensation coefficient by selecting a small number of reference images, and then performs illumination compensation on the image, thereby solving the problems of uneven image brightness and brightness differences between different cameras. When subsequent illumination compensation is required, only simple calculations are needed using the illumination compensation template and compensation coefficient, which has the characteristics of low computational load. Attached Figure Description
[0035] Figure 1 A schematic diagram of the multi-camera illumination compensation method flow;
[0036] Figure 2 This is a schematic diagram illustrating the effect of the image before illumination compensation.
[0037] Figure 3 This is a schematic diagram illustrating the effect of the image after illumination compensation. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0039] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0040] It should be noted that, unless otherwise specified, the embodiments and features described in this invention can be combined with each other.
[0041] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0042] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product of this invention is in use, or the orientation or positional relationship commonly understood by those skilled in the art. They are only used for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention. In addition, the terms "first," "second," etc., are only used to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0043] In the description of this invention, it should also be noted that, unless otherwise explicitly specified and limited, the terms "set," "install," "connect," and "link" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0044] In this embodiment, as Figure 1 As shown, a multi-camera illumination compensation method for tunnels includes the following steps:
[0045] S1: Set up n cameras, select m images, sort them according to the grayscale standard deviation, and select the first k images as reference images;
[0046] S2: Stack k reference images into a matrix M with k channels. s Calculate M s The mean matrix M is obtained by taking the mean values of pixels at the same location across different channels. m ;
[0047] S3: Calculate the grayscale mean value by dividing the mean matrix into blocks to obtain the illumination compensation template;
[0048] S4: Calculate the mean of all illumination compensation templates to obtain the illumination compensation coefficient;
[0049] S5: Perform illumination compensation on the image of each camera based on the illumination compensation template and illumination compensation coefficients. In scenarios where multiple cameras acquire apparent images in a tunnel, compared to commonly used illumination compensation methods, this invention calculates the illumination compensation template and illumination compensation coefficients by selecting a small number of reference images, and then performs illumination compensation on the images. This solves the problems of uneven image brightness and brightness differences between different cameras, and its effect is comparable to... Figure 2 and Figure 3As shown, when subsequent illumination compensation is needed for the image, only simple calculations are required using the illumination compensation template and illumination compensation coefficients, which has the advantage of low computational complexity.
[0050] Furthermore, step S1 also includes the following steps:
[0051] S11: Given n cameras, for the image captured by the i-th (i = 1, 2, ..., n) camera, the width and height of the image are both (w, h). Select m images and calculate the grayscale standard deviation σ of the j-th (j = 1, 2, ..., m) image. j ,
[0052]
[0053] in, Let μ be the pixel value of the j-th image. j The average value is the pixel value; specifically, the main function of step S11 is to make the grayscale of the selected image uniform.
[0054] S12: Sort the images in ascending order based on their grayscale standard deviation. Further, in step S11, if the number of images captured by a single camera is less than m, then all images are selected. In this embodiment, parameters m and k can be set according to actual conditions.
[0055] In this embodiment, in step S2, M s Given a matrix of dimension (k, w, h), obtain the mean matrix M of dimension (w, h). m Calculate M m Medium pixel value p (x,y) ,
[0056]
[0057] in, For M s The pixel value with coordinates (x, y) in the l-th (l = 1, 2, ..., k) channel.
[0058] Furthermore, step S3 also includes the following steps:
[0059] S31: Let the block size be b = 256, and the creation size be (w b ,h b The block mean matrix of ) Where w b =ceil(w / b),h b =ceil(h / b), in the mean matrix M m Calculate the average grayscale value by dividing the data into blocks, and enter the average value of each block. Calculate at the corresponding position Medium pixel value
[0060]
[0061] Where mean is the mean operation on the matrix, M' m For M m Block matrices in a matrix;
[0062] S32: When in In the diagram, the coordinates (x', y') correspond to M. m The range of the matrix is:
[0063]
[0064] S33: Divide the block mean matrix By (w b ,h b Upsampled to size (w,h), the illumination compensation template for this camera image is obtained.
[0065] In this embodiment, in step S4, the average value is calculated by summing the average values of all illumination compensation templates as the illumination compensation coefficient β between different cameras. The calculation formula is as follows:
[0066]
[0067] Where, mean is the operation of calculating the average of a matrix. Let n be the illumination compensation template for the i-th camera, and n be the number of cameras.
[0068] Furthermore, in step S5, the formula for calculating illumination compensation for each camera's image based on the illumination compensation template and illumination compensation coefficient is as follows:
[0069]
[0070] Among them, I i For the image from the i-th camera, I' i This is the image after illumination compensation.
[0071] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A multi-camera illumination compensation method for tunnels, characterized in that: Includes the following steps: S1: Settings Each camera is selected. Images were selected and sorted in ascending order based on their grayscale standard deviation. Zhang image is used as a reference image; S2: Will Zhang reference images are stacked to form a... A matrix of channels ,calculate The mean matrix is obtained by taking the average values of pixels at the same location across different channels. ; S3: Create a size of Block mean matrix In the mean matrix Calculate the average grayscale value by dividing the data into blocks, and enter the average value of each block. At the corresponding positions, the block mean matrix will be... Depend on Upsampling Size, to obtain the illumination compensation template of the image. ; S4: Calculate the mean of all illumination compensation templates to obtain the illumination compensation coefficient; S5: Perform illumination compensation on the images of each camera based on the illumination compensation template and illumination compensation coefficient; In step S4, the mean value is calculated by summing the mean values of all illumination compensation templates, which serves as the illumination compensation coefficient between different cameras. The calculation formula is: ; in, To calculate the mean of a matrix, For the first A camera's illumination compensation template Number of cameras; In step S5, the formula for calculating illumination compensation for each camera's image based on the illumination compensation template and illumination compensation coefficient is as follows: ; in, For the first Images from one camera, This is the image after illumination compensation.
2. The multi-camera illumination compensation method for tunnels according to claim 1, characterized in that: In step S1, there are: The camera, for the first The image captured by the camera, with image dimensions of [width and height]. Select The nth image, calculate the nth grayscale standard deviation of the image , ; in, For the first The pixel values of the image. This represents the pixel average.
3. The multi-camera illumination compensation method for tunnels according to claim 2, characterized in that: In step S11, when the number of images captured by a single camera is less than If so, then select all images.
4. The multi-camera illumination compensation method for tunnels according to claim 3, characterized in that: In step S2 Matrix dimension is The dimension obtained is mean matrix ,calculate Medium pixel value , ; in, for No. The coordinates on each channel are The pixel value.
5. The multi-camera illumination compensation method for tunnels according to claim 4, characterized in that: Step S3 further includes the following steps: S31: Set the block size Create a size of Block mean matrix ,in In the mean matrix Calculate the average grayscale value by dividing the data into blocks, and enter the average value of each block. Calculate at the corresponding position Medium pixel value , ; in, To calculate the mean of a matrix, In order to be in Block matrices in a matrix; S32: When in In the middle, the coordinates are ( The location corresponds to The range of the matrix is: ; S33: Divide the block mean matrix Depend on Upsampling Size, to obtain the lighting compensation template for this camera image. .
Citation Information
Patent Citations
Brightness compensation method and device for displayer
CN107240384A
Exposure compensation adjustment method for multi-lens shooting
CN109889734A
