Cigarette pack ash color detection method, cigarette combustion quality detection method, electronic equipment and medium
By extracting the ash column area in the cigarette ash image, edge detection and identification and removal of the crack area are performed, the problem of degradation of the color detection accuracy of the cigarette ash color is solved, and higher color recognition accuracy and stability are achieved.
Patent Information
- Application Number
- CN202510109191.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-06-20
AI Technical Summary
The existing cigarette ash color detection method is difficult to accurately identify the ash color, especially when the cracks exist, resulting in a decrease in recognition accuracy.
By obtaining the ash-covered image during the cigarette burning process, extracting the ash-column area, performing edge detection, identifying the crack area, eliminating interference in the crack area, and calculating the brightness value of the ash-column area that does not contain the crack area to obtain the ash-column color.
It effectively reduces noise interference, improves the accuracy and stability of gray color recognition, and ensures the accuracy of color measurement.
Smart Images

Figure CN120182631A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image detection, and in particular, to a method for detecting the ash color of a cigarette pack, a method for detecting the burning quality of a cigarette, an electronic device, and a medium. Background Art
[0002] The appearance of the ash column (ash pillar) formed during the burning of a cigarette is an important indicator for measuring the burning quality of the cigarette. Consumers usually pay attention to characteristics such as ash color, crack, and integrity during use. These factors not only affect the aesthetic appearance of the cigarette but also reflect the uniformity of tobacco filling and the sufficiency of burning. Therefore, quantitative analysis and evaluation of the ash color can provide an objective measurement basis for the burning quality of the cigarette.
[0003] Traditional methods for detecting cigarette ash mainly rely on manual observation and subjective evaluation, and it is difficult to accurately reflect the actual quality of cigarette burning. Since the changes in ash color and crack are affected by various factors such as lighting conditions and burning state during the burning process, manual detection not only has low efficiency but also has poor stability and repeatability of the detection results. In recent years, with the development of image processing and machine learning technologies, using computer vision to detect the ash color and crack characteristics of cigarette packs has become a hot research direction.
[0004] Existing computer vision methods have been applied to cigarette detection to a certain extent, but most are limited to simple color extraction or contour recognition and fail to fully handle the complex ash crack characteristics during cigarette burning. The color of the ash crack is different from the ash color, so when identifying the ash color, the color of the crack will interfere with the recognition of the ash color, thereby leading to a decrease in the accuracy of identifying the ash color. Summary of the Invention
[0005] In view of this, the purpose of the embodiments of the present application is to provide a method for detecting the ash color of a cigarette pack, a method for detecting the burning quality of a cigarette, an electronic device, and a medium, which can improve the problem of the decrease in the accuracy of identifying the ash color.
[0006] To achieve the above technical purpose, the technical solution adopted by the present application is as follows:
[0007] In a first aspect, an embodiment of the present application provides a method for detecting the ash color of a cigarette pack, the method comprising:
[0008] Obtaining an ash image during the burning of a cigarette;
[0009] Extracting the ash column area in the ash image to obtain an ash column area image;
[0010] Performing edge detection on the ash column area image to obtain all edge features of the ash column area image;
[0011] When there are the edge features representing the crack region, obtain the luminance values of the gray column region image excluding the crack region, and the luminance values represent the gray wrapping color.
[0012] Further, when performing edge detection on the gray column region image to obtain all the edge features of the gray column region image and when there are the edge features representing the crack region, obtain the luminance values of all the pixel points in the gray column region image excluding the crack region, the method further includes:
[0013] Calculate the degree of curvature change and / or the degree of dispersion of each of the edge features to obtain an intermediate variable, and the intermediate variable represents the edge features whose degree of curvature change is greater than a preset degree of curvature change and / or a preset degree of dispersion;
[0014] Increase the weight of the intermediate variable in the gray column region image to obtain an intermediate image;
[0015] Based on the connected component analysis algorithm, extract all the connected components in the intermediate image, and based on the connected components, obtain the crack region.
[0016] Further, the increasing the weight of the intermediate variable in the gray column region image to obtain an intermediate image includes:
[0017] Input the gray column region image into a first convolutional neural network model, where the first convolutional neural network model has an adaptive gating mechanism, the adaptive gating mechanism is based on a dynamic gating function, the dynamic gating function calculates the weight of each pixel point of the gray column region image to generate a weight map, and the weight coefficient of the pixel points of the intermediate variable in the gray column region image is greater than the weight coefficient of the pixel points at other positions in the gray column region image;
[0018] After multiplying the weight map and the gray column region image element by element, output the intermediate image.
[0019] Further, the obtaining the luminance values of all the pixel points in the gray column region image excluding the crack region and obtaining the gray wrapping color based on the luminance values includes:
[0020] Obtain the luminance values of all the pixel points in the gray column region image excluding the crack region in the CIELAB color space;
[0021] Calculate the average value of the obtained luminance values of all the pixel points, and the average value represents the luminance value of the gray column region image.
[0022] Further, the gray wrapping image includes a background region and a gray column region;
[0023] Extracting the ash column region in the ash-wrapped image to obtain the ash column region image includes:
[0024] Taking the ash-wrapped image as the input image and inputting it into a second convolutional neural network model. The second convolutional neural network model has a self-attention mechanism. The second convolutional neural network model outputs an ash-wrapped image in which the attention weight of the ash column region is greater than the attention weight of the background region, forming an output image, so that the saliency degree of the ash column region is greater than that of the background region;
[0025] Inputting the output image into a segmentation model to obtain the ash column region image. The segmentation model is a deep learning model. The segmentation model divides the processed ash-wrapped image into the ash column region image and the background region image. The segmentation model is obtained by training based on multiple training images. The training images include a first annotation and a second annotation. The first annotation represents the pixel points of the ash-wrapped region in the training image, and the second annotation represents the pixel points of the background region in the training image.
[0026] Further, between the second convolutional neural network model outputting an ash-wrapped image in which the attention weight of the ash column region is greater than the attention weight of the background region and inputting the ash-wrapped image in which the attention weight of the ash column region is greater than the attention weight of the background region into the segmentation model, the method further includes:
[0027] Adjusting the resolution of the output image until the resolution of the output image is consistent with the resolution of the input image.
[0028] In a second aspect, an embodiment of the present application proposes a method for testing the combustion quality of cigarettes, including:
[0029] Collecting multiple groups of ash-wrapped images, each group of ash-wrapped images corresponding to each stage of cigarette combustion, and each group of ash-wrapped images including multiple ash-wrapped images consecutive in acquisition time;
[0030] According to the cigarette ash-wrapped color detection method described above, obtaining the brightness values of all the ash-wrapped images;
[0031] Based on the ash-wrapped colors of all the ash-wrapped images, obtaining a curve of the brightness value of the ash-wrapped image over time in each stage of cigarette combustion;
[0032] Evaluating the cigarette combustion quality based on the curve.
[0033] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory coupled to each other. A computer program is stored in the memory. When the computer program is executed by the processor, the electronic device is enabled to execute a method for detecting the ash color of a cigarette pack or a method for testing the combustion quality of a cigarette.
[0034] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium. When the computer program runs on a computer, the computer is enabled to execute a method for detecting the ash color of a cigarette pack or a method for testing the combustion quality of a cigarette.
[0035] The invention adopting the above technical solution has the following advantages:
[0036] In the technical solution provided by the present application, an ash image is acquired; the ash column region in the ash image is extracted to obtain an ash column region image; edge detection is performed on the ash column region image to obtain all edge features of the ash column region image, and based on all the edge features, a crack region is obtained; the brightness values of all pixel points in the ash column region image excluding the crack region are acquired, and based on the brightness values, the ash color of the ash image is obtained. By extracting the crack region in the ash column region image, after acquiring the brightness values of all pixel points in the ash column region image excluding the crack region, the interference of the crack region on obtaining the ash color is excluded, effectively reducing noise interference, ensuring the stability of color measurement, and improving the accuracy of identifying the ash color.
[0037] In the technical solution provided by the present application, by setting a first convolutional neural network model with an adaptive gating mechanism, the significance level of the edge features corresponding to the crack is improved, which is beneficial to improving the accuracy of separating the crack region.
[0038] In the technical solution provided by the present application, a second convolutional neural network model with a self-attention mechanism is set, which improves the significance level of the ash column region relative to the background region, and is beneficial to improving the accuracy of subsequent segmentation of the ash column region and the background region. Description of the Drawings
[0039] The present application can be further illustrated by the non-limiting embodiments given in the drawings. It should be understood that the following drawings only show some embodiments of the present application, and thus should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0040] Figure 1 It is a schematic diagram of the cigarette structure provided by the embodiment of the present application.
[0041] Figure 2The flowchart provided in Embodiment 1 of this application.
[0042] Figure 3 The flowchart of S120 provided in Embodiment 1 of this application.
[0043] Figure 4 The schematic diagram of the CSegNet network structure provided in Embodiment 1 of this application.
[0044] Figure 5 The schematic diagram of the joint excitation upsampling JEU module structure provided in Embodiment 1 of this application.
[0045] Figure 6 The flowchart of the second convolutional neural network for processing pictures provided in Embodiment 1 of this application.
[0046] Figure 7 The flowchart of S130 provided in Embodiment 1 of this application.
[0047] Figure 8 The flowchart of S132 provided in Embodiment 1 of this application.
[0048] Figure 9 The flowchart of S140 provided in Embodiment 1 of this application.
[0049] Figure 10 The flowchart of the detection process of the packet ash color provided in Embodiment 1 of this application.
[0050] Figure 11 The flowchart of the method provided in Embodiment 2 of this application.
[0051] Icons: 1 - crack, 2 - packet ash area, 3 - carbon line, 4 - ash column area, 5 - unburned area. Detailed implementation manners
[0052] The following will describe this application in detail in conjunction with the accompanying drawings and specific embodiments. It should be noted that in the drawings or the description of the specification, similar or identical parts use the same figure numbers, and the implementation manners not shown or described in the drawings are in the forms known to those of ordinary skill in the art. In the description of this application, the terms "first", "second", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0053] Embodiment 1
[0054] As Figure 1 shown, a cigarette generally includes a crack 1, a packet ash area 2, a carbon line 3, an ash column area 4, and an unburned area 5.
[0055] Please refer to Figure 2 , this application also provides a method for detecting the packet ash color of a cigarette. Among them, the method for detecting the packet ash color of a cigarette may include the following steps:
[0056] S110, Obtain the ash wrapper image during the cigarette burning process;
[0057] S120, Extract the ash column area in the ash wrapper image to obtain the ash column area image;
[0058] S130, Perform edge detection on the ash column area image to obtain all edge features of the ash column area image;
[0059] S140, When there are the edge features representing the crack area, obtain the brightness value of the ash column area image excluding the crack area.
[0060] The following will elaborate on each step of the cigarette ash wrapper color detection method in detail as follows:
[0061] In step S110, a multi-angle camera system can be installed on the cigarette burning detection device, including front-view, side-view, and top-view cameras, for capturing images of different angles of cigarette burning to ensure complete coverage of the ash column area. Camera parameters such as exposure, white balance, resolution, etc. are set uniformly and illuminated by a fixed light source to reduce ambient light interference.
[0062] During the entire cigarette burning process, images are collected at a rate of 20 frames per second, and high-quality images are ensured to be obtained at different burning stages. Through the image acquisition method of multiple angles and multiple time nodes, comprehensive monitoring of the dynamic changes of the ash column is realized.
[0063] In this embodiment, the camera system collects sample images. Since the sample images are collected from multiple angles, there will be some sample images without an ash column area. Therefore, by setting a classification model, the sample images with an ash column area are screened based on the classification model, and the sample images with an ash column area are the ash wrapper images.
[0064] Exemplarily, the classification model can adopt a random forest model. Select multiple sample images, use a part of the sample images as the training set and the other part as the test set, label the ash column area and other areas of the sample images, and improve the accuracy of the random forest model through the test set to obtain the above classification model.
[0065] In S120, as Figure 3 shown, it includes the following steps:
[0066] S121: Input the ash wrapper image as the input image into the second convolutional neural network model. The second convolutional neural network model has a self-attention mechanism. The second convolutional neural network model outputs the ash wrapper image with the attention weight of the ash column area greater than that of the background area to form an output image, making the significance level of the ash column area greater than that of the background area;
[0067] S122: Input the output image into a segmentation model to obtain the gray column area image. The segmentation model is a deep learning model that divides the processed ash-covered image into the gray column area image and the background area image. The segmentation model is obtained by training based on multiple training images, and the training images include a first annotation and a second annotation. The first annotation represents the pixel points of the ash-covered area in the training image, and the second annotation represents the pixel points of the background area in the training image.
[0068] In this embodiment, the second convolutional neural network model is a CNN model. The CNN model performs multi-scale feature extraction on the ash-covered image, divides the ash-covered image into multiple stages at different scales, and adaptively enhances the correlation of feature channels during the encoding process through a Squeeze-and-Excitation module (SE module).
[0069] Among them, the convolutional layer of the CNN model includes multiple convolutional kernels, and each convolutional kernel has a corresponding scale, that is, each convolutional kernel performs convolutional operations in different ways, and each convolutional kernel generates a corresponding feature map. For example, after the 1×1 convolutional kernel performs convolutional operations on the ash-covered image, a feature map reflecting the edge part of the ash-covered image is obtained. After the 3×3 convolutional kernel performs convolutional operations on the ash-covered image, a feature map reflecting the unburned area of the ash-covered image is obtained.
[0070] After all the convolutional kernels generate the corresponding feature maps, all the feature maps are fused to generate a processed ash-covered image, so that the significance level of the gray column area in the processed ash-covered image is greater than that of the background area.
[0071] Exemplarily, the second convolutional neural network model is obtained through the following training method, including:
[0072] I. Data preparation Data collection: Collect an image dataset containing an ash-covered area. These images should have a clear ash-covered area, and the position of the ash-covered area should be marked or a corresponding mask should be provided.
[0073] Data preprocessing: Preprocess the images, such as scaling, cropping, normalization, etc., to ensure the consistency of the input data. At the same time, according to the task requirements, corresponding labels or masks may need to be generated.
[0074] II. Model design Basic CNN architecture: Select or design a suitable CNN architecture as the basis of the model. This can be a simple convolutional neural network or a more complex deep convolutional neural network.
[0075] Introduce attention mechanism: Introduce attention mechanism in the CNN architecture, such as SE module, channel attention or spatial attention, etc. The attention mechanism can help the model pay more attention to the packet gray area during the feature extraction process. Feature fusion and emphasis: After the feature extraction layer, design a feature fusion strategy to ensure that the features of the packet gray area are more emphasized during the fusion process. This can be achieved by methods such as weighted fusion, Feature Pyramid Network (FPN), etc.
[0076] Output layer design: Design the output layer according to the task requirements. If the goal is to generate an image that emphasizes the packet gray area, the output layer may be a feature map with the same size as the input image, where the feature values of the packet gray area are enhanced.
[0077] III. Loss function design Custom loss function: Design a custom loss function to measure the difference between the model output and the expected output (i.e., the image that emphasizes the packet gray area). This loss function can be designed based on pixel-level differences, feature map differences, or region-level differences.
[0078] Combine multiple losses: To more comprehensively measure the performance of the model, multiple loss functions can be combined and used. For example, pixel-level mean squared error loss and region-level intersection over union loss can be combined.
[0079] IV. Model training and optimization Optimizer selection: Select a suitable optimizer to update the weights of the model. Commonly used optimizers include SGD, Adam, etc.
[0080] Learning rate adjustment: Adjust the learning rate according to the training situation of the model. A fixed learning rate can be used, or a learning rate decay strategy can be used. Regularization and Dropout: To prevent overfitting, regularization terms can be added to the model or Dropout technology can be used. Data augmentation: Increase the diversity of data through data augmentation techniques (such as rotation, flipping, cropping, etc.) to improve the generalization ability of the model. Model evaluation and adjustment: Regularly evaluate the performance of the model during training, and adjust the model architecture, loss function, or optimization strategy, etc. according to the evaluation results. V. Post-processing and visualization Post-processing: Perform post-processing on the output of the model, such as threshold segmentation, morphological operations, etc., to generate a clearer and more accurate image that emphasizes the packet gray area. Visualization: Use visualization tools (such as Matplotlib, TensorBoard, etc.) to display the output of the model and key metrics during the training process to better understand and debug the model. Example Assume we have an image dataset containing packet gray areas and want to train a CNN model to emphasize these areas.
[0081] The following is an example process:
[0082] Data Preparation: Collect and preprocess the image dataset to generate corresponding labels or masks.
[0083] Model Design: Select a simple CNN architecture and introduce the SE module as an attention mechanism. Design a feature fusion strategy to ensure that the features of the ash-containing area are emphasized during the fusion process.
[0084] Loss Function Design: Design a custom loss function based on pixel-level differences and combine the region-level intersection over union loss to comprehensively measure the performance of the model.
[0085] Model Training and Optimization: Use the Adam optimizer for training and adjust the learning rate according to the training situation. Add a Dropout layer to prevent overfitting. Use data augmentation techniques to increase the diversity of the data.
[0086] Post-processing and Visualization: Perform post-processing steps such as threshold segmentation and morphological operations on the output of the model to generate an image that emphasizes the ash-containing area. Use tools such as Matplotlib to display the output of the model and key metrics during the training process.
[0087] In S121, the ash-containing image is processed by the second convolutional neural network model to obtain a processed ash-containing image, which emphasizes the ash-containing area and weakens the background area.
[0088] In S122, the segmentation model is used to classify the ash column area and the background area. When the segmentation model realizes the classification, it traverses all the pixel points of the ash-containing image where the attention weight of the ash column area is greater than that of the background area, and labels all the pixel points as the first label and the second label. The first label represents the pixel points of the ash-containing area, and the second label represents the pixel points of the background area. Extract all the pixel points with the first label to form an ash-containing area image.
[0089] In this embodiment, an encoder and a decoder can be designed.
[0090] The encoder is provided with a second convolutional neural network model. The second convolutional neural network model uses ResNeXT50 as a feature extraction module. After inputting the image, it first extracts features through multiple layers of convolution, gradually reduces the resolution, and generates multi-scale feature maps. The residual block is used to enhance the feature discrimination ability between the ash column and the background, making the CNN more adaptable to complex backgrounds. Specifically, in this embodiment, the crack segmentation algorithm (CrackSegmentation Network, CSegNet) that combines the convolutional neural network CNN and the Transformer self-attention mechanism is adopted. The CSegNet network adopts an Encoder-Decoder encoding and decoding framework similar to DeepLab V3+, as Figure 4 shown, and includes the following steps:
[0091] a) Employ a ResNeXt-Transformer (ResNeXTR) module in the encoder, which includes a ResNeXt50 convolutional network and a Swin-Transformer network, for extracting local and global features in the image;
[0092] b) Incorporate an Efficient Convolutional Block Attention Module (ECBAM) in the decoder, which contains an Efficient Channel Attention Module (ECAM) and a Spatial Attention Module (SAM), for enhancing the salient features in the crack region;
[0093] c) Use average pooling and pointwise convolution operations to reduce the dimension of the encoder output, so as to reduce the cost of self-attention calculation;
[0094] d) Use a combined loss function of Binary Cross-Entropy with Logits and Dice loss. The Binary Cross-Entropy with Logits loss and the Dice loss function are combined with weights of 0.5 each to optimize the segmentation accuracy and edge detection effect.
[0095] SE module enhancement: Introduce a Squeeze-and-Excitation (SE) module after each layer of feature extraction to adaptively weight the channels of the feature map, so as to enhance the salient features in the gray column region and ensure that the gray column region is preferentially emphasized during multi-scale fusion of features.
[0096] Adopt a Joint Excitation Upsampling (JEU) module in the decoder to fuse and upsample the feature maps of each scale through spatial and channel attention mechanisms. Combine the cascading method of multi-level feature maps to restore the decoded image to the same resolution as the input image, forming a fine gray column segmentation map. This segmentation map is used to extract the ash-containing region in subsequent steps.
[0097] The Joint Excitation Upsampling Network JEUNet proposed in this embodiment has a classic encoder-decoder symmetric structure, and its network framework is as Figure 5 and 6As shown. The yellow arrow represents the direct input; the black arrow represents a 3×3 convolution operation with a step size of 1, which uses the Zero-padding strategy to keep the feature maps of the same level at the same size; the gray arrow represents the shear and concatenation operation, which shears the left feature map to the same size as the right one and then concatenates them; the blue arrow represents the 1×1 operation for final classification, and the last two-layer outputs are the result and the background; the red arrow represents downsampling the feature map by 2×2 max pooling; the green arrow represents upsampling the feature map by a factor of 2 using a 2×2 transposed convolution operation. k represents the number of base channels of the convolutional feature maps (in this embodiment, k = 32).
[0098] The encoder part of JEUNet is consistent with the backbone network of UNet. The original input image is encoded through consecutive convolutional layers in 4 stages by the encoder, and is transmitted through 2× max pooling downsampling between every 2 stages. Therefore, there are a total of 5 scales including the original image, and the feature maps of each scale contain information with different receptive fields. The shallow feature maps are mainly the detailed texture information of local pixels, while the deep feature maps contain the local semantic information in the image. In the decoder process of JEUNet, the outputs of the 2nd, 3rd, and 4th stages are input into the designed JEU (Joint Excitation Up-sampling block) module, which replaces the consecutive upsampling of convolutions at three scales in the original UNet. The output of the JEU module is upsampled once and concatenated with the output of the 1st stage of the encoder, then two 3×3 convolution operations are performed in the same layer, and finally it is upsampled to the size of the original image and concatenated with the initial convolution result of the original image, and the prediction result is obtained after two convolution operations. In the decoder part, the concatenation operation between the upsampled feature maps and the shallow features of the encoder part can improve the prediction accuracy of local pixels.
[0099] The Joint Excitation Up-sampling JEU module is a computational unit that integrates spatial attention into the joint upsampling network. On the one hand, 3 feature maps with different receptive fields are adjusted to the same size and concatenated into a joint feature map T; on the other hand, a transformation vector W is constructed to excite each channel in the tensor T. During the upsampling process, the JEU module takes into account both multi-scale feature information and channel-wise correlation, improving the accuracy of semantic segmentation while reducing the complexity of the upsampling calculation. Figure 4 Shows the structural diagram of the JEU block. The purple arrow represents the joint upsampling path, and the red arrow represents the multi-level feature map joint upsampling of the feature map excitation path.
[0100] In this embodiment, JEUNet uses joint upsampling to replace the initial two-layer progressive upsampling in the decoder part of UNet. Through embedded vector extraction, the multi-level feature maps output in the second, third, and fourth stages are respectively input into the designed JEU module. The feature maps of stage 4 (w×w) and stage 3 (2w×2w) are upsampled to 4w×4w of the same size as that of stage 2. A concat operation is performed on the feature maps after joint upsampling to obtain a multi-level feature map T with a size of 4w×4w×X (X = 4k + 8k + 16k = 28k = 896). After joint upsampling, the new three feature maps are concatenated and merged into a multi-level feature map T with a size of 4w×4w×X, where X = 4k + 8k + 16k = 28k = 896. The multi-level feature map T contains 4w×4w embedded vectors with a size of 1×X. Each embedded vector contains semantic information of three different receptive fields and corresponds one-to-one with each position (x, y) in the original image.
[0101] After joint upsampling, the JPUblock then uses dilated convolutions with four different dilation rates to extract features and perform splicing, aiming to capture feature information at different scales in the multi-level feature map to ensure the accuracy of the upsampling decoder for semantic segmentation. However, each scale of the feature map in the multi-level feature map itself contains semantic information of different receptive fields. The practice of using multiple dilated convolutions may be redundant with the multi-level embedding vector itself, resulting in no obvious improvement in the semantic segmentation accuracy. In addition, the multi-level feature map T contains X channels, each of which is obtained by the operation of convolution kernels with different parameters. The correlation between these channels has not been concerned, so its improvement in the accuracy of the semantic segmentation prediction result is limited.
[0102] To adaptively recalibrate the feature responses in the channel direction and model the interdependence between different channels, we introduce the SE (Squeeze-and-Excitation) module into the JEUblock, integrating spatial attention into the structure of the upsampling network, which is also the significant difference between the JEU and JPU modules. As shown in formula (1), for the Tensor T of 4w×4w×X, the global average pooling function is used to compress it into a 1×X feature vector F. The x-th element F x is calculated as follows:
[0103]
[0104] In the formula, F(x) corresponds to the x-th channel in the Tensor T, and I and J are the feature maps of the x-th channel T xThe length and width are (I = J = 4w), where i and j represent the coordinates of each point on the feature map. To establish the correlation between features of different channels, F is connected to two fully connected layers, which are used to calculate the contribution weight of different channels during the learning process and activate the corresponding channels in the feature map during prediction, as shown in Equation (2).
[0105]
[0106] In the formula, δ() represents the ReLU activation function, and σ() represents the Sigmoid activation function.
[0107] During the learning process, the feature vector F is mapped through two fully connected layers to form the final weight vector W. The weight value W of each channel in W x predicts the importance of the corresponding channel x in the multi-level feature map T, thereby modeling the correlation between feature channels. During the operations of the two fully connected layers, the vector F undergoes a scaling (1 / 2) and a reduction operation to reduce the computational amount. w1 is the mapping weight vector of the first fully connected layer, and w2 is the mapping weight vector of the second fully connected layer. represents the feature map T corresponding to the x-th channel x and the weight vector W x The excitation feature map obtained by weighted multiplication. The JEU block assigns new response weights to each channel c in the multi-level feature map T obtained by joint upsampling through the weight vector W, and finally obtains the multi-level feature map after spatial channel excitation
[0108] In S130, as Figure 7 shown, it includes the following steps:
[0109] S131: Calculate the degree of curvature change and / or the degree of dispersion of each of the edge features to obtain an intermediate variable, where the intermediate variable characterizes the edge features whose degree of curvature change is greater than a preset degree of curvature change and / or a preset degree of dispersion;
[0110] S132: Increase the weight of the intermediate variable in the image of the gray column region to obtain an intermediate image;
[0111] S133: Based on the connected component analysis algorithm, extract all the connected components in the intermediate image, and based on the connected components, obtain the crack region.
[0112] In S131, to obtain the edge features, the Sobel operator or the Canny edge detection algorithm can be used to extract the edge features in the image of the gray column region. Exemplarily, when using the Sobel operator for edge detection, it includes the following steps:
[0113] 1. Grayscale conversion: Since the Sobel operator mainly processes grayscale images, the color image needs to be converted to a grayscale image first.
[0114] 2. Gradient calculation: Convolve the image with the horizontal direction kernel (Gx) to calculate the gradient in the X direction. Convolve the image with the vertical direction kernel (Gy) to calculate the gradient in the Y direction.
[0115] 3. Determination of magnitude and direction: Combining the gradients in the X and Y directions, the magnitude and direction of the gradient can be calculated. The magnitude is usually used to represent the intensity of the edge, while the direction is used to represent the orientation of the edge.
[0116] 4. Threshold processing: To remove noise and unnecessary details, a threshold is usually set. Only when the magnitude of the gradient exceeds this threshold is the pixel considered to belong to an edge.
[0117] 5. Edge thinning: According to the need, the detected edges can be thinned to highlight the edge features.
[0118] After extracting the edge features, the crack area is initially identified by extracting the irregular and scattered edge features in the gray column area image, where the irregular edge features are the edge features with a curvature change degree greater than the preset curvature change degree, and the scattered edge features are the edge features with a dispersion degree greater than the preset dispersion degree. Among them, the preset curvature change degree and the preset dispersion degree can be set according to actual needs.
[0119] In S132, as Figure 8 shown, it includes the following steps:
[0120] S1321: Input the gray column area image into the first convolutional neural network model, where the first convolutional neural network model has an adaptive gating mechanism, the adaptive gating mechanism is based on a dynamic gating function, the dynamic gating function calculates the weight of each pixel point of the gray column area image, generates a weight map, and the weight coefficient of the pixel points of the edge features with a curvature change degree greater than the preset curvature change degree and / or preset dispersion degree in the gray column area image is greater than the weight coefficient of the pixel points in other positions of the gray column area image;
[0121] S1322: After multiplying the weight map and the gray column area image element by element, output the intermediate image.
[0122] In S133, first, the gray column area image is converted into a binary image, that is, each pixel point in the binary image is either black or white. Then, a connected component detection algorithm (such as connected component labeling) is used to traverse the binary image to identify and label all connected components. Each connected component consists of a group of interconnected pixels and represents an independent structure in the gray column area image.
[0123] After obtaining the connected components, these connected components are filtered according to criteria such as area size and shape contour, and small or irregular connected components are removed. The remaining connected components are the crack areas. A connected component area threshold can be set, or a contour curvature threshold can be set to filter the connected components with an area larger than the connected component area threshold, and / or filter the connected components with a contour area larger than the contour curvature threshold as the crack areas.
[0124] After determining the crack areas, the crack areas are filled through area filling algorithms such as morphological closing operations. If the crack area is large, a multi-scale filling strategy is adopted, that is, filling layer by layer from the center to the edge to ensure that the filled image with the gray column is complete without defects for subsequent color detection.
[0125] In S140, as Figure 9 shown, it includes the following steps:
[0126] S141: Obtain the brightness values of all pixel points in the gray column area image except the crack areas in the CIELAB color space;
[0127] S142: Calculate the average value of the brightness values of all the pixel points, and the average value characterizes the brightness value of the gray column area image.
[0128] In S141, the image of the area with the gray column after removing the crack areas is converted from the RGB color space to the CIELAB color space. This conversion process can better simulate the human eye's perception of color and adapt to changes in different lighting environments. In the CIELAB color space, the L (brightness), a (red-green component), and b (yellow-blue component) values are extracted. On this basis, the average value of the L values of all pixels in the area with the gray column is calculated to represent the color gray information of the gray column. The mean value of the L value can accurately reflect the depth of the color of the area with the gray column. At the same time, the color of the image is calibrated based on the D65 light source of the CIELAB color space standard to ensure that the detection results are not affected by changes in external light, especially to maintain consistent color measurement under different ambient lightings. The method of gray histogram equalization is combined to process the image of the area with the gray column after removing the cracks. By dynamically adjusting the image brightness and contrast, the gray distribution is made more uniform, thereby ensuring the stability of the detection of the color of the area with the gray column at different combustion stages.
[0129] Convert the calculated grayscale representation of the L value to a standardized grayscale range of [0 - 100%], and export the result as structured data for the quantitative evaluation of the ash color of cigarette packs.
[0130] As Figure 10 shown, according to S110 - S140, first, based on the sample image, generate the ash image, then segment the ash area image from the ash image, remove the crack area of the ash area image, and then obtain the brightness value (color feature) of the ash area image without the crack area.
[0131] The solution of this embodiment has the following advantages:
[0132] 1. Achieve precise segmentation of the ash area and improve the accuracy of color detection: The present invention adopts the automatic segmentation technology of the ash column area based on the convolutional neural network (CNN). Through the ResNeXT50 feature extraction module and the residual block design, the ash area and the background area can be accurately separated at different combustion stages. This feature segmentation enables the detection system to effectively reduce the interference of the background, thereby providing a reliable basis for the accurate extraction of color features.
[0133] 2. The crack removal technology effectively reduces noise interference and ensures the stability of color measurement: The present invention uses the adaptive gating mechanism and the connected component analysis method to identify and remove the crack area, avoiding the interference of the crack area on the ash color measurement. Through edge detection, adaptive gating adjustment, connected component filtering of the crack area, and multi-scale filling processing, the crack can be effectively filled, so that the color feature is extracted only based on the complete ash area, ensuring the continuity and stability of the detection result.
[0134] 3. Multi-angle image acquisition and color space conversion improve the reliability of color detection results: The present invention obtains the ash images at different angles and stages through the multi-angle imaging system, so that the color detection is not limited by a single angle and illumination. In addition, converting the image color from the RGB space to the CIELAB color space and combining it with the D65 standard light source for color calibration make the ash color data have a higher degree of standardization, ensuring the detection consistency and accuracy under different illumination conditions.
[0135] 4. Gray level equalization and standardized output to achieve quantitative evaluation of color changes: Through the gray level equalization algorithm, the present invention dynamically adjusts the brightness and contrast of the image, so that the gray level information in the color detection process remains consistent. In the output of the detection result, by quantifying the color gray level into a standardized gray level range of [0 - 100%] and combining with the color change trend chart of the whole combustion process, the change of the ash color is quantitatively and intuitively expressed in each combustion stage, providing a scientific basis for the analysis and evaluation of the apparent combustion quality of cigarettes.
[0136] 5. Improve the detection efficiency and automation level, suitable for large-scale industrial applications: The present invention realizes fully automated ash color detection of cigarette packs through deep learning technology, including a complete process from image acquisition, ash column segmentation, crack removal, color feature extraction to result output. This method can adapt to the dynamic changes during the cigarette combustion process, and has high detection accuracy and stability, and is applicable to the automatic detection of the apparent combustion quality in large-scale cigarette production, with important industrial application value.
[0137] In summary, through the comprehensive application of deep learning and image processing technologies in this embodiment, high-precision, standardization and automation are achieved in the ash color detection of cigarette packs, providing an objective and stable detection scheme for the apparent combustion quality of cigarettes, and can effectively improve the quality monitoring level and market competitiveness of cigarette products.
[0138] Embodiment 2
[0139] This embodiment proposes a method for testing the combustion quality of cigarettes, as Figure 11 shown, including the following steps:
[0140] S1: Collect multiple groups of ash images, each group of ash images corresponding to each stage of cigarette combustion, and each group of ash images including multiple ash images consecutive in the acquisition time;
[0141] S2: According to the cigarette ash color detection method described in Embodiment 1, obtain the brightness values of all the ash images;
[0142] S3: Based on the brightness values of all the ash images, obtain the curve of the brightness value of the ash images over time in each stage of the cigarette combustion;
[0143] S4: Based on the curve, detect the combustion quality of the cigarette.
[0144] The curve records the gray-scale changes in each combustion stage, facilitating the observation and analysis of the dynamic changes in the ash color during the cigarette combustion process. Summarize the data such as the detected gray-scale values, crack rates and ash column integrity, and generate a comprehensive report on the cigarette combustion quality. This report details the gray-scale changes, crack conditions and ash column integrity of the ash color during the combustion process, which can help cigarette manufacturers evaluate and improve product quality, and provide more intuitive product quality data for consumers.
[0145] Embodiment 3
[0146] An embodiment of the present application provides an electronic device, which may include a processing module and a storage module. A computer program is stored in the storage module. When the computer program is executed by the processing module, the electronic device can execute the corresponding steps in the cigarette pack ash color detection method described in Embodiment 1, or execute the corresponding steps in the cigarette combustion quality test method described in Embodiment 2.
[0147] In this embodiment, the processing module may be an integrated circuit chip with signal processing capabilities. The above-mentioned processing module may be a general-purpose processor. For example, the processor may be a central processing unit (CPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application.
[0148] The storage module may be, but is not limited to, a random access memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, etc. In this embodiment, the storage module may be used to store a program, and the processing module executes the program after receiving an execution instruction.
[0149] It should be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described electronic device can refer to the corresponding processes of the steps in the foregoing methods, and will not be elaborated herein.
[0150] Embodiment 4
[0151] An embodiment of the present application further provides a computer-readable storage medium. A computer program is stored in the computer-readable storage medium. When the computer program runs on a computer, the computer executes the corresponding steps in the cigarette pack ash color detection method described in Embodiment 1, or executes the corresponding steps in the cigarette combustion quality test method described in Embodiment 2.
[0152] Through the description of the above embodiments, those skilled in the art can clearly understand that this application can be implemented through hardware or by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of this application can be embodied in the form of a software product, and the software product can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various implementation scenarios of this application.
[0153] In the embodiments provided in this application, it should be understood that the disclosed method can also be implemented in other ways. The method embodiments described above are only illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of the methods and computer program products according to multiple embodiments of this application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions. In addition, the functional modules in various embodiments of this application can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0154] The above are only the embodiments of this application and are not used to limit the protection scope of this application. For those skilled in the art, this application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included in the protection scope of this application.
Claims
1. A method for detecting cigarette ash color, characterized in that: The method comprises: Acquire the ash image of cigarette during burning process; Extracting a gray column region in the gray-enclosed image to obtain a gray column region image; Performing edge detection on the gray column region image to obtain all edge features of the gray column region image; When the edge feature representing the crack region exists, the brightness value of the gray column region image not including the crack region is acquired, and the brightness value represents the gray color.
2. The method according to claim 1, characterized in that: In performing edge detection on the gray column region image to obtain all edge features of the gray column region image and when the edge features representing the crack region exist, obtaining the brightness values of all pixel points in the gray column region image excluding the crack region, the method further includes: Calculating the curvature variation degree and / or the dispersion degree of each edge feature to obtain an intermediate variable, wherein the intermediate variable represents an edge feature whose curvature variation degree is greater than a preset curvature variation degree and / or a preset dispersion degree; Increasing the weight of the intermediate variable in the gray column region image to obtain an intermediate image; Based on a connected domain analysis algorithm, all connected domains in the intermediate image are extracted, and based on the connected domains, the crack region is obtained.
3. The method according to claim 2, characterized in that: The step of increasing the weight of the intermediate variable in the gray column region image to obtain an intermediate image includes: Inputting the gray column region image into a first convolutional neural network model, wherein the first convolutional neural network model has an adaptive gating mechanism, and the adaptive gating mechanism is based on a dynamic gating function, and the dynamic gating function calculates the weight of each pixel point of the gray column region image to generate a weight map, and the weight coefficient of the pixel point of the intermediate variable in the gray column region image is greater than the weight coefficient of the pixel point at other positions in the gray column region image; After element-by-element multiplication of the weight map and the gray column region image, the intermediate image is output.
4. The method according to claim 1, characterized in that: The calculation to obtain the brightness values of all pixels in the gray column area image excluding the crack area includes: Obtaining the brightness values of all pixels of the gray column area image except the crack area in the CIELAB space; An average value of the brightness values of all the pixels is calculated, and the average value represents the brightness value of the gray column region image.
5. The method according to claim 1, characterized in that: The gray-enclosed image includes a background area and a gray column area; Extracting the gray column area in the gray-enclosed image to obtain the gray column area image includes: Inputting the gray-enclosed image as an input image into a second convolutional neural network model, wherein the second convolutional neural network model has a self-attention mechanism, and the second convolutional neural network model outputs the gray-enclosed image in which the attention weight of the gray column area is greater than the attention weight of the background area, to form an output image, so that the prominence of the gray column area is greater than the prominence of the background area; The output image is input into a segmentation model to obtain the gray column area image. The segmentation model is a deep learning model. The segmentation model segments the processed gray-enclosed image into the gray column area image and the background area image. The segmentation model is obtained by training based on multiple training images. The training images include a first annotation and a second annotation. The first annotation represents the pixel points of the gray-enclosed area in the training image, and the second annotation represents the pixel points of the background area in the training image.
6. The method according to claim 5, characterized in that: Between the second convolutional neural network model outputting a gray-enclosed image in which the attention weight of the gray column area is greater than the attention weight of the background area, and inputting the gray-enclosed image in which the attention weight of the gray column area is greater than the attention weight of the background area into the segmentation model, the method further includes: The resolution of the output image is adjusted until the resolution of the output image is consistent with the resolution of the input image.
7. A method for detecting cigarette combustion quality, characterized in that: include: Collecting a plurality of ash image groups, each of which corresponds to each stage of cigarette burning, and each of which includes a plurality of ash images that are consecutive in acquisition time; According to the cigarette ash color detection method according to any one of claims 1 to 6, the brightness values of all the ash images are obtained; Based on the brightness values of all the ash images, a curve of the brightness value of the ash images over time in each stage of the cigarette burning is obtained; Based on the curve, the burning quality of the cigarette is detected.
8. An electronic device, characterized in that: The electronic device includes a processor and a memory coupled to each other, wherein the memory stores a computer program. When the computer program is executed by the processor, the electronic device executes the method as claimed in any one of claims 1 to 6, or executes the method as claimed in claim 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 6, or to execute the method according to claim 7.