A method for measuring the width of tobacco based on skeleton direction adaptation

CN122841306APending Publication Date: 2026-09-29SHANGHAI MICRO VISION TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202610987232.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-03
Publication Date
2026-09-29

AI Technical Summary

Technical Problem

[0018]针对上述现有的测量烟丝宽度所存在的方向不确定、对称性假设过强、分支处理能力不足、统计信息单一等技术问题,本发明提供了一种基于骨架方向自适应的烟丝宽度测量方法

Benefits of technology

[0100](1)测量精度显著提高

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122841306A_ABST
    Figure CN122841306A_ABST
Patent Text Reader

Abstract

This invention provides a method for measuring tobacco width based on skeleton orientation adaptation. First, a color image of a tobacco sample is acquired, then preprocessed to obtain a binary image. The binary image undergoes region segmentation and edge filling. The filled image is then subjected to skeleton extraction and adaptive trimming to obtain an optimized skeleton. Next, local orientation adaptive estimation is performed on the measurement points on the skeleton to obtain the tangential direction of the measurement points. Based on the tangential direction of the measurement points, the normal direction of the measurement points is obtained, and the width is measured by projecting the normal direction. Finally, the measured widths are statistically analyzed to obtain a weighted average of the widths of the measurement points. By using PCA adaptive estimation to determine the local orientation of the skeleton points, the width measurement is ensured to be performed along the true normal direction of the tobacco, significantly improving measurement accuracy. Furthermore, the use of a normal projection coefficient matching algorithm to find symmetrical boundary points along the normal direction significantly enhances the anti-interference capability of this measurement method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of tobacco processing quality testing technology, specifically to a method for measuring tobacco shred width based on adaptive skeleton orientation. Background Technology

[0002] Tobacco shred width is one of the key quality indicators in cigarette processing. The shred width directly affects the cigarette's combustion performance, draw resistance stability, smoke emission, and sensory quality. Shreds that are too wide tend to result in cigarettes with empty ends and poor combustibility; shreds that are too thin reduce the yield and increase production costs. Therefore, accurately measuring tobacco shred width is crucial for process control and product quality assurance.

[0003] Currently, methods for measuring tobacco width are mainly classified into the following categories:

[0004] (a) Traditional manual measurement method

[0005] The method involves manually measuring each tobacco strand individually using a projector and reading the width using a ruler in the eyepiece. This method has several significant drawbacks: first, it is extremely inefficient, measuring only 20-30 strands per hour, which is insufficient for batch testing; second, the sampling is highly subjective, with operators often selecting only regularly shaped tobacco strands with intact edges; and third, it only measures the width of a specific location within the tobacco strand, failing to reflect the overall width distribution characteristics.

[0006] (II) Measurement method based on minimum bounding rectangle

[0007] This method calculates the minimum bounding rectangle of the tobacco shred profile and uses the width of the shorter side of the rectangle as the tobacco shred width. However, this method idealizes the tobacco shreds into a rectangular shape, ignoring the actual irregular shape of the tobacco shreds, resulting in a larger measurement error for curved or forked tobacco shreds.

[0008] (III) Measurement method based on skeleton and contour distance

[0009] For example, Chinese patent application CN115979134A, entitled "A Method for Measuring Tobacco Width Based on Machine Vision," first extracts the tobacco skeleton, then calculates the Euclidean distance between the skeleton points and all contour points, takes the minimum distance value as the radius of that point, and uses twice that radius as the diameter for width measurement. This method has the following technical drawbacks:

[0010] Directional uncertainty: The direction of the line connecting the minimum distance point and the skeleton point is not necessarily consistent with the direction of the tobacco shred normal. Especially when there are serrations or local protrusions on the edge of the tobacco shred, the minimum distance point often falls on the protruding position, resulting in a systematic underestimation of the width measurement value.

[0011] The symmetry assumption is too strong: This method implicitly assumes that the outline of the tobacco shreds is completely symmetrical about the skeleton point, but in reality, due to the squeezing and curling during the cutting process, the left and right outlines of the tobacco shreds are often asymmetrically deformed.

[0012] Branching is simple: For tobacco shreds with branching (caused by tobacco stems or leaf veins), this method does not provide an effective strategy for discarding or removing skeletal branches.

[0013] (iv) Measurement method based on variable diameter circle

[0014] For example, the Chinese patent application CN112330663A, entitled "Method for Detecting Tobacco Shred Width Based on a Variable Diameter Circle," involves drawing a variable diameter circle from one end of the skeleton with a certain step size. When the circle is tangent to the contour, the diameter is taken as the width. This method has the following problems in practice: first, the tangency condition is difficult to determine accurately and is greatly affected by image discretization; second, it requires a preset initial width value, which introduces subjectivity; and third, the computational efficiency is low.

[0015] (v) Method based on candidate box symmetry determination

[0016] For example, the Chinese patent application CN110345874A, entitled "Method for Measuring Tobacco Width Based on Machine Vision," sets candidate boxes on a tobacco image and calculates the width through symmetrical measurement. This method requires a preset width threshold for candidate box filtering, and parameters need to be adjusted for tobacco of different widths, resulting in limited generalization ability.

[0017] In summary, existing technologies generally suffer from problems such as uncertain direction, overly strong symmetry assumptions, insufficient branch processing capabilities, and limited statistical information. There is an urgent need for a measurement method that can adapt to the local morphology of tobacco shreds, accurately measure width, and has comprehensive statistical analysis capabilities. Summary of the Invention

[0018] To address the technical problems of existing methods for measuring tobacco width, such as directional uncertainty, excessive symmetry assumptions, insufficient branch processing capabilities, and limited statistical information, this invention provides a tobacco width measurement method based on adaptive skeleton orientation.

[0019] The tobacco width measurement method based on skeleton orientation adaptation provided by this invention includes the following steps:

[0020] Step 1: Place the tobacco sample on the stage and obtain an image of the tobacco sample;

[0021] Step 2: Preprocess the image from Step 1 to obtain a binary image.

[0022] Step 3: Segment the tobacco region in the binary image from Step 2 and fill the edges;

[0023] Step 4: Extract the skeleton and adaptively trim it on the filled binary image to obtain the optimized skeleton;

[0024] Step 5: Perform local orientation adaptive estimation on the measurement points on the optimized skeleton to obtain the tangential direction of the measurement points;

[0025] Step 6: Obtain the normal direction of the measurement point based on the tangential direction of the measurement point, and measure the width based on the projection of the normal direction;

[0026] Step 7: Perform statistical analysis on the measured widths to obtain the weighted average of the widths at the measurement points.

[0027] Furthermore, the tobacco width measurement method based on skeleton orientation adaptation provided by the present invention may also have the following features: In step two, the preprocessing of the tobacco sample image includes the following steps: converting the RGB image of the tobacco sample into a single-channel grayscale image; using global threshold segmentation to convert the grayscale image into a binary image, wherein the tobacco area is the foreground and the background is black; using a closing operation to fill the tiny holes inside the tobacco, and using a hole filling algorithm to remove noise areas with an area smaller than a preset threshold.

[0028] Furthermore, the tobacco width measurement method based on skeleton orientation adaptation provided by the present invention may also have the following features: In step three, the region segmentation and edge filling of the binary image includes the following steps: using connected component analysis or contour detection algorithm, extracting the independent ROI of each tobacco shred from the binary image, recording the position information of its minimum bounding rectangle for each ROI; and extending the boundary by 2 pixels around the image, with a filling value of 0.

[0029] Furthermore, the tobacco width measurement method based on skeleton orientation adaptation provided by the present invention may also have the following features: In step four, the skeleton extraction and adaptive trimming of the filled binary image includes the following steps: skeleton extraction, extracting the tobacco skeleton from the filled binary image using the median transformation method, and calculating the distance value from each pixel to the nearest boundary; skeleton graph structure construction; skeleton trimming based on reconstruction loss.

[0030] Furthermore, the tobacco width measurement method based on skeleton orientation adaptation provided by this invention may also have the following features: the skeleton extraction method is as follows:

[0031] Let the binary image be I, its foreground region be S, and its background region be its complement. For any pixel p in the foreground, its distance transform value is defined as:

[0032]

[0033] In the formula, The Euclidean distance function is used, and the skeleton point is defined as: the set of pixels corresponding to at least two nearest boundary points in different directions in the distance transformation graph;

[0034] The skeleton diagram structure is constructed as follows:

[0035] Represent the skeleton as an undirected graph ,

[0036] In the formula, It is a set of nodes, including skeleton branch points (degree ≥ 3) and endpoints (degree = 1). Let be the set of edges, representing the skeleton paths between nodes.

[0037] Furthermore, the tobacco width measurement method based on skeleton orientation adaptation provided by this invention may also have the following feature: the skeleton trimming method based on reconstruction loss is as follows:

[0038] For any skeleton edge and its contained skeleton point sequence The steps for calculating reconstruction loss are as follows:

[0039] Initialize a zero-based matrix of the same size as the original tobacco region. ;

[0040] For each point in the skeleton point sequence Centered on this point, the distance transformation value Generate circular structuring elements with radius , and accumulate them into the reconstruction matrix. middle:

[0041]

[0042] In the formula, Indicates Centered on, with radius The circular area

[0043] Calculate reconstruction loss :

[0044]

[0045] In the formula, This represents the XOR operation. The image is a binary image of the original tobacco region, and the loss value is... This reflects the incremental contribution of this skeletal branch to the reconstruction of the complete tobacco morphology.

[0046] like Less than the preset threshold If the branch is found to be redundant, it is removed from the skeleton graph and the reconstruction matrix is ​​then removed. Subtract the contribution of that branch from the middle.

[0047] Repeat the above process until no more branches are deleted, resulting in the optimized skeleton.

[0048] Furthermore, the tobacco width measurement method based on skeleton orientation adaptation provided by the present invention may also have the following features: In step five, the local orientation adaptive estimation of the measurement points on the optimized skeleton includes the following steps:

[0049] Let the points of the skeleton to be measured be... .definition Let be the side length (in pixels) of the square's neighborhood, initially set to . ,

[0050] by Centered on a square region of side length L, extract the coordinates of all skeleton points to form a point set. ,

[0051] Principal component analysis is performed on the point set S(L) using the following steps:

[0052] Calculate the geometric center of the point set

[0053] Constructing the covariance matrix

[0054] Perform eigenvalue decomposition on the covariance matrix to obtain eigenvalues. and its corresponding eigenvectors and ,

[0055] Among them, the eigenvector corresponding to the largest eigenvalue This refers to the principal direction of the local skeleton point set, representing the tangential direction of the tobacco shreds in that region.

[0056] Define direction angle The range of values ​​is ,

[0057] Calculate the relative rate of change of orientation angles for two adjacent neighborhood sizes:

[0058]

[0059] In the formula, Small positive numbers (e.g.) ),

[0060] like < Convergence threshold (recommend Right now If the current iteration count is greater than 1, then the direction estimation is considered to have converged, and the current direction angle is taken. As the final tangential direction.

[0061] Furthermore, the tobacco width measurement method based on skeleton orientation adaptation provided by the present invention may also have the following features: In step six, the width measurement of the measurement point includes the following steps:

[0062] Centered on the skeleton point P0 to be tested, with a radius of... Using the search radius, select boundary points located within this circular region to form a local boundary point set. .in for Distance transformation value at that location,

[0063] Convert local boundary points to coordinates relative to skeleton points:

[0064]

[0065] Calculate the projection coefficients of each relative coordinate vector in the normal direction:

[0066]

[0067] In the formula, · represents the vector dot product operation, and the projection coefficient is... The sign indicates whether the boundary point is located in the positive or negative direction of the normal.

[0068] Filter the boundary points with the largest projection coefficients in both the positive and negative directions of the normal:

[0069]

[0070] Let the coordinates of the two points be respectively and The candidate width is then:

[0071]

[0072] To ensure that the measurement line segment actually passes through the interior of the tobacco and does not run along the boundary, and The connection is validated, and the validation steps are as follows:

[0073] Generate a sequence of all pixels between two points. ;

[0074] examine The number of pixels located outside the foreground area of ​​the tobacco is used to determine the validity of the connection. If all pixels are located within the foreground area, the connection is considered valid.

[0075] If more than two pixels fall outside the foreground area, it indicates that the connection may cross the background area or the tobacco shred recess. In this case, a dynamic threshold adjustment strategy is used: the projection coefficient screening threshold is gradually reduced from the maximum value, and matching is performed again.

[0076] Dynamic adjustment formula: ,

[0077] In the formula, λ decreases from 0.999 to 0.990 with a step size of 0.001. For each value, the candidate point pairs are recalculated until the connection validity check passes.

[0078] The Euclidean distance that passed the validity check The width measurement value of this skeleton point is recorded in the width sequence.

[0079] Furthermore, the tobacco width measurement method based on skeleton orientation adaptation provided by the present invention may also have the following features: In step seven, the statistical analysis of the measured width includes the following steps:

[0080] Use a standard reference object of known size (such as a calibration ruler) to calibrate the pixel size against the actual size. Establish a linear transformation model:

[0081]

[0082] In the formula: Width is measured in pixels. The actual width is in millimeters. For calibration coefficients, For the intercept compensation term,

[0083] Remove invalid values ​​from the width sequence, as well as outliers that significantly deviate from the normal range.

[0084] The representative width of the tobacco shreds is calculated using a weighted average method over the intervals, as follows:

[0085] Let the width sequence be ,

[0086] In the formula, The total number of valid measurement points,

[0087] Determine the boundaries of the statistical interval:

[0088]

[0089]

[0090] by As the interval, divide the interval [ , Divided into A small interval, among which

[0091] Constructing histogram statistics:

[0092] No. The range of each interval is

[0093] Statistics fall into the first Number of measurement points in each interval

[0094] Calculate the weights for each interval:

[0095]

[0096] Assign weights to each measurement point: If the measurement point If it falls into the j-th interval, then its weight is...

[0097] Calculate the weighted average:

[0098] .

[0099] The function and effects of this invention:

[0100] (1) Measurement accuracy is significantly improved

[0101] By adaptively determining the local orientation of the skeleton points using PCA, the width measurement is ensured to be performed along the true normal direction of the tobacco shreds. Theoretical analysis and experimental verification show that this measurement method reduces the measurement error in the bent tobacco shred region by approximately 60% compared to the minimum distance method.

[0102] (2) The anti-interference ability is significantly enhanced.

[0103] A normal projection coefficient matching algorithm is employed to find symmetrical boundary points along the normal direction. Combined with connection validity verification, this effectively resists interference from serrated edges and local protrusions in tobacco shreds. For shredded tobacco with high edge roughness, the standard deviation of the measurement results is reduced by approximately 40% compared to existing methods.

[0104] (3) More intelligent skeleton processing

[0105] The skeleton pruning algorithm based on reconstruction loss uses the importance of skeleton branches to the overall structure as the criterion for selection. Compared with the simple length threshold method, it is more scientific and reasonable, and can effectively distinguish between true bifurcation caused by tobacco stems and false bifurcation caused by noise.

[0106] (4) The statistical methods are more scientific

[0107] The interval weighted average method is used to process the width data, avoiding statistical bias caused by uneven sampling density of skeleton points. This method can more realistically reflect the concentration trend of tobacco width and improves the correlation with manual visual assessment by about 25%.

[0108] (5) Wider applicability

[0109] This method for measuring tobacco width can uniformly handle various forms of tobacco, such as regular tobacco, forked tobacco, curled tobacco, and serrated edge tobacco, without requiring switching algorithms or adjusting parameters for different forms.

[0110] (6) Information output is more comprehensive

[0111] This method for measuring tobacco shred width can simultaneously output the mean, standard deviation, quantiles, histogram, and kernel density curve of the width distribution, providing rich statistical information for process quality analysis and helping to pinpoint the root cause of problems in the shredding equipment. Attached Figure Description

[0112] Figure 1 This is a flowchart of a tobacco width measurement method based on skeleton orientation adaptation in an embodiment of the present invention;

[0113] Figure 2 This is a schematic diagram of PCA direction adaptive estimation in an embodiment of the present invention. Detailed Implementation

[0114] To make the technical means, creative features, objectives and effects of this invention easier to understand, the following embodiments, in conjunction with the accompanying drawings, will specifically illustrate the technical solution of this invention.

[0115] like Figure 1 As shown, the tobacco width measurement method based on skeleton orientation adaptation includes the following steps:

[0116] Step 1: Disperse the tobacco sample evenly on a white stage, flatten it with a transparent glass plate to ensure that the tobacco is flat and in the same focal plane, and use an industrial camera equipped with a backlight to vertically capture a color image of the tobacco.

[0117] Step 2: Perform the following preprocessing steps on the acquired color images:

[0118] (1) Grayscale conversion: Converting an RGB image into a single-channel grayscale image;

[0119] (2) Binarization: Global thresholding is used to convert the grayscale image into a binary image, where the tobacco area is the foreground (white) and the background is black;

[0120] (3) Morphological filtering: The closing operation is used to fill the tiny holes inside the tobacco, and the hole filling algorithm is used to remove noise areas with an area smaller than a preset threshold (such as 4000 pixels);

[0121] Step 3: Using connected component analysis or contour detection algorithms, extract the independent ROI (Region of Interest) for each tobacco shred from the binary image. For each ROI, record the position information of its minimum bounding rectangle for subsequent annotation on the original image.

[0122] To eliminate the impact of edge effects on skeleton extraction, edge padding is performed on each ROI: the boundary is extended by 2 pixels around the image, and the padding value is 0 (background).

[0123] Step 4: For the filled binary image, use the Medial Axis Transform method to extract the tobacco skeleton, and at the same time calculate the distance value of each pixel to the nearest boundary.

[0124] The specific method is as follows:

[0125] Let the binary image be I, its foreground region be S, and its background region be its complement. For any pixel p in the foreground, its distance transform value is defined as:

[0126]

[0127] in The distance function is Euclidean. A skeleton point is defined as the set of pixels in the distance-transformed graph that correspond to at least two nearest boundary points in different directions.

[0128] Skeleton diagram structure construction

[0129] Represent the skeleton as an undirected graph ,

[0130] In the formula: It is a set of nodes, including skeleton branch points (degree ≥ 3) and endpoints (degree = 1). Let be the set of edges, representing the skeleton paths between nodes.

[0131] Skeleton Pruning Based on Reconstruction Loss

[0132] Residual stems or veins in tobacco shreds often result in unnecessary skeletal branches. To remove branches that contribute less, the contribution of each skeletal branch to the reconstruction of the complete tobacco shred morphology is evaluated. A skeletal pruning method based on reconstruction loss is adopted, with the following specific steps:

[0133] For any skeleton edge and its contained skeleton point sequence The steps for calculating reconstruction loss are as follows:

[0134] (1) Initialize a zero matrix with the same size as the original tobacco region. ;

[0135] (2) For each point in the skeleton point sequence Centered on this point, the distance transformation value Generate circular structuring elements with radius , and accumulate them into the reconstruction matrix. middle:

[0136]

[0137] in Indicates Centered on, with radius A circular area.

[0138] (3) Calculate reconstruction loss :

[0139]

[0140] in This represents the XOR operation. This is a binary image of the original tobacco shred region. Loss value. This reflects the incremental contribution of this skeletal branch to the reconstruction of the complete tobacco morphology.

[0141] like Less than the preset threshold (Recommended value is 500), then the branch is determined to be a redundant branch, removed from the skeleton diagram, and removed from the reconstruction matrix. Subtract the contribution of that branch from the middle.

[0142] Repeat the above process until no more branches are deleted, resulting in the optimized skeleton.

[0143] Step 5: For each measurement point on the optimized frame, the tangential direction of the tobacco at that point needs to be accurately estimated, such as... Figure 2 As shown, the adaptive estimation is performed using the PCA direction estimation method with adaptive expanded neighborhood. The specific steps are as follows:

[0144] Let the points of the skeleton to be measured be... .definition Let be the side length (in pixels) of the square's neighborhood, initially set to . .

[0145] Local point set extraction

[0146] by Centered on a square region of side length L, extract the coordinates of all skeleton points to form a point set. .

[0147] PCA direction calculation

[0148] Principal component analysis was performed on the point set S(L):

[0149] (1) Calculate the geometric center of the point set.

[0150] (2) Construct the covariance matrix

[0151] (3) Perform eigenvalue decomposition on the covariance matrix to obtain the eigenvalues. and its corresponding eigenvectors and .

[0152] In the formula, the eigenvector corresponding to the largest eigenvalue is... This refers to the main direction of the local skeleton point set, which represents the tangential direction of the tobacco shreds in that region.

[0153] Define direction angle The range of values ​​is .

[0154] Adaptive convergence judgment

[0155] Calculate the relative rate of change of orientation angles for two adjacent neighborhood sizes:

[0156]

[0157] in Small positive numbers (e.g.) ), to prevent division by zero errors.

[0158] like < Convergence threshold (recommend Right now If the current iteration count is greater than 1, then the direction estimation is considered to have converged, and the current direction angle is taken. As the final tangential direction.

[0159] Otherwise, increase the neighborhood edge length by 2, i.e. Repeat the three steps described above: local point set extraction, PCA direction calculation, and adaptive convergence judgment.

[0160] Boundary processing

[0161] If the neighborhood expands beyond the image boundary, the largest effective region within the boundary is taken, and the convergence threshold is lowered to continue the calculation.

[0162] Step Six: Obtain the tangential direction at the skeleton point. Backwards, in the direction of the normal It can be rotated The corresponding boundary point pairs are obtained using the normal projection matching method. The specific steps are as follows:

[0163] Boundary point set acquisition

[0164] The Canny edge detection operator is used to extract the precise contour boundary of the tobacco shreds, resulting in a set of boundary points. At the same time, the connected component labels of each tobacco region are recorded to ensure that boundary matching is performed within the same connected component.

[0165] Local boundary filtering

[0166] Centered on the skeleton point P0 to be tested, with a radius of... Using the search radius, select boundary points located within this circular region to form a local boundary point set. .in for The distance transformation value at that location.

[0167] Relative coordinate transformation

[0168] Convert local boundary points to coordinates relative to skeleton points:

[0169]

[0170] Calculation of normal projection coefficients

[0171] Calculate the projection coefficients of each relative coordinate vector in the normal direction:

[0172]

[0173] In the formula, · represents the vector dot product operation. Projection coefficients. The positive or negative sign indicates whether the boundary point is located in the positive or negative direction of the normal.

[0174] Symmetric boundary point matching

[0175] Filter the boundary points with the largest projection coefficients in both the positive and negative directions of the normal:

[0176] (i.e., the point with the largest absolute value in the negative direction)

[0177] Let the coordinates of the two points be respectively and The candidate width is:

[0178]

[0179] Connection validity check

[0180] To ensure that the measurement line segment actually passes through the interior of the tobacco and does not run along the boundary, and The connection is validated for validity. The specific validation method is as follows:

[0181] (1) Use the Bresenham line generation algorithm to generate a sequence of all pixels between two points. ;

[0182] (2) Inspection The number of pixels located outside the foreground area of ​​the tobacco. If all pixels are located within the foreground area (slight errors at the endpoints are allowed), the connection is considered valid.

[0183] (3) If more than two pixels fall outside the foreground area, it means that the line may cross the background area or the tobacco shred recess. In this case, a dynamic threshold adjustment strategy is adopted: the projection coefficient screening threshold is gradually reduced from the maximum value and the matching is performed again.

[0184] Dynamic adjustment formula: Where λ decreases from 0.999 to 0.990, with a step size of 0.001. For each value, the candidate point pair is recalculated until the connection validity check passes.

[0185] Width Record

[0186] The Euclidean distance that passed the validity check The width measurement value of this skeleton point is recorded in the width sequence.

[0187] Step 7: Perform statistical analysis on the measured widths. The specific steps are as follows:

[0188] Width calibration

[0189] Use a standard reference object of known size (such as a calibration ruler) to calibrate the pixel size against the actual size. Establish a linear transformation model:

[0190]

[0191] In the formula: Width is measured in pixels. The actual width is in millimeters. The calibration factor is (pixels / mm). This is the intercept compensation term.

[0192] Outlier filtering

[0193] Remove invalid values ​​(such as zero or negative values) from the width sequence, as well as outliers that deviate significantly from the normal range (such as measurements that exceed the preset threshold range).

[0194] Interval weighted average method

[0195] The representative width of the tobacco shreds is calculated using an interval weighted average method to avoid statistical bias caused by uneven distribution of skeleton points (such as dense skeleton points in curved areas). The specific method is as follows:

[0196] Let the width sequence be ,in This represents the total number of valid measurement points.

[0197] (1) Determine the boundaries of the statistical interval:

[0198]

[0199]

[0200] by As the interval, divide the interval [ , Divided into A small interval, among which ,

[0201] (2) Constructing histogram statistics:

[0202] No. The range of each interval is

[0203] Statistics fall into the first Number of measurement points in each interval

[0204] (3) Calculate the weight (frequency) of each interval:

[0205]

[0206] (4) Assign weights to each measurement point: If the measurement point If it falls into the j-th interval, then its weight is... ,

[0207] (5) Calculate the weighted average:

[0208] .

[0209] The tobacco width measurement method described in the above embodiments utilizes local PCA direction adaptive estimation, projection coefficient symmetric boundary matching, reconstruction loss skeleton optimization, and interval weighted average statistics to achieve accurate, stable, and comprehensive measurement of tobacco width.

[0210] The above embodiments are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. For those skilled in the art, the present invention can have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A method for measuring tobacco shred width based on adaptive skeleton orientation, characterized in that, Includes the following steps: Step 1: Place the tobacco sample on the stage and obtain an image of the tobacco sample; Step 2: Preprocess the image from Step 1 to obtain a binary image. Step 3: Segment the tobacco region in the binary image from Step 2 and fill the edges; Step 4: Extract the skeleton and adaptively trim it on the filled binary image to obtain the optimized skeleton; Step 5: Perform local orientation adaptive estimation on the measurement points on the optimized skeleton to obtain the tangential direction of the measurement points; Step 6: Obtain the normal direction of the measurement point based on the tangential direction of the measurement point, and measure the width based on the projection of the normal direction; Step 7: Perform statistical analysis on the measured widths to obtain the weighted average of the widths at the measurement points.

2. The tobacco width measurement method based on skeleton orientation adaptation as described in claim 1, characterized in that: In step two, the preprocessing of the tobacco sample image includes the following steps: The RGB image of the tobacco sample was converted into a single-channel grayscale image. Global thresholding is used to convert the grayscale image into a binary image, where the tobacco area is the foreground and the background is black. The algorithm employs a closing operation to fill the tiny pores inside the tobacco shreds and a pore-filling algorithm to remove noise areas with an area smaller than a preset threshold.

3. The tobacco width measurement method based on skeleton orientation adaptation as described in claim 1, characterized in that: In step three, the region segmentation and edge filling of the binary image include the following steps: Connectivity analysis or contour detection algorithms are used to extract independent Regions of Interest (ROIs) for each tobacco shred from the binary image. For each ROI, the position information of its minimum bounding rectangle is recorded. It also extends the border by 2 pixels around the image, with a padding value of 0.

4. The tobacco width measurement method based on skeleton orientation adaptation as described in claim 1, characterized in that: In step four, the skeleton extraction and adaptive trimming of the filled binary image includes the following steps: Skeleton extraction: For the filled binary image, the median transformation method is used to extract the tobacco skeleton, and the distance value from each pixel to the nearest boundary is calculated at the same time. Skeleton diagram structure construction; Skeleton pruning based on reconstruction loss.

5. The tobacco width measurement method based on skeleton orientation adaptation as described in claim 4, characterized in that: The skeleton extraction method is as follows: Let the binary image be I, its foreground region be S, and its background region be its complement. For any pixel p in the foreground, its distance transform value is defined as: In the formula, The Euclidean distance function is used, and the skeleton point is defined as: the set of pixels corresponding to at least two nearest boundary points in different directions in the distance transformation graph; The skeleton diagram structure is constructed as follows: Represent the skeleton as an undirected graph , In the formula, It is a set of nodes, including skeleton branch points (degree ≥ 3) and endpoints (degree = 1). Let be the set of edges, representing the skeleton paths between nodes.

6. The tobacco width measurement method based on skeleton orientation adaptation as described in claim 4, characterized in that: The skeleton pruning method based on reconstruction loss is as follows: For any skeleton edge and its contained skeleton point sequence The steps for calculating reconstruction loss are as follows: Initialize a zero-based matrix of the same size as the original tobacco region. ; For each point in the skeleton point sequence Centered on this point, the distance transformation value Generate circular structuring elements with radius , and accumulate them into the reconstruction matrix. middle: In the formula, Indicated by Centered on, with radius The circular area Calculate reconstruction loss : In the formula, This represents the XOR operation. The image is a binary image of the original tobacco region, and the loss value is... This reflects the incremental contribution of this skeletal branch to the reconstruction of the complete tobacco morphology. like Less than the preset threshold If the branch is found to be redundant, it is removed from the skeleton graph and the reconstruction matrix is ​​then removed. Subtract the contribution of that branch from the middle. Repeat the above process until no more branches are deleted, resulting in the optimized skeleton.

7. The tobacco width measurement method based on skeleton orientation adaptation as described in claim 1, characterized in that: In step five, the local orientation adaptive estimation of the measurement points on the optimized skeleton includes the following steps: Let the points of the skeleton to be measured be... .definition Let be the side length (in pixels) of the square's neighborhood, initially set to . , by Centered on a square region of side length L, extract the coordinates of all skeleton points to form a point set. , Principal component analysis is performed on the point set S(L) using the following steps: Calculate the geometric center of the point set Constructing the covariance matrix Perform eigenvalue decomposition on the covariance matrix to obtain eigenvalues. and its corresponding eigenvectors and , Among them, the eigenvector corresponding to the largest eigenvalue This refers to the principal direction of the local skeleton point set, representing the tangential direction of the tobacco shreds in that region. Define direction angle The range of values ​​is , Calculate the relative rate of change of orientation angles for two adjacent neighborhood sizes: In the formula, Small positive numbers (e.g.) ), like < Convergence threshold (recommend Right now If the current iteration count is greater than 1, then the direction estimation is considered to have converged, and the current direction angle is taken. As the final tangential direction.

8. The tobacco width measurement method based on skeleton orientation adaptation as described in claim 1, characterized in that: In step six, the width measurement of the measurement point includes the following steps: Centered on the skeleton point P0 to be tested, with a radius of... Using the search radius, select boundary points located within this circular region to form a local boundary point set. .in for Distance transformation value at that location, Convert local boundary points to coordinates relative to skeleton points: Calculate the projection coefficients of each relative coordinate vector in the normal direction: In the formula, · represents the vector dot product operation, and the projection coefficient is... The sign indicates whether the boundary point is located in the positive or negative direction of the normal. Filter the boundary points with the largest projection coefficients in both the positive and negative directions of the normal: Let the coordinates of the two points be respectively and The candidate width is: To ensure that the measurement line segment actually passes through the interior of the tobacco and does not run along the boundary, and The connection is validated, and the validation steps are as follows: Generate a sequence of all pixels between two points. ; examine The number of pixels located outside the foreground area of ​​the tobacco is used to determine the validity of the connection. If all pixels are located within the foreground area, the connection is considered valid. If more than two pixels fall outside the foreground area, it indicates that the connection may cross the background area or the tobacco shred recess. In this case, a dynamic threshold adjustment strategy is used: the projection coefficient screening threshold is gradually reduced from the maximum value, and matching is performed again. Dynamic adjustment formula: , In the formula, λ decreases from 0.999 to 0.990 with a step size of 0.

001. For each value, the candidate point pairs are recalculated until the connection validity check passes. The Euclidean distance that passed the validity check The width measurement value of this skeleton point is recorded in the width sequence.

9. The tobacco width measurement method based on skeleton orientation adaptation as described in claim 1, characterized in that, Also includes: In step seven, the statistical analysis of the measured width includes the following steps: Use a standard reference object of known size (such as a calibration ruler) to calibrate the pixel size against the actual size. Establish a linear transformation model: In the formula: Width is measured in pixels. The actual width is in millimeters. For calibration coefficients, For the intercept compensation term, Remove invalid values ​​from the width sequence, as well as outliers that significantly deviate from the normal range. The representative width of the tobacco shreds is calculated using a weighted average method over the intervals, as follows: Let the width sequence be , In the formula, The total number of valid measurement points, Determine the boundaries of the statistical interval: by As the interval, divide the interval [ , Divided into A small interval, among which Constructing histogram statistics: No. The range of each interval is Statistics fall into the first Number of measurement points in each interval Calculate the weights for each interval: Assign weights to each measurement point: If the measurement point If it falls into the j-th interval, then its weight is... Calculate the weighted average: .

Citation Information

Patent Citations

  • Novel method for measuring width of cut tobacco based on machine vision detection technology

    CN110345874A

  • Computer vision tobacco shred width detection method based on reducing circle

    CN112330663A

  • Tobacco shred width measuring method based on machine vision

    CN115979134A