Tobacco shred component and structure determination method based on deep semantic segmentation model

Through deep semantic segmentation models and image processing technology, it solves the problems of time-consuming, inaccurate and health risks of existing cut tobacco detection methods, achieves efficient and accurate determination of cut tobacco components and structure, and supports rapid detection in the tobacco industry.

CN118747734APending Publication Date: 2024-10-08CHINA TOBACCO HUNAN IND CORP
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410748862.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-10-08

AI Technical Summary

Technical Problem

Existing tobacco detection methods rely on traditional vibrating screening methods and manual detection, which are time-consuming, labor-intensive, and the accuracy is affected by human factors. There is a risk of missed detection and false detection, and the use of chemical reagents is not good for the health of practitioners.

Method used

A method for determining the components and structure of cut tobacco based on a deep semantic segmentation model is adopted. The SegFormer model is combined with image processing technology to achieve segmentation and identification of cut tobacco images and determine the components and structure of cut tobacco.

Benefits of technology

It improves the accuracy and efficiency of the determination of cut tobacco components and structure, reduces the cost of manual labeling, enables fast, simple and accurate cigarette quality testing, and reduces health risks to employees.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118747734A_ABST
    Figure CN118747734A_ABST
Patent Text Reader

Abstract

The invention discloses a cut tobacco component and structure determination method based on a deep semantic segmentation model, and the method comprises the steps: obtaining a cut tobacco image, and carrying out the image preprocessing; extracting a region of interest of the preprocessed image, and performing matrix correction on the region of interest; carrying out binarization segmentation on the corrected region of interest to obtain a tobacco shred distribution region; based on a SegFormer semantic segmentation model obtained through pre-training, performing tobacco shred type identification on the tobacco shred distribution area, and determining tobacco shred components in the to-be-detected tobacco shred image; image enhancement processing is carried out on the tobacco shred distribution area, binarization segmentation is carried out on the tobacco shred distribution area after image enhancement, a tobacco shred communication area is obtained, and the tobacco shred structure in the image is measured based on morphology. According to the method, the identification accuracy of various tobacco shreds and stem slivers can be improved, the tobacco shred components and the tobacco shred structure proportion can be efficiently measured, the training samples can be automatically generated and marked, and the cost required by manual image marking is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of tobacco processing, and in particular refers to a method for determining tobacco shred components and structures based on a deep semantic segmentation model. Background Art

[0002] Tobacco testing has always been a difficult point in tobacco quality testing. Tobacco testing is divided into structural testing and component analysis. The purpose of structural testing is to count the whole and broken tobacco rates, understand the overall structure and morphological characteristics of tobacco, and provide an important reference for cigarette quality testing. Component analysis is to give the proportion of different tobacco in tobacco, such as leaf, thin, stem, stem and expanded. The proportion of different components will directly affect the taste, combustion performance and other characteristics of cigarettes. Therefore, the proportion of tobacco components and tobacco structure are key indicators for evaluating cigarette quality, and can provide a scientific basis and quality assurance for cigarette production.

[0003] Existing tobacco companies often use the traditional vibration screening method to detect tobacco structure. At the same time, there is a lack of standard detection methods for tobacco component detection, and they mainly rely on manual selection and detection. However, this method is not only time-consuming and labor-intensive, but also the detection accuracy is greatly affected by human subjective factors. As the working time increases, the probability of missed detection and false detection increases further. In addition, chemical reagents need to be used in the manual detection process, which is not conducive to the health of practitioners.

[0004] In view of this, a method for determining tobacco components and structures based on a deep semantic segmentation model is urgently needed in this field. Summary of the invention

[0005] In view of the above-mentioned problems in the prior art, the object of the present invention is to provide a method for measuring tobacco components and structure based on a deep semantic segmentation model. By combining the image processing method with the trained SegFormer semantic segmentation model, tobacco segmentation and recognition in tobacco images can be achieved, and tobacco components and structure can be measured accurately and efficiently.

[0006] In order to achieve the above object, the present invention adopts the following technical scheme:

[0007] In a first aspect, an embodiment of the present invention provides a method for determining tobacco components and structures based on a deep semantic segmentation model, comprising the following steps:

[0008] S1: Acquire the image of the tobacco to be tested;

[0009] S2: preprocessing the tobacco image to be tested to obtain a preprocessed tobacco image to be tested;

[0010] S3: extracting a region of interest from the preprocessed tobacco image to be tested, and performing matrix correction on the region of interest;

[0011] S4: Binarization segmentation is performed on the corrected region of interest based on the OTSU method to obtain the tobacco scattering area of ​​the tobacco image to be tested;

[0012] S5: Based on the pre-trained SegFormer semantic segmentation model, the tobacco type is identified in the tobacco scattering area, and based on the surface density ratio of each type of tobacco, the tobacco components in the tobacco image to be tested are determined;

[0013] S6: Perform image enhancement processing on the tobacco scattering area, perform binary segmentation on the tobacco scattering area after image enhancement by the OTSU method, obtain the tobacco connected area of ​​the tobacco image to be tested, and determine the tobacco structure in the tobacco image to be tested based on morphological analysis and measurement of the length of each tobacco connected area.

[0014] Furthermore, in S1, the specific steps of obtaining the image of the tobacco to be tested are:

[0015] Place the tobacco to be tested on a vibration table;

[0016] After the tobacco to be tested is dispersed by a vibration table, the dispersed tobacco to be tested is compacted and flattened by using a transparent material;

[0017] Collecting images of tobacco to be tested;

[0018] The shredded tobacco image to be tested includes a shredded tobacco image of mixed shredded tobacco formed by mixing at least two of slices, shredded stems, shredded leaves, expanded shredded leaves and shredded stems.

[0019] Furthermore, in S2, the specific steps of preprocessing the tobacco image to be tested are:

[0020] S210: grayscale conversion is performed on the tobacco image to be tested, and the image size is reduced by downsampling operation;

[0021] S220: performing pixel-by-pixel subtraction of the downsampled image to obtain highlight pixels in the image, and performing binary segmentation of the highlight pixels using the OTSU method to obtain white connected areas;

[0022] S230: Perform straight line detection on the downsampled image through Hough transform processing, and retain straight lines close to the horizontal direction and close to the vertical direction.

[0023] Furthermore, S3 includes the following specific steps:

[0024] S310: Obtain a set of rectangles by exhaustively enumerating rectangles formed by a pair of horizontal straight lines and a pair of vertical straight lines;

[0025] S320: extracting a rectangle having the largest proportion of white connected areas from the rectangular set to obtain a region of interest of the tobacco image to be tested;

[0026] S330: Based on the affine transformation model, rectangular correction is performed on the region of interest of the tobacco image to be tested.

[0027] Furthermore, the S5 comprises the following specific steps:

[0028] S510: Based on the pre-trained SegFormer semantic segmentation model, identify the stems and types of tobacco in the tobacco scattering area, and obtain the areas of the stems and the corresponding types of tobacco;

[0029] S520: Obtaining the surface density ratio of the stems and various types of shredded tobacco;

[0030] S530: Calculate the proportion of tobacco components and the stem rate in the tobacco image to be tested according to the area and surface density ratio of the stems and the corresponding types of tobacco.

[0031] Furthermore, in S5, the specific steps of training the SegFormer semantic segmentation model based on the pre-training include:

[0032] Build the SegFormer semantic segmentation model and modify the output category of the SegFormer semantic segmentation model to the tobacco component category;

[0033] Collect various tobacco shreds, stems and blank vibration table images to obtain a sample image set;

[0034] The images in the sample image set are simulated to generate a training image set;

[0035] Based on the training image set and the cross entropy loss function, the modified SegFormer model is iteratively trained to obtain the trained SegFormer semantic segmentation model.

[0036] Furthermore, the step of simulating the acquired images to generate a training data set specifically includes:

[0037] Perform image segmentation on the images in the sample image set, and extract each tobacco strand and stem in the image;

[0038] Before the tobacco is superimposed on the background image, a completely black image with the same size as the background image is generated as a true value image; the background image is a blank vibration table image;

[0039] Each type of tobacco and stem is randomly selected and superimposed on the background image, and the centroid position and rotation angle of each tobacco and stem are randomly generated with uniform distribution during superposition;

[0040] According to the generated centroid position and rotation angle, corresponding color marks are generated on the truth map according to the category of the stem and each tobacco strip with the same centroid position and rotation angle.

[0041] Furthermore, the S6 comprises the following specific steps:

[0042] S610: for the tobacco scattering area of ​​the tobacco image to be tested, a Gaussian filter is used to smooth the area to eliminate the edge shadow interference of the tobacco scattering area; then, the tobacco is filtered out by a morphological closing operation to obtain a background image of the tobacco scattering area, and the background image is subtracted from the original scattering area image to obtain a difference image;

[0043] S620: using the OTSU method to perform binary segmentation on the difference image to obtain a tobacco connected region of the tobacco image to be tested;

[0044] S630: Extract the tobacco skeleton in each tobacco connected area based on a morphological method, and calculate the tobacco length according to the length of the tobacco skeleton, as shown in the following formula:

[0045]

[0046] Wherein, Ls is the physical length of tobacco, ls is the pixel length of tobacco; Lm is the physical length of the vibration table surface, lm is the pixel length of the vibration table surface;

[0047] The skeleton length is the pixel length of the tobacco;

[0048] S640: Determine the structural category of the tobacco according to the preset screening length threshold T, as shown in the following formula:

[0049]

[0050] S650: Counting the area ratio of whole shreds to broken shreds in all shredded tobacco, and determining the shredded tobacco structure in the shredded tobacco image to be tested.

[0051] In a second aspect, an embodiment of the present invention provides a tobacco component and structure determination system based on a deep semantic segmentation model, comprising:

[0052] An image acquisition module is used to acquire the image of the tobacco to be tested;

[0053] An image preprocessing module is used to preprocess the tobacco image to be tested to obtain a preprocessed tobacco image to be tested;

[0054] An image extraction module is used to extract the region of interest of the pre-processed tobacco image to be tested, and perform matrix correction on the region of interest;

[0055] An image segmentation module is used to perform binary segmentation on the corrected region of interest based on the OTSU method to obtain the tobacco scattering area of ​​the tobacco image to be tested;

[0056] A tobacco component module, for identifying tobacco types in the tobacco distribution area by using a pre-trained SegFormer semantic segmentation model, and determining tobacco components in the tobacco image to be tested based on the surface density ratio of each type of tobacco;

[0057] The tobacco structure module is used to perform image enhancement processing on the tobacco scattering area, perform binary segmentation on the tobacco scattering area after image enhancement by the OTSU method, obtain the tobacco connected area of ​​the tobacco image to be tested, and determine the tobacco structure in the tobacco image to be tested based on morphological analysis and measurement of the length of each tobacco connected area.

[0058] In a third aspect, an embodiment of the present invention provides a readable storage medium storing a computer program, wherein the computer program is called by a processor to implement:

[0059] The steps of the method for determining the composition and structure of cut tobacco are as described above.

[0060] The beneficial effects brought by the embodiments provided by the present invention include:

[0061] The present invention uses a pre-trained SegFormer semantic segmentation model to segment and identify tobacco to be tested, thereby improving the accuracy of identifying various types of tobacco and stems, and realizing efficient determination of tobacco components and tobacco structure (whole and broken) proportions; the present invention collects tobacco examples of various categories and vibration table background images for simulation, generates images that can better simulate the effect of the vibration table shaking tobacco, realizes automatic generation and labeling of training samples, and can provide sufficient and effective training samples for the SegFormer semantic segmentation model, avoiding the overhead required for manual image labeling; the present invention can quickly collect tobacco images to be tested through edge devices such as portable image acquisition terminals, and use cloud data platforms to realize tobacco component analysis and tobacco structure determination, and can dynamically check tobacco quality without space and time restrictions, helping tobacco industry practitioners to achieve simple, fast and accurate cigarette quality testing, thereby providing effective assistance for tobacco quality testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0063] Figure 1 A schematic flow chart of a method for determining tobacco components and structures provided by an embodiment of the present invention;

[0064] Figure 2 A schematic flow chart of another method for determining the composition and structural proportion of cut tobacco provided by an embodiment of the present invention;

[0065] Figure 3 A schematic diagram of a method for locating tobacco regions and segmenting tobacco provided in an embodiment of the present invention;

[0066] Figure 4 A diagram of the SegFormer model recognition results provided by an embodiment of the present invention;

[0067] Figure 5 Examples of various types of tobacco, stems and background images provided in the embodiments of the present invention;

[0068] Figure 6 A schematic diagram of the SegFormer model architecture provided by an embodiment of the present invention;

[0069] Figure 7 Training example graphs and corresponding truth value graphs of various types of tobacco shreds and stems provided in the embodiments of the present invention;

[0070] Figure 8 An example diagram of obtaining the surface density ratio of various types of shredded tobacco and stems provided in an embodiment of the present invention;

[0071] Fig. 9 This is a structural block diagram of a tobacco component and structure determination system provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0072] In order to make the objectives, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0073] However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, the description of the known technology is omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0074] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The term "comprising" used herein indicates the existence of features, steps, operations, but does not exclude the existence or addition of one or more other features. It should be noted that all terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used here should be interpreted as having meanings consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0075] Some block diagrams and / or flow charts are shown in the accompanying drawings. It should be understood that some boxes or combinations thereof in the block diagrams and / or flow charts can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that these instructions can create a device for implementing the functions / operations described in these block diagrams and / or flow charts when executed by the processor. The technology of the present disclosure can be implemented in the form of hardware and / or software (including firmware, microcode, etc.). In addition, the technology of the present disclosure can take the form of a computer program product on a computer-readable storage medium storing instructions, which can be used by an instruction execution system or used in conjunction with an instruction execution system.

[0076] Example 1

[0077] like Figure 1 , Figure 2 As shown, an embodiment of the present invention provides a method for determining tobacco components and structures based on a deep semantic segmentation model, comprising the following steps:

[0078] S1: Acquire the image of the tobacco to be tested.

[0079] In some embodiments, the specific steps of step S1 are:

[0080] Place the tobacco to be tested on a vibration table; shake the tobacco to be tested apart by the vibration table so that the tobacco does not overlap;

[0081] Use non-reflective transparent material to completely cover all the tobacco shreds, and use the transparent material to compact and flatten the scattered tobacco shreds to be tested;

[0082] The image of the tobacco to be tested on the vibration table is collected by looking down through the image acquisition device;

[0083] The shredded tobacco image to be tested includes a shredded tobacco image of mixed shredded tobacco formed by mixing at least two of slices, shredded stems, shredded leaves, expanded shredded leaves and shredded stems.

[0084] S2: preprocessing the tobacco image to be tested to obtain a preprocessed tobacco image to be tested.

[0085] In some embodiments, in S2, the specific steps of preprocessing the tobacco image to be tested are:

[0086] S210: grayscale conversion is performed on the tobacco image to be tested, and the image size is reduced by downsampling operation;

[0087] S220: performing pixel-by-pixel subtraction of the downsampled image to obtain highlight pixels in the image, and performing binary segmentation of the highlight pixels using the OTSU method to obtain white connected areas;

[0088] Specifically, in the process of binary segmentation of highlight pixels using the OTSU algorithm, the steps of finding the segmentation threshold include:

[0089] By analyzing the image and the corresponding histogram, because the brightness of the vibration platform is above the mean of the entire image, the pixels smaller than the mean in the image are discarded, and only the part larger than the mean in the histogram is considered;

[0090] In the part of the histogram that is greater than the mean, the loading area is in a brighter area compared to other areas on the vibration table, and two grayscale peaks appear on the histogram;

[0091] The trough position between the two peaks found by the OTSU algorithm is the segmentation threshold; Figure 3 As shown, Figure 3 (a) is the downsampled image. Figure 3 (b) is the image mean, Figure 3 (c) is the histogram of the part greater than the mean value. Figure 3 (d) Figure 3 The image corresponding to the maximum peak in (c) is Figure 3 (e) is the binarization result after segmentation by OTSU algorithm. Figure 3 (f) for Figure 3 (e) The largest connected domain after hole filling.

[0092] Among them, the OTSU method is a general method in the field of image binarization.

[0093] S230: Perform straight line detection on the downsampled image through Hough transform processing, and retain straight lines close to the horizontal direction and close to the vertical direction.

[0094] In the disclosure of this application, "close to a horizontal straight line" means that the horizontal straight line is within the range of 0° to ±5° unless otherwise specified. In addition, "close to a vertical straight line" means that the vertical straight line is within the range of 90° to ±5° unless otherwise specified.

[0095] S3: extracting the region of interest of the pre-processed tobacco image to be tested, and performing matrix correction on the region of interest.

[0096] In some embodiments, S3 includes the following specific steps:

[0097] S310: Obtain a set of rectangles by exhaustively enumerating rectangles formed by a pair of horizontal straight lines and a pair of vertical straight lines;

[0098] S320: extracting a rectangle having the largest proportion of white connected areas from the rectangular set to obtain a region of interest of the tobacco image to be tested;

[0099] S330: Based on the affine transformation model, rectangular correction is performed on the region of interest of the tobacco cut image to be measured, so as to ensure the accuracy of subsequent measurement and prevent affine distortion of the region caused by the photographer's random shooting.

[0100] S4: Binarization segmentation is performed on the corrected region of interest based on the OTSU method to obtain the tobacco scattering area of ​​the tobacco image to be tested.

[0101] S5: The pre-trained SegFormer semantic segmentation model is used to identify the tobacco type in the tobacco scattering area, and the tobacco components in the tobacco image to be tested are determined based on the surface density ratio of each type of tobacco.

[0102] like Figure 4 As shown, in some embodiments, S5 includes the following specific steps:

[0103] S510: Based on the SegFormer semantic segmentation model, identify the stems and tobacco types in the tobacco scattering area, and obtain the areas of the stems and tobacco of the corresponding types;

[0104] S520: Obtaining the surface density ratio of the stems and various types of shredded tobacco;

[0105] S530: Calculating the proportion of tobacco components and the stem rate in the tobacco image to be tested according to the area and surface density ratio of the stems and corresponding types of tobacco;

[0106] The calculation formula for the proportion of tobacco components is:

[0107]

[0108] The calculation formula of the stem signing rate is:

[0109]

[0110] Among them, Wi represents the surface density ratio of different types of shredded tobacco or stem sticks; Ni represents the area of ​​different types of shredded tobacco or stem sticks; i represents the number of different types of shredded tobacco or stem sticks (i=1, 2, 3, 4, 5), where when i=1, 2, 3, 4, 5, i represents thin slices, shredded stems, shredded leaves, expanded shredded leaves, and stem sticks, respectively.

[0111] For example, in S5, the specific training process of the pre-trained SegFormer semantic segmentation model is as follows:

[0112] Build the SegFormer semantic segmentation model and modify the output category of the SegFormer semantic segmentation model to the tobacco component category;

[0113] Collect various types of tobacco, stems and blank vibration table images to obtain a sample image set; wherein, when collecting images, each image only contains a single type of tobacco or stem instance, such as Figure 5 As shown, Figure 5 (a) is a sample example of leaf silk. Figure 5 (b) is an example of an expanded wire sample. Figure 5 (c) is a sample example of a thin film. Figure 5 (d) is a sample example of shredded stems. Figure 5 (e) is a sample example of a stem label. Figure 5 (f) is a sample example of a blank vibration table;

[0114] The images in the sample image set are simulated to generate a training image set;

[0115] Based on the training image set and the cross entropy loss function, the modified SegFormer model is iteratively trained to obtain the trained SegFormer semantic segmentation model.

[0116] More specifically, when training the SegFormer model in this embodiment, the image size in the training image set is 1500*1200. First, n models of different sizes b0, b1, bn are trained for 100 epochs on each of the n models, and then the performance of the n models in terms of pixel accuracy is compared, and the optimal effect model is output.

[0117] In this embodiment, the cross entropy loss function is:

[0118]

[0119] Among them, L represents the cross entropy loss function; N represents the total number of training samples; L i represents the loss of the i-th sample; M is the number of categories; y ic is a sign function, if the true category of sample i is equal to category c, it takes 1, otherwise it takes 0; p icis the predicted probability that the observed sample i belongs to category c.

[0120] like Figure 6 As shown, this embodiment provides a SegFormer semantic segmentation model architecture diagram, by building a SegFormer semantic segmentation model, using the attention mechanism, multi-scale feature fusion integrated to achieve tobacco segmentation, detection and recognition of various types of tobacco and stems;

[0121] First, an image with a dimension of [H, W, 3] is input into the SegFormer semantic segmentation model. The input image is divided into several overlapping patches through the overlapping block coding layer to reduce the feature dimension of the input image. These patches are passed as input to the Transfommer module to extract features. This model includes four overlapping block coding layers and the Transfommer module. The image feature map after each processing becomes 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the original, thereby fusing features of different scales of the input image. The fused features are then passed to the MLP decoder to decode the fused features. The segmentation mask is predicted at the resolution of N CIS is the number of categories;

[0122] Among them, the step size of the convolution kernel in the overlapping block coding layer is smaller than the kernel size, so there will be some repeated information between adjacent blocks, ensuring that in the process of feature extraction, local information can be retained and transmitted between adjacent blocks without causing discontinuity and loss of information due to strict blocking.

[0123] Exemplarily, simulating the acquired images to generate a training data set includes the following specific steps:

[0124] Perform image segmentation on the images in the sample image set, and extract each tobacco strand and stem in the image;

[0125] Before the tobacco is superimposed on the background image, a completely black image with the same size as the background image is generated as a true value image; the background image is a blank vibration table image;

[0126] Each type of tobacco and stem is randomly selected and superimposed on the background image, and the centroid position and rotation angle of each tobacco and stem are randomly generated with uniform distribution during superposition;

[0127] According to the generated centroid position and rotation angle, the corresponding color mark is generated on the truth map according to the category of the stem label and each tobacco strip with the same centroid position and rotation angle, such as Figure 7 As shown, Figure 7 (a) is a training example of various types of tobacco and stems. Figure 7 (b) Figure 7(a) The corresponding truth graph; where Figure 7 In (b), red is leaf filaments, blue is expanded leaf filaments, green is thin slices, yellow is stem filaments, and gray is stem sticks.

[0128] Exemplarily, obtaining the surface density ratio of stems and tobacco of various types includes the following specific steps:

[0129] Measure and record the actual weight of each type of tobacco and stems;

[0130] Place the tobacco and stems of different types in clusters on the vibrating table, and make sure that the tobacco and stems of different types do not stick to each other, and the tobacco and stems of the same type do not overlap or cross each other. Figure 8 As shown (the upper left area in the figure is the leaf shreds, the upper right area is the thin slices, the lower left area is the expanded leaf shreds, the lower right area is the stem shreds, and the middle area is the stem sticks);

[0131] All the tobacco shreds are completely covered with non-reflective transparent materials, the scattered tobacco shreds are compacted and flattened with the transparent materials, and the image of the tobacco shreds on the vibration table is collected by looking down with an image acquisition device;

[0132] The tobacco cut image is processed in sequence according to the steps S2 to S4 above to obtain the scattered areas of different types of tobacco cuts and stems;

[0133] The number of pixels in the distribution area of ​​different types of tobacco and stems is recorded, and the surface density ratio of different types of tobacco and stems is calculated as follows:

[0134]

[0135] Among them, W1, W2...W5 represent the surface density ratios of thin slices, stem shreds, leaf shreds, expanded leaf shreds, and stem sticks, respectively; n1, n2...n5 represent the number of pixels (pixel area) of thin slices, stem shreds, leaf shreds, expanded leaf shreds, and stem sticks, respectively; m1, m2...m5 represent the actual weights of thin slices, stem shreds, leaf shreds, expanded leaf shreds, and stem sticks, respectively.

[0136] S6: Perform image enhancement processing on the tobacco scattering area, perform binary segmentation on the tobacco scattering area after image enhancement by the OTSU method, obtain the tobacco connected area of ​​the tobacco image to be tested, and determine the tobacco structure in the tobacco image to be tested based on morphological analysis and measurement of the length of each tobacco connected area.

[0137] In some embodiments, S6 includes the following specific steps:

[0138] S610: for the tobacco scattering area of ​​the tobacco image to be tested, a Gaussian filter is used to smooth the area to eliminate the edge shadow interference of the tobacco scattering area; then, the tobacco is filtered out by a morphological closing operation to obtain a background image of the tobacco scattering area, and the background image is subtracted from the original scattering area image to obtain a difference image;

[0139] S620: using the OTSU method to perform binary segmentation on the difference image to obtain a tobacco connected region of the tobacco image to be tested;

[0140] S630: Extract the tobacco skeleton in each tobacco connected area based on a morphological method, and calculate the tobacco length according to the length of the tobacco skeleton, as shown in the following formula:

[0141]

[0142] Wherein, Ls is the physical length of the tobacco, ls is the pixel length of the tobacco; Lm is the physical length of the vibration table surface, lm is the pixel length of the vibration table surface; the skeleton length is the pixel length of the tobacco;

[0143] S640: Determine the structural category of the tobacco according to the preset screening length threshold T, as shown in the following formula:

[0144]

[0145] S650: Count the area ratio of whole shreds to broken shreds in all shredded tobacco, and measure the shredded tobacco structure in the shredded tobacco image to be measured. Table 1 shows a set of shredded tobacco component and structure ratio measurement results, and it can be seen that the relative error of this method is less than or equal to 5%.

[0146] Table 1 shows the measurement errors of tobacco components and structural proportions

[0147]

[0148] This embodiment avoids or reduces the factors that affect the accuracy of measuring the proportion of tobacco components and structures in multiple links. By introducing a powerful semantic segmentation model to handle tobacco segmentation and recognition, and using a simulation algorithm to automatically generate and label training samples, it can accurately and efficiently measure the proportion of tobacco components and structures.

[0149] Example 2

[0150] like Fig. 9 As shown, the embodiment of the present invention provides a tobacco component and structure determination system 100 based on a deep semantic segmentation model, comprising

[0151] An image acquisition module 101 is used to acquire an image of the tobacco to be tested;

[0152] An image preprocessing module 102 is used to preprocess the tobacco image to be tested to obtain a preprocessed tobacco image to be tested;

[0153] An image extraction module 103 is used to extract the region of interest of the pre-processed tobacco image to be tested, and perform matrix correction on the region of interest;

[0154] An image segmentation module 104 is used to perform binary segmentation on the corrected region of interest based on the OTSU method to obtain a tobacco scattering region of the tobacco image to be tested;

[0155] The tobacco component module 105 is used to identify the tobacco type in the tobacco distribution area through the pre-trained SegFormer semantic segmentation model, and determine the tobacco components in the tobacco image to be tested based on the surface density ratio of each type of tobacco;

[0156] The tobacco structure module 106 is used to perform image enhancement processing on the tobacco scattering area, and to perform binary segmentation on the tobacco scattering area after image enhancement by the OTSU method to obtain the tobacco connected area of ​​the tobacco image to be tested, and to determine the tobacco structure in the tobacco image to be tested based on morphological analysis and measurement of the length of each tobacco connected area.

[0157] Example 3

[0158] As shown in the figure, an embodiment of the present invention provides a readable storage medium storing a computer program, wherein the computer program is called by a processor to implement:

[0159] The steps of the method for determining tobacco cut component and structure are as described in Example 1.

[0160] It should be noted that the computer-readable storage medium of the present embodiment may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0161] In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device, or device. In this embodiment, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable storage medium other than a computer-readable storage medium, which may send, propagate, or transmit a program used by or in combination with an instruction execution system, device, or device. The computer program contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0162] The computer readable storage medium can be written in one or more programming languages ​​or a combination thereof to execute the computer program of the present embodiment, and the programming language includes an object-oriented programming language, such as Python, Java, C++, and also includes a conventional procedural programming language, such as C language or similar programming languages. The program can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0163] In summary, the present invention segments and identifies the tobacco to be tested through the pre-trained SegFormer semantic segmentation model, thereby improving the accuracy of identifying various types of tobacco and stems, and realizing efficient determination of tobacco components and tobacco structure (whole and broken) proportions; the present invention collects various types of tobacco examples and vibration table background images for simulation, generates images that can better simulate the effect of the vibration table shaking the tobacco, realizes automatic generation and labeling of training samples, and can provide sufficient and effective training samples for the SegFormer semantic segmentation model, avoiding the overhead required for manual image labeling; the present invention can quickly collect tobacco images to be tested through edge devices such as portable image acquisition terminals, and use cloud data platforms to realize tobacco component analysis and tobacco structure determination, and can dynamically check tobacco quality without space and time restrictions, helping tobacco industry practitioners to achieve simple, fast and accurate cigarette quality detection, thereby providing effective assistance for tobacco quality detection.

[0164] The above description is only a preferred embodiment of the present invention. It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and the present invention can be implemented in other specific forms without departing from the spirit or basic features of the present invention. Therefore, no matter from which point of view, the embodiments should be regarded as exemplary and non-restrictive. The scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention.

Claims

1. A method for determining tobacco components and structures based on a deep semantic segmentation model, characterized in that: The following steps are involved: S1: Acquire the image of the tobacco to be tested; S2: preprocessing the tobacco image to be tested to obtain a preprocessed tobacco image to be tested; S3: extracting a region of interest from the preprocessed tobacco image to be tested, and performing matrix correction on the region of interest; S4: Binarization segmentation is performed on the corrected region of interest based on the OTSU method to obtain the tobacco scattering area of ​​the tobacco image to be tested; S5: Based on the pre-trained SegFormer semantic segmentation model, the tobacco type is identified in the tobacco scattering area, and based on the surface density ratio of each type of tobacco, the tobacco components in the tobacco image to be tested are determined; S6: Perform image enhancement processing on the tobacco scattering area, perform binary segmentation on the tobacco scattering area after image enhancement by the OTSU method, obtain the tobacco connected area of ​​the tobacco image to be tested, and determine the tobacco structure in the tobacco image to be tested based on morphological analysis and measurement of the length of each tobacco connected area.

2. The method according to claim 1, characterized in that The S1 comprises the following specific steps: Place the tobacco to be tested on a vibration table; After the tobacco to be tested is dispersed by a vibration table, the dispersed tobacco to be tested is compacted and flattened by using a transparent material; Collecting images of tobacco to be tested; The shredded tobacco image to be tested includes a shredded tobacco image of mixed shredded tobacco formed by mixing at least two of slices, shredded stems, shredded leaves, expanded shredded leaves and shredded stems.

3. The method according to claim 1, characterized in that In S2, the specific steps of preprocessing the tobacco image to be tested are: S210: grayscale conversion is performed on the tobacco image to be tested, and the image size is reduced by downsampling operation; S220: performing pixel-by-pixel subtraction of the downsampled image to obtain highlight pixels in the image, and performing binary segmentation of the highlight pixels using the OTSU method to obtain white connected areas; S230: Perform straight line detection on the downsampled image through Hough transform processing, and retain straight lines close to the horizontal direction and close to the vertical direction.

4. The method according to claim 3, characterized in that The S3 comprises the following specific steps: S310: Obtain a set of rectangles by exhaustively enumerating rectangles formed by a pair of horizontal straight lines and a pair of vertical straight lines; S320: extracting a rectangle having the largest proportion of white connected areas from the rectangular set to obtain a region of interest of the tobacco image to be tested; S330: Based on the affine transformation model, rectangular correction is performed on the region of interest of the tobacco image to be tested.

5. The method according to claim 1, characterized in that The S5 comprises the following specific steps: S510: Based on the pre-trained SegFormer semantic segmentation model, identify the stems and types of tobacco in the tobacco scattering area, and obtain the areas of the stems and the corresponding types of tobacco; S520: Obtaining the surface density ratio of the stems and various types of shredded tobacco; S530: Calculate the proportion of tobacco components and the stem rate in the tobacco image to be tested according to the area and surface density ratio of the stems and the corresponding types of tobacco.

6. The method according to claims 1-5, characterized in that: In S5, the specific steps of training the SegFormer semantic segmentation model based on the pre-training include: Build the SegFormer semantic segmentation model and modify the output category of the SegFormer semantic segmentation model to the tobacco component category; Collect various tobacco shreds, stems and blank vibration table images to obtain a sample image set; The images in the sample image set are simulated to generate a training image set; Based on the training image set and the cross entropy loss function, the modified SegFormer model is iteratively trained to obtain the trained SegFormer semantic segmentation model.

7. The method according to claim 6, characterized in that The generating of the training data set after simulating the acquired images specifically includes: Perform image segmentation on the images in the sample image set, and extract each tobacco strand and stem in the image; Before the tobacco is superimposed on the background image, a completely black image with the same size as the background image is generated as a true value image; the background image is a blank vibration table image; Each type of tobacco and stem is randomly selected and superimposed on the background image, and the centroid position and rotation angle of each tobacco and stem are randomly generated with uniform distribution during superposition; According to the generated centroid position and rotation angle, corresponding color marks are generated on the truth map according to the category of the stem and each tobacco strip with the same centroid position and rotation angle.

8. The method according to claim 1, characterized in that The S6 comprises the following specific steps: S610: for the tobacco scattering area of ​​the tobacco scattering image to be tested, a Gaussian filter is used to smooth the area to eliminate the edge shadow interference of the tobacco scattering area; then, the tobacco scattering is filtered out by a morphological closing operation to obtain a background image of the tobacco scattering area, and the background image is subtracted from the original scattering area image to obtain a difference image; S620: using the OTSU method to perform binary segmentation on the difference image to obtain a tobacco connected region of the tobacco image to be tested; S630: Extract the tobacco skeleton in each tobacco connected area based on a morphological method, and calculate the tobacco length according to the length of the tobacco skeleton, as shown in the following formula: Wherein, Ls is the physical length of tobacco, ls is the pixel length of tobacco; Lm is the physical length of the vibration table surface, lm is the pixel length of the vibration table surface; The skeleton length is the pixel length of the tobacco; S640: Determine the structural category of the tobacco according to the preset screening length threshold T, as shown in the following formula: S650: Counting the area ratio of whole shreds to broken shreds in all shredded tobacco, and determining the shredded tobacco structure in the shredded tobacco image to be tested.

9. A tobacco component and structure determination system based on a deep semantic segmentation model, characterized in that: include: An image acquisition module is used to acquire the image of the tobacco to be tested; An image preprocessing module is used to preprocess the tobacco image to be tested to obtain a preprocessed tobacco image to be tested; An image extraction module is used to extract the region of interest of the pre-processed tobacco image to be tested, and perform matrix correction on the region of interest; An image segmentation module is used to perform binary segmentation on the corrected region of interest based on the OTSU method to obtain the tobacco scattering area of ​​the tobacco image to be tested; A tobacco component module, for identifying tobacco types in the tobacco distribution area by using a pre-trained SegFormer semantic segmentation model, and determining tobacco components in the tobacco image to be tested based on the surface density ratio of each type of tobacco; The tobacco structure module is used to perform image enhancement processing on the tobacco scattering area, perform binary segmentation on the tobacco scattering area after image enhancement by the OTSU method, obtain the tobacco connected area of ​​the tobacco image to be tested, and determine the tobacco structure in the tobacco image to be tested based on morphological analysis and measurement of the length of each tobacco connected area.

10. A readable storage medium, characterized in that: A computer program is stored, which is called by a processor to implement: The steps of the method for determining tobacco components and structure according to any one of claims 1 to 8.

Citation Information

Cited By

  • Tobacco material detection method and system, computer system and storage medium

    CN121475004A