Tobacco leaf image color calibration method and equipment

By segmenting and calibrating the color calibration plate area in tobacco leaf images, generating an actual color matrix and performing correction, the environmental and equipment influences in tobacco leaf image color calibration are resolved, improving the accuracy and consistency of color features, and making it suitable for complex acquisition environments.

CN121190579APending Publication Date: 2025-12-23ZHENGZHOU TOBACCO RES INST OF CNTC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511137862.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-14
Publication Date
2025-12-23

AI Technical Summary

Technical Problem

Existing methods for color calibration of tobacco leaf images are affected by ambient lighting conditions, differences in equipment parameters, and the randomness of sample placement, leading to deviations in color characteristics and affecting the accuracy and consistency of analytical results.

Method used

By segmenting the color calibration plate area, the RGB mean value of the center of the color block is extracted to generate the actual color matrix. The color calibration matrix is ​​then calculated by combining it with the standard color matrix. This matrix is ​​used to correct the image color and eliminate the influence of environmental and device factors.

Benefits of technology

It enables accurate correction of color deviation in tobacco leaf images under complex acquisition environments, improves the standardization and consistency of color features, and supports tobacco leaf quality analysis and digital characterization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121190579A_ABST
    Figure CN121190579A_ABST
Patent Text Reader

Abstract

The invention relates to a tobacco leaf image color calibration method and equipment, and belongs to the field of digital image processing, and the method comprises the steps: segmenting a color calibration plate region from an original image containing tobacco leaves and a color calibration plate; extracting an RGB mean value of the center of each color block in the color calibration plate area; generating an actual color matrix of the color calibration board according to the RGB mean values of the centers of all the color blocks; calculating a color calibration matrix according to the actual color matrix and a standard color matrix of a prefabricated color calibration plate; according to the method, the original image is subjected to color correction by using the color calibration matrix to obtain the calibrated tobacco leaf image, so that the calibration and recognition accuracy of the color of the tobacco leaf image is remarkably improved, and the color calibration of the tobacco leaf image is not influenced by factors such as complex illumination, environmental stability and a shooting angle any more.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method and apparatus for calibrating the color of tobacco leaf images, belonging to the field of digital image processing. Background Technology

[0002] With the rapid development of information technology and intelligentization in modern agriculture, the quality control and characteristic analysis of tobacco leaves are gradually shifting from traditional manual assessment to precise measurement based on digital image and spectral technologies. Color characteristics of tobacco leaf images, as one of the important indicators for evaluating tobacco leaf quality, are of great significance in tobacco leaf classification, grading, and quality control. However, due to inconsistencies in ambient lighting conditions, differences in equipment parameters, and the randomness of sample placement, significant deviations occur in the color characteristics of the acquired tobacco leaf images, thus affecting the accuracy and consistency of the analysis results. Therefore, a method that can eliminate the influence of environmental and equipment differences and accurately correct the color of tobacco leaf images is urgently needed.

[0003] Currently, color correction technology mainly relies on standard color calibration plates, using the standard color patches in the calibration plate to perform global color correction on the image. However, traditional methods are mostly based on manually selecting calibration areas or simple color transformation models, which have the following limitations: on the one hand, manually selecting calibration areas is inefficient and easily affected by subjective factors; on the other hand, existing color correction algorithms lack stability under complex lighting conditions and are difficult to adapt to diverse acquisition environments. In addition, the geometric deformation of the calibration plate in the image caused by shooting angle or perspective distortion has not been adequately addressed, limiting the improvement of correction accuracy. Summary of the Invention

[0004] The purpose of this invention is to provide a method and device for calibrating the color of tobacco leaf images, in order to solve the problem of inaccurate color recognition of tobacco leaf images.

[0005] To achieve the above objectives, the present invention proposes a method for calibrating the color of tobacco leaf images, comprising the following steps:

[0006] 1) Segment the color calibration plate region from the original image containing tobacco leaves and the color calibration plate;

[0007] 2) Extract the RGB mean value of the center of each color patch in the color calibration panel area; generate the actual color matrix of the color calibration panel based on the RGB mean value of the center of all color patches;

[0008] 3) Calculate the color calibration matrix based on the actual color matrix and the standard color matrix of the pre-made color calibration plate;

[0009] 4) Use the color calibration matrix to perform color correction on the original image to obtain the calibrated tobacco leaf image.

[0010] Furthermore, the color calibration plate region is segmented from the image containing tobacco leaves and the color calibration plate using the following method:

[0011] The original image is converted into an HSV image, and a dynamic thresholding segmentation algorithm is called to segment the first region and the second region from the HSV image;

[0012] The first and second regions are analyzed using connected component analysis. Regions corresponding to tobacco leaves are identified and removed from the first and second regions. The regions that are not removed from the first and second regions are identified as color calibration plate regions.

[0013] Furthermore, after converting the original image into an HSV image, the brightness and saturation information in the HSV image are extracted, and the segmentation parameters in the dynamic threshold segmentation algorithm are adjusted based on the brightness and saturation information to segment the first region and the second region from the HSV image.

[0014] Furthermore, when analyzing the first region and the second region using the connected component analysis method, the region whose connected area is closest to the actual area of ​​the tobacco leaf is selected from the first region and the second region, and the selected region whose connected area is closest to the actual area of ​​the tobacco leaf is determined as the region of the tobacco leaf.

[0015] Further, step 2) includes the following steps:

[0016] 21) Determine the bounding box of the color calibration plate in the image based on the geometric characteristics of the color calibration plate region;

[0017] 22) Based on the bounding box of the color calibration plate, call the perspective transformation algorithm to perform set correction on the color calibration plate area, generate a standard-shaped color calibration plate area, and determine the standard-shaped color calibration plate area as the target area;

[0018] 23) Divide the target area into several color blocks according to the color block grid of the pre-made color calibration plate, and extract the RGB mean value of the center of each color block;

[0019] 24) Based on the RGB value of the center of any color patch in the target area, correct the orientation of the target area so that the orientation of the corrected target area is consistent with the orientation of the pre-made color calibration plate;

[0020] 25) Generate the actual color matrix of the color calibration plate based on the orientation of the calibrated target area and the RGB values ​​of the centers of all color blocks in the target area.

[0021] Further, step 21) includes: extracting the convex hull vertices of the color calibration plate region based on the geometric characteristics of the color calibration plate region, and determining the bounding box of the color calibration plate in the image based on the convex hull vertices.

[0022] Further, step 24) includes: determining the current orientation of the target area by identifying the position of the white color block based on the RGB value of the white color block in the target area; and correcting the orientation of the target area based on the current orientation of the target area and the orientation of the pre-made color calibration plate.

[0023] Furthermore, the color calibration matrix is ​​represented by the following formula:

[0024]

[0025] Where MCC is the color calibration matrix; S RGB For standard color matrix; I RGB This is the actual color matrix.

[0026] On the other hand, the present invention also proposes a calibration device for the color of a tobacco leaf image, including a processor for executing the above-described calibration method for the color of a tobacco leaf image.

[0027] The beneficial effects of this invention are as follows: By segmenting the color calibration plate region from the original image containing tobacco leaves and a color calibration plate; extracting the RGB mean value of the center of each color block in the color calibration plate region; generating the actual color matrix of the color calibration plate based on the RGB mean value of the centers of all color blocks; calculating the color calibration matrix based on the actual color matrix and the pre-made standard color matrix of the color calibration plate; and using the color calibration matrix to perform color correction on the original image to obtain a calibrated tobacco leaf image, this invention cleverly processes images containing both tobacco leaves and a color calibration plate, breaking through the conventional thinking of existing tobacco leaf image color calibration, obtaining the actual color matrix, and then combining it with the standard color matrix to obtain the color calibration matrix. The entire process is unaffected by the acquisition environment and requires no manual intervention, enabling the color calibration matrix to accurately reflect the relationship between the actual color and the standard color. Using the color calibration matrix to calibrate the color of the tobacco leaf image significantly improves the accuracy of tobacco leaf image color calibration and recognition, and ensures that the color calibration of the tobacco leaf image is no longer affected by factors such as complex lighting, environmental stability, and shooting angle. This allows for accurate correction of color deviations in tobacco leaf images under complex acquisition environments, significantly improving the standardization and consistency of color features in tobacco leaf images, and providing reliable technical support for tobacco quality analysis and digital characterization. Attached Figure Description

[0028] Figure 1 This is a flowchart illustrating the practical application of the tobacco leaf image color calibration method proposed in this invention.

[0029] Figure 2 This is a schematic diagram of the tobacco leaf image calibration process in practical application scenario 1, based on the tobacco leaf image color calibration method proposed in this invention.

[0030] Figure 3This is a schematic diagram showing the automatic identification and orientation correction results of the color calibration method for tobacco leaf images proposed in this invention under different initial angle directions in practical application scenario 2.

[0031] Figure 4 This is a schematic diagram showing the image comparison of three groups of samples under different light source conditions in actual application scenario 3 of the tobacco leaf image color calibration method proposed in this invention.

[0032] Figure 5 This is a schematic diagram showing the comparison of calibrated images of three groups of samples under different light source conditions in actual application scenario 3 of the tobacco leaf image color calibration method proposed in this invention.

[0033] Figure 6 This is a schematic diagram comparing the average color difference of tobacco leaf areas before and after calibration under three light source conditions in practical application scenario 4 of the tobacco leaf image color calibration method proposed in this invention. Detailed Implementation

[0034] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0035] The inventive concept of this invention is as follows: To avoid the influence of subjective human factors and complex lighting conditions on calibration results caused by manual selection of calibration areas or simple color transformation models, an image containing tobacco leaves and a color calibration plate is acquired, and the color calibration plate area is segmented in the image containing tobacco leaves and the color calibration plate; then, based on the actual color matrix and the standard color matrix of the color calibration plate, a color calibration matrix reflecting the relationship between the actual color and the standard color is obtained, thereby calibrating the color of the tobacco leaf image according to the color calibration matrix, and using the color calibration matrix to objectively reflect color deviation, achieving accurate color calibration that is unaffected by changes in environmental factors.

[0036] Detailed implementation method 1:

[0037] The present invention proposes a method for calibrating the color of tobacco leaf images, comprising steps S1-S4, specifically...

[0038] Step S1: Segment the color calibration plate area from the original image containing tobacco leaves and the color calibration plate. It should be noted that when acquiring the original image containing tobacco leaves and the color calibration plate, in order to ensure that the tobacco leaves and the color calibration plate can be clearly separated in the original image, the tobacco leaves and the color calibration plate are set on a solid color background, which includes but is not limited to pure black, pure white, dark gray and other colors.

[0039] Simultaneously, in step S1, after acquiring the original image containing tobacco leaves and a color calibration plate, the original image is converted into an HSV image, and a dynamic threshold segmentation algorithm is called to segment the first and second regions from the HSV image. Here, converting the original image into an HSV image means converting the color space of the original image into the HSV color space to generate the corresponding HSV image. The HSV color space describes color through three components: hue, saturation, and brightness. Its core advantages are that it conforms to human intuition, resists lighting interference, and simplifies color segmentation. The dynamic threshold segmentation algorithm adaptively adjusts the segmentation parameters according to the image lighting conditions and segments the image according to the adjusted segmentation parameters. It is applicable to images acquired under different shooting environments and lighting conditions, thus avoiding the phenomenon of difficult segmentation and inaccurate segmentation caused by factors such as shooting angle and shooting lighting.

[0040] When segmenting the first and second regions, brightness and saturation information are extracted from the HSV image. Based on this information, the segmentation parameters in the dynamic threshold segmentation algorithm are adjusted to segment the first and second regions from the HSV image. This filters out extremely bright or dark areas in the HSV image, retaining the first or second region used to represent the tobacco leaf area or the color calibration plate area.

[0041] After segmenting the first and second regions, connected component analysis is used to analyze them. Regions corresponding to the tobacco leaves are identified and removed from both regions. The remaining regions are designated as the color calibration plate regions. It should be noted that when analyzing the first and second regions using connected component analysis, the region with the closest connected area to the actual area of ​​the tobacco leaf is selected. This selected region is then designated as the tobacco leaf region. In practical applications, to quickly determine the tobacco leaf region, the relationship between the actual tobacco leaf area and the actual area of ​​the color calibration plate is usually considered. The region with the largest / smallest area in the connected region of the first and second regions is selected as the tobacco leaf region (if the actual tobacco leaf area is larger than the actual color calibration plate area, the region with the largest area in the connected region of the first and second regions is selected as the tobacco leaf region; if the actual tobacco leaf area is smaller than the actual color calibration plate area, the region with the smallest area in the connected region of the first and second regions is selected as the tobacco leaf region).

[0042] Step S2: Extract the RGB mean value of the center of each color patch in the color calibration plate area; generate the actual color matrix of the color calibration plate based on the RGB mean value of the center of all color patches.

[0043] Step S3: Calculate the color calibration matrix based on the actual color matrix and the standard color matrix of the pre-made color calibration plate. Specifically, the color calibration matrix is ​​expressed by the following formula:

[0044]

[0045] Where MCC is the color calibration matrix; S RGB For standard color matrix; I RGB This is the actual color matrix.

[0046] Step S4: Use the color calibration matrix to perform color correction on the original image to obtain the calibrated tobacco leaf image.

[0047] Through the above steps S1-S4, the image containing tobacco leaves and color calibration plate is analyzed and processed, and the color calibration plate area is accurately segmented. Then, the actual color matrix is ​​generated based on the color calibration plate area, and the color deviation is projected onto the color calibration matrix. The color calibration matrix can be used directly to correct the color of the tobacco leaf image. This can accurately correct the color deviation of the tobacco leaf image in complex acquisition environments and significantly improve the standardization and consistency of the color features of the tobacco leaf image.

[0048] Method Detailed Implementation 2:

[0049] Following the above embodiments, in this invention, step S2 includes the following steps:

[0050] 21) Based on the geometric characteristics of the color calibration plate region, determine the bounding box of the color calibration plate in the image to lock the bounding box of the color calibration plate. It should be noted that the geometric characteristics refer to the geometric shape features of the color calibration plate, such as rectangular shape features, square shape features, etc. Specifically, when determining the bounding box of the color calibration plate, the convex hull contour algorithm is used to determine the bounding box: based on the geometric characteristics of the color calibration plate region, the convex hull vertices of the color calibration plate region are extracted, and the bounding box of the color calibration plate in the image is determined based on the convex hull vertices. The convex hull contour algorithm is the minimum convex polygon boundary that describes a set of discrete points (or object contours). Its core function is to simplify complex shapes, extract structured features, and assist in subsequent analysis.

[0051] 22) Based on the bounding box of the color calibration plate, the perspective transformation algorithm is called to perform set correction on the color calibration plate area to generate a standard-shaped color calibration plate area, and the standard-shaped color calibration plate area is determined as the target area; Here, the perspective transformation algorithm refers to a technique that transforms an image from one perspective (two-dimensional plane) to another perspective (such as tilt, top view or non-parallel projection) through geometric projection to correct distortion, simulate three-dimensional perspective or achieve image registration.

[0052] 23) Divide the target area into several color blocks according to the color block grid of the pre-made color calibration plate, and extract the RGB mean value of the center of each color block. The extraction process is based on the center area of ​​the color block (preferably the size of the center area of ​​each color block is set to 25% of the grid area) to avoid interference from the edge of the color block and ensure the accuracy and consistency of color information.

[0053] 24) Correct the orientation of the target area based on the RGB value of the center of any color block in the target area so that the orientation of the corrected target area is consistent with the orientation of the pre-made color calibration plate. Here, the current orientation of the target area can be determined by identifying the position of the white color block based on the RGB value of the white color block in the target area. Correct the orientation of the target area based on the current orientation of the target area and the orientation of the pre-made color calibration plate. Ensure that the calibration plate is in the standard orientation for subsequent processing through orientation correction.

[0054] 25) Generate the actual color matrix of the color calibration plate based on the orientation of the calibrated target area and the RGB values ​​of the centers of all color blocks in the target area.

[0055] Through the above steps 21)-25), color analysis of the color calibration plate area is achieved, and the actual color matrix is ​​generated. At the same time, in order to facilitate the calculation of the color calibration matrix during color analysis, the standard color area is subjected to bounding box locking, grid segmentation, color block mean calculation, and calibration plate orientation correction, so as to more accurately reflect the image color deviation.

[0056] Method Detailed Implementation 3:

[0057] like Figure 1 The diagram shown illustrates the process of applying the tobacco leaf image color calibration method proposed in this invention in practice, which includes the following steps:

[0058] Step S1, Image Acquisition: Place the tobacco leaf sample and the standard color calibration plate together on a solid-color background. Use an image acquisition device to acquire an RGB original image containing the tobacco leaf and the calibration plate. Specifically, the solid-color background includes, but is not limited to, pure black, pure white, and dark gray, to create a significant contrast between the solid-color background and the tobacco leaf and color calibration plate, ensuring that they can be clearly separated in the image. The image acquisition device includes, but is not limited to, a digital camera, an industrial camera, or a smartphone. When acquiring images, ring light sources, diffused light sources, or other auxiliary light sources can be used to optimize image quality and avoid uneven lighting, overexposure, or underexposure. At the same time, reasonable white balance, exposure parameters (such as ISO and exposure time), and resolution (300 dpi or higher recommended) should be set when acquiring images to ensure the integrity of image details and color information, adapting to various shooting scenarios and environmental conditions.

[0059] Step S2, Color Region Segmentation: The acquired original image is converted to the HSV color space, and the luminance and saturation channel information is extracted. The color regions of the tobacco leaves and color calibration plate in the image are segmented. Specifically, the acquired original image is converted from the RGB color space to the HSV color space, and the luminance channel (V channel) and saturation channel (S channel) information are extracted. A dynamic thresholding algorithm is then used to initially segment the color regions of the tobacco leaves and color calibration plate in the image (i.e., obtaining the first and second regions). The dynamic thresholding algorithm adaptively adjusts the segmentation parameters according to the image lighting conditions, making it suitable for different shooting environments and lighting conditions. Morphological operations, including but not limited to erosion, dilation, opening, and closing operations, are incorporated during the segmentation process to remove small noise areas, smooth edges, and fill holes to generate an optimized binary mask, ensuring that the tobacco leaf and color calibration plate regions can be clearly distinguished.

[0060] Step S3: Tobacco Leaf Region Removal and Calibration Plate Segmentation Optimization: The tobacco leaf region is removed through region analysis, while the calibration plate region is retained. The segmentation result is optimized to ensure the integrity of each color block within the calibration plate. Specifically, connected component analysis is used to analyze the initially segmented color regions (i.e., the first and second regions), extracting the region with the largest area as the tobacco leaf region and removing it from the binary mask. After removing the tobacco leaf region, a combined brightness and saturation refinement segmentation method is applied to the retained color calibration plate region. The threshold is dynamically adjusted to enhance the recognition ability of dark or small color blocks, ensuring the integrity of each color block within the color calibration plate. This method can adapt to different color calibration plate configurations and diverse shooting conditions.

[0061] Step S4: Vertex Extraction of the Calibration Board: Four vertices are extracted based on the geometric characteristics of the calibration board region, and the bounding box of the calibration board is locked. Specifically, based on the geometric characteristics of the calibration board region, the convex hull contour of the region is extracted, and the positions of the four vertices of the calibration board are determined based on the convex hull vertices. The vertex extraction method includes, but is not limited to, geometric analysis, edge detection combined with region feature analysis, etc., to ensure that the bounding box of the calibration board can be accurately locked. Furthermore, a template matching algorithm can be used to optimize the initial positioning of the calibration board region, improving the accuracy of the four vertex detections and adapting to image processing needs under different shooting angles and background environments.

[0062] Step S5: Calibration Board Perspective Transformation and Network Division: A perspective transformation is performed on the calibration board area to correct it into a standard rectangle (i.e., the target area). Specifically, a perspective transformation algorithm is used to geometrically correct the calibration board area, transforming it into a standard rectangle. The perspective transformation method calculates the perspective transformation matrix based on the coordinates of the four vertices of the calibration board, eliminating angular deviations and perspective distortions generated during the shooting process. The resolution of the corrected calibration board area can be dynamically adjusted according to actual needs; a preferred resolution is 600×600 pixels to meet the accuracy requirements of subsequent color extraction.

[0063] Step S6: RGB mean value at the center of each color patch: Based on the calibrated calibration plate, divide the area into grids and extract the RGB mean value at the center of each color patch. Specifically, divide the calibrated calibration plate area into several color patch areas according to a predefined grid, and extract the RGB mean value at the center of each color patch. The extraction process is based on the central area (preferably, the size of the central area of ​​each color patch is set to 25% of the grid area) to avoid interference from the edges of the color patches and ensure the accuracy and consistency of color information.

[0064] Step S7, Calibration Plate Orientation Correction: Based on the position of the white block on the calibration plate, determine the orientation of the calibration plate and rotate it to position the white block in the upper left corner to ensure the calibration plate is processed in the standard orientation. Specifically, the orientation of the calibration plate is determined by identifying the position of the white block, and the calibration plate area is rotated to fix the white block in the upper left corner. The detection of the white block is achieved by analyzing the average values ​​of the luminance and saturation channels. The characteristics of the white block include, but are not limited to, a luminance channel value close to 1 (e.g., V>0.9) and a saturation channel value close to 0 (e.g., S<0.1). The rotation correction direction is determined based on the position of the white block, including but not limited to rotating 90° clockwise, 90° counterclockwise, or 180°, to ensure the calibration plate is processed in the standard orientation.

[0065] Step S8: Color Calibration Matrix Calculation and Original Image Color Calibration: A color calibration matrix is ​​calculated using the actual color matrix of the calibration board and the standard color matrix. Global color correction is then performed on the original image. Specifically, the color calibration matrix is ​​calculated by comparing the actual color matrix of the calibration board with the standard color matrix, and this matrix is ​​used to perform global color correction on the original image. Further, the RGB mean values ​​of each color block in the calibration board area are first extracted to construct the actual color matrix of the calibration board. Then, based on the known standard color matrix, the color calibration matrix is ​​calculated using the least squares method or other optimization algorithms. Finally, this calibration matrix is ​​applied to each pixel of the original image to adjust color deviations in the image, eliminating color deviations caused by uneven lighting or equipment differences during shooting, thereby achieving accurate color correction of the image and ensuring that the final output image color is consistent with the standard color.

[0066] Through the above steps S1-S8, the standardization characteristics of the color calibration plate and image processing technology are combined to automatically complete the region segmentation, vertex detection, perspective correction and color calibration process of the calibration plate. At the same time, the present invention has high efficiency and robustness, and can accurately correct the color deviation of tobacco leaf images in complex acquisition environments, significantly improve the standardization and consistency of color features of tobacco leaf images, provide reliable technical support for tobacco quality analysis and digital characterization, and also provide an innovative solution to the color correction problem in the image analysis of other crops.

[0067] Method Detailed Implementation 4:

[0068] This invention proposes a method for calibrating the color of tobacco leaf images, based on MATLAB digital image processing technology, combined with actual experimental procedures and... Figure 2 (This is a schematic diagram of the tobacco leaf image calibration process in practical application scenario 1, illustrating the color calibration method for tobacco leaf images proposed in this invention.) A detailed explanation follows:

[0069] Experimental Design: Ten groups of tobacco leaf samples were selected, and images were captured under three different color temperature conditions (3000K, 5000K, and 6500K). An industrial camera was used as the image acquisition device during the imaging process, with a resolution set to 1920×1080 pixels to ensure that the calibration plate and tobacco leaf samples were clearly visible in the images. Simultaneously, to avoid the influence of uneven illumination, the imaging environment was optimized by combining a ring light source and a diffuser.

[0070] Specific steps:

[0071] Step 1: Image Acquisition and Preprocessing: Place the tobacco leaf sample and the standard color calibration plate together on a pure black background, ensuring the calibration plate is fully visible. During shooting, the industrial camera is vertically aligned with the sample to avoid angular deviation. Appropriate white balance and exposure parameters are set (ISO 100, exposure time 10ms) to ensure the image is neither overexposed nor underexposed. The pure black background provides a significant contrast with the tobacco leaves and calibration plate, laying the foundation for subsequent segmentation. Simultaneously, the light source color temperature is set to three conditions (3000K, 5000K, 7000K) to verify the robustness of the method.

[0072] Step 2: Color region segmentation, including S21 and S22. In S21, the acquired original RGB image is converted into HSV color space, and the luminance channel (V) and saturation channel (S) information are extracted. The color regions of the tobacco leaf and the calibration plate are segmented by dynamic thresholding. In S22, the segmentation results are optimized by morphological operations, including filling small holes and removing small area noise.

[0073] In actual experiments, the following is the core code for implementing S21:

[0074] "% converted to HSV color space"

[0075] hsvImg=rgb2hsv(img);

[0076] V = hsvImg(:,:,3); % Brightness channel

[0077] S = hsvImg(:,:,2); % Saturation channel

[0078] %Dynamic threshold segmentation

[0079] mask=(V>0.1&V<0.8)&(S>0.1);

[0080] The parameters are explained as follows: Brightness range (V>0.1 & V<0.8): Ensures that extremely bright or dark areas are filtered out, preserving the tobacco leaf and calibration plate areas. Saturation threshold (S>0.1): Removes low-saturation noise from the background.

[0081] The following is the core code for implementing S22:

[0082] % Morphological Operations

[0083] mask = imfill(mask, 'holes'); % Fill holes

[0084] mask = bwareaopen(mask, 500); % Removes noise with an area smaller than 500 pixels.

[0085] Step 3: Tobacco leaf region removal and calibration plate optimization segmentation, including S31 and S32. In S31, the largest area region (tobacco leaf region) in the image is extracted through connected component analysis and removed from the binary mask, leaving only the color calibration plate region. In S32, after removing the tobacco leaf, the ability to retain dark areas is enhanced by dynamically adjusting the brightness and saturation thresholds to ensure the integrity of the calibration plate region.

[0086] In actual experiments, the following is the core code for implementing S31:

[0087] "% Connectivity Analysis"

[0088] CC = bwconncomp(mask);

[0089] stats=regionprops(CC,'Area');

[0090] [~,idx] = max([stats.Area]); % The connected component with the largest area (tobacco leaf).

[0091] % Excluded tobacco leaf areas

[0092] mask(CC.PixelIdxList{idx}) = 0; % Remove tobacco leaves.

[0093] The following is the core code for implementing S32:

[0094] "%Optimized Segmentation"

[0095] mask=(V>0.2&V<0.9)&(S>0.1&S<0.8);

[0096] Parameter description: The dynamically adjusted brightness threshold range (0.2~0.9) adapts to different lighting conditions, ensuring the integrity of dark areas.

[0097] Step 4: Vertex extraction of the calibration board, including S41 and S42. S41: Extract the convex hull contour of the calibration board region based on geometric characteristics, and locate the four corner points of the calibration board through the convex hull vertices. S42: To further optimize the location of the four vertices, lock the calibration board region by combining the template matching algorithm and detect its bounding rectangle.

[0098] In actual experiments, the following is the core code for implementing S41:

[0099] "% Extract convex hull"

[0100] convexHull=regionprops(mask,'ConvexHull');

[0101] corners=convexHull.ConvexHull;".

[0102] The following is the core code for implementing S42:

[0103] "% Template matching optimization positioning"

[0104] template = imcrop(img,[x,y,w,h]); % Select the template region

[0105] corr=normxcorr2(rgb2gray(template),rgb2gray(img));

[0106] [~,maxIdx]=max(corr(:));

[0107] [yPeak,xPeak]=ind2sub(size(corr),maxIdx);”.

[0108] Step 5: Perspective Transformation and Mesh Generation of the Calibration Board. Based on the coordinates of the four vertices of the calibration board, a perspective transformation is performed to correct the calibration board area into a standard rectangle, and a mesh is generated to extract the center color of each color block. In the actual experiment, the following is the core code for implementing Step 5:

[0109] % perspective transformation

[0110] tform=fitgeotrans(corners,[0 0;1 0;1 1;0 1],'projective');

[0111] rectifiedImg=imwarp(img,tform,'OutputView',imref2d([600 600]));

[0112] % grid division

[0113] rows = 4; cols = 6;

[0114] blockHeight=size(rectifiedImg,1) / rows;

[0115] blockWidth=size(rectifiedImg,2) / cols;”.

[0116] Step Six: Calculate the RGB mean value at the center of each color patch. Within the calibrated calibration board area, divide the region into a 4×6 grid (based on the layout of a common 24-color calibration board). Each grid represents a color patch. Extract the RGB mean value of the center region of each grid to generate the actual color matrix of the calibration board. In the actual experiment, the following is the core code for implementing Step Six:

[0117]

[0118]

[0119] Step 7: Calibration plate orientation correction. The orientation of the calibration plate is determined by detecting the position of the white patch within it, thus completing the rotation correction. The white patch is characterized by a luminance channel close to 1 and a saturation close to 0. In the actual experiment, the following is the core code for implementing Step 7:

[0120]

[0121] Step 8: Color Calibration Matrix Calculation and Original Image Color Calibration. Using the actual color matrix of the calibration board extracted in Step 7, combined with the standard color matrix of the calibration board, the color calibration matrix (MCC) is calculated. This color calibration matrix is ​​then applied to the original image to achieve automated and accurate color restoration of the original image. In the actual experiment, the following is the core code for implementing Step 8:

[0122]

[0123]

[0124] Method Detailed Implementation 5:

[0125] In the practical application of this invention, accuracy correction was performed based on images of 10 groups of tobacco leaf samples taken under three color temperature conditions (3000K, 5000K, and 6500K):

[0126] (1) Color plate area identification and correction

[0127] First, a set of tobacco leaf samples was selected, and their color chart images were taken at 8 different viewing angles (e.g., ...). Figure 3 (As shown). After correction and testing, regardless of the initial placement angle of the color swatches, the present invention can achieve accurate identification, automatic rotation, correction, and color block extraction of the color swatch area, proving the robustness and adaptability of the method.

[0128] (2) Color difference comparison between uncalibrated and calibrated

[0129] Without color calibration, images of the same group of tobacco leaves under different color temperatures show significant color differences (e.g., Figure 4 (As shown). Specific color difference results are as follows: the color difference between 3000K and 5000K is 19.43; the color difference between 3000K and 6500K is 9.15; the color difference between 5000K and 6500K is 12.66 (as shown). Figure 6 (As shown).

[0130] The automatic color calibration method of this invention significantly improves color uniformity under different light source conditions (e.g., ...). Figure 5 (As shown). After calibration, the color differences between the above light sources were reduced to 6.68, 4.45, and 3.32, respectively (as shown). Figure 6 As shown in the figure, this further demonstrates the effectiveness of the method in reducing the influence of color temperature and improving color consistency.

[0131] Detailed implementation of the equipment:

[0132] In another aspect, the present invention also provides another calibration device for the color of tobacco leaf images, including a processor for executing the above-described calibration method for the color of tobacco leaf images. Here, for specific implementation of the device, please refer to the specific real-time methods 1-5, which will not be repeated here.

[0133] In summary, the technical features of this invention include: 1. A segmentation method combining a color calibration plate and a dynamic threshold algorithm, which can accurately extract tobacco leaf and calibration plate regions, ensuring processing stability under complex backgrounds and diverse lighting conditions; 2. Removing tobacco leaf regions and optimizing calibration plate color block segmentation through connected component analysis, enhancing the retention of dark and small color blocks; 3. Extracting the positions of the four vertices of the calibration plate using convex hull-based geometric analysis, and achieving high-precision geometric correction of the calibration plate by combining perspective transformation; 4. Extracting the RGB mean of the central region of each color block on the calibration plate through a predefined grid, calculating the color calibration matrix by combining it with a standard color matrix, and performing global color correction on the original image using the least squares method or other optimization algorithms to complete color standardization. This improves the standardization and consistency of color features in tobacco leaf images, providing a scientific and reliable basis for tobacco leaf quality analysis, and is applicable to diverse imaging equipment and complex environmental conditions, demonstrating significant adaptability and practical value.

Claims

1. A method for calibrating the color of a tobacco leaf image, characterized in that, Includes the following steps: 1) Segment the color calibration plate region from the original image containing tobacco leaves and the color calibration plate; 2) Extract the RGB mean value of the center of each color patch in the color calibration panel area; generate the actual color matrix of the color calibration panel based on the RGB mean value of the center of all color patches; 3) Calculate the color calibration matrix based on the actual color matrix and the standard color matrix of the pre-made color calibration plate; 4) Use the color calibration matrix to perform color correction on the original image to obtain the calibrated tobacco leaf image.

2. The method for calibrating the color of tobacco leaf images according to claim 1, characterized in that, The color calibration plate region was segmented from an image containing tobacco leaves and a color calibration plate using the following method: The original image is converted into an HSV image, and a dynamic thresholding segmentation algorithm is called to segment the first region and the second region from the HSV image; The first and second regions are analyzed using connected component analysis. Regions corresponding to tobacco leaves are identified and removed from the first and second regions. The regions that are not removed from the first and second regions are identified as color calibration plate regions.

3. The method for calibrating the color of tobacco leaf images according to claim 2, characterized in that, After converting the original image to an HSV image, the brightness and saturation information in the HSV image are extracted. Based on the brightness and saturation information, the segmentation parameters in the dynamic threshold segmentation algorithm are adjusted to segment the first region and the second region from the HSV image.

4. The method for calibrating the color of tobacco leaf images according to claim 2, characterized in that, When analyzing the first and second regions using the connected component analysis method, the region whose connected area is closest to the actual area of ​​the tobacco leaf is selected from the first and second regions, and the selected region whose connected area is closest to the actual area of ​​the tobacco leaf is determined as the region of the tobacco leaf.

5. The method for calibrating the color of tobacco leaf images according to claim 1, characterized in that, Step 2) includes the following steps: 21) Determine the bounding box of the color calibration plate in the image based on the geometric characteristics of the color calibration plate region; 22) Based on the bounding box of the color calibration plate, call the perspective transformation algorithm to perform set correction on the color calibration plate area, generate a standard-shaped color calibration plate area, and determine the standard-shaped color calibration plate area as the target area; 23) Divide the target area into several color blocks according to the color block grid of the pre-made color calibration plate, and extract the RGB mean value of the center of each color block; 24) Based on the RGB value of the center of any color patch in the target area, correct the orientation of the target area so that the orientation of the corrected target area is consistent with the orientation of the pre-made color calibration plate; 25) Generate the actual color matrix of the color calibration plate based on the orientation of the calibrated target area and the RGB values ​​of the centers of all color blocks in the target area.

6. The method for calibrating the color of tobacco leaf images according to claim 5, characterized in that, Step 21) includes: extracting the convex hull vertices of the color calibration plate region based on the geometric characteristics of the color calibration plate region, and determining the bounding box of the color calibration plate in the image based on the convex hull vertices.

7. The method for calibrating the color of tobacco leaf images according to claim 5, characterized in that, Step 24) includes: determining the current orientation of the target area by identifying the position of the white block based on the RGB value of the white block in the target area; and correcting the orientation of the target area based on the current orientation of the target area and the orientation of the pre-made color calibration plate.

8. The method for calibrating the color of a tobacco leaf image according to any one of claims 1-7, characterized in that, The color calibration matrix is ​​represented by the following formula: Where MCC is the color calibration matrix; S RGB For standard color matrix; I RGB This is the actual color matrix.

9. A calibration device for the color of tobacco leaf images, characterized in that, Includes a processor for performing a method for calibrating the color of a tobacco leaf image as described in any one of claims 1-8.