An adaptive correction method for natural color restoration of cigar drying nighttime images
Through the adaptively corrected natural color recovery method of cigar smoke drying night images, the color inconsistency problem caused by day and night lighting differences is solved, and efficient color restoration and automated monitoring are achieved during cigar smoke drying.
Patent Information
- Application Number
- CN202510368624.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-03-27
AI Technical Summary
During the process of drying cigar cigarettes, the image color inconsistency caused by differences in day and night lighting conditions affects the quality of tobacco status monitoring and the reliability of computer vision analysis, increasing complexity.
Adaptively corrected cigar smoke drying night images are used to restore natural color of cigar smoke, including image preprocessing, depth feature extraction, color migration and image fusion. Through adaptive color correction and adjustment, natural color restoration of cigar smoke night images is achieved.
It effectively corrects the color temperature and tone differences of cigar smoke night images, reduces color deviation, provides high-quality image data support, and provides reliable data support for automated monitoring of cigar smoke drying.
Smart Images

Figure CN119887590B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural color restoration of cigar drying images at night, and in particular to a natural color restoration method of cigar drying images at night with adaptive correction. Background Art
[0002] With the widespread application of image processing technology in the tobacco industry, its applications have expanded to encompass tobacco field monitoring, agricultural monitoring during rainy weather, and cigar drying monitoring, among other aspects of tobacco production. The cigar drying process is crucial for ensuring quality and requires 24 / 7 monitoring to document the condition of the tobacco leaves. However, due to differences in lighting conditions between day and night, significant color inconsistency exists during image acquisition. Daytime images rely on natural light, resulting in high color reproduction and a true reflection of the tobacco leaves' actual condition. Nighttime images, on the other hand, require the use of artificial lighting (such as LEDs), resulting in significant differences in image color temperature and hue, resulting in unnatural leaf color and significant overall image color deviation. This color inconsistency not only impacts the quality of continuous monitoring of the tobacco drying process but also complicates the subsequent delineation of cigar drying stages. It can even interfere with automated computer vision-based analysis systems, reducing data reliability and consistency, and limiting its practical application in cigar drying. Summary of the Invention
[0003] The purpose of the present invention is to overcome the deficiencies of the prior art and to provide a method for restoring the natural colors of cigar drying images at night with adaptive correction.
[0004] The object of the present invention is achieved through the following technical solutions:
[0005] The present invention discloses a method for restoring the natural color of a night-time image of a cigar drying process by adaptive correction, comprising the following steps:
[0006] S1. Input an image, obtaining an image of tobacco leaves drying in a cigar drying room from the network or a hard disk; and loading a first cigar nighttime image and a first reference image dataset from the obtained tobacco leaves drying image.
[0007] S2, image preprocessing, performing image preprocessing on the first cigar nighttime image and the first reference image dataset to obtain a second cigar nighttime image and a second reference image dataset;
[0008] S3, deep feature extraction, calculating the image features of the second cigar night image and the second reference image dataset respectively, and obtaining the best image in the second reference image dataset;
[0009] S4, color migration: using the best image obtained in step S3 as a benchmark, and based on the adaptive colors corresponding to the feature similarities, performing color migration on the second cigar night image to obtain a third cigar night image;
[0010] S5, image adjustment, performing contrast adjustment, saturation adjustment, and brightness adjustment on the night image of the third cigar;
[0011] S6. Image fusion: performing weighted fusion, histogram equalization, and final fusion on the third cigar night image after image adjustment to obtain and output a cigar night corrected image.
[0012] Furthermore, the preprocessing described in step S2 specifically includes the following steps:
[0013] S21, through the formula For the first input image Perform normalization to obtain the first image , wherein the first input image including a first cigar night image and a first reference image dataset, Represents the first input image The maximum value of Represents the first input image The minimum value of , (x, y) represents the image coordinate point, x represents the horizontal coordinate; y represents the vertical coordinate;
[0014] S22, through the formula For the first image Perform Z-Score normalization to obtain the second image ,in Indicates the first image The mean of each color channel in , Indicates the first image The standard deviation of each color channel in; then through the formula For the second image The mean of is calculated, where Represents the second image The width, Represents the second image height, Represents the second image The mean of For the second image The standard deviation is calculated, where Represents the second image The standard deviation of
[0015] S23, through the formula For the second image Perform Gaussian filtering to obtain the third image ;
[0016] S24, through the formula For the third image Perform bilateral filtering to obtain the fourth image , the fourth image including a second cigar night image and a second reference image dataset, Ω(x,y) Indicates the third image The neighborhood of the image coordinate point (x,y), Represents image coordinate points The third image at value, represents the spatial Gaussian kernel, represents the standard deviation of the spatial Gaussian kernel, Represents the image coordinate point (x, y) and the image coordinate point The spatial distance between represents the range Gaussian kernel, represents the standard deviation of the range Gaussian kernel, Represents the image coordinate point (x, y) and the image coordinate point The difference in pixel values between Represents the normalization factor, and its weight sum is 1, which is calculated as follows .
[0017] Preferably, the step S3 specifically includes the following steps:
[0018] S31, through the formula For the fourth image Perform convolution operation to extract its local features and capture its local texture features and edge features. Indicates that the output feature map is in the image The median coordinate is The value at Representing an image In coordinates The pixel value at Indicates the relative position of the convolution kernel The weight value at ;
[0019] S32, through the ReLU activation function Removal Negative values increase its nonlinearity and prevent the gradient from disappearing;
[0020] S33, through the formula Perform image batch averaging Calculate, where represents the mean of the image batch, Represents the output value of the ReLU function in step S32, m represents the batch size; then through the formula Variance of image batches Calculate and finally pass the formula and Perform batch normalization calculation, where represents a constant to prevent division by zero, γ represents a learnable scaling parameter, β represents a learnable translation parameter, express In the coordinates ( i , j )’s normalized eigenvalue;
[0021] S34, through the formula The result of batch normalization Perform adaptive pooling, where represents adaptive average pooling;
[0022] S35, calculate the feature similarity, specifically including the formula Calculate the similarity of the feature vectors, where Representing an image The eigenvector of Representing an image The eigenvector of Represents the feature vector The i-th component of Represents the feature vector The i-th component of Represents the feature vector The L2 norm of Represents the feature vector The L2 norm of n represents the length of the vector, Represents the feature vector and eigenvectors degree of similarity.
[0023] Preferably, step S4 specifically includes the following steps:
[0024] S41, through the formula Calculate the adaptive weights, where represents the color migration weight, represents the feature weight coefficient, min() represents the function used to limit the result to [0, 1];
[0025] S42, through the formula For the fourth image Perform color migration to obtain the fifth image , the fifth image Includes a third cigar night image, where Represents the average value of the reference images of the second reference image dataset.
[0026] Preferably, step S5 specifically includes the following steps:
[0027] S51, through the formula For the fifth image Adjust the contrast to obtain the contrast adjustment result ,in Indicates the fifth image The minimum value of Indicates the fifth image The maximum value of
[0028] S52, through the formula For the fifth image Adjust the saturation to get the saturation adjustment result , where γ represents the saturation index;
[0029] S53, through the formula For the fifth image Adjust the brightness to get the brightness adjustment result ,in represents the contrast parameter, Represents the brightness parameter.
[0030] Preferably, step S6 specifically includes the following steps:
[0031] S61, through the formula The contrast adjustment results, brightness adjustment results, and saturation adjustment results are integrated to balance the processing effects. Indicates the component weight of the brightness adjustment result, Indicates the component weight of the contrast adjustment result, represents the component weight of the saturation adjustment result, and ;
[0032] S62, through the formula performing local histogram equalization on each channel in a second input image, wherein the second input image comprises a third cigar nighttime image after image adjustment; represents the local values of the channel map of the second input image, Indicates the maximum channel value in the current local area, Indicates the minimum channel value in the current local area;
[0033] S63, through the formula Perform range clipping, where Indicates the minimum allowed value, Indicates the maximum allowed value.
[0034] The beneficial effects of the present invention are:
[0035] 1) The proposed adaptive correction algorithm for natural color restoration of nighttime cigar drying images uses zero-shot adaptive correction image processing technology, breaking through the application bottleneck of traditional enhancement methods and deep learning algorithms in the complex environment of cigar drying.
[0036] 2) While ensuring efficient computation, this invention comprehensively corrects nighttime images of cigars: it effectively adjusts the color temperature and hue of nighttime images of cigars that differ significantly from those during the day, reduces image color deviation, and achieves accurate color reproduction.
[0037] 3) The present invention has a significant effect on image correction under night-time cigar drying conditions and can restore night-time images of cigars in complex environments, filling the gap in current night-time cigar image correction algorithms. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 Schematic diagram of the steps of a method for restoring natural colors of a night-time image of cigars by adaptive correction according to an embodiment of the present invention;
[0039] Figure 2 The figure is a flow chart of a method for restoring natural colors of a night-time image of cigars by adaptive correction according to an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following will clearly and completely describe the technical solutions of the present invention in conjunction with the embodiments. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work shall fall within the scope of protection of the present invention.
[0041] The present invention provides an adaptive correction method for restoring the natural color of nighttime images of cigar drying. Through image preprocessing, deep feature extraction, feature similarity calculation, color migration model, image adjustment, image fusion, etc., it effectively solves the problems of obvious differences in color temperature and hue between cigar drying images and daytime images, unnatural tobacco leaf color, and large overall image color deviation. It can provide high-quality cigar drying images and provide reliable data support for automated monitoring of cigar drying. The steps are shown in the figure below. Figure 1 The flow chart is as shown in Figure 2 As shown, the specific steps include:
[0042] S1. Input an image, obtaining an image of tobacco leaves drying in a cigar drying room from the network or a hard disk; and loading a first cigar nighttime image and a first reference image dataset from the obtained tobacco leaves drying image.
[0043] S2, image preprocessing, performing image preprocessing on the first cigar nighttime image and the first reference image dataset to obtain a second cigar nighttime image and a second reference image dataset;
[0044] S3, deep feature extraction, calculating the image features of the second cigar night image and the second reference image dataset respectively, and obtaining the best image in the second reference image dataset;
[0045] S4, color migration: using the best image obtained in step S3 as a benchmark, and based on the adaptive colors corresponding to the feature similarities, performing color migration on the second cigar night image to obtain a third cigar night image;
[0046] S5, image adjustment, performing contrast adjustment, saturation adjustment, and brightness adjustment on the night image of the third cigar;
[0047] S6. Image fusion: performing weighted fusion, histogram equalization, and final fusion on the third cigar night image after image adjustment to obtain and output a cigar night corrected image.
[0048] Specifically, the preprocessing described in step S2 specifically includes the following steps:
[0049] S21, through the formula For the first input image Perform normalization to obtain the first image , wherein the first input image including a first cigar night image and a first reference image dataset, Represents the first input image The maximum value of Represents the first input image The minimum value of , (x, y) represents the image coordinate point, x represents the horizontal coordinate; y represents the vertical coordinate;
[0050] S22, through the formula For the first image Perform Z-Score standardization, which is a data preprocessing method that converts data into a mean of 0 and a standard deviation of 1, to obtain the second image ,in Indicates the first image The mean of each color channel in , Indicates the first image The standard deviation of each color channel in; then through the formula For the second image The mean of is calculated, where Represents the second image The width, Represents the second image height, Represents the second image The mean of For the second image The standard deviation is calculated, where Represents the second image The standard deviation of
[0051] S23, through the formula For the second image Perform Gaussian filtering to obtain the third image ;
[0052] S24, through the formula For the third image Perform bilateral filtering to obtain the fourth image , the fourth image including a second cigar night image and a second reference image dataset, Ω(x,y) Indicates the third image In the neighborhood of the image coordinate point (x,y), Represents image coordinate points The third image at value, represents the spatial Gaussian kernel, represents the standard deviation of the spatial Gaussian kernel, Represents the image coordinate point (x, y) and the image coordinate point The spatial distance between represents the range Gaussian kernel, represents the standard deviation of the range Gaussian kernel, Represents the image coordinate point (x, y) and the image coordinate point The difference in pixel values between Represents the normalization factor, and its weight sum is 1, which is calculated as follows .
[0053] Specifically, step S3 includes the following steps:
[0054] S31, through the formula For the fourth image Perform convolution operation to extract its local features and capture its local texture features and edge features. Indicates that the output feature map is in the image The median coordinate is The value at Representing an image In coordinates The pixel value at Indicates the relative position of the convolution kernel The weight value at ;
[0055] S32, through the ReLU activation function Removal Negative values increase its nonlinearity and prevent the gradient from disappearing;
[0056] S33, through the formula Perform image batch mean calculation, where represents the mean of the image batch, Represents the output value of the ReLU function in step S32, m represents the batch size; then through the formula Calculate the variance of the image batch and finally use the formula and Perform batch normalization calculation, where represents a constant to prevent division by zero, γ represents a learnable scaling parameter, β represents a learnable translation parameter, express In the coordinates ( i , j )’s normalized eigenvalues; batch normalization can stabilize deep network training, reduce internal covariate shift, accelerate network convergence, and improve model generalization ability;
[0057] S34, through the formula The result of batch normalization Perform adaptive pooling, where represents adaptive average pooling;
[0058] S35, calculate the feature similarity, specifically including the formula Calculate the similarity of the feature vectors, where Representing an image The eigenvector of Representing an image The eigenvector of Represents the feature vector The i-th component of Represents the feature vector The i-th component of Represents the feature vector The L2 norm of Represents the feature vector The L2 norm of n represents the length of the vector, Represents the feature vector and eigenvectors Here we calculate the similarity between two feature vectors, which is used to measure the vector similarity in the feature space.
[0059] Specifically, step S4 includes the following steps:
[0060] S41, through the formula Calculate the adaptive weights, where represents the color migration weight, Represents the feature weight coefficient, min() represents a function used to limit the result to [0, 1]. The content in the brackets is the smaller value to be selected;
[0061] S42, through the formula For the fourth image Perform color migration to obtain the fifth image , the fifth image Includes a third cigar night image, where Represents the average value of the reference images of the second reference image dataset.
[0062] Specifically, step S5 includes the following steps:
[0063] S51, through the formula For the fifth image Adjust the contrast to obtain the contrast adjustment result ,in Indicates the fifth image The minimum value of Indicates the fifth image The maximum value of
[0064] S52, through the formula For the fifth image Adjust the saturation to get the saturation adjustment result , where γ represents the saturation index;
[0065] S53, through the formula For the fifth image Adjust the brightness to get the brightness adjustment result ,in represents the contrast parameter, Indicates the brightness parameter. is 1.01, It is 9.
[0066] Specifically, step S6 includes the following steps:
[0067] S61, through the formula The contrast adjustment results, brightness adjustment results, and saturation adjustment results are integrated to balance the processing effects. Indicates the component weight of the brightness adjustment result, Indicates the component weight of the contrast adjustment result, represents the component weight of the saturation adjustment result, and ;
[0068] S62, through the formula performing local histogram equalization on each channel in a second input image, wherein the second input image comprises a third cigar nighttime image after image adjustment; represents the local values of the channel map of the second input image, Indicates the maximum channel value in the current local area, Indicates the minimum channel value in the current local area;
[0069] S63, through the formula Perform range clipping, where Indicates the minimum allowed value, Indicates the maximum allowed value. The value is 0. The value is 255.
[0070] The proposed adaptive correction algorithm for restoring natural colors from nighttime cigar drying images utilizes zero-shot adaptive correction image processing technology to overcome the application bottlenecks of traditional enhancement methods and deep learning algorithms in the complex environment of cigar drying. While ensuring computational efficiency, this method comprehensively corrects nighttime cigar images, effectively adjusting the significant differences in color temperature and hue between nighttime cigar drying images and daytime cigar drying images, reducing image color deviation and achieving accurate color restoration. This method achieves significant image correction results under nighttime cigar drying conditions and is capable of restoring nighttime cigar drying images in complex environments, filling a gap in current nighttime cigar image correction algorithms.
[0071] The foregoing description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein and should not be construed as excluding other embodiments. Rather, the present invention can be used in various other combinations, modifications, and environments and can be modified within the scope of the concept described herein through the above teachings or techniques or knowledge in the relevant field. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention are intended to be protected by the appended claims.
Claims
1. A method for restoring the natural color of a night-time image of cigars by adaptive correction, characterized in that: The following steps are involved: S1. Input an image, obtaining an image of tobacco leaves drying in a cigar drying room from the network or a hard disk; and loading a first cigar nighttime image and a first reference image dataset from the obtained tobacco leaves drying image. S2, image preprocessing, performing image preprocessing on the first cigar nighttime image and the first reference image dataset to obtain a second cigar nighttime image and a second reference image dataset; S3, deep feature extraction, calculating the image features of the second cigar night image and the second reference image dataset respectively, and obtaining the best image in the second reference image dataset; S4, color migration: using the best image obtained in step S3 as a benchmark, and based on the adaptive colors corresponding to the feature similarities, performing color migration on the second cigar night image to obtain a third cigar night image; S5, image adjustment, performing contrast adjustment, saturation adjustment, and brightness adjustment on the night image of the third cigar; S6, image fusion, performing weighted fusion, histogram equalization, and final fusion on the third cigar night image after image adjustment to obtain and output a cigar night corrected image; The pre-processing described in step S2 specifically includes the following steps: S21, through the formula For the first input image I ori (x, y) is normalized to obtain the first image I ori_nor (x, y), where the first input image I ori (x, y) includes the first cigar night image and the first reference image dataset, max(I ori (x, y)) represents the first input image I ori The maximum value of (x, y), min(I ori (x, y) represents the first input image I ori The minimum value of (x, y), (x, y) represents the image coordinate point, x represents the horizontal coordinate, and y represents the vertical coordinate; S22, through the formula For the first image I ori_nor (x, y) is normalized by Z-Score to obtain the second image I z_score_nor (x, y), where μ ori_nor Represents the first image I ori_nor The mean of each color channel in (x, y), σ ori_nor Represents the first image I ori_nor The standard deviation of each color channel in (x, y); then the formula For the second image I z_score_nor The mean of (x, y) is calculated, where M z_score_nor Represents the second image I z_score_nor The width of (x,y), N z_score_nor Represents the second image I z_score_nor (x, y) height, μ z_score_nor Represents the second image I z_score_nor The mean of (x, y); finally, the formula For the second image I z_score_nor The standard deviation of (x, y) is calculated, where σ z_score_nor Represents the second image I z_score_nor The standard deviation of (x, y); S23, through the formula For the second image I z_score_nor (x, y) is Gaussian filtered to obtain the third image I gauss_nor (x, y); S24, through the formula For the third image I gauss_nor (x, y) is subjected to bilateral filtering to obtain the fourth image I filter_base (x, y), the fourth image I filter_base (x, y) includes the second cigar night image and the second reference image dataset, Ω(x, y) represents the third image I gauss_nor (x, y) The neighborhood of the image coordinate point (x, y), I gauss_nor (x′, y′) represents the third image I at the image coordinate point (x′, y′) gauss_nor (x, y) values, represents the spatial Gaussian kernel, σ s represents the standard deviation of the spatial Gaussian kernel, Represents the spatial distance between the image coordinate point (x, y) and the image coordinate point (x′, y′), represents the range Gaussian kernel, σ r represents the standard deviation of the range Gaussian kernel, |I gauss_nor (x, y)-I gauss_nor (x′, y′)| represents the difference in pixel value between the image coordinate point (x, y) and the image coordinate point (x′, y′), ω p (x, y) represents the normalization factor, and its weight sum is 1, which is calculated as follows The step S3 specifically includes the following steps: S31, through the formula For the fourth image I filter_base (x, y) performs convolution operation to extract its local features and capture its local texture features and edge features, where F(i, j) represents the output feature map in image I filter_base The value at coordinate (i, j) in (x, y), I filter_base (m, n) represents image I filter_baxe (x, y) is the pixel value at the coordinate (m, n), K(im, jn) represents the weight value of the convolution kernel at the relative position (im, jn); S32, through the ReLU activation function Remove the negative values of F(i, j), increase its nonlinearity, and prevent the gradient from disappearing; S33, through the formula Perform image batch mean μ batch Calculate, where μ batch represents the mean of the image batch, F a (i, j) represents the output value of the ReLU function in step S32, and m represents the batch size; then, by formula Variance of image batches Calculate and finally use the formula and Perform batch normalization calculation, where ε represents a constant to prevent division by zero, γ represents a learnable scaling parameter, and β represents a learnable translation parameter. Indicates F a (i, j) the normalized eigenvalue at coordinate (i, j); S34, through the formula The result of batch normalization Perform adaptive pooling, where represents adaptive average pooling; S35, calculate the feature similarity, specifically including the formula Calculate the similarity of the feature vectors, where Representing an image The eigenvector of Representing an image The eigenvector of F 1i Represents the feature vector The i-th component of F 2i Represents the feature vector The i-th component of Represents the feature vector The L2 norm of Represents the feature vector The L2 norm of n represents the length of the vector, Represents the feature vector and eigenvectors degree of similarity; Step S4 specifically includes the following steps: S41, through the formula Calculate the adaptive weight, where ω adaptive represents the color migration weight, ω f Represents the feature weight coefficient, min(,) represents a function used to limit the result to [0, 1]; S42, through formula I color (x, y) = ω adaptive I filter_base (x, y)+(1-ω adaptive )·I reference (x, y) for the fourth image I filter_base (x, y) performs color migration to obtain the fifth image I color (x, y), the fifth image I color (x, y) includes the third cigar night image, where I reference (x, y) represents the reference image average of the second reference image dataset; Step S5 specifically includes the following steps: S51, through the formula For the fifth image I color The contrast of (x, y) is adjusted to obtain the contrast adjustment result I contrast (x, y), where min(I color (x, y)) represents the fifth image I color The minimum value of (x, y), max(I color (x, y)) represents the fifth image I color The maximum value of (x, y); S52, through the formula For the fifth image I color The saturation of (x, y) is adjusted to obtain the saturation adjustment result I saturation (x, y), where γ represents the saturation index; S53, through formula I brightness (x, y) = α × I color (x, y) + β′ for the fifth image I color The brightness of (x, y) is adjusted to obtain the brightness adjustment result I brightness (x, y), where α represents the contrast parameter and β′ represents the brightness parameter; Step S6 specifically includes the following steps: S61, through formula I final (x, y) = ω1 × I brightness (x, y) + ω2 × I contrast (x, y)+ω3×I saturation (x, y) fuses the contrast adjustment results, brightness adjustment results, and saturation adjustment results to balance the processing effects, where ω1 represents the component weight of the brightness adjustment result, ω2 represents the component weight of the contrast adjustment result, ω3 represents the component weight of the saturation adjustment result, and ω1+ω2+ω3=1; S62, through the formula Performing local histogram equalization on each channel in the second input image, wherein the second input image includes the third cigar night image after image adjustment; wherein I fusion (x, y) represents the local value of the channel map of the second input image, max(I fusion (x, y)) represents the maximum channel value in the current local area, min(I fusion (x, y)) represents the minimum channel value in the current local area; S63, through the formula Perform range clipping, where min val Indicates the minimum allowed value, max val Indicates the maximum allowed value.
Citation Information
Patent Citations
Night image enhancement and noise suppression integrated system based on deep learning
CN118941462A