A CTvSeg-UNet-based real-time segmentation method and system for tobacco veins in the entire baking process

By constructing the CTVSeg-UNet model and combining it with generative adversarial network adversarial training, the problem of inaccurate leaf vein segmentation during the entire tobacco curing process was solved. This achieved accurate segmentation of the main vein and branch veins of tobacco leaves, improved the integrity and robustness of the segmentation results, and supported the monitoring and process optimization of tobacco curing.

CN123142196APending Publication Date: 2026-11-20HENAN AGRICULTURAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611191700.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-07
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

Existing technologies struggle to accurately segment leaf veins throughout the entire tobacco curing process, especially when there are significant color changes, increased leaf wrinkles, and vein contraction and refinement. This results in insufficient extraction of vein features, omission of fine branch veins, and incomplete segmentation results, affecting curing characteristic analysis and quality evaluation.

Method used

A leaf vein segmentation model based on CTVSeg-UNet is constructed, introducing class weight units and co-sampling units, and combining them with generative adversarial networks for adversarial training. The leaf vein segmentation model is optimized by constructing a joint adversarial training of the generator and discriminator, so as to achieve accurate segmentation of the main vein and branch veins of tobacco leaves.

Benefits of technology

It improves the integrity and robustness of leaf vein segmentation, enabling real-time segmentation of the main vein and lateral veins of tobacco leaves, and provides reliable data support for monitoring the tobacco curing process and optimizing intelligent curing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123142196A_ABST
    Figure CN123142196A_ABST
Patent Text Reader

Abstract

The present application relates to the field of tobacco intelligent curing and image recognition, and particularly relates to a curing whole-process tobacco vein real-time segmentation method and system based on CTVSeg-UNet, comprising the following steps: S1, obtaining a curing whole-process tobacco image, constructing a single tobacco leaf image sample set after pretreatment, and completing dataset division and enhancement; S2, constructing an improved UNet vein segmentation model comprising an encoder, a decoder, a collaborative up-sampling unit and a category weight unit; S3, inputting the sample set into the improved UNet vein segmentation model, constructing a generative adversarial network with the model as a generator and PatchGAN as a discriminator, and completing adversarial training to obtain a CTVSeg-UNet model; S4, inputting a to-be-tested tobacco image into the trained CTVSeg-UNet model, outputting a vein segmentation mask, and realizing overall vein segmentation of tobacco in the curing process. The present application realizes high-precision and continuous real-time segmentation of main veins and branch veins of tobacco in the whole curing process, and improves the accuracy and robustness of tobacco vein recognition of different varieties and different curing stages.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent tobacco curing and image recognition technology, and in particular to a method and system for real-time segmentation of tobacco leaf veins throughout the curing process based on CTVSeg-UNet. Background Technology

[0002] Tobacco curing is a crucial step in determining tobacco quality. During curing, the vein structure undergoes dynamic changes due to moisture loss, tissue shrinkage, and color variations. As a vital component for material transport and structural support within the tobacco leaf, the vein's morphological characteristics reflect the curing state and physiological changes. Therefore, accurate segmentation and dynamic extraction of tobacco veins throughout the curing process are essential for analyzing curing characteristics, evaluating quality, and optimizing intelligent curing processes. With the development of computer vision and deep learning technologies, automatic identification of tobacco veins using image segmentation techniques has become an important research direction in this field.

[0003] Current research on tobacco leaf vein detection and segmentation mainly focuses on post-curing grading and re-curing. It lacks the ability to adapt to the continuously dynamic changes in leaf veins throughout the entire curing process. During curing, tobacco leaves undergo significant color changes, increased leaf wrinkling, vein contraction and thinning, and blurred vein-to-leaf boundaries, easily leading to insufficient vein feature extraction, omission of small branches, poor vein continuity, and incomplete segmentation results. Furthermore, the vein region occupies a small proportion of the image and has an uneven distribution of categories, making it difficult for existing methods to simultaneously capture both the overall structure and local details of the veins, thus affecting the accuracy of vein segmentation and its practical application. Summary of the Invention

[0004] This invention provides a method and system for real-time segmentation of tobacco leaf veins throughout the entire curing process based on CTVSeg-UNet. By constructing a leaf vein segmentation model based on the UNet network, introducing class weight units and collaborative upsampling units, and combining it with generative adversarial networks for adversarial training, the method achieves accurate segmentation of the main veins and branch veins of tobacco leaves throughout the curing process, improving the completeness, continuity, and robustness of the leaf vein segmentation results. This provides reliable technical support for monitoring the tobacco curing process, analyzing curing characteristics, and optimizing intelligent curing processes.

[0005] A real-time leaf vein segmentation method for tobacco leaves during the entire baking process based on CTVSeg-UNet includes the following steps: S1. Acquire tobacco leaf images throughout the roasting process, preprocess the tobacco leaf images by segmenting them into independent images and converting them to a white background, construct a single tobacco leaf image sample set using the S component images of the HSV color space, and divide the single tobacco leaf image sample set into a training set, a validation set, and a test set, and perform data augmentation processing on the training set. S2, Construct a leaf vein segmentation model based on the UNet network. The leaf vein segmentation model includes an encoder, a decoder, a cooperative upsampling unit, and a class weighting unit. The class weighting unit adopts a 40:1 ratio of leaf vein to background class weights. The cooperative upsampling unit performs bilinear interpolation upsampling and deconvolution upsampling in parallel in the decoder, and performs feature fusion on the bilinear interpolation upsampling results and deconvolution upsampling results to obtain the leaf vein segmentation model. S3, input the single tobacco leaf image sample set into the leaf vein segmentation model, and use the leaf vein segmentation model as a generator, construct a generative adversarial network model with PatchGAN as a discriminator, use the generative adversarial network model to perform adversarial training on the leaf vein segmentation model, so that the generator outputs a pseudo leaf vein mask, and the discriminator distinguishes between the real leaf vein mask and the pseudo leaf vein mask in order to optimize the generator parameters and obtain the trained CTVSeg-UNet model; S4. Input the tobacco leaf image to be tested into the trained CTVSeg-UNet model and output the corresponding leaf vein segmentation mask to achieve the segmentation of the main vein and branch veins of the tobacco leaf.

[0006] Optionally, S1 includes: S11, collect image data of tobacco leaves during the entire baking process, including the yellowing period, color fixing period and dry rib period. The collected objects include single tobacco leaf images from multiple production areas and different tobacco varieties, forming an original tobacco leaf image set. S12, perform single-leaf segmentation on the original tobacco leaf image to obtain independent tobacco leaf images, and convert the independent tobacco leaf images to a uniform white background. Convert the independent tobacco leaf images from RGB color space to HSV color space, extract the S component image as the input image for leaf vein segmentation, so as to enhance the color saturation difference between leaf veins and leaf surface, and construct a single-leaf tobacco leaf image sample set. S13, the single tobacco leaf image sample set is divided into a training set, a validation set and a test set, and the training set images are subjected to horizontal flipping, random rotation, random brightness adjustment and Gaussian blur processing.

[0007] Optionally, S12 includes: S121, Extract the region of a single tobacco leaf from each tobacco leaf image in the original tobacco leaf image set, and segment the original image, which includes the background and the main body of the tobacco leaf, into independent tobacco leaf images that only include the main body of a single tobacco leaf, to obtain an independent tobacco leaf image set; S122, the main tobacco leaf area in the independent tobacco leaf image is preserved, and the background area outside the main tobacco leaf area is uniformly replaced with a white background to obtain an independent tobacco leaf image with a white background. S123, convert the independent tobacco leaf image under the white background from RGB color space to HSV color space, extract the S component image from the HSV image as the input image for leaf vein segmentation, and summarize all S component images to construct a single tobacco leaf image sample set.

[0008] Optionally, S2 includes: S21, a leaf vein segmentation model is constructed based on the UNet network. The encoder extracts features layer by layer from the input S component image to obtain coded features at different levels. The coded features are then input into the decoder for layer-by-layer recovery to obtain the corresponding decoded features, and the decoded features are used as input features. S22, In the leaf vein segmentation model, set the category weight unit, set the background category weight to 1, set the leaf vein category weight to 40, and use the weighted cross-entropy loss function to calculate the loss value between the output of the leaf vein segmentation model and the true label; S23, a collaborative upsampling unit is set in the decoder to perform bilinear interpolation upsampling and deconvolution upsampling on the same layer of input features respectively, and the results of bilinear interpolation upsampling and deconvolution upsampling are concatenated and fused to obtain fused decoded features.

[0009] Optionally, S3 includes: S31, using the leaf vein segmentation model as the generator and PatchGAN as the discriminator, a generative adversarial network model is constructed. The generator is used to receive tobacco leaf images from a single tobacco leaf image sample set and output the corresponding leaf vein segmentation results. The discriminator is used to distinguish the difference between the generator output results and the real leaf vein mask. S32, input the training set images from the single tobacco leaf image sample set into the generator, the generator outputs the corresponding pseudo vein mask, combine the tobacco leaf image with the real vein mask to form a real sample pair, combine the tobacco leaf image with the pseudo vein mask to form a generated sample pair, and input them into the PatchGAN discriminator to construct the input data of the discriminator. S33 uses the PatchGAN discriminator to distinguish between real sample pairs and generated sample pairs, outputs the corresponding discrimination results, iteratively updates the generator parameters based on the discrimination results, and obtains the trained CTVSeg-UNet model through joint adversarial training of the generator and discriminator.

[0010] Optionally, S31 includes: S311, using the leaf vein segmentation model as a generator, after inputting the tobacco leaf image, the pseudo leaf vein mask is obtained through the encoder, co-sampling decoder and output mapping; S312, perform channel splicing between the tobacco leaf image and the real leaf vein mask to obtain real sample pairs, and perform channel splicing between the tobacco leaf image and the pseudo leaf vein mask to obtain generated sample pairs; S313, input the real sample pairs and generated sample pairs into the PatchGAN discriminator respectively. The PatchGAN discriminator outputs the corresponding discrimination score map through convolution operation, specifically including: S3131, the constructed real sample pairs and generated sample pairs are respectively input into the PatchGAN discriminator and used as input features for the first layer convolution operation of the discriminator; S3132 utilizes the PatchGAN discriminator to perform layer-by-layer convolution operations on the input features, extracting leaf vein structure features from real sample pairs and generated sample pairs. S3133 calculates the corresponding discrimination score map based on the features of the last convolutional layer to represent the probability that the input sample is a real leaf vein mask or a pseudo leaf vein mask.

[0011] Optionally, S32 includes: S321, Input the tobacco leaf images in the training set into the generator, and use the generator to extract features, decode and restore, and classify pixels of the tobacco leaf images to obtain the corresponding leaf vein segmentation probability map; S322, Threshold the probability of each pixel in the leaf vein segmentation probability map, convert the probability value into a binary leaf vein label, and obtain a pseudo leaf vein mask. S323: The input tobacco leaf image and the real leaf vein mask are concatenated along the channel dimension to construct real sample pairs. The input tobacco leaf image and the pseudo leaf vein mask are concatenated along the channel dimension to construct generated sample pairs, which are used as input data for the PatchGAN discriminator.

[0012] Optionally, S33 includes: S331, input the real sample pairs and generated sample pairs into the PatchGAN discriminator respectively, and output the corresponding discrimination score map after multi-layer convolution calculation. Each position in the discrimination score map represents the discrimination result of the corresponding local image block. S332, calculate the discriminator loss based on the discrimination scores of real sample pairs and generated sample pairs, calculate the generator loss based on the discrimination scores of generated sample pairs, and calculate the feature loss by combining the feature differences between the pseudo leaf vein mask and the real leaf vein mask. S333 uses the AdamW optimizer to iteratively update the generator parameters. In each iteration, the generator parameters are updated based on the generator loss and feature loss. After training, the updated generator is used as the CTVSeg-UNet model.

[0013] Optionally, S4 includes: S41, convert the tobacco leaf region in the tobacco leaf image to be tested into an independent tobacco leaf image against a white background, and extract the S component image in the HSV color space as the input image for the trained CTVSeg-UNet model; S42, input the S component image corresponding to the tobacco leaf image to be tested into the trained CTVSeg-UNet model, output the predicted value of each pixel belonging to the leaf vein category and the background category through the CTVSeg-UNet model, and calculate the probability of each pixel belonging to the leaf vein category based on the predicted value; S43. Based on the probability of the leaf vein category and the probability of the background category corresponding to each pixel, determine the category label of the pixel, and combine the category labels of all pixels to form a leaf vein segmentation mask, thereby obtaining the segmentation results of the main vein and branch veins in the tobacco leaf image to be tested.

[0014] A real-time leaf vein segmentation system for tobacco leaves throughout the entire curing process based on CTVSeg-UNet is provided to implement the aforementioned real-time leaf vein segmentation method for tobacco leaves throughout the curing process based on CTVSeg-UNet. The system includes the following modules: Sample set construction module: acquire tobacco leaf images throughout the roasting process, preprocess the tobacco leaf images, segment the tobacco leaf images into independent images and convert them to white background, construct a single tobacco leaf image sample set using the S component images of the HSV color space, and divide the single tobacco leaf image sample set into training set, validation set and test set, and perform data augmentation processing on the training set; Leaf vein segmentation model construction module: Constructs a leaf vein segmentation model based on the UNet network. The leaf vein segmentation model includes an encoder, a decoder, a co-sampling unit, and a class weighting unit. The class weighting unit adopts a 40:1 weight ratio between the leaf vein and the background classes. The co-sampling unit performs bilinear interpolation upsampling and deconvolution upsampling in parallel in the decoder, and performs feature fusion on the bilinear interpolation upsampling results and the deconvolution upsampling results to obtain the leaf vein segmentation model. Adversarial training module: The single tobacco leaf image sample set is input into the leaf vein segmentation model, and the leaf vein segmentation model is used as a generator. PatchGAN is used as a discriminator to construct a generative adversarial network model. The generative adversarial network model is used to perform adversarial training on the leaf vein segmentation model, so that the generator outputs a pseudo leaf vein mask. The discriminator distinguishes between the real leaf vein mask and the pseudo leaf vein mask to optimize the generator parameters and obtain the trained CTVSeg-UNet model. Real-time leaf vein segmentation module: Input the image of the tobacco leaf to be tested into the trained CTVSeg-UNet model, and output the corresponding leaf vein segmentation mask to achieve the segmentation of the main vein and branch veins of the tobacco leaf.

[0015] The beneficial effects of this invention are: This invention acquires tobacco leaf images covering the yellowing, color-fixing, and drying stages, and constructs a single-leaf image sample set using the S-component image of the HSV color space. Simultaneously, by combining training, validation, and test set divisions with data enhancement processing such as horizontal flipping, random rotation, random brightness adjustment, and Gaussian blur, it effectively preserves the saturation difference information between tobacco leaf veins and leaf surface, enhances the diversity and completeness of sample data, and improves the model's adaptability to tobacco leaf images from different varieties, production areas, and curing stages.

[0016] This invention constructs a leaf vein segmentation model that includes an encoder, a decoder, a collaborative upsampling unit, and a class weighting unit. In the decoder, bilinear interpolation upsampling and deconvolution upsampling are performed in parallel, and the sampling results from the two paths are fused. At the same time, a 40:1 weighting of leaf vein and background classes and a weighted cross-entropy loss function are used for training. This enables the full extraction and recovery of the features of the main vein and fine branch veins of tobacco leaves, improves the recognition ability and segmentation integrity of the leaf vein region, and enhances the ability of the leaf vein segmentation results to represent complex leaf vein structures.

[0017] This invention constructs a generative adversarial network model by using a leaf vein segmentation model as a generator and PatchGAN as a discriminator. It continuously optimizes the generator parameters using an adversarial training mechanism between real and pseudo leaf vein masks, and uses the trained CTVSeg-UNet model to segment the leaf veins of the tobacco leaf image under test. It can output accurate leaf vein segmentation masks, realize real-time segmentation of the main vein and branch veins of tobacco leaves, improve the continuity and integrity of the leaf vein contour, and provide reliable data support for monitoring the tobacco curing process, analyzing curing characteristics, and optimizing intelligent curing technology. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only for this invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a schematic diagram of the segmentation method according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the system functional modules according to an embodiment of the present invention. Detailed Implementation

[0020] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. Those skilled in the art may employ other alternative methods to implement some well-known technologies; moreover, the accompanying drawings are only for more specific description of the embodiments and are not intended to specifically limit the present invention.

[0021] like Figure 1 As shown, a real-time leaf vein segmentation method for tobacco leaves during the entire baking process based on CTVSeg-UNet includes the following steps: S1. Acquire tobacco leaf images throughout the roasting process, preprocess the tobacco leaf images, segment the tobacco leaf images into independent images and convert them to white background, construct a single tobacco leaf image sample set using the S component images of the HSV color space, and divide the single tobacco leaf image sample set into training set, validation set and test set, and perform data augmentation processing on the training set. S2. Construct a leaf vein segmentation model based on the UNet network. The leaf vein segmentation model includes an encoder, a decoder, a co-sampling unit, and a class weighting unit. The class weighting unit adopts a 40:1 ratio of leaf vein to background class weights. The co-sampling unit performs bilinear interpolation upsampling and deconvolution upsampling in parallel in the decoder, and performs feature fusion on the bilinear interpolation upsampling results and deconvolution upsampling results to obtain the leaf vein segmentation model. S3. Input the single tobacco leaf image sample set into the leaf vein segmentation model, and use the leaf vein segmentation model as a generator. Use PatchGAN as a discriminator to build a generative adversarial network model. Use the generative adversarial network model to perform adversarial training on the leaf vein segmentation model, so that the generator outputs a pseudo leaf vein mask. The discriminator distinguishes between the real leaf vein mask and the pseudo leaf vein mask to optimize the generator parameters and obtain the trained CTVSeg-UNet model. S4. Input the image of the tobacco leaf to be tested into the trained CTVSeg-UNet model, and output the corresponding leaf vein segmentation mask to achieve the segmentation of the main vein and branch veins of the tobacco leaf.

[0022] S1 includes: S11, Collect image data of tobacco leaves throughout the entire curing process, including the yellowing stage, color-fixing stage, and vegetative drying stage. The collected images include single tobacco leaves from multiple production areas and different tobacco varieties, ensuring that the resulting images reflect the color changes, morphological changes, and vein visibility at different curing stages, forming an original tobacco leaf image set. Specifically, this includes: (1) The entire process of tobacco curing is used as the image acquisition range. The acquisition of image data starts and ends synchronously with the curing process, so that the acquisition results cover the entire process of changes in tobacco leaf color, shape, and vein visibility as the curing process progresses. This is represented as follows: ; in, This is a collection for the baking stage. It is the yellowing period. For the color fixation period, This is the dry muscle stage; (2) Collect images of individual tobacco leaves according to production area and variety. During each curing stage, collect images of individual tobacco leaves corresponding to multiple production areas and different tobacco varieties, so that the image data simultaneously includes stage differences, production area differences, and variety differences, as shown below: ; in, For the first The first baking stage, the... Each production area, the first A subset of single tobacco leaf images corresponding to each tobacco variety. For the first in the corresponding subset Image of tobacco leaves Number the baking stages. Number the production area. Number the tobacco varieties. Image sequence number; (3) The subsets of single tobacco leaf images collected at different curing stages, in different production areas, and from different tobacco varieties are summarized to form the original tobacco leaf image set, which is represented as: ; in, This is a set of original tobacco leaf images; S12, perform single-leaf segmentation on the original tobacco leaf image to obtain independent tobacco leaf images, and convert the independent tobacco leaf images to a uniform white background. Convert the independent tobacco leaf images from RGB color space to HSV color space, extract the S component image as the input image for leaf vein segmentation, so as to enhance the color saturation difference between leaf veins and leaf surface, and construct a single-leaf tobacco leaf image sample set. S13, the single tobacco leaf image sample set is divided into training set, validation set, and test set, and the training set images are subjected to horizontal flipping, random rotation, random brightness adjustment, and Gaussian blur processing to expand the training samples and improve the model's generalization ability. Specifically, this includes: (1) The sample set of single tobacco leaf images is divided into a training set, a validation set, and a test set in a ratio of 8:1:1. The training set is used for model parameter learning, the validation set is used for model performance verification during training, and the test set is used for performance testing after training. This is represented as follows: ; ; ; in, This is a sample set of images of single tobacco leaves. For the training set, For the validation set, For the test set, This corresponds to the number of samples in the dataset. For set merging, For the intersection of sets, It is an empty set; (2) The tobacco leaf images in the training set are horizontally flipped and randomly rotated to make the training samples contain tobacco leaf images with different orientations and postures, thereby improving the adaptability of the leaf vein segmentation model to changes in the tobacco leaf placement angle, as shown in the following: ; ; in, The original input images in the training set, This is the image after horizontal flipping. The image is after random rotation. Image width, Image pixel coordinates, For random rotation of the load angle; (3) Random brightness adjustment and Gaussian blur processing are applied to the tobacco leaf images in the training set to enable the training samples to simulate different acquisition lighting conditions and slight imaging blur, thereby improving the generalization ability of the leaf vein segmentation model in complex baking image environments, as shown below: ; ; ; in, The image after brightness adjustment. This is the brightness adjustment factor. The image after Gaussian blurring. The kernel is a Gaussian convolution. The standard deviation of the Gaussian kernel. , These are the relative pixel coordinates within the convolution kernel. Where is the radius of the convolution window. It is an exponential function.

[0023] S12 includes: S121, for each tobacco leaf image in the original tobacco leaf image set, extract the region of a single tobacco leaf, and segment the original image, which includes the background and the main body of the tobacco leaf, into independent tobacco leaf images that only include the main body of a single tobacco leaf, to obtain an independent tobacco leaf image set, represented as: ; ; in, Masking the tobacco leaf area. Coordinates in the original tobacco leaf image grayscale value at that location The threshold for tobacco leaf segmentation. Indicates the tobacco leaf area. Indicates the background area. For individual tobacco leaf images, Original tobacco leaf image; ; in, For candidate thresholds, For grayscale values ​​less than or equal to the threshold The proportion of pixels to all pixels, For grayscale values ​​greater than the threshold The proportion of pixels to all pixels, For grayscale values ​​less than or equal to the threshold The average grayscale value of the pixels. For grayscale values ​​greater than the threshold The average grayscale value of the pixels. This represents the inter-class variance between the foreground and background. S122, the main tobacco leaf area in the independent tobacco leaf image is preserved, and the background area outside the main tobacco leaf area is uniformly replaced with a white background, resulting in an independent tobacco leaf image with a white background, represented as: ; in, coordinates The pixel values ​​of the isolated tobacco leaf image against the white background. coordinates The pixel values ​​of the individual tobacco leaf image at that location. White background pixel values; S123, convert the independent tobacco leaf image against a white background from the RGB color space to the HSV color space, extract the S component image from the HSV image as the input image for leaf vein segmentation, and summarize all S component images to construct a single tobacco leaf image sample set, specifically including: (1) Obtain the RGB channel values ​​of each pixel in an independent tobacco leaf image against a white background, and normalize the pixel values ​​of each channel to the range of 0 to 1 to obtain the normalized RGB channel values, represented as: ; ; ; in, , , These represent the red, green, and blue channel values ​​of a single pixel in an image of an isolated tobacco leaf against a white background. , , These represent the normalized red, green, and blue channel values, respectively. The maximum pixel value in an 8-bit RGB image; (2) Based on the normalized RGB channel values, calculate the maximum, minimum, and difference values ​​of the three channels respectively, and determine the saturation component of the corresponding pixel based on the maximum and difference values, thus obtaining the S component value of the pixel in the HSV color space, expressed as: ; ; ; ; in, The maximum value among the normalized RGB channel values. The minimum value among the normalized RGB channel values. It is the difference between the maximum and minimum values. This represents the saturation component value corresponding to that pixel. (3) Calculate the S-component value pixel by pixel for each independent tobacco leaf image against a white background, combine the S-component values ​​of all pixels to form the corresponding S-component image, and summarize all S-component images to form a single tobacco leaf image sample set, represented as: ; ; in, coordinates The S-component image pixel values ​​at that location, coordinates The saturation component value calculated at that point, This is a sample set of images of single tobacco leaves. For the first S-component image, This represents the total number of S-component images in the sample set.

[0024] S2 includes: S21, a leaf vein segmentation model is constructed based on the UNet network. The encoder extracts features layer by layer from the input S-component image, obtaining encoded features at different levels. These encoded features are then input to the decoder for layer-by-layer reconstruction, yielding the corresponding decoded features. These decoded features are then used as input features, represented as follows: ; ; in, For encoder number Layer output features, For encoder number Layer output features, For encoder number Layer feature extraction operation, For decoder number Layer input features, For decoder number Decoding features of the layer For decoder number Layer decoding operation; S22, in the leaf vein segmentation model, class weight units are set, with the background class weight set to 1 and the leaf vein class weight set to 40. The weighted cross-entropy loss function is used to calculate the loss value between the output of the leaf vein segmentation model and the true label, expressed as: ; in, The weighted cross-entropy loss function is... The total number of pixels involved in the calculation. The total number of categories, For category numbering, For category weights, Indicates the background category weight. Indicates the weight of leaf vein categories. For the first The true category label for each pixel. For the model to predict the first Each pixel belongs to the category The probability, Indicates an indicator function; S23, a co-sampling unit is set in the decoder to perform bilinear interpolation upsampling and deconvolution upsampling on the same layer of input features respectively, and the results of bilinear interpolation upsampling and deconvolution upsampling are concatenated and convolved to obtain the fused decoded features, represented as: ; ; in, For decoder number Layer input features, This is a bilinear interpolation upsampling operation. This is a deconvolution upsampling operation. For feature splicing operations, To achieve collaborative upsampling features, For convolutional fusion operations, These are the decoded features after fusion.

[0025] S3 includes: S31, using the leaf vein segmentation model as the generator and PatchGAN as the discriminator, a generative adversarial network model is constructed. The generator is used to receive tobacco leaf images from a single tobacco leaf image sample set and output the corresponding leaf vein segmentation results. The discriminator is used to distinguish the difference between the generator output results and the real leaf vein mask. S32, input the training set images from the single tobacco leaf image sample set into the generator, the generator outputs the corresponding pseudo vein mask, combine the tobacco leaf image with the real vein mask to form a real sample pair, combine the tobacco leaf image with the pseudo vein mask to form a generated sample pair, and input them into the PatchGAN discriminator to construct the input data of the discriminator. S33. The PatchGAN discriminator is used to distinguish between real sample pairs and generated sample pairs, and the corresponding discrimination results are output. The generator parameters are iteratively updated according to the discrimination results, so that the generator continuously outputs pseudo leaf vein masks that are closer to the real leaf vein masks. Through joint adversarial training between the generator and the discriminator, the trained CTVSeg-UNet model is obtained.

[0026] S31 includes: S311, using the leaf vein segmentation model as a generator, after inputting a tobacco leaf image, the pseudo-leaf vein mask is obtained through an encoder, a co-upsampling decoder, and an output mapping, as shown below: ; in, The pseudo-vein mask output by the generator. It is the Sigmoid activation function. To output the convolution kernel weights, The fused decoding features are the output of the last layer of the decoder. For output convolution bias; S312, perform channel concatenation between the tobacco leaf image and the real leaf vein mask to obtain real sample pairs, and perform channel concatenation between the tobacco leaf image and the pseudo leaf vein mask to obtain generated sample pairs, represented as follows: ; ; in, For real sample pairs, To generate sample pairs, This is for channel splicing operations. To input a tobacco leaf image, This is a mask for the actual leaf veins. For pseudo-vein masking; S313, input the real sample pairs and generated sample pairs into the PatchGAN discriminator respectively. The PatchGAN discriminator outputs the corresponding discrimination score map through convolution operation, specifically including: S3131, the constructed real sample pairs and generated sample pairs are respectively input into the PatchGAN discriminator, and used as input features for the first layer convolution operation of the discriminator, as shown below: ; ; in, The initial input features are the pairs of real samples. To generate the initial input features corresponding to the sample pairs, For real sample pairs, To generate sample pairs; S3132 utilizes the PatchGAN discriminator to perform layer-by-layer convolution operations on the input features, extracting leaf vein structure features from real sample pairs and generated sample pairs, represented as: ; in, For the PatchGAN discriminator, the first Layer output features, For the PatchGAN discriminator, the first Layer output features, For the PatchGAN discriminator, the first Layer convolution weights, For the PatchGAN discriminator, the first Layer bias, The activation function for the convolutional layer. Number the convolutional layers for the discriminator; After the final convolutional layer, we get: , ,in, For each real sample pair, the corresponding feature of the last convolutional layer is... To generate the last convolutional feature corresponding to each sample pair, The last layer number of the PatchGAN discriminator; S3133, calculate the corresponding discriminant score map based on the features of the last convolutional layer, to represent the probability that the input sample is a true leaf vein mask or a false leaf vein mask, expressed as: ; ; in, This is the discriminant score map corresponding to the real sample pairs. To generate the discriminant score map corresponding to the sample pairs, The weights of the output layer convolutional kernel. For output layer bias, This is the Sigmoid activation function.

[0027] S32 includes: S321, Input the tobacco leaf images from the training set into the generator. The generator performs feature extraction, decoding and restoration, and pixel classification on the tobacco leaf images to obtain the corresponding leaf vein segmentation probability map, represented as: ; ; in, coordinates The predicted probability that a pixel belongs to the leaf vein category. coordinates The output value corresponding to the leaf vein category. coordinates The output value corresponding to the background category. It is an exponential function. This is a probability plot of leaf vein segmentation. This is the set of pixel coordinates for a tobacco leaf image; S322, threshold the probability of each pixel in the leaf vein segmentation probability map, convert the probability values ​​into binary leaf vein labels, and obtain the pseudo leaf vein mask, represented as: ; in, coordinates The pseudo-vein mask value at that location, Predicting the probability of leaf veins The threshold for determining the probability of leaf veins. Represents leaf vein pixels, Represents background pixels; ; in, The average predicted probability of the probability plot. Let be the standard deviation of the probability plot. This is the threshold adjustment coefficient; ; in, The pseudo-vein mask output by the generator; S323, the input tobacco leaf image and the real leaf vein mask are concatenated along the channel dimension to construct real sample pairs. The input tobacco leaf image and the pseudo leaf vein mask are concatenated along the channel dimension to construct generated sample pairs, which are used as input data for the PatchGAN discriminator, represented as follows: ; ; in, For real sample pairs, To generate sample pairs, Input tobacco leaf image in coordinates Pixel value at that location, Masking the true leaf veins at coordinates The label value at that location, For the pseudo-vein mask in coordinates The label value at that location, This refers to the channel number after the data has been combined. Represents the tobacco leaf image channels. This is the leaf vein mask channel.

[0028] S33 includes: S331, input the real sample pairs and generated sample pairs into the PatchGAN discriminator respectively. After multi-layer convolution calculation, the corresponding discrimination score map is output. Each position in the discrimination score map represents the discrimination result of the corresponding local image patch, as shown below: ; ; in, For the discriminator Layer in position and channels eigenvalues ​​on, For the first Layer convolution kernel weights, For the first Layer bias, The kernel size is the convolution kernel size. This represents the number of channels in the previous layer. For activation function, The last layer of features of the discriminator, For the output layer convolution weights, For output layer bias, For the Sigmoid function, To determine the position in the score graph The discrimination score is denoted as , and the discrimination score of the real sample is denoted as . The discrimination scores of the generated sample pairs are denoted as follows: ; S332, calculate the discriminator loss based on the discrimination scores of real sample pairs and generated sample pairs, and calculate the generator loss based on the discrimination scores of generated sample pairs. Simultaneously, calculate the feature loss by combining the feature differences between the pseudo-vein mask and the real vein mask, expressed as: ; ; ; ; in, For discriminator loss, For generator loss, For feature loss, The total loss of the generative adversarial network model is... , These are the height and width of the discrimination score image, respectively. For the real sample pair at the location The discrimination score at the point, To generate sample pairs at location The discrimination score at the point, The first in the pseudo-vein mask pixel value, The first in the true leaf vein mask pixel value, This represents the total number of pixels in the mask. S333 uses the AdamW optimizer to iteratively update the generator parameters. In each iteration, the generator parameters are updated based on the generator loss and feature loss. After training, the updated generator is used as the CTVSeg-UNet model, represented as: ; ; ; ; ; ; in, For the first Generator parameters at the next iteration For the updated generator parameters, For the first The gradient of the generator parameters at the next iteration For first-order moment estimation, For second-order moment estimation, For the corrected first-order moment estimate, For the corrected second-order moment estimate, , To estimate the attenuation coefficient using moments, For learning rate, To prevent the stability constant from having a denominator of zero, This is the weight decay coefficient.

[0029] S4 includes: S41, the tobacco leaf region in the tobacco leaf image to be tested is converted into an independent tobacco leaf image against a white background, and the S component image in the HSV color space is extracted as the input image of the trained CTVSeg-UNet model, represented as: ; ; ; ; ; ; ; in, , , The images of the tobacco leaves to be tested are located in coordinates. The red, green, and blue channel values ​​at that location. , , These are the normalized RGB channel values. The maximum value in the normalized RGB channels. The minimum value in the normalized RGB channels. It is the difference between the maximum and minimum values. The pixel value of the S-component image corresponding to the image of the tobacco leaf to be tested; S42, input the S-component image corresponding to the tobacco leaf image to be tested into the trained CTVSeg-UNet model. The CTVSeg-UNet model outputs the predicted value of each pixel belonging to the leaf vein category and the background category, and calculates the probability of each pixel belonging to the leaf vein category based on the predicted value, expressed as: ; ; in, coordinates The probability that a pixel belongs to the leaf vein category. coordinates The probability that a pixel belongs to the background category. The leaf vein category prediction value output by the CTVSeg-UNet model. The background category prediction value output by the CTVSeg-UNet model. It is an exponential function; S43, based on the probability of the leaf vein category and the probability of the background category corresponding to each pixel, determine the category label of the pixel, and combine the category labels of all pixels to form a leaf vein segmentation mask, thereby obtaining the segmentation results of the main vein and branch veins in the tobacco leaf image to be tested, as shown below: ; ; in, coordinates Leaf vein segmentation mask value at the location, This pixel represents a leaf vein pixel. This pixel is designated as the background pixel. For the probability of leaf vein category, For background category probability, Let be the set of pixel coordinates of the image of the tobacco leaves. Use a mask to segment the leaf veins in the output.

[0030] like Figure 2 As shown, a real-time tobacco leaf vein segmentation system based on CTVSeg-UNet for the entire tobacco leaf curing process is used to implement the aforementioned real-time tobacco leaf vein segmentation method based on CTVSeg-UNet for the entire tobacco leaf curing process. The system includes the following modules: Sample set construction module: Acquire tobacco leaf images throughout the baking process, preprocess the tobacco leaf images, segment the tobacco leaf images into independent images and convert them to white background, construct a single tobacco leaf image sample set using the S component images of the HSV color space, and divide the single tobacco leaf image sample set into training set, validation set and test set, and perform data augmentation processing on the training set; Leaf vein segmentation model construction module: Construct a leaf vein segmentation model based on the UNet network. The leaf vein segmentation model includes an encoder, a decoder, a co-sampling unit, and a class weight unit. The class weight unit adopts a 40:1 weight ratio between the leaf vein and the background classes. The co-sampling unit uses bilinear interpolation upsampling and deconvolution upsampling in parallel in the decoder, and performs feature fusion on the bilinear interpolation upsampling results and the deconvolution upsampling results to obtain the leaf vein segmentation model. Adversarial training module: Input the single tobacco leaf image sample set into the leaf vein segmentation model, and use the leaf vein segmentation model as the generator. Use PatchGAN as the discriminator to build a generative adversarial network model. Use the generative adversarial network model to perform adversarial training on the leaf vein segmentation model, so that the generator outputs a pseudo leaf vein mask. The discriminator distinguishes between the real leaf vein mask and the pseudo leaf vein mask to optimize the generator parameters and obtain the trained CTVSeg-UNet model. Real-time leaf vein segmentation module: Input the image of the tobacco leaf to be tested into the trained CTVSeg-UNet model, and output the corresponding leaf vein segmentation mask to achieve the segmentation of the main vein and branch veins of the tobacco leaf.

[0031] This invention encompasses any substitutions, modifications, equivalent methods, and solutions made within the spirit and scope of this invention. To provide the public with a thorough understanding of this invention, specific details are described in detail in the following preferred embodiments; however, those skilled in the art will fully understand the invention even without these details. Furthermore, to avoid unnecessary misunderstanding of the essence of this invention, well-known methods, processes, procedures, components, and circuits are not described in detail.

[0032] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for real-time segmentation of tobacco leaf veins throughout the entire baking process based on CTVSeg-UNet, characterized in that, Includes the following steps: S1. Acquire tobacco leaf images throughout the roasting process, preprocess the tobacco leaf images by segmenting them into independent images and converting them to a white background, construct a single tobacco leaf image sample set using the S component images of the HSV color space, and divide the single tobacco leaf image sample set into a training set, a validation set, and a test set, and perform data augmentation processing on the training set. S2, Construct a leaf vein segmentation model based on the UNet network. The leaf vein segmentation model includes an encoder, a decoder, a cooperative upsampling unit, and a class weighting unit. The class weighting unit adopts a 40:1 ratio of leaf vein to background class weights. The cooperative upsampling unit performs bilinear interpolation upsampling and deconvolution upsampling in parallel in the decoder, and performs feature fusion on the bilinear interpolation upsampling results and deconvolution upsampling results to obtain the leaf vein segmentation model. S3, input the single tobacco leaf image sample set into the leaf vein segmentation model, and use the leaf vein segmentation model as a generator, construct a generative adversarial network model with PatchGAN as a discriminator, use the generative adversarial network model to perform adversarial training on the leaf vein segmentation model, so that the generator outputs a pseudo leaf vein mask, and the discriminator distinguishes between the real leaf vein mask and the pseudo leaf vein mask in order to optimize the generator parameters and obtain the trained CTVSeg-UNet model; S4. Input the tobacco leaf image to be tested into the trained CTVSeg-UNet model and output the corresponding leaf vein segmentation mask to achieve the segmentation of the main vein and branch veins of the tobacco leaf.

2. The method for real-time segmentation of tobacco leaf veins throughout the baking process based on CTVSeg-UNet according to claim 1, characterized in that, S1 includes: S11, collect image data of tobacco leaves during the entire baking process. The baking process includes the yellowing period, the color fixing period, and the drying period. The collection starts and ends synchronously with the baking process. The collected objects include single tobacco leaf images from multiple production areas and different tobacco varieties, forming an original tobacco leaf image set. S12, perform single-leaf segmentation on the original tobacco leaf image to obtain independent tobacco leaf images, and convert the independent tobacco leaf images to a uniform white background. Convert the independent tobacco leaf images from RGB color space to HSV color space, extract the S component image as the input image for leaf vein segmentation, so as to enhance the color saturation difference between leaf veins and leaf surface, and construct a single-leaf tobacco leaf image sample set. S13, the single tobacco leaf image sample set is divided into a training set, a validation set and a test set, and the training set images are subjected to horizontal flipping, random rotation, random brightness adjustment and Gaussian blur processing.

3. The method for real-time segmentation of tobacco leaf veins throughout the baking process based on CTVSeg-UNet according to claim 2, characterized in that, S12 includes: S121, Extract the region of a single tobacco leaf from each tobacco leaf image in the original tobacco leaf image set, and segment the original image, which includes the background and the main body of the tobacco leaf, into independent tobacco leaf images that only include the main body of a single tobacco leaf, to obtain an independent tobacco leaf image set; S122, the main tobacco leaf area in the independent tobacco leaf image is preserved, and the background area outside the main tobacco leaf area is uniformly replaced with a white background to obtain an independent tobacco leaf image with a white background. S123, convert the independent tobacco leaf image under the white background from RGB color space to HSV color space, extract the S component image from the HSV image as the input image for leaf vein segmentation, and summarize all S component images to construct a single tobacco leaf image sample set.

4. The method for real-time segmentation of tobacco leaf veins throughout the baking process based on CTVSeg-UNet according to claim 3, characterized in that, S2 includes: S21, a leaf vein segmentation model is constructed based on the UNet network. The encoder extracts features layer by layer from the input S component image to obtain coded features at different levels. The coded features are then input into the decoder for layer-by-layer recovery to obtain the corresponding decoded features, and the decoded features are used as input features. S22, In the leaf vein segmentation model, set the category weight unit, set the background category weight to 1, set the leaf vein category weight to 40, and use the weighted cross-entropy loss function to calculate the loss value between the output of the leaf vein segmentation model and the true label; S23, a collaborative upsampling unit is set in the decoder to perform bilinear interpolation upsampling and deconvolution upsampling on the same layer of input features respectively, and the results of bilinear interpolation upsampling and deconvolution upsampling are concatenated and fused to obtain fused decoded features.

5. The method for real-time segmentation of tobacco leaf veins throughout the baking process based on CTVSeg-UNet according to claim 4, characterized in that, S3 includes: S31, using the leaf vein segmentation model as the generator and PatchGAN as the discriminator, a generative adversarial network model is constructed. The generator is used to receive tobacco leaf images from a single tobacco leaf image sample set and output the corresponding leaf vein segmentation results. The discriminator is used to distinguish the difference between the generator output results and the real leaf vein mask. S32, input the training set images from the single tobacco leaf image sample set into the generator, the generator outputs the corresponding pseudo vein mask, combine the tobacco leaf image with the real vein mask to form a real sample pair, combine the tobacco leaf image with the pseudo vein mask to form a generated sample pair, and input them into the PatchGAN discriminator to construct the input data of the discriminator. S33 uses the PatchGAN discriminator to distinguish between real sample pairs and generated sample pairs, outputs the corresponding discrimination results, iteratively updates the generator parameters based on the discrimination results, and obtains the trained CTVSeg-UNet model through joint adversarial training of the generator and discriminator.

6. The method for real-time segmentation of tobacco leaf veins throughout the baking process based on CTVSeg-UNet according to claim 5, characterized in that, S31 includes: S311, using the leaf vein segmentation model as a generator, after inputting the tobacco leaf image, the pseudo leaf vein mask is obtained through the encoder, co-sampling decoder and output mapping; S312, perform channel splicing between the tobacco leaf image and the real leaf vein mask to obtain real sample pairs, and perform channel splicing between the tobacco leaf image and the pseudo leaf vein mask to obtain generated sample pairs; S313, input the real sample pairs and generated sample pairs into the PatchGAN discriminator respectively. The PatchGAN discriminator outputs the corresponding discrimination score map through convolution operation, specifically including: S3131, the constructed real sample pairs and generated sample pairs are respectively input into the PatchGAN discriminator and used as input features for the first layer convolution operation of the discriminator; S3132 utilizes the PatchGAN discriminator to perform layer-by-layer convolution operations on the input features, extracting leaf vein structure features from real sample pairs and generated sample pairs. S3133 calculates the corresponding discrimination score map based on the features of the last convolutional layer to represent the probability that the input sample is a real leaf vein mask or a pseudo leaf vein mask.

7. The method for real-time segmentation of tobacco leaf veins throughout the baking process based on CTVSeg-UNet according to claim 6, characterized in that, S32 includes: S321, Input the tobacco leaf images in the training set into the generator, and use the generator to extract features, decode and restore, and classify pixels of the tobacco leaf images to obtain the corresponding leaf vein segmentation probability map; S322, Threshold the probability of each pixel in the leaf vein segmentation probability map, convert the probability value into a binary leaf vein label, and obtain a pseudo leaf vein mask. S323: The input tobacco leaf image and the real leaf vein mask are concatenated along the channel dimension to construct real sample pairs. The input tobacco leaf image and the pseudo leaf vein mask are concatenated along the channel dimension to construct generated sample pairs, which are used as input data for the PatchGAN discriminator.

8. The method for real-time segmentation of tobacco leaf veins throughout the baking process based on CTVSeg-UNet according to claim 7, characterized in that, S33 includes: S331, input the real sample pairs and generated sample pairs into the PatchGAN discriminator respectively, and output the corresponding discrimination score map after multi-layer convolution calculation. Each position in the discrimination score map represents the discrimination result of the corresponding local image block. S332, calculate the discriminator loss based on the discrimination scores of real sample pairs and generated sample pairs, calculate the generator loss based on the discrimination scores of generated sample pairs, and calculate the feature loss by combining the feature differences between the pseudo leaf vein mask and the real leaf vein mask. S333 uses the AdamW optimizer to iteratively update the generator parameters. In each iteration, the generator parameters are updated based on the generator loss and feature loss. After training, the updated generator is used as the CTVSeg-UNet model.

9. A method for real-time segmentation of tobacco leaf veins throughout the baking process based on CTVSeg-UNet according to claim 8, characterized in that, S4 includes: S41, convert the tobacco leaf region in the tobacco leaf image to be tested into an independent tobacco leaf image against a white background, and extract the S component image in the HSV color space as the input image for the trained CTVSeg-UNet model; S42, input the S component image corresponding to the tobacco leaf image to be tested into the trained CTVSeg-UNet model, output the predicted value of each pixel belonging to the leaf vein category and the background category through the CTVSeg-UNet model, and calculate the probability of each pixel belonging to the leaf vein category based on the predicted value; S43. Based on the probability of the leaf vein category and the probability of the background category corresponding to each pixel, determine the category label of the pixel, and combine the category labels of all pixels to form a leaf vein segmentation mask, thereby obtaining the segmentation results of the main vein and branch veins in the tobacco leaf image to be tested.

10. A real-time leaf vein segmentation system for tobacco leaves throughout the entire curing process based on CTVSeg-UNet, used to implement the real-time leaf vein segmentation method for tobacco leaves throughout the entire curing process based on CTVSeg-UNet as described in any one of claims 1-9, characterized in that, Includes the following modules: Sample set construction module: acquire tobacco leaf images throughout the roasting process, preprocess the tobacco leaf images, segment the tobacco leaf images into independent images and convert them to white background, construct a single tobacco leaf image sample set using the S component images of the HSV color space, and divide the single tobacco leaf image sample set into training set, validation set and test set, and perform data augmentation processing on the training set; Leaf vein segmentation model construction module: Constructs a leaf vein segmentation model based on the UNet network. The leaf vein segmentation model includes an encoder, a decoder, a co-sampling unit, and a class weighting unit. The class weighting unit adopts a 40:1 weight ratio between the leaf vein and the background classes. The co-sampling unit performs bilinear interpolation upsampling and deconvolution upsampling in parallel in the decoder, and performs feature fusion on the bilinear interpolation upsampling results and the deconvolution upsampling results to obtain the leaf vein segmentation model. Adversarial training module: The single tobacco leaf image sample set is input into the leaf vein segmentation model, and the leaf vein segmentation model is used as a generator. PatchGAN is used as a discriminator to construct a generative adversarial network model. The generative adversarial network model is used to perform adversarial training on the leaf vein segmentation model, so that the generator outputs a pseudo leaf vein mask. The discriminator distinguishes between the real leaf vein mask and the pseudo leaf vein mask to optimize the generator parameters and obtain the trained CTVSeg-UNet model. Real-time leaf vein segmentation module: Input the image of the tobacco leaf to be tested into the trained CTVSeg-UNet model, and output the corresponding leaf vein segmentation mask to achieve the segmentation of the main vein and branch veins of the tobacco leaf.