#### Abstract

Cigarette filter rods are a kind of easily deformed and irregularly shaped parts, and the quality of cigarette filter rods is often measured by the filter rod roundness index, although they are affected by factors such as environment and humidity, which can affect the detection of filter rod roundness and show blurred images. For the detection of blurred filter rod image roundness, an improved active contour snake model algorithm is proposed. The experimental results show that in the analysis of the algorithm iteration number on the model performance, the model performance gradually leveled off at the iteration number of 200. Comparing the PR of the improved algorithm with the traditional snake algorithm with the balloon force snake algorithm, the accuracy and recall rates obtained were 0.803 and 0.798, respectively, which were greater than the other two algorithms; the error of the value of the residual under the improved snake algorithm was always smaller than the other algorithms, which indicated that the convergence effect of the improved snake algorithm on the error of filter bar roundness was better than the other experimental algorithms. The abovementioned results indicate that the improved snake algorithm has high feasibility and effectiveness in the application of filter bar roundness error detection and has a significant value.

#### 1. Introduction

The rapid development of the tobacco industry has intensified the market competition among various tobacco companies [1]. Tobacco product quality is one of the important ways for tobacco companies to improve their market competitiveness; tobacco companies need to secure the overall quality of tobacco to gain a competitive advantage in the market, and the quality of tobacco products produced on line is often measured by the roundness index of tobacco filter rods [2]. Studies of smoke generation methods have shown that the roundness of cigarette filter rods directly affects the quality of cigarettes when the roundness error of the rods exceeds national standards [3]. In order to solve the problem of roundness error of cigarette filter rods, the study combined the characteristics of fuzzy filter rod images and introduced the improved active contour snake model. The snake model is insensitive to the case of noise and contrast and can segment the target from the fuzzy complex background and effectively track the complex changes in the processing target [4]. It is now widely used in image processing fields such as image segmentation and object tracking [5]. Therefore, the study uses the snake model to detect the fuzzy filter rod images during the production process and uses it to monitor the roundness of cigarette filter rods on line and in real time to improve the quality of filter rod roundness, which is urgently needed to provide a feasible research study to explore the significance of measuring the roundness of cigarette filter rods.

#### 2. Related Works

The continuous development of the economy requires companies to produce higher and higher quality products and stricter production processes, which has prompted a large number of methods to detect product quality to be applied to drive the tobacco industry forward. Jin and Weng proposed an ACM algorithm driven by pre-fitting bias correction and optimized fuzzy c-mean (FCM) algorithm, which was demonstrated experimentally on real and synthetic images that the algorithm model can effectively segment images with severe grayscale inhomogeneities with better noise and initialization robustness, segmentation efficiency, and accuracy than most region-based models [6]. Pramanik et al. proposed an algorithm for active contour model segmentation of SRs in TBI to study the segmentation of suspicious regions in TBI for breast cancer identification, a particularly important and challenging problem, and experimentally showed that studying only SRs rather than the whole breast is more effective in distinguishing abnormal from normal breasts [7]. Tchoketch Kebir et al. proposed a complete and fully automated MRI brain tumor detection and segmentation method by using active contour, wavelet transform, etc., as an effective clinical aid, presenting fast, accurate, effective and fully automated results without any human intervention as well as prior knowledge in the training phase [8]. Qiu et al. team extracted the complete boundary of lung nodules by using an improved snake model and made full use of the algorithm to build maximum density based on the physician's diagnosis process of lung nodules projection model to construct a new neural network structure [9]. Guo et al. developed an automatic liver segmentation method based on a new framework that uses structured network results to define the external binding force of the activity contour model. The resulting integrated active contour model has the advantage of combining both high-level and low-level image information while enhancing contour smoothing [10].

Wang et al. used eQUEST and scenario analysis to simulate and calculate the energy consumption, energy saving potential, and energy consumption structure of 11 green industrial building projects in China's cigarette manufacturing industry and identified the problems in the operation of green workshops in cigarette industrial enterprises and proposed corresponding improvement measures that could more effectively help enterprises to meet the standards [11]. Aaron et al. compared the effects of unvaporized ECL and e-cigarette vapor condensate (ECVC) on the alveolar macrophage (AM) function. The inhibition of phagocytosis also suggested that users may be affected by impaired bacterial clearance, further validating the proinflammatory effects of vaping condensates on human alveolar macrophages [12]. Zhao et al. used inductively coupled plasma mass spectrometry to determine the concentrations of 14 metals in e-cigarette aerosols collected by droplet deposition and obtained the result that the concentrations of As, Cr, Cu, Mn, Ni, and Sb did not change significantly when the power was further increased from intermediate (40 W) to high (80 W) settings [13]. Halstead et al. developed and validated a simple, high-metal purity fluoropolymer trap to develop and validate reliable laboratory test methods, suitable aerosol generation, and trapping media for accurate determination of terminal aerosol metal release by using the trap [14]. Guo et al. used a recently developed highly sensitive mass spectrometry method to quantify AP sites by derivatization with O-(pyridin-3-yl-methyl)-hydroxylamine (PMOA). Moreover, there was no significant increase in AP sites in human lung and leukocyte DNA from smokers compared with nonsmokers [15].

In summary, in the context of the current economic boom, the production process and product quality in the tobacco industry have begun to receive attention from researchers in various industries. Scholars at home and abroad have also examined the quality of filter rods affecting cigarettes through various research algorithms, but no academic research using the snake algorithm has been conducted. In this study, based on the traditional algorithm and the balloon force snake algorithm, an improved active contour snake model is proposed to detect the roundness error of the filter rod and evaluate it with the least squares circle algorithm, which is expected to contribute to the detection of roundness error of cigarette filter rods.

#### 3. Improved Snake Tobacco Filter Bar Roundness Detection Model Construction

##### 3.1. Detection Method of the Fuzzy Filter Bar Roundness Image Based on an Improved Snake Algorithm

The active contour model, also known as “Snakes,” is an architecture for extracting object contour lines from 2D images that may contain noise [16]. The traditional snake model is a closed parametric curve next to the target boundary, and the curve is shown in equation (1).

In equation (1), and represent the coordinate positions in the curve contour, represents the arc length after the curve contour is normalized, and there exists ; the energy parameterization can solve the internal and external force fields smoothly by solving the minimization of the curve energy under the joint action of internal and external energy. Since the traditional snake model algorithm is susceptible to the initial contour and requires manual work in setting the initial contour, which cannot effectively detect the boundary contour of the target, the traditional algorithm is improved and combined with the Hough transform to determine the edge pixels. In order to filter bar edge detection more accurately, the study selected the balloon force snake model. The contour curve of the snake model during the motion is affected by the internal and external forces get, and the snake contour curve motion stops when the internal and external forces balance each other, see equation (2).

In Formula (2), “” represents the internal energy “” corresponding to the internal force of the initial contour curve, which is responsible for ensuring the continuity and smoothness of the contour during the curve movement. The external energy corresponding to the external force on the initial contour curve is responsible for driving the contour curve toward the target boundary. The expression of the relationship between internal force and energy is shown in equation (3).

If the external energy satisfies , then the external force applied at this moment is said to be the Gaussian potential capacity. However, the range of the Gaussian potential capacity acting in the internal region of the model is small, acting in the edge region of the image, which has an impact on the accuracy and precision of the snake model detection. To improve this deficiency, the balloon force is applied to the snake model, and the balloon force is defined in equation (4).

In equation (4), represents the constant coefficient of the balloon force and represents the unit normal vector of the contour curve toward the interior. This shows that the balloon force is an external force that is not directly related to the image features, and any region of the image where the curve is located can be subjected to the balloon force regardless of the distribution of the image features. In order that the contour curve will expand or contract wirelessly because of the action of the internal force and the balloon force, the balloon force is combined with the Gaussian potential energy and introduced into the snake model to produce the balloon snake model, and the expression is given in equation (5).

In equation (5), the contour curve outside the balloon is referred to by and is the external force outside the balloon and the Gaussian potential energy jointly external force. The implementation process is the same compared with the conventional algorithm, except that the balloon force is implemented differently, and the implementation of is the numerical implementation of the unit normal vector . The calculation of the tangent vector to the contour curve *X* is shown in equation (6).

In equation (6), is the tangent vector and the unit vector is obtained by rotating the vector by 90° in the corresponding direction according to the contour line parameterization. The balloon force snake curve model due to its own characteristics of the capacity function will have an impact on the curvature constraint, which can easily cause the curve to be deformed during the motion. Therefore, an external energy term is introduced to solve the problem, and the new energy function of the contour curve is shown in equation (7).

Moreover, the internal energy of the contour curve is shown in equation (8).

In equation (8), represents the speciated arc length, the first order differentiation of to represents the elasticity of the contour curve, and in the second order differentiation, the curvature constraint of the curve *x* represents the energy of the curve as it bends. and are the numerical magnitudes of the points on the contour curve, i.e., they represent the degree of bending and stretching of the contour curve between the two points. It is determined by the change of profile curve *X* and *Y*. A discretization operation on equation (7) yields equation (9).

In equation (9), the corresponding energy is expressed in equation (10).where is the number of points on the balloon snake profile curve and the coordinates of the th point on the balloon profile curve are denoted as . The total energy of the model is then converged to the limit by numerical iterations, and the corresponding contour line is used as the boundary of the target profile. The steps for the implementation of the optimized snake model algorithm are shown in Figure 1.

Figure 1 shows that the program starts with the input of the filter bar blurred image I. First, the contour obtained by using the modified Hough transform is extended along the normal direction and used as the initial contour line of snake, thus avoiding the tedious and uncontrollable manual selection; then, the iterative calculation of the algorithm is carried out, calculate the energy within the area of the first point *i* on the initial contour curve according to the formula, and transfer the energy of the minimum point min in the area to point *i*. The energy of the smallest point min in this region is transferred to the point . Then, the curvature energy of the point is calculated and compared with the maximum curvature energy defined in the study; finally, it is determined whether the point is the final point in the original contour curve. If yes, the iterative calculation is finished; if not, the iterative calculation is continued.

##### 3.2. Evaluation Method of Roundness Error of the Filter Rod

There are many indicators to evaluate the quality of cigarettes, among which the filter bar roundness error is one of the more important indicators. The evaluation process first receives the edges of the filter bar image, analyzes the data error at the image edge points, judges the degree of error according to the fitting effect, and finally evaluates the roundness error. In addition, the application of image segmentation technology has been fully explored in existing literature, and this article has sufficient relevance, which will also be used as a reference in the future of this study [17]. The study used the least squares curve fitting method to fit the more discrete edge points, followed by the least squares circle rating method to evaluate the roundness of the cigarette filter bar [18]. The least-squares circle algorithm (LSCM) is to determine the minimum sum of squares of distances from each circumferential contour point to the center of the circle, and using this algorithm requires certain conditions to be satisfied, assuming that there exists a least-squares circle with the smallest fitting effect and using it as the determination circle while taking the center of the least-squares circle as the determination center, which is then the least-squares condition in the ideal state. Although cigarette filter rods always have irregular elliptical variations, the detected roundness error of the filter rods meets the error range of the minimum deviation, so the least squares circle algorithm can be used to evaluate the quality of cigarette filter rods with high accuracy. The error caused by using the least squares rounding algorithm is also smaller compared with the roundness error of the filter rod. The least squares rounding algorithm is shown in Figure 2.

In Figure 2, the center of the least-squares circle is denoted as and represents the radius of the least-squares circle. According to the parameters in the figure, the expression of the measured contour roundness error can be obtained from equation (11).

In equation (11), denotes the radius of the largest circle and denotes the radius of the smallest circle. The study uses the least squares method to fit the edge points, and the plot of the fitted circle is shown in Figure 2.

In Figure 3, it is assumed that the set of edge points on the contour of the cigarette filter stick is , , and the center coordinates of the circle in the fitted state are , and the radius is , with the equation of the fitted circle general circle given in equation (12).

The interpretation of each parameter in equation (12) is shown in equation (13).

In equation (13), the quantities of and are known and the values of the unknown quantities and need to be found. In the process of curve fitting, if the number of edge points of the measured contour is , the equation based on the equation can find a unique set of solutions for the values of and , and the fitted circle can pass through the three measured points. However, when the points on the boundary of the measured contour meet , the measured contour point cannot satisfy the equation, which means there is a residual difference between the actual measured point and the residual . The residual is shown in equation (14).

Equation (14) shows that the residuals can be positive or negative, but because of the nature of random errors, the positive and negative errors can be canceled out. Let the error sum of squares be the minimum, using the least squares approximation criterion, the equation becomes a problem of solving the maximum and minimum values of the function of multiple elements with and as the quantities to be obtained, and it is also possible to calculate and by the conditions under the extreme values of the function of multiple elements, and then solve the center coordinates and radius of the least-squares fitted circle. The center coordinates and the radius are given in equation (15).

By using equation (15) to fit the lowest squares to the scattered edge points on the filter bar, the coordinates of the circle midpoint and the circle radius can be found to achieve better accuracy of the residual. The center of the circle is used as the center of the least squares circle to evaluate the roundness error of the filter bar and the difference between the maximum distance of the points on the boundary of the measured filter bar and the center of the circle and the value of the minimum distance is the roundness error of the filter bar.

#### 4. Performance Analysis and Simulation Test of Filter Bar Roundness Detection under the Improved Snake Algorithm

##### 4.1. Performance Analysis of Filter Bar Roundness Detection under an Improved Snake Algorithm

In order to verify the effectiveness of the active contour model of the improved snake algorithm, the improved active contour snake model proposed by the research was compared and analyzed with the traditional snake model and the improved balloon force snake model using the Windows XP operating system platform and the writing program of MATLAB software, and the processing results of the three models are shown in Figure 4 [19].

**(a)**

**(b)**

**(c)**

**(d)**

As can be seen in Figure 4, Figure 4(a) uses the improved Hough transform for the test analysis of the filter bar edge, at which time the contour curve almost completely includes the edge part of the filter bar. In contrast, the Gaussian potential capability of the conventional snake model has a limited range of action, so the filter bar contour in Figure 4(b) is poorly positioned. As can be seen in Figure 4(c), the improved balloon force snake model uses the Gaussian potential and balloon force to locate the edge of the filter bar contour, but the external extension of the balloon force is small and the effective range of the model is not significantly improved, so the positioning accuracy of the improved balloon force snake model is not high. Figure 4(d) adopts the improved active contour snake model for contour positioning and introduces the curvature energy in the curvature limit of the contour curve; the target boundary clarity of the contour curve is significantly improved, and the contour positioning accuracy is effectively improved, which proves that the contour positioning capability of the improved active contour snake model proposed by the research is significantly better than other models, with optimization and effectiveness. The relationship between the number of iterations of model training and the model performance is shown in Figure 5.

Figure 5 investigates the effect of the number of algorithm iterations on the model performance, where the horizontal axis indicates the number of iterations, the vertical axis indicates the model performance, the blue curve indicates the training set, and the orange curve indicates the validation set. From Figure 5, it can be seen that increasing the number of iterations can further improve the performance of the model. After 200 iterations, the model performance is basically very stable and the model tends to converge. At this point, increasing the number of iterations has little effect on the model performance and the training can end at 200 iterations. Finally, 200 iterations are chosen for optimal training of the model. In the algorithm performance analysis, the algorithm performance comparison was conducted for the improved snake algorithm, and the traditional snake algorithm and the traditional balloon force snake algorithm were used for comparison and analysis, and the PR curves comparing the three algorithms are shown in Figure 6.

As can be seen in Figure 6, in the change of PR curves of the three algorithms, the accuracy rate of the balloon force snake algorithm is 0.785 and the magnitude of the recall rate at that accuracy rate is 0.789. The accuracy rate and recall rate of the traditional snake algorithm are lower compared with the balloon force snake algorithm, which are 0.782 and 0.785, respectively. While, on the contrary, the improved comparing the changes in the PR curves of the three algorithms, we can see that the improved snake algorithm used in the study has a higher accuracy and recall rate than the balloon force snake algorithm and the traditional snake algorithm, indicating that the improved snake algorithm has a higher accuracy rate in filter bar roundness error detection and can extract more effective teaching resources, while the better recall rate can also occupy a better market position in the environmental market. Then, the optimal running time of the proposed method is discussed, as shown in Figure 7.

Figure 7 shows the relationship between the time spent and the number of iterations gradually when different methods reach a stable state as soon as possible. The proposed method has always performed well in the operation process, and the degree of support for filter rod error detection has always been maintained at a high level. Figure 7 shows that with the increase in iteration times, the operation time of the filter rod in a stable state starts to change. The algorithm states are stable when the number of iterations reaches 200. Among them, the algorithm proposed in the research takes the shortest time, 5.75 s. Other algorithms consume more time than the improved snake algorithm. This means that the algorithm proposed by the research can achieve high-efficiency calculation and operation in a short time for the test of filter rod roundness error, which is very desirable.

##### 4.2. Simulation Test of Filter Bar Roundness under the Improved Snake Algorithm

The study uses MATLAB statistical analysis software to verify and analyze the performance of the proposed research algorithm. The study first detects the roundness of the simulated image of the filter bar and introduces noise into the simulated image to verify the accuracy of roundness detection and the noise immunity of the improved snake algorithm. Then, the simulated image is blurred to further verify whether the improved algorithm has the desired roundness detection accuracy and antiblurring capability in the blurred filter bar image. MATLAB software is used to verify the feasibility and effectiveness of the research algorithm. First, the improved algorithm was used to detect the roundness of the simulated image of the filter bar, and the noise was added to the simulated image, and then, the antinoise ability and the accuracy of roundness detection of the clear filter bar image with the improved snake algorithm were tested; then, the simulated image was blurred to further test the antiblurring ability and roundness detection accuracy of the research algorithm for the fuzzy filter bar image [20]. The improved balloon force snake model was used to detect the roundness of the fuzzy filter stick images. Figure 8 shows the roundness error of the improved snake model algorithm in the simulated image of the finger filter stick simulation.

**(a)**

**(b)**

In Figure 8, the parameters of the snake model are defined as follows, the maximum number of iterations is 200, and the four coefficients of balloon force, external Gaussian potential energy, rigid energy, and internal elastic energy are 0.1, 2, 0.2, and 0.2, respectively. Figure8(a)shows that when gradually larger noise is added to the clear filter bar simulation image, the final roundness obtained also shows a positive growth trend. When the variance of the noise is lower than 0.01, the roundness error of the improved snake model algorithm gradually increases; when the variance of the noise takes the interval [0.01, 0.02], the increase of the roundness error of the algorithm can be approximately negligible; when the variance of the noise takes the value of less than 0.15, the maximum roundness error is 1.4998l pixels (0.025 mm). The improved snake algorithm has a good noise suppression effect. Figure 8(b) shows that the number of Gaussian templates in the image and the roundness error of the algorithm show a positive growth trend. When the number of Gaussian templates exceeds the value of 5, the increasing trend of roundness error becomes more and more rapid; otherwise, the value of roundness error is controlled within a certain value. The maximum roundness error is 1.5726 pixels (0.0275 mm), which can reflect the strong processing ability of the proposed algorithm in boundary-blurred image processing to a certain extent. The roundness error of the filter bar image can be accurately detected under certain blurred image boundaries. Then, the measured roundness error of the filter bar under the research algorithm is compared with other algorithms for detection, see Figure 9.

In Figure 9, it can be found that with the gradual increase of the number of iterations, when the number of iterations is less than 150, the roundness error under all algorithms is in a growing state and reaches the maximum error value of around 140; and then, the number of iterations increases gradually, the roundness error under all algorithms is a greatly reduced state and reaches the minimum roundness error value around 200. The minimum roundness error is obtained by subtracting the maximum error value at iteration number 140 from the minimum error value at iteration number 200. In the study of the comparison algorithm, the roundness error of various algorithms showed a large fluctuation error and the error growth was greater than that of the improved snake algorithm; so, the improved snake algorithm was selected for the roundness error measurement. In Figure 8, the maximum error value under the improved snake algorithm is 0.938 and the minimum error value is 0.228. The calculated roundness error of the filter bar is 0.710, which is a good result. The error plots of the residual obtained under different algorithms are shown in Figure 10.

The comparison experiments in Figure 10 show that the improved snake algorithm outperforms both of the other two algorithms under the same conditions. When the number of iterations increases, the errors of the residuals of the traditional snake algorithm and the balloon force snake algorithm are higher than those of the improved snake algorithm. As the number of iterations increases, the error of all algorithms decreases, but the error of the residual of the improved snake algorithm is always the smallest. When the number of iterations reached 200, the minimum error of the residual was 0.0075, which indicated that the improved snake algorithm was excellent. Next, programming was performed on the Windows XP platform in MATLAB to verify the effectiveness and feasibility of the improved algorithm, and actual image experiments were conducted on filter bars. The roundness detection of 50 clear filter bar images and 50 fuzzy filter bar images was measured by using the two algorithms studied. The measurement results are shown in Figure 11.

In Figure 11, the camera model used for filter rod image acquisition in the study is dh-hvl303um, the image resolution is 640 × 480 pixels, the field of view size is 16 mm × 12 mm, and the standard coefficient is set to 0.0175 mm/pixel. If the measured filter rod image quality is relatively good, the self-calibration accuracy is greater than 0.02 pixels, which is the same as the measurement accuracy of the tobacco filter rod. There is a large difference, so do not consider the impact of the camera nominal error on the test accuracy, reducing the complexity and complexity of the experimental process. The maximum allowable roundness error of the tobacco filter bar in accordance with national standards is 0.175 mm, which is the value of 10 pixels of the image of the object under study. In Figure 8, the maximum roundness error value of the clear filter bar image is 9.125, while the maximum roundness error value of the fuzzy filter bar image is 8.659, which does not exceed the national standard, and the error can be accurate to 0.1%, which has a high accuracy guarantee.

A comprehensive analysis of the above results obtained that by using the improved active contour snake algorithm to test the roundness error of cigarette filter rods, both simulation experiments and performance analysis can get good results and accuracy rate and get better evaluation results.

#### 5. Conclusion

Economic times require strict quality control in the tobacco industry, and the cigarette filter bar as an important feature in assessing tobacco quality cannot be ignored. In order to have a simple and accurate method for detecting the roundness of filter sticks, an improved active profile snake algorithm is proposed, and then, the roundness error is evaluated by using the least squares circle algorithm. The results show that compared with the traditional snake algorithm and the balloon force snake algorithm, the performance enters a stable state when the number of iterations of the algorithm reaches 200; the error monitoring comparison between different algorithms fluctuates widely, and there is a maximum error value of 0.938 and a minimum error value of 0.228 under the improved snake algorithm, and the value of the roundness error of the filter bar is 0.710, which is calculated well The error value of the residual is also better than that of other algorithms. In the actual filter bar roundness error detection, the maximum roundness error value of the clear filter bar image is 9.125 pixels, while the maximum roundness error value of the fuzzy filter bar image is 8.659, both of which do not exceed the national standard of 10 pixels, and the error is accurate to 0.1%. This indicates that the improved snake algorithm is feasible for detecting the roundness error of filter bars with high accuracy. However, there are few and limited methods to detect the roundness error of filter bars, so adding algorithms to the field of cigarette filter bars is still the next research direction to be explored. Moreover, because of the universality of computer algorithms, they may be widely used in other fields in the future, such as iris location, face detection and location, and other image-related fields.

#### Data Availability

The datasets used and/or analyzed during the current study are available from the corresponding author upon reasonable request.

#### Conflicts of Interest

The authors declare that they have no conflicts of interest.