Next Article in Journal
Experimental Study on Deformation and Strength of Silt Under Plane Strain Unloading Conditions
Previous Article in Journal
Research on an Intelligent Scheduling Method Based on GCN-AM-LSTM for Bus Passenger Flow Prediction
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

An Adaptive Extraction Method for Knitted Patterns Based on Bayesian-Optimized Bilateral Filtering

1
College of Mechanical Engineering, Zhejiang Sci-Tech University, Hangzhou 310018, China
2
Zhejiang Provincial Innovation Center of Advanced Textile Technology, Shaoxing 312030, China
3
Zhejiang Key Laboratory of Intelligent Manufacturing Equipment for Flexible Functional Materials, Zhejiang Sci-Tech University, Hangzhou 310018, China
4
Pingyang Institute of Science and Technology Innovation, Wenzhou 325400, China
*
Author to whom correspondence should be addressed.
Appl. Sci. 2026, 16(5), 2526; https://doi.org/10.3390/app16052526
Submission received: 12 February 2026 / Revised: 27 February 2026 / Accepted: 4 March 2026 / Published: 5 March 2026

Abstract

Extracting standardized digital design patterns from real knitted fabric images is critical for textile reverse engineering and digital archiving. Unlike smooth graphics, knitted fabrics exhibit high-frequency textures from yarn loop interlacing, introducing significant grayscale variations within same-color regions. Existing algorithms struggle to distinguish these from pattern edges, causing color quantization and segmentation failures. To suppress yarn texture while preserving edges between color blocks, we propose an adaptive pattern extraction method using Bayesian-optimized bilateral filtering. The primary contribution lies in providing a domain-specific, application-focused integrated framework. Specifically, (1) a knitting-texture-aware multidimensional evaluation parameter is constructed by integrating physical-cause-based texture features (gray-level co-occurrence matrix (GLCM) contrast, homogeneity, and Laplacian variance) with perception-based edge preservation metrics (the Sobel operator and the structural similarity index (SSIM)), enabling accurate discrimination between yarn-level texture noise and pattern-level color block boundaries—a distinction that generic image quality metrics cannot make. (2) Then, this domain-specific objective function is embedded within a Bayesian optimization framework to achieve automatic, zero-shot, per-image parameter adaptation across different knitting processes, without requiring any external training data. K-means color quantization maps in continuous tones to discrete classes, generating standardized patterns meeting knitting requirements. Experiments on 316 samples covering six processes show our method outperforms standard denoising and advanced algorithms like relative total variation (RTV), achieving an average SSIM of 0.83 and PSNR of 26.92 dB, reducing processing time from 15–30 min to 21 s per image, providing efficient automation for knitted Computer-Aided Design (CAD) systems.

1. Introduction

Knitted textiles are widely used in apparel, home textiles, and industrial textile applications due to their unique loop-interlaced structures. With the rapid development of personalized customization and intelligent manufacturing, there is an increasing demand to digitize existing fabric patterns to expand design resource libraries and facilitate rapid redesign [1,2]. However, traditional pattern extraction processes rely heavily on manual tracing by designers, which is not only labor-intensive and time-consuming but also strongly influenced by subjective factors, rendering them unsuitable for large-scale digital archiving. Therefore, developing efficient automated pattern extraction methods has become a key technical challenge in the field of textile digitization.
From a computer vision perspective, extracting discrete-color design patterns from knitted fabric images can be formulated as an image posterization problem [3], which involves simplifying complex images into flat patterns with limited colors through image segmentation and color quantization. The objective is to simplify color representation while preserving the structural integrity of the original patterns. However, pattern extraction from knitted fabrics poses unique challenges. Unlike smooth graphic images, knitted fabric surfaces exhibit high-frequency textures formed by yarn loops, variations in twist, and three-dimensional stacking effects [4]. These textures demonstrate significant “multiscale quasi-periodic” characteristics: microscopic-level yarn twist variations at scales of 0.1–0.5 mm, mesoscopic-level loop interlacing structures at scales of 1–3 mm, and macroscopic-level pattern color block boundaries spanning scales of 10–50 mm, covering three orders of magnitude. This multiscale characteristic introduces two primary challenges: on one hand, texture details within regions introduce significant intensity variations that are often misinterpreted as semantic edges by conventional image segmentation algorithms, resulting in over-segmentation or excessive smoothing; on the other hand, single-scale smoothing methods are unable to simultaneously suppress texture noise and preserve pattern boundaries. Therefore, texture-aware preprocessing has become a critical step that distinguishes knitted-specific methods from general posterization approaches.
Beyond the multiscale characteristics of textures, the diversity of knitting processes further exacerbates the complexity of knitted textures. Plain knitted fabrics, intarsia jacquard fabrics, float jacquard fabrics, double-faced fabrics, and terry fabrics exhibit substantial differences in yarn stacking, density distribution, and surface relief, leading to highly variable frequency, intensity, and spatial distribution of texture features. Consequently, filtering methods with fixed parameters are unable to adapt to such cross-process texture variability [5], while optimization-based approaches incur high computational costs and often depend heavily on empirical parameter settings. Deep learning methods are constrained by the scarcity of paired training data and limited cross-process generalization capability.
In response to the above challenges, bilateral filtering has emerged as an effective tool for suppressing textures while preserving edges due to its ability to selectively smooth images based on spatial proximity and photometric similarity [6]. However, its performance is highly sensitive to the configuration of three parameters: the spatial standard deviation (σspace), the color standard deviation (σcolor), and the filter kernel diameter (d). Inappropriate parameter settings may lead to edge halos or residual textures [7], and the optimal parameters vary significantly across different knitting processes, making them difficult to determine through manual trial-and-error or grid search. This issue of parameter sensitivity therefore requires systematic resolution.
To address these issues, this study proposes an adaptive knitted pattern extraction method based on Bayesian-optimized bilateral filtering. The primary contribution lies in providing a domain-specific, application-focused framework for knitted pattern extraction. Specifically, (1) a knitting-texture-aware multidimensional evaluation parameter is constructed by integrating physical-cause-based texture features (gray-level co-occurrence matrix (GLCM) contrast, homogeneity, and Laplacian variance) with perception-based edge preservation metrics (the Sobel operator and the structural similarity index (SSIM)), enabling accurate discrimination between yarn-level texture noise and pattern-level color block boundaries—a distinction that generic image quality metrics cannot make. (2) Then, this domain-specific objective function is embedded within a Bayesian optimization framework to achieve automatic, zero-shot, per-image parameter adaptation across different knitting processes, without requiring any external training data. The value of this work lies in the validated effectiveness of this integrated solution for a concrete and industrially relevant application problem. Experiments on 316 samples covering six representative knitting processes demonstrate that the proposed method significantly outperforms existing approaches in both extraction quality and computational efficiency.
The remainder of this paper is organized as follows: Section 2 reviews related work. Section 3 describes the proposed method in detail. Section 4 presents the experimental results. Section 5 discusses the limitations and advantages of the method. Section 6 concludes the paper and outlines directions for future work.

2. Related Work

2.1. Image Posterization and Color Quantization

The digital extraction of knitted patterns can be regarded as a process of image posterization and color quantization under specific manufacturing constraints. Foundational research in this area has primarily focused on clustering algorithms operating in color space. Classical K-means clustering [8] and its variants are computationally efficient; however, they rely solely on pixel-wise color statistics and neglect spatial image structure. To incorporate spatial constraints, mean shift clustering [9] and superpixel segmentation methods [10] have been widely adopted.
In recent years, Ru et al. [11] proposed a knitted pattern color separation algorithm based on superpixels and fuzzy C-means (FCMs), in which Real-ESRGAN was employed to enhance boundary clarity prior to color separation. Gümüş and Akin [12] further introduced multi-algorithm error diffusion systems, emphasizing that color quantization must comply with physical constraints such as yarn inventory and machine resolution. However, these methods generally assume that images consist of color-homogeneous regions. In real knitted fabrics, the high-frequency three-dimensional textures formed by loop interlacing make it difficult for algorithms to distinguish microscopic yarn textures from macroscopic pattern structures. Illumination variations within yarns are often misinterpreted as semantic edges by generic quantization algorithms, resulting in significant noise in the extracted patterns. Consequently, texture-aware smoothing preprocessing is essential for achieving high-quality knitted pattern extraction.

2.2. Texture Smoothing and Structure Extraction

Existing approaches to texture smoothing and structure extraction can be broadly categorized into optimization-based methods and learning-based methods. The relative total variation (RTV) model proposed by Xu et al. [13] effectively separates oscillatory textures from smooth structures by minimizing an energy function incorporating a total variation regularization term. However, its iterative optimization process incurs substantial computational cost, rendering it unsuitable for real-time industrial applications.
With the advancement of deep learning techniques, Lu et al. [14] proposed a deep texture–structure awareness network, and Zhang et al. [15] introduced pyramid texture filtering (PTF); both achieved impressive results on general image datasets. Furthermore, convolutional neural networks have also been applied to textile pattern classification tasks [16,17]. Nevertheless, data-driven approaches face significant challenges in textile reverse engineering. The Fab-ME framework proposed by Wang et al. [18] and the compact deep learning model developed by Lin et al. [19] achieved high accuracy in fabric defect detection, but such fully supervised methods require massive amounts of pixel-level annotated data. Acquiring paired fabric scan images and corresponding design patterns is extremely time-consuming (15–30 min of manual annotation per image), thereby rendering large-scale dataset construction impractical.
In terms of structure generation, Sheng et al. [20] attempted to directly infer knitting instructions using end-to-end deep networks, while Adeyokunnu et al. [21] applied generative adversarial networks (GANs) for fabric data style transfer. However, these data-driven models struggle to generalize across different knitting processes. Due to the strong process nonlinearity of knitted fabrics, models trained on specific datasets exhibit limited generalization capability and are prone to structural discontinuities when applied to previously unseen fabric types. Although the deep texture filtering network proposed by Lu et al. [14] effectively smooths textures in natural images, it lacks prior knowledge of knitted loop topology and tends to blur critical design edges.
In response to these issues, Chao et al. [22] pointed out that for artistic posterization tasks with limited training data, non-learning, filter-based approaches are often more robust. Owing to their high efficiency and non-iterative nature, bilateral filters [23] remain a practical choice in industrial applications; nevertheless, their sensitivity to parameter settings remains a critical unresolved issue.

2.3. Automated Parameter Tuning

Traditional manual trial-and-error approaches are not only highly subjective but are also extremely time-consuming when adapting to diverse knitting processes. Grid search or random search methods [24] are inefficient in high-dimensional continuous parameter spaces, while metaheuristic algorithms such as particle swarm optimization (PSO) [25] typically require hundreds or even thousands of function evaluations. In contrast, Bayesian optimization offers a more efficient global optimization strategy. Agrawal et al. [26] demonstrated that Bayesian optimization, by leveraging Gaussian process surrogate models, can locate global optima in complex non-convex spaces with a minimal number of iterations. This property is leveraged in the present study to construct an adaptive parameter optimization method driven solely by domain-specific evaluation metrics, without requiring any training data.

2.4. Limitations of Existing Methods and Positioning This Work

In summary, existing approaches exhibit significant limitations when applied to knitted pattern extraction. Generic image smoothing methods (e.g., bilateral filtering and Gaussian filtering) with fixed parameters cannot adapt to the multiscale non-periodic characteristics of knitted textures. Optimization-based methods (such as RTV and L0 smoothing), although effective, are built upon a binary assumption of “oscillatory texture versus smooth structure” and therefore fail to account for the quasi-periodicity and three-dimensional stacking characteristics of knitted loops. Deep learning methods are constrained by the scarcity of paired training data and insufficient cross-process generalization capability.
By analyzing the physical origins (yarn twist, loop interlacing, and illumination variations) and visual characteristics (multiscale, non-periodic, and three-dimensional relief) of knitted textures, this study constructs a domain-customized, knitting-texture-aware multidimensional evaluation parameter. This design enables the bilateral filter to adaptively adjust its parameters within a Bayesian optimization framework, achieving process-specific performance improvements without increasing algorithmic complexity.

3. Method

This paper proposes an adaptive pattern extraction framework based on Bayesian-optimized bilateral filtering for knitted fabrics. As illustrated in Figure 1, a bilateral filter is first applied as the core texture-smoothing operator to suppress texture noise caused by knitted structures. A knitting-texture-aware multidimensional evaluation parameter is then constructed as the optimization objective by integrating GLCM statistics, Laplacian variance analysis, and the SSIM to quantify filtering performance from two complementary aspects: texture suppression and edge preservation. Based on this evaluation parameter, Bayesian optimization is used to automatically search for the optimal combination of filter parameters within a high-dimensional parameter space, thereby enhancing the adaptability of the algorithm to different knitting processes. Finally, K-means clustering is applied to the filtered results for color quantization, generating simplified color patterns suitable for knitting production. The proposed method operates in a zero-shot manner, relying solely on the internal statistical characteristics of the input image for adaptive adjustment, and requires no external training data to accommodate the texture variations in different knitting processes. The remainder of this section focuses on the optimization of bilateral filtering parameters, while the color quantization step is not discussed in detail.

3.1. Construction of the Optimization Objective Function Based on Knitted Texture Characteristics

The core challenge of knitted pattern extraction lies in distinguishing between “textures that should be suppressed” and “edges that should be preserved.” Unlike natural images, the texture of knitted fabrics is not random noise but rather quasi-periodic patterns determined by the physical structure of yarns. For instance, the V-shaped loops of plain knitted fabrics exhibit regular arrangements at the microscopic level, yet the grayscale value of each loop exhibits random fluctuations due to variations in shooting angle and illumination conditions. In terry fabrics, protruding loops create strong three-dimensional shadows, the grayscale gradients of which may even exceed those at the boundaries of pattern color blocks. Generic image quality assessment metrics cannot distinguish between these two types of edges because they are based solely on pixel differences and do not consider the semantic meaning of edges.
Therefore, the key innovation of the knitting-texture-aware multidimensional evaluation parameter lies in the incorporation of domain-specific knowledge of knitted textures: (1) texture feature extraction based on physical causes—the contrast and homogeneity of the GLCM can capture local grayscale fluctuations induced by yarn twist, while Laplacian variance can quantify the high-frequency details of loop edges; (2) edge evaluation based on visual perception—SSIM focuses on the harmony of overall structure, whereas the Sobel edge detector emphasizes the clarity of local contours. The combination of these two aspects avoids excessive sensitivity to pseudo-edges in textures. This multidimensional fusion strategy enables the evaluation parameter to accurately quantify the degree to which texture noise is suppressed and the degree to which pattern boundaries are preserved, thereby providing a domain-specific objective function for parameter optimization in knitted fabrics. Based on the above analysis, the knitting-texture-aware multidimensional evaluation parameter constructed in this paper is defined as shown in Equation (1):
E = wtexStex + wedgSedg
where Stex is the texture removal score, Sedg is the edge preservation score, and wtex and wedg are the weighting parameters for texture removal and edge preservation, respectively, satisfying wtex + wedg = 1. In this study, the weight for texture removal is set to wtex = 0.8, and the weight for edge preservation is set to wedg = 0.2. This weighting reflects the core requirement of knitted pattern extraction: compared with edge preservation, effective removal of texture noise is the critical factor limiting extraction performance. To validate this choice, a sensitivity analysis was conducted in Section 4.4, which demonstrates that wtex = 0.8 yields the highest average SSIM and PSNR across all tested images, confirming that this weighting is not only domain-motivated but also empirically optimal. The construction methods for the two sub-metrics are elaborated in detail below.

3.1.1. Texture Removal Evaluation

The texture removal evaluation metric is used to quantify the ability of the bilateral filter to remove non-critical texture information from the fabric surface. To comprehensively quantify the texture suppression effect, we adopt a multi-metric fusion evaluation strategy, integrating GLCM features and Laplacian variance analysis to quantify the degree of texture suppression from two complementary perspectives.
The GLCM captures texture characteristics by statistically analyzing the co-occurrence frequency of grayscale values under specific spatial relationships. First, the input color image is converted to a grayscale image I using the standard weighted method. For a grayscale image I, its GLCM is defined as P(i,j|d,θ), representing the co-occurrence probability of pixel pairs with grayscale values i and j at distance d and direction θ. In this paper, the average GLCM is computed using distance d = 1 and directions θ = {0°, 45°, 90°, 135°}. We extract two key features.
Contrast, denoted as C, measures the intensity of local grayscale variations in the image and is defined as shown in Equation (2):
C = i = 0 L 1 j = 0 L 1 i j 2 P ( i , j )
where L is the number of grayscale levels (set to 256 in this paper). A larger contrast value C indicates greater grayscale differences between adjacent pixels and coarser texture.
The contrast reduction rate is defined as the relative change in contrast between the original image and the filtered image, as shown in Equation (3):
R C = max 0 , C o r i C f i l C o r i
where Cori and Cfil represent the contrast of the original image and the filtered image, respectively. This metric has a value range of [0, 1], and higher values indicate more significant suppression of texture contrast. where max ( 0 , x ) ensures R C [ 0 , 1 ] by clamping negative values that may arise when filtering increases local contrast, and R C is defined as 0 when C o r i = 0 to avoid division by zero.
Homogeneity (hereinafter abbreviated as H) quantifies the uniformity of local regions in the image and is defined as shown in Equation (4):
H = i = 0 L 1 j = 0 L 1 P ( i , j ) 1 + i j
A homogeneity value H closer to 1 indicates that the grayscale values of adjacent pixels are more similar and the region is more uniform. After effective smoothing of knitted fabrics, grayscale fluctuations within yarn textures decrease, and homogeneity is expected to increase.
The homogeneity growth rate is shown in Equation (5):
R H = max 0 , H f i l H o r i 1 H o r i
where Hori and Hfil represent the homogeneity of the original image and the filtered image, respectively. The denominator ( 1 H o r i ) ensures R H [ 0 , 1 ] by construction since H f i l 1 by definition of GLCM homogeneity, and max ( 0 , x ) prevents negative values arising from unexpected decreases in homogeneity after filtering.
As a second-order differential operator, the Laplacian operator is highly sensitive to high-frequency variations in images and can highlight texture edges and noise components. This paper employs the standard 4-neighbor Laplacian kernel for image convolution, which is defined as shown in Equation (6):
2 = 0 1 0 1 4 1 0 1 0
For an image I(x,y), the discrete form of the Laplacian convolution operation is shown in Equation (7):
L ( x , y ) = 2 I ( x , y ) = I ( x + 1 , y ) + I ( x 1 , y ) + I ( x , y + 1 ) + I ( x , y 1 ) 4 I ( x , y )
where * denotes the convolution operation, and L(x,y) is the image after Laplacian filtering. The pixel values of this image reflect the magnitude of the second-order derivative of the original image at the corresponding positions; larger values indicate more drastic grayscale changes at those locations.
The variance (hereinafter abbreviated as V) of the Laplacian-filtered image L reflects the distribution intensity of high-frequency components in the image and is defined as shown in Equation (8):
V = V a r ( L ) = 1 M × N x = 1 M y = 1 N [ L ( x , y ) L ¯ ] 2
where M × N is the image size, and L ¯ is the mean of L. The loop edges and yarn undulations in knitted textures result in larger Laplacian variance, which should be significantly reduced by effective smoothing.
The Laplacian variance reduction rate is shown in Equation (9):
R V = V o r i V f i l V o r i
where Vori and Vfil represent the variance of the original image and the filtered image after Laplacian convolution, respectively. The implementation applies a max ( 0 , x ) clamp to ensure R V [ 0 , 1 ] , and R V is defined as 0 when V o r i = 0 to avoid division by zero. Higher values indicate more thorough suppression of high-frequency texture details.
Finally, considering that the contrast reduction rate RC reflects overall changes in spatial statistical relationships, the homogeneity growth rate RH reflects improvements in local uniformity, and the variance reduction rate RV reflects the suppression of high-frequency details, a comprehensive texture removal score Stex is constructed as shown in Equation (10):
Stex = w1RC + w2RH + w3RV
where the weights are set to w1 = 0.4, w2 = 0.3, and w3 = 0.3. Contrast reduction is assigned a higher weight because the strong contrast variations generated by the loop structures of knitted fabrics are the primary source of texture interference. The weights for homogeneity growth and variance reduction are relatively balanced, supplementing the evaluation of texture smoothing effects from the perspectives of global statistical characteristics and local variation intensity, respectively. Sensitivity analysis in Section 4.4 confirms that the specific sub-weight values are not critical and the current settings represent one of many equally effective configurations within a robust plateau. This metric has a value range of [0, 1], and higher values indicate better texture removal performance.

3.1.2. Edge Preservation Evaluation

Edge preservation measures the ability of the bilateral filter to retain pattern edge information while removing texture noise from the image. We employ two complementary evaluation methods: Sobel edge detection to assess the retention of local edge intensity, and the SSIM to evaluate overall structural consistency.
The Sobel operator detects edges by computing first-order gradient approximations of the image in the horizontal and vertical directions. For a grayscale image I(x,y), the Sobel operator performs convolution operations using the horizontal kernel Gx and the vertical kernel Gy, as shown in Equations (11) and (12):
G x = 1 0 1 2 0 2 1 0 1
G y = 1 2 1 0 0 0 1 2 1
The gradient magnitude G(x,y) is calculated as shown in Equation (13):
G ( x , y ) = ( G x I ) 2 + ( G y I ) 2
where * denotes the convolution operation. To distinguish primary pattern contours from fragmented edges caused by textures, pixels with gradient magnitudes greater than a threshold Te = 0.05 are marked as strong edge regions. The set of strong edge pixels Estr is defined as shown in Equation (14):
E s t r = { ( x , y ) G ( x , y ) > T e }
The threshold Te = 0.05 was selected based on visual inspection of the Sobel gradient response maps across representative samples from different knitting process categories. For Sobel responses normalized to [0, 1], this value retains pixels whose gradient magnitude falls within the upper 5% of the response range, which was found to effectively separate strong pattern boundaries from weak yarn-texture-induced gradients across all tested knitting process categories. It is further noted that Te influences only the RE sub-term within the edge preservation component, whose contribution to the overall objective function is scaled by wedg × w4 = 0.08, limiting its practical influence on the Bayesian optimization outcome. The edge preservation rate RE is defined as the proportion of original strong edges retained in the filtered image, as shown in Equation (15):
R E = | E f i l E o r i | | E o r i |
where Eori and Efil represent the strong edge sets of the original image and the filtered image, respectively.
Next, SSIM is employed to comprehensively evaluate the overall structural preservation of the image from three dimensions, namely luminance, contrast, and structure, as shown in Equation (16):
S S I M ( x , y ) = ( 2 μ x μ y + C 1 ) ( 2 σ x y + C 2 ) ( μ x 2 + μ y 2 + C 1 ) ( σ x 2 + σ y 2 + C 2 )
where μx and μy are the image means, σx and σy are the standard deviations, σxy is the covariance, and C1 = (0.01 × 255)2 and C2 = (0.03 × 255)2 are stabilization constants used to prevent division by zero. Considering that the edge preservation rate focuses on the precise retention of local edge intensity, while SSIM emphasizes the overall structural similarity of the image, the two methods possess distinct complementary advantages. Therefore, a comprehensive edge preservation score Sedg is constructed as shown in Equation (17):
Sedg = w4RE + w5 ∙ SSIM
where the weights are set to w4 = 0.4 and w5 = 0.6. The SSIM is assigned a higher weight because the aesthetic appeal and functionality of knitted patterns are more prominently reflected in the harmonious unity of the overall structure rather than the precise retention of local edges. The edge preservation rate serves as a supplementary evaluation to ensure that critical contour information is not completely lost during the filtering process. Sensitivity analysis in Section 4.4 confirms that the specific sub-weight values are not critical and the current settings represent one of many equally effective configurations within a robust plateau. This metric has a value range of [0, 1], and higher values indicate better edge preservation performance.

3.2. Adaptive Parameter Selection Based on Bayesian Optimization

This paper employs a Bayesian optimization framework to solve the bilateral filtering parameter optimization problem. Bayesian optimization constructs a probabilistic surrogate model between the parameter space and the objective function using a Gaussian process, and utilizes the expected improvement (EI) acquisition function to balance exploration of unknown regions and exploitation of known advantageous regions, achieving efficient global search.
During the optimization process, the algorithm intelligently searches through the parameter space, predicting the performances of different parameter combinations. The acquisition function maintains a balance between exploring new regions and exploiting known promising regions. Each iteration updates the posterior probability distribution based on the current optimal result, thereby guiding the selection of parameters for the next step. The Bayesian optimization was implemented using the open-source Bayesian Optimization library (v1.4.0) in Python 3.9, with a Matérn kernel ( ν = 2.5 ) as the Gaussian process surrogate model. The parameter search space was defined as d [ 5 , 21 ] , σ c o l o r [ 10 , 250 ] , and σ s p a c e [ 10 , 250 ] , with bounds selected based on domain knowledge of bilateral filtering behavior on knitted fabrics. Since d must be integer-valued, the continuous value proposed by the Gaussian process was rounded to the nearest integer via d = i n t ( r o u n d ( d ) ) prior to filter evaluation. The objective function is deterministic, and a fixed random seed of 42 was used throughout to ensure full reproducibility. No explicit early stopping criterion was applied. The optimization budget of 55 evaluations (5 initial points + 50 iterations) was determined based on preliminary experiments, as will be detailed in Section 4.1, demonstrating that the objective function value stabilizes well before the maximum number of iterations is reached across representative samples from different knitting processes.

3.3. Validation and Analysis of the Knitting-Texture-Aware Multidimensional Evaluation Parameter

To validate the effectiveness of the knitting-texture-aware multidimensional evaluation parameter, this section presents an analysis from three dimensions: visual quality, perceptual similarity, and subjective user evaluation.

3.3.1. Visual Effect Analysis

To demonstrate the visual effectiveness of this metric, we selected representative knitted fabric images for testing. Figure 2 presents a validation of the optimization effect guided by the knitting-texture-aware multidimensional evaluation parameter. From left to right are comparisons of texture removal effect, edge preservation effect, and overall visual effect, respectively. The comparison reveals that: in terms of texture removal, the dense loop textures and irregular surface undulations in the original images are significantly suppressed, while the primary pattern contours and color distribution are preserved; in terms of edge preservation, the Sobel edge detection results of the optimized images are clearer, the primary pattern contours are more prominent, and the fragmented pseudo-edges generated by texture interference are effectively suppressed; in terms of overall visual effect, the texture noise in the optimized images is significantly smoothed, the pattern contours are complete and clear, presenting a simplified effect more suitable for digital archiving. These results validate that the knitting-texture-aware multidimensional evaluation parameter can accurately quantify the trade-off performance of the bilateral filter between texture suppression and edge preservation.

3.3.2. Perceptual Similarity Analysis

To further validate the optimization effect, this paper employs the Learned Perceptual Image Patch Similarity (LPIPS) metric for quantitative evaluation. LPIPS extracts image features through deep neural networks and can more accurately reflect the perceptual differences in image quality as perceived by the human eye. We calculated the LPIPS distance between the images before and after optimization and the manually processed ground truth on 50 test samples.
As shown in Table 1, experimental results show that the average LPIPS value before optimization was 0.342 ± 0.056, which decreased to 0.068 ± 0.013 after optimization. Lower LPIPS values indicate that the optimized images are closer to the ideal results of manual processing in terms of perceptual quality. This result is consistent with visual observations and further validates the effectiveness of the knitting-texture-aware multidimensional evaluation parameter in guiding the parameter optimization process.

3.3.3. User Study Analysis

To assess the practical application value of the method, we conducted a subjective user evaluation experiment. Fifteen professionals with backgrounds in textile design were invited to participate in the evaluation. The 30 image pairs were presented in randomized order independently for each participant, and the left/right positioning of the two versions within each pair was counterbalanced across participants to eliminate position bias. Participants were informed only that they were evaluating two versions of knitted pattern extraction results and were given no information regarding which version was produced by the proposed method or any baseline, ensuring full blinding throughout the evaluation. They were asked to score each pair on a five-point scale according to standardized written criteria across three dimensions: (1) texture clarity, (2) edge integrity, and (3) overall quality.
As shown in Table 2, user evaluation results show that the average scores of the optimized images in the three dimensions were 4.32 ± 0.51, 4.18 ± 0.63, and 4.26 ± 0.48, respectively, significantly higher than the pre-optimization scores of 2.87 ± 0.72, 3.12 ± 0.68, and 2.94 ± 0.65. These results indicate that the proposed method has gained widespread recognition from professional users in terms of subjective perceptual quality and has good potential for practical application.
In summary, through comprehensive validation from three dimensions—visual analysis, perceptual similarity metrics, and user studies—the effectiveness and reliability of the knitting-texture-aware multidimensional evaluation parameter are fully demonstrated. This evaluation function can accurately quantify the texture smoothing and edge preservation performance of the bilateral filter, providing a reliable objective function for parameter optimization.

4. Experimental Results and Analysis

This section presents the experimental results of our proposed texture removal method. We collected 316 real knitted pattern photographs as the test set, covering six typical knitting processes: plain knitted fabrics, intarsia jacquard fabrics, float jacquard fabrics, double-faced fabrics, terry fabrics, and others, with approximately 50 samples for each process. All images were captured using a digital camera under natural lighting conditions, with resolutions ranging from 1000 × 1000 to 3000 × 3000 pixels, realistically reflecting the various shooting conditions and fabric states encountered in practical applications.
To establish objective evaluation criteria, we invited three professional textile designers with more than five years of experience to manually process these 316 original fabric images using Adobe Photoshop, with the workload distributed approximately equally among them (approximately 105 images per designer). The manual processing procedure included the following: (1) removing texture noise from the fabric surface using the healing brush tool and clone stamp tool; (2) precisely delineating pattern edges using the pen tool and magic wand tool; and (3) simplifying the patterns into 3–8 primary colors using color reduction techniques. The manual processing of each image required an average of approximately 15–30 min. To ensure annotation quality, each processed image was subsequently reviewed and confirmed by the remaining two designers. Any case where a meaningful discrepancy was identified—such as a difference in the number of color regions or inconsistent edge treatment—was returned to the original designer for revision until a consensus was reached, resulting in a single final reference per image reflecting the collective judgment of all three designers. The resulting posterized patterns serve as the ground truth for each image, representing the ideal knitted pattern extraction result.
For each image, we independently searched for its optimal bilateral filtering parameters using Bayesian optimization to validate the universality of the method. All algorithms were implemented in Python 3.9 and executed on a computer equipped with an Intel Core i7-8550U processor, 8 GB of RAM, and the Windows 10 operating system.

4.1. Bayesian Optimization Results

To optimize the bilateral filtering parameters for achieving optimal image processing results, we employed the Bayesian optimization method. During the optimization process, we configured the optimizer to use 5 initial random points and perform 50 iterations, with the random seed set to 42 to ensure reproducibility of the results.
Table 3 presents the optimized parameter results for 10 different fabric images. To validate the method’s adaptability to different knitting processes, we selected samples from five typical knitting processes for display: Images I and II are plain knitted fabrics, Images III and IV are intarsia jacquard fabrics, Images V and VI are float jacquard fabrics, Images VII and VIII are double-faced fabrics, and Images IX and X are terry fabrics. As can be observed from the table, the optimal parameter combinations for different knitting processes exhibit significant variations, validating that the Bayesian optimization method can automatically adjust parameter configurations according to the texture characteristics of different knitting processes, achieving adaptive optimization.
Figure 3 presents the optimization convergence curves. Since Bayesian optimization is performed independently for different fabric samples, each sample forms a unique convergence trajectory. Therefore, Figure 3 displays three typical convergence curves corresponding to images from three different knitting processes. As the number of iterations increases, the objective function value shows a clear upward trend and stabilizes after a certain number of iterations, demonstrating good convergence performance of the optimization process and indicating that the algorithm successfully found the global optimal solution in the parameter space. Compared with traditional grid search or random search methods, Bayesian optimization can identify superior parameter combinations with fewer function evaluations, significantly improving optimization efficiency.
Figure 4 illustrates the variation trajectories of the three key parameters of bilateral filtering during each iteration of the Bayesian optimization process. From the parameter evolution curves, it can be observed that the neighborhood diameter d exhibits relatively large fluctuations in the early stages of optimization and gradually converges to the optimal range as iterations proceed, indicating that the algorithm progressively determines the best neighborhood size suitable for knitted fabric texture processing during the exploration process. The σcolor demonstrates a relatively stable trend during the optimization process, with most iteration results concentrated within a reasonable value range, reflecting the sensitivity requirements of knitted pattern extraction for color similarity judgment. In contrast, the σspace exhibits a larger variation range and exploratory behavior, showing a broader distribution across different iterations. This variation pattern reflects the intelligent search characteristics of the Bayesian optimization algorithm when balancing exploration and exploitation strategies. Analysis of the parameter evolution process reveals that the algorithm can effectively conduct global search in high-dimensional parameter spaces, avoiding the tendency of traditional optimization methods to become trapped in local optima. Ultimately, personalized optimal parameter configurations are found for different fabric characteristics, further validating the applicability and effectiveness of the Bayesian optimization method in automatic knitted pattern extraction.

4.2. Comparison with Other Algorithms

To validate the effectiveness of the proposed method, we conducted comparative experiments with various classical denoising algorithms,0 as well as advanced structure extraction algorithms, including median filtering, non-local means filtering, wavelet denoising, traditional bilateral filtering, mean filtering, Gaussian filtering, RTV, and PTF.
It should be noted that there is a fundamental difference in parameter settings between the proposed method and the comparison algorithms. This study automatically searches for the optimal parameter combination for each input image through Bayesian optimization, whereas the comparison algorithms employ their respective default parameter settings widely used in the image processing field or “universal parameters” adjusted through small-scale sample experiments. Specifically, median filtering, non-local means filtering, wavelet denoising, traditional bilateral filtering, mean filtering, and Gaussian filtering adopt their respective default parameters; RTV is configured with λ = 0.02 and σ = 3 according to the recommendations in the original literature; and PTF is set with σs = 5 and σr = 0.07. The rationale for this comparison approach is as follows: (1) default parameters represent the typical performance of each algorithm in general application scenarios; (2) most of these traditional algorithms do not support adaptive parameter adjustment mechanisms similar to Bayesian optimization; (3) although RTV and PTF are advanced methods, their parameter settings require manual adjustment based on image characteristics and cannot achieve adaptive parameter selection; and (4) the advantage of the proposed method lies precisely in its ability to automatically optimize for specific fabric types rather than relying on fixed parameters. The processing results of all comparison algorithms are uniformly subjected to K-means clustering for color quantization to ensure fairness in the post-processing stage. The clustering number parameter remains consistent across all algorithms and is manually selected.
For each image, the number of clusters K for K-means color quantization was determined through a systematic visual inspection procedure. Since K = 1 yields a single flat color representation that retains no design information, the procedure begins from K = 2. K was incrementally increased until no perceptually significant color was absent from the quantized output. The final K value was selected as the smallest value beyond which further increments produced only spurious color fringe artifacts along existing pattern edges—caused by the gradual color transition zones at yarn boundaries—rather than introducing additional perceptually meaningful design colors. As illustrated in Figure 5, which presents the original image alongside K-means quantization results for K = 2 through K = 6, the output progressively recovers design-relevant colors as K increases. K = 4 yields a visually complete color representation faithful to the original design, while K = 5 and K = 6 introduce only narrow artifact color bands along pattern boundaries without contributing new design-relevant color regions, confirming K = 4 as the appropriate selection for this image. This selection was cross-referenced against the corresponding manually processed ground truth image, in which the number of distinct colors reflects the judgment of experienced textile designers.
To validate the universality of the proposed algorithm, we selected knitted patterns with six different knitting processes for testing. The six fabric images displayed in Table 4 represent typical knitting processes in the textile field: the first is a plain knitted fabric, which is the most basic knitting structure; the second is an intarsia jacquard fabric with additional decorative yarns on the surface, featuring complex surface textures; the third is an intarsia jacquard fabric with different color regions exhibiting textures of varying densities; the fourth is a float jacquard fabric, characterized by relatively long floats on the reverse side; the fifth is a double-faced fabric with greater thickness, where patterns on both the front and reverse sides can be used; and the sixth is a terry fabric with a distinct loop structure on the surface. These fabrics with different knitting processes exhibit significant variations in texture complexity, surface luster, and three-dimensional relief, enabling comprehensive assessment of the algorithm’s adaptability and stability when processing different types of knitted fabrics.
Table 4 presents the processing effects of various filtering algorithms on the same fabric images. Table 4a shows actual photographs of real knitted patterns, where all four photographs exhibit obvious knitted textures, with different shooting angles, uneven illumination, and irregular textures. From a visual perspective, as shown in Table 4b, although median filtering can remove some texture noise, it also causes noticeable blocky artifacts at edges. As shown in Table 4c, non-local means filtering performs well in preserving edges but does not sufficiently process complex fabric textures, leaving considerable texture residues. As shown in Table 4d, wavelet denoising can effectively remove high-frequency noise, but its effect is limited when processing the irregular textures characteristic of fabrics, and pattern edges exhibit slight blurring. As shown in Table 4e, when traditional bilateral filtering uses default parameters, although it can balance texture removal and edge preservation to some extent, the effect is not ideal, with problems of texture residues and edge blurring. As shown in Table 4f,g, mean filtering and Gaussian filtering, as linear filtering methods, severely damage the edge information of patterns while removing textures, resulting in blurred pattern contours. As shown in Table 4h, the RTV method performs excellently in texture smoothing of plain knitted fabrics but exhibits edge blurring caused by over-smoothing on samples with strong three-dimensional textures such as terry fabrics, because its fixed parameters cannot simultaneously adapt to the uniform textures of plain knitted fabrics and the strong undulations of terry fabrics. As shown in Table 4i, PTF achieves good texture-structure separation through multi-scale decomposition but exhibits edge loss on intarsia jacquard fabric samples, indicating that fixed pyramid levels and smoothing strength cannot cope with fabric density variations caused by different knitting processes. In contrast, as shown in Table 4j, the Bayesian-optimized bilateral filtering method proposed in this paper can effectively remove fabric texture noise while maintaining good pattern edge clarity and structural integrity. The optimized parameters enable the bilateral filter to better adapt to the characteristics of knitted fabrics, achieving an optimal balance between texture removal and edge preservation.
It should be noted that the texture removal and edge preservation evaluation metrics constructed in this paper are mainly used to guide the Bayesian optimization process to find filtering parameters most suitable for knitted fabric characteristics. When making horizontal comparisons with other algorithms, we adopt objective standard evaluation metrics: mean square error (MSE), peak signal-to-noise ratio (PSNR), and SSIM, using manually processed reference patterns as the evaluation baseline.
MSE measures the pixel difference between the filtered image and the reference image, calculated as
M S E = 1 M N i = 0 M 1 j = 0 N 1 [ I ( i , j ) K ( i , j ) ] 2
where I(i,j) is the pixel value at position (i,j) in the image processed by each filtering algorithm, K(i,j) is the pixel value at the corresponding position in the standard knitted pattern extracted through manual processing, and M and N are the width and height of the image, respectively. The smaller the MSE value, the closer the filtered image is to the high-quality manually processed result, indicating better algorithm performance.
PSNR is calculated based on MSE and reflects the signal-to-noise ratio level of the image, with the formula
P S N R = 10 log 10 M A X I 2 M S E
where MAXI is the maximum possible pixel value of the image (255 for 8-bit images). The larger the PSNR value, the better the image quality.
As defined in Equation (16), SSIM evaluates image similarity from three dimensions: luminance, contrast, and structure. The closer the SSIM value is to 1, the higher the structural similarity between the two images, indicating better algorithm performance. The closer the SSIM value is to 1, the higher the structural similarity between the two images, indicating better algorithm performance.
We conducted a comprehensive quantitative evaluation of various filtering algorithms using the 316 collected real knitted patterns as test samples. As can be seen from the results in Table 5, the proposed method achieves the lowest MSE value (227.56), indicating the smallest pixel difference between its output and the manually processed reference patterns; the highest PSNR value (26.92 dB), indicating that the image quality is closest to the manual standard; and the highest SSIM value (0.83), indicating the best structural similarity. Among traditional filtering methods, mean filtering and median filtering perform relatively well but still exhibit noticeable texture residues or edge loss. RTV and PTF, as advanced structure extraction algorithms, outperform traditional filtering methods in overall performance (SSIM of 0.76 and 0.77, respectively) but are significantly inferior to the proposed method. More importantly, by analyzing the performance fluctuations of each method across six different knitting processes, the standard deviation of each method is significantly larger than that of the proposed method, indicating that fixed-parameter methods yield unsatisfactory results when facing diverse knitting processes. In terms of computational efficiency, RTV requires approximately 24 s per image on average due to the need for iterative solution of optimization problems, PTF’s multi-scale decomposition process requires approximately 36 s on average, while the total processing time of the proposed method including the Bayesian optimization process is only 21 s. Although the proposed method performs approximately 55 filtering parameter evaluations on each image, due to the high efficiency of bilateral filtering itself and the fast convergence characteristics of Bayesian optimization, the overall computational overhead is still significantly lower than the RTV method, which requires hundreds of iterations. These three metrics validate from different perspectives that the proposed method achieves the closest quality to manual processing in automatic knitted pattern extraction. It is worth noting that even the best-performing algorithm achieves an SSIM value of only 0.83, which still has a gap from the ideal value of 1.0. This reflects the inherent difficulty of the automatic knitted pattern extraction task—automatic algorithms struggle to fully replicate the meticulous judgment and precise operations involved in manual processing. Nevertheless, the proposed method significantly outperforms other traditional denoising algorithms, providing an efficient and practical solution for the automated extraction of knitted patterns.
It is worth noting that standard bilateral filtering with default parameters is included as an explicit baseline in Table 5 (SSIM = 0.66, PSNR = 23.83 dB). This provides a natural controlled comparison between the untuned and tuned versions of the same base algorithm, allowing readers to attribute performance differences more clearly. Furthermore, applying such per-image automated tuning to the other evaluated baseline methods is not practically feasible in our real-world, no-reference scenario, as they lack the domain-specific, texture-aware objective function that our pipeline introduces.

4.3. Ablation Study

The following ablation study isolates the contribution of the Bayesian tuning strategy by comparing it against grid search and random search under controlled evaluation budgets.
In the experimental setup, grid search was conducted in the following parameter space: d with values of 5, 9, 15, 21; σcolor with values of 50, 100, 150, 200, 250; and σspace with values of 50, 100, 150, 200, 250, totaling 100 parameter combinations, i.e., 100 evaluations. Random search randomly sampled 50 times within the same parameter range. Bayesian optimization used 5 initial points and 50 iterations.
Table 6 shows the performance comparison of the three methods under the same evaluation budget. From the results, it can be seen that Bayesian optimization achieved performance comparable to 100 evaluations of grid search after 50 evaluations, with shorter computation time, demonstrating its advantage in search efficiency. Compared with random search, Bayesian optimization models the parameter space through a Gaussian process model, enabling more intelligent selection of the next evaluation point, avoiding the blindness of random search, and achieving higher comprehensive scores under comparable computation time. These results confirm that the gains of the proposed method arise from the combination of the intelligent search strategy and the knitting-texture-aware objective function, rather than from tuning budget alone.

4.4. Parameter Sensitivity Analysis

To justify the critical design choices in the proposed objective function, we conducted sensitivity analyses on the primary weighting parameters: the large-scale weights wtex and wedg, as well as the texture removal sub-weights w1, w2, and w3 and edge preservation sub-weights w4 and w5. All analyses were performed on a representative subset of 60 images drawn from the full dataset of 316 images, with 10 images selected from each of the 6 typical knitting process categories to ensure process diversity. All analyses use the mean SSIM and PSNR against ground truth as the external evaluation criterion, ensuring that the assessment is independent of the objective function configuration under test.
Table 7 reports the final extraction quality under nine configurations of wtex ranging from 0.1 to 0.9, with wedg = 1 − wtex fixed accordingly. The results demonstrate a clear unimodal trend: SSIM and PSNR increase steadily as wtex increases from 0.1 to 0.8, and then decline at wtex. The current setting of wtex achieves the highest mean SSIM of 0.8792 and mean PSNR of 28.76 dB, confirming that it represents a genuine optimum rather than an arbitrary boundary value. This finding is consistent with the domain motivation: in knitted pattern extraction, texture suppression is the primary bottleneck, and assigning excessive weight to edge preservation (low wtex) substantially degrades extraction quality, while over-suppressing edge information (wtex = 0.9) also incurs a measurable performance penalty.
Table 8 reports the final extraction quality under representative configurations of the texture removal sub-weights (w1, w2, w3) and edge preservation sub-weights (w4, w5), with the large-scale weights fixed at their optimal values. Two key observations emerge. First, any configuration that employs all sub-metrics simultaneously yields virtually identical SSIM and PSNR regardless of the specific weight values (SSIM variation < 0.001), indicating that the objective function resides within a broad robust plateau with respect to sub-weight choices. Second, reducing either sub-metric group to a single metric results in substantial performance degradation, with SSIM drops of 0.10–0.29 for the texture removal sub-weights and approximately 0.10 for the edge preservation sub-weights. These findings confirm that the multi-metric design is essential for capturing the complementary aspects of texture suppression in knitted fabric images, while the specific sub-weight values are not critical and the current settings represent one of many equally effective configurations within the robust plateau.

5. Discussion

The adaptive knitted pattern extraction method based on Bayesian-optimized bilateral filtering proposed in this paper demonstrates significant advantages. The constructed knitting-texture-aware multidimensional evaluation parameter, by integrating texture removal performance (based on GLCM features and Laplacian variance) and edge preservation performance (based on the Sobel operator and SSIM), can accurately quantify the trade-off relationship of the bilateral filter between “suppressing intra-region yarn textures” and “preserving inter-region pattern boundaries.” Unlike traditional image quality assessment metrics, this evaluation parameter is specifically designed for knitted texture characteristics, providing a reliable objective function for parameter optimization. The introduction of the Bayesian optimization framework significantly improves parameter search efficiency, achieving the performance of 100 grid search evaluations with only 50 iterations, representing an efficiency improvement of approximately 50%. More importantly, by independently performing optimization on each input image, the method can automatically adjust parameter configurations according to different knitting processes. Experiments demonstrate that the optimal parameter combinations for plain knitted fabrics, intarsia jacquard fabrics, float jacquard fabrics, double-faced fabrics, and terry fabrics exhibit significant variations, validating the adaptive performance of the method. Comparison with the advanced texture smoothing algorithms RTV and PTF further highlights the core advantages: although these two algorithms perform well on plain knitted fabrics after tuning, their performance significantly declines on various knitting processes due to the use of fixed parameters, whereas the proposed method maintains consistently high performance across all knitting processes.
However, several limitations of the current study point to directions for future improvement. Regarding the objective function, the edge preservation metric is computed on grayscale images, which may fail to capture purely chromatic edges—boundaries between color regions that share similar luminance but differ in chromaticity. While the practical impact of this limitation is mitigated in our dataset by the luminance constraints of industrial yarn color selection, and while the RGB-aware bilateral filter inherently preserves color discontinuities through its photometric similarity weighting, future work should extend the edge preservation evaluation to a perceptually uniform color space such as CIE Lab, incorporating Sobel gradient information from the a* and b* chromatic channels to improve robustness under all color conditions. The evaluation metric may also require additional constraints to maintain effectiveness under extreme illumination conditions or severe geometric distortions. Regarding pipeline automation, the current manual K selection procedure, while guided by a consistent domain-informed criterion based on the onset of spurious boundary fringe artifacts, remains a degree of freedom that limits full automation. Future work will investigate automatic K selection strategies such as perceptual color difference thresholds based on the CIE ΔE metric or artifact-aware over-segmentation detection. Regarding dataset reliability, the ground truth annotation protocol—in which each image was processed by one experienced textile designer and reviewed by the remaining two—provides meaningful quality control, but inter-annotator variability was not quantitatively measured. Future work should incorporate a formal reliability assessment, such as computing pairwise SSIM between independent annotations of the same image, to better characterize ground truth uncertainty. Regarding computational efficiency, each image currently requires approximately 21 s of processing time; a transfer learning strategy that leverages the parameter distribution of already-optimized samples could accelerate optimization of new samples. Finally, the current framework validates parameter optimization specifically for bilateral filtering, and future work will explore its extension to other parameterizable filters to construct a more general adaptive texture smoothing framework.

6. Conclusions

This study addresses the domain-specific trade-off problem between texture suppression and edge preservation in knitted pattern extraction through an adaptive extraction method based on Bayesian-optimized bilateral filtering. The core innovation lies in the construction of a knitting-texture-aware multidimensional evaluation parameter tailored to the characteristics of knitted textures. This parameter integrates GLCM statistics to quantify local contrast variations caused by yarn twist, Laplacian variance analysis to capture high-frequency details of loop edges, the Sobel operator to detect and retain strong edge regions at pattern boundaries, and the SSIM to evaluate the degree of overall pattern structure preservation, collectively enabling accurate discrimination between texture noise that should be suppressed and pattern boundaries that should be preserved. Through the Bayesian optimization framework, this evaluation parameter guides the bilateral filter to achieve automatic parameter adjustment requiring zero training data at a processing efficiency significantly superior to manual operation.
Experimental results demonstrate that on 316 real fabric samples covering six typical knitting processes, the proposed method achieves an average SSIM of 0.83 and a PSNR of 26.92 dB, significantly outperforming traditional denoising algorithms, as well as advanced texture smoothing algorithms (RTV and PTF). Comparative experiments validate the core advantage of the method: Bayesian optimization enables adaptive parameter adjustment across different knitting processes, with the optimal parameter combinations for plain knitted fabrics, intarsia jacquard fabrics, float jacquard fabrics, double-faced fabrics, and terry fabrics varying significantly across process types. The processing time is reduced from 15–30 min of manual operation to approximately 21 s per image, representing a substantial gain in efficiency.
The method operates in a zero-shot manner, relying solely on the internal statistical characteristics of the input image for adaptive adjustment. It accommodates the texture characteristics of different knitting processes without requiring external training data, providing an efficient automated solution for knitted computer-aided design (CAD) systems. Future work will proceed in the following directions: (1) adopting transfer learning strategies to improve processing efficiency; (2) introducing additional constraints to maintain effectiveness and enhance adaptability under extreme conditions; (3) extending the framework to other parameterizable filters to construct a more general adaptive texture smoothing framework; (4) investigating automatic K selection strategies, such as perceptual color difference thresholds based on the CIE ΔE metric, to achieve full pipeline automation; (5) extending the edge preservation evaluation to a perceptually uniform color space such as CIE Lab to improve robustness under all color conditions; and (6) incorporating a formal inter-annotator reliability assessment to better characterize ground truth uncertainty.

Author Contributions

Conceptualization, X.R., Y.W. and L.P.; Methodology, X.R., Y.W. and L.P.; Software, X.R. and Y.W.; Validation, X.R., Y.W. and L.P.; Formal analysis, X.R.; Investigation, X.R., Y.W. and L.P.; Resources, Y.W. and J.L.; Data curation, X.R., Y.W. and J.L.; Writing—original draft, X.R. and Y.W.; Writing—review & editing, X.R., Y.W., L.P. and J.L.; Visualization, Y.W.; Supervision, X.R., L.P. and J.L.; Project administration, X.R., L.P. and J.L.; Funding acquisition, X.R., L.P. and J.L. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by The National Key Research and Development Program of China (grant number SQ2023YFB3200093), The Special Support Plan for High-Level Talents in Zhejiang Province (Provincial Ten Thousand Talents Plan) (grant number 2023R5212) and Key Technologies for Process Reengineering and Fully Automated Flexible Assembly of Low-voltage Electrical Appliances—Key Technologies for Process Reengineering and Fully Automated Intelligent Flexible Production Line Assembly of High-performance Motor (grant number 2024C01133).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The raw data and code generated during the current study are not open to the public owing to proprietary constraints. Researchers may request access by contacting the corresponding author, provided that permission is obtained from the supporting institutions.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Papahristou, E.; Bilalis, N. 3D virtual prototyping traces new avenues for fashion design and product development: A qualitative study. J. Text. Sci. Eng. 2017, 7, 1000297. [Google Scholar]
  2. Kim, M.; Ahn, J.; Kang, J.; Kim, S. A systematic review on smart manufacturing in the garment industry. Korean Fash. Text. Res. J. 2020, 22, 660–675. [Google Scholar]
  3. Celebi, M.E. Improving the performance of k-means for color quantization. Image Vis. Comput. 2011, 29, 260–271. [Google Scholar] [CrossRef]
  4. Ngan, H.Y.T.; Pang, G.K.H.; Yung, N.H.C. Automated fabric defect detection—A review. Image Vis. Comput. 2011, 29, 442–458. [Google Scholar] [CrossRef]
  5. Kumar, A. Computer-vision-based fabric defect detection: A survey. IEEE Trans. Ind. Electron. 2008, 55, 348–363. [Google Scholar] [CrossRef]
  6. Paris, S.; Kornprobst, P.; Tumblin, J.; Durand, F. Bilateral filtering: Theory and applications. Found. Trends Comput. Graph. Vis. 2009, 4, 1–73. [Google Scholar] [CrossRef]
  7. Zhang, B.; Allebach, J.P. Adaptive bilateral filter for sharpness enhancement and noise removal. IEEE Trans. Image Process. 2008, 17, 664–678. [Google Scholar] [CrossRef] [PubMed]
  8. Jain, A.K. Data clustering: 50 years beyond K-means. Pattern Recognit. Lett. 2010, 31, 651–666. [Google Scholar] [CrossRef]
  9. Comaniciu, D.; Meer, P. Mean shift: A robust approach toward feature space analysis. IEEE Trans. Pattern Anal. Mach. Intell. 2002, 24, 603–619. [Google Scholar] [CrossRef]
  10. Achanta, R.; Shaji, A.; Smith, K.; Lucchi, A.; Fua, P.; Süsstrunk, S. SLIC superpixels compared to state-of-the-art superpixel methods. IEEE Trans. Pattern Anal. Mach. Intell. 2012, 34, 2274–2282. [Google Scholar] [CrossRef] [PubMed]
  11. Ru, X.; Chen, R.; Peng, L.; Shi, W. Fast automatic fuzzy C-means knitting pattern color-separation algorithm based on superpixels. Sensors 2024, 24, 281. [Google Scholar] [CrossRef] [PubMed]
  12. Gümüş, O.; Akin, E. From pixels to knitted fabrics: A multialgorithm error diffusion system for knitting design. Text. Res. J. 2025. [Google Scholar] [CrossRef]
  13. Xu, L.; Yan, Q.; Xia, Y.; Jia, J. Structure extraction from texture via relative total variation. ACM Trans. Graph. (TOG) 2012, 31, 139. [Google Scholar] [CrossRef]
  14. Lu, K.; You, S.; Barnes, N. Deep texture and structure aware filtering network for image smoothing. In Proceedings of the European Conference on Computer Vision (ECCV), Munich, Germany, 8–14 September 2018; pp. 217–233. [Google Scholar]
  15. Zhang, Q.; Jiang, H.; Nie, Y.; Zheng, W.-S. Pyramid Texture Filtering. ACM-Trans. Graph. 2023, 42, 11. [Google Scholar] [CrossRef]
  16. Wang, S.; Zhang, H.; Kang, F. Emotion classification of necktie pattern based on convolution neural network. J. Text. Res. 2018, 39, 117–123. [Google Scholar]
  17. Jia, X.J.; Deng, H.; Liu, Z.; Ye, L. Vein pattern classification based on VGGNet convolutional neural network for blue calico. J. Optoelectron. Laser 2019, 30, 867–875. [Google Scholar]
  18. Wang, S.; Kong, H.; Li, B.; Zheng, F. Fab-ME: A vision state-space and attention-enhanced framework for fabric defect detection. In Advanced Intelligent Computing Technology and Applications; Springer Nature: Singapore, 2025; pp. 103–114. [Google Scholar]
  19. Lin, K.; Sun, H.; Chen, F. Fabric Defect Detection Method Based on Unlabeled Compact Deep Learning. In Digital Multimedia Communications; Springer Nature: Singapore, 2024; pp. 201–212. [Google Scholar]
  20. Sheng, H.; Cai, S.; Zheng, X.; Lau, M. Knitting Robots: A Deep Learning Approach for Reverse-Engineering Fabric Patterns. Electronics 2025, 14, 1605. [Google Scholar] [CrossRef]
  21. Adeyokunnu, O.; Abayomi-Alli, A.; Alabi, O.A.; Arogundade, O.; Daniel, D.W.; Omoyiola, B.O. Classification and Augmentation of African Fabrics Using Convolutional Neural Network and Generative Adversarial Network Models. In 2024 IEEE 5th International Conference on Electro-Computing Technologies for Humanity (NIGERCON); IEEE: New York, NY, USA, 2024; pp. 1–5. [Google Scholar]
  22. Chao, C.K.T.; Singh, K.; Gingold, Y. PosterChild: Blend-Aware Artistic Posterization. Comput. Graph. Forum 2021, 40, 87–99. [Google Scholar] [CrossRef]
  23. Tomasi, C.; Manduchi, R. Bilateral filtering for gray and color images. In Sixth International Conference on Computer Vision (IEEE Cat. No. 98CH36271); IEEE: New York, NY, USA, 1998; pp. 839–846. [Google Scholar]
  24. Bergstra, J.; Bengio, Y. Random search for hyper-parameter optimization. J. Mach. Learn. Res. 2012, 13, 281–305. [Google Scholar]
  25. Frackiewicz, M.; Palus, H.; Prandzioch, D. Superpixel-based PSO algorithms for color image quantization. Sensors 2023, 23, 1108. [Google Scholar] [CrossRef] [PubMed]
  26. Agrawal, P. A survey on hyperparameter optimization of machine learning models. In 2024 2nd International Conference on Disruptive Technologies (ICDT); IEEE: New York, NY, USA, 2024; pp. 11–15. [Google Scholar]
Figure 1. Flowchart of the Bayesian-optimized bilateral filtering process for knitted-pattern extraction.
Figure 1. Flowchart of the Bayesian-optimized bilateral filtering process for knitted-pattern extraction.
Applsci 16 02526 g001
Figure 2. Comparison of filtering effects before and after under the guidance of the knitting-texture-aware multidimensional evaluation parameter.
Figure 2. Comparison of filtering effects before and after under the guidance of the knitting-texture-aware multidimensional evaluation parameter.
Applsci 16 02526 g002
Figure 3. Bayesian optimization convergence curves for representative samples, showing the improvement of the objective function value over iterations.
Figure 3. Bayesian optimization convergence curves for representative samples, showing the improvement of the objective function value over iterations.
Applsci 16 02526 g003
Figure 4. Evolution trajectories of the three bilateral filtering parameters (d, σcolor, σspace) during the Bayesian optimization process. The red dashed line denotes the default parameter value; the blue dashed line indicates the optimal value ascertained by the algorithm.
Figure 4. Evolution trajectories of the three bilateral filtering parameters (d, σcolor, σspace) during the Bayesian optimization process. The red dashed line denotes the default parameter value; the blue dashed line indicates the optimal value ascertained by the algorithm.
Applsci 16 02526 g004
Figure 5. Illustration of the K selection procedure for a representative knitted fabric image. From left to right: filtered original image; K = 2; K = 3; K = 4; K = 5; K = 6. K = 4 is identified as the optimal value, as it yields a visually complete color representation without introducing spurious color fringe artifacts along pattern boundaries, which become visible at K = 5 and K = 6.
Figure 5. Illustration of the K selection procedure for a representative knitted fabric image. From left to right: filtered original image; K = 2; K = 3; K = 4; K = 5; K = 6. K = 4 is identified as the optimal value, as it yields a visually complete color representation without introducing spurious color fringe artifacts along pattern boundaries, which become visible at K = 5 and K = 6.
Applsci 16 02526 g005
Table 1. Perceptual similarity comparison before and after optimization.
Table 1. Perceptual similarity comparison before and after optimization.
Evaluation MetricBefore OptimizationAfter Optimization
LPIPS0.342 ± 0.0560.068 ± 0.013
Note: Bold values indicate the best performance under the corresponding condition.
Table 2. User evaluation scores for different quality dimensions.
Table 2. User evaluation scores for different quality dimensions.
Evaluation DimensionBefore OptimizationAfter Optimization
Texture Clarity2.87 ± 0.724.32 ± 0.51
Edge Integrity3.12 ± 0.684.18 ± 0.63
Overall Quality2.94 ± 0.654.26 ± 0.48
Note: Bold values indicate the best performance under the corresponding condition.
Table 3. Optimized Parameters for Bayesian Bilateral Filtering.
Table 3. Optimized Parameters for Bayesian Bilateral Filtering.
Image IImage IIImage IIIImage IVImage VImage VIImage VIIImage VIIIImage IXImage X
d15161920191921202021
σcolor140134156162177172180193250243
σspace18202825222528305142
Table 4. Visual Effect Comparison Among Various Algorithms.
Table 4. Visual Effect Comparison Among Various Algorithms.
aApplsci 16 02526 i001
bApplsci 16 02526 i002
cApplsci 16 02526 i003
dApplsci 16 02526 i004
eApplsci 16 02526 i005
fApplsci 16 02526 i006
gApplsci 16 02526 i007
hApplsci 16 02526 i008
iApplsci 16 02526 i009
jApplsci 16 02526 i010
kApplsci 16 02526 i011
Note: (a) Actual photographs of real knitted patterns; (b) median filtering algorithm results; (c) non-local means filtering algorithm results; (d) wavelet filtering algorithm results; (e) bilateral filtering algorithm results; (f) mean filtering algorithm results; (g) Gaussian filtering algorithm results; (h) RTV algorithm results; (i) PTF algorithm results; (j) proposed algorithm results; (k) manually processed reference images (ground truth).
Table 5. Average MSE, average PSNR, average SSIM and average processing time of nine algorithms.
Table 5. Average MSE, average PSNR, average SSIM and average processing time of nine algorithms.
AlgorithmAverage MSE (↓)Average PSNR/dB (↑)Average SSIM (↑)Average Processing Time/s (↓)
Median334.06 ± 112.5825.03 ± 2.120.70 ± 0.080.04 ± 0.01
NLM677.70 ± 201.4521.21 ± 2.640.44 ± 0.118.96 ± 2.14
Wavelet665.42 ± 188.9221.23 ± 2.580.44 ± 0.1049.12 ± 7.28
Mean299.02 ± 78.9425.25 ± 1.580.71 ± 0.050.04 ± 0.01
Gaussian387.34 ± 95.2323.85 ± 1.890.60 ± 0.060.05 ± 0.01
Bilateral483.26 ± 156.7823.83 ± 2.350.66 ± 0.090.19 ± 0.03
RTV257.64 ± 82.6725.39 ± 1.980.76 ± 0.0724.20 ± 3.48
PTV260.12 ± 85.1425.47 ± 2.010.77 ± 0.0735.77 ± 5.36
Ours227.56 ± 51.2326.92 ± 1.150.83 ± 0.0421.43 ± 4.12
Note: Bold values indicate the best performance under the corresponding condition. (↑) and (↓) indicate that higher and lower values are better, respectively.
Table 6. Comparison of Different Parameter Search Methods.
Table 6. Comparison of Different Parameter Search Methods.
Search MethodNumber of Evaluations (↓)Optimal Comprehensive Score (↑)Computation Time/s (↓)
Bayesian optimization550.852318.24
Grid search1000.848932.18
Random search500.821215.67
Note: The Optimal Comprehensive Score reported for each method corresponds to the value of the bounded objective function defined in Equation (1), which is guaranteed to lie within [ 0 , 1 ] through the metric boundedness established in Section 3.1, and can thus be interpreted as a normalized measure of combined texture suppression and edge preservation performance, with higher values unambiguously indicating better performance. (↑) and (↓) indicate that higher and lower values are better, respectively.
Table 7. Sensitivity of extraction quality to large-scale weight wtex.
Table 7. Sensitivity of extraction quality to large-scale weight wtex.
wtexwedgAverage SSIM (↑)Average PSNR/dB (↑)
0.10.90.28 ± 0.0621.46 ± 1.20
0.20.80.28 ± 0.0621.47 ± 1.18
0.30.70.29 ± 0.0521.60 ± 1.13
0.40.60.39 ± 0.0622.84 ± 1.28
0.50.50.44 ± 0.0823.54 ± 1.67
0.60.40.64 ± 0.2425.91 ± 3.77
0.70.30.77 ± 0.0527.78 ± 3.12
0.80.20.88 ± 0.0528.76 ± 2.81
0.90.10.71 ± 0.0626.76 ± 2.91
Note: Bold values indicate the best performance under the corresponding condition. (↑) and (↓) indicate that higher and lower values are better, respectively.
Table 8. Sensitivity of extraction quality to sub-weight configurations.
Table 8. Sensitivity of extraction quality to sub-weight configurations.
ConfigurationAverage SSIM (↑)Average PSNR/dB (↑)
Texture removal sub-weightsw1 = w2 = w3 = 1/30.87 ± 0.0528.76 ± 2.81
w1 = 0.4, w2 = 0.3, w3 = 0.30.88 ± 0.0528.76 ± 2.81
w1 = 0.6, w2 = 0.2, w3 = 0.20.87 ± 0.0528.76 ± 2.80
w1 = 0.2, w2 = 0.2, w3 = 0.60.87 ± 0.0528.76 ± 2.83
w1 = 1, w2 = 0, w3 = 00.76 ± 0.0526.77 ± 2.82
w1 = 0, w2 = 1, w3 = 00.76 ± 0.0426.74 ± 2.79
w1 = 0, w2 = 0, w3 = 10.57 ± 0.1325.24 ± 2.68
Edge preservation sub-weightsw4 = w5 = 0.50.87 ± 0.0528.75 ± 2.80
w4 = 0.4, w5 = 0.60.88 ± 0.0528.76 ± 2.81
w4 = 0.7, w5 = 0.30.87 ± 0.0528.76 ± 2.81
w4 = 0.2, w5 = 0.80.87 ± 0.0528.77 ± 2.81
w4 = 1, w5 = 00.77 ± 0.0525.77 ± 2.81
w4 = 0, w5 = 10.77 ± 0.0525.75 ± 2.81
Note: Bold values indicate the current setting used in the proposed method. (↑) and (↓) indicate that higher and lower values are better, respectively.
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Ru, X.; Wang, Y.; Peng, L.; Li, J. An Adaptive Extraction Method for Knitted Patterns Based on Bayesian-Optimized Bilateral Filtering. Appl. Sci. 2026, 16, 2526. https://doi.org/10.3390/app16052526

AMA Style

Ru X, Wang Y, Peng L, Li J. An Adaptive Extraction Method for Knitted Patterns Based on Bayesian-Optimized Bilateral Filtering. Applied Sciences. 2026; 16(5):2526. https://doi.org/10.3390/app16052526

Chicago/Turabian Style

Ru, Xin, Yanhao Wang, Laihu Peng, and Jianqiang Li. 2026. "An Adaptive Extraction Method for Knitted Patterns Based on Bayesian-Optimized Bilateral Filtering" Applied Sciences 16, no. 5: 2526. https://doi.org/10.3390/app16052526

APA Style

Ru, X., Wang, Y., Peng, L., & Li, J. (2026). An Adaptive Extraction Method for Knitted Patterns Based on Bayesian-Optimized Bilateral Filtering. Applied Sciences, 16(5), 2526. https://doi.org/10.3390/app16052526

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop