Image path generation method for engraving processing constraints
By using multimodal data fusion and deep learning to enhance the network to generate carving paths, the problems of unprocessable paths and loss of details in existing technologies are solved, and high-quality carving path generation is achieved.
Patent Information
- Application Number
- CN202610586529.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-29
- Publication Date
- 2026-07-24
AI Technical Summary
Existing technologies have not fully considered the constraints of carving and processing in the process of digitizing intangible cultural heritage, resulting in problems such as unprocessable paths, unrecoverable hidden structures, severe loss of details, and discontinuous or jagged paths.
By employing multimodal data generation, structural saliency weighted fusion, deep learning augmentation network, and path optimization techniques, an image path that satisfies the constraints of the carving process is generated.
It significantly improves the ability to retain details, enhances path continuity and smoothness, reduces file complexity, and makes the generated paths directly usable for engraving.
Smart Images

Figure CN122453632A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer image processing technology, specifically to an image path generation method oriented towards carving constraints. Background Technology
[0002] Intangible cultural heritage, as part of the world's cultural heritage, encompasses traditional crafts, art forms, and performing arts. These artworks often possess exquisite details and rich artistic value, such as wood carvings, ceramic crafts, and architectural drawings; however, as these art forms gradually disappear or are destroyed, digital preservation becomes particularly important.
[0003] In the field of image processing and path generation, there are already some related methods in the existing technology, such as contour extraction methods based on edge detection (e.g., Canny) and path generation methods based on bitmap vectorization (e.g., Potrace). Although existing methods have certain effects in general graphics processing, they have the following obvious shortcomings in the digitization of intangible cultural heritage (e.g., wood carving, traditional patterns): 1. Lack of consideration for machining constraints: The paths generated by existing methods do not fully consider tool radius, minimum turning radius, and machining continuity, resulting in paths that are visible but not machineable; 2. Lack of multimodal information utilization mechanism: Relying only on single image information, it is impossible to recover hidden structures; 3. Severe loss of details: Complex textures (such as wood carving grain) are easily destroyed during binarization and contour extraction; 4. Path discontinuity or obvious jaggedness: It cannot meet the requirements of carving equipment for continuous paths. Summary of the Invention
[0004] To address the shortcomings of existing technologies, this invention provides an image path generation method oriented towards carving and processing constraints, which solves the problems of existing technologies in the process of digitizing intangible cultural heritage, such as paths that are visible but cannot be processed, the inability to recover hidden structures, severe loss of details, and discontinuous or jagged paths.
[0005] To achieve the above objectives, the present invention provides the following technical solution: In a first aspect, an image path generation method oriented towards carving processing constraints is provided, the method comprising the following steps: Step S1: Input the RGB image of the artwork, preprocess the input RGB image, and generate multimodal data; Step S2: Construct a gradient field based on multimodal data, construct a structure-guided weight function based on structure saliency, and perform weighted fusion of each modality image in the multimodal data according to the structure-guided weight function to obtain a fused image; Step S3: Input the fused image into the enhancement network for detail enhancement and output the enhanced image. The enhancement network adopts an encoder-decoder structure with skip connections. Path generation operators are defined in the enhancement network, and a loss function is constructed for model training. Step S4: Extract paths and calculate curvature from the enhanced image to obtain a path set and a curvature sequence; Step S5: Optimize the path based on the obtained path set and curvature sequence; Step S6: Generate the final PLT file.
[0006] Secondly, an image path generation apparatus oriented towards carving processing constraints, the apparatus comprising: The multimodal data generation module is used to input RGB images of artworks, preprocess the input RGB images, and generate multimodal data. The image fusion module is used to construct a gradient field based on multimodal data, construct a structure-guided weight function based on structural saliency, and perform weighted fusion of each modality image in the multimodal data according to the structure-guided weight function to obtain a fused image. The detail enhancement module is used to input the fused image into the enhancement network for detail enhancement and output the enhanced image. The enhancement network adopts an encoder-decoder structure with skip connections. Path generation operators are defined in the enhancement network, and a loss function is constructed for model training. The path extraction module is used to extract paths and calculate curvature in the enhanced image, resulting in a path set and a curvature sequence. The path optimization module is used to process the path set and curvature sequence using optimization strategies to obtain optimized paths. The file generation module is used to generate the final PLT file.
[0007] By adopting the above-described technical solution of the present invention, at least the following beneficial effects are achieved: 1. Significantly improves detail retention: By introducing a structure-guided multimodal fusion mechanism and a deep learning enhancement model with edge consistency constraints, the ability to retain image details is significantly improved, which is especially suitable for the digital preservation of art forms such as wood carving and ceramic crafts. 2. Improved path continuity (avoiding breaks and jagged edges): By introducing path smoothing constraints and curvature control mechanisms, the continuity and smoothness of the generated path are significantly improved; 3. Reduce file complexity (path compression and optimization): By using a curvature adaptive sampling strategy, the number of path points can be effectively reduced while ensuring detail accuracy, thereby reducing the complexity of PLT files; 4. Can directly meet carving requirements: The carving process constraint model is introduced, and the physical processing conditions are integrated into the path generation process, so that the final generated path is not only "visible" but also "processable". Attached Figure Description
[0008] Figure 1 This is a flowchart of an image path generation method for carving processing constraints according to the present invention; Figure 2 This is a schematic diagram of the structure of an image path generation device for carving processing constraints according to the present invention. Detailed Implementation
[0009] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. Example
[0010] Please see the appendix Figure 1 This invention provides an image path generation method oriented towards carving processing constraints, the method comprising the following steps: Step S1: Input an RGB image of the artwork, preprocess the input RGB image, and generate multimodal data. In step S1: When inputting RGB images, this invention supports uploading in formats such as jpg / png / psd / bmp / tiff, and uniformly converts them into RGB matrices through decoding; the input RGB image is represented as follows: ,in, Image height, The width is 3, and 3 represents the three RGB channels.
[0011] The preprocessing of the input RGB image specifically includes: Convert the input RGB image to grayscale: ,in: Represents pixel coordinates The red channel value at that location, Represents pixel coordinates The green channel value at that location Represents pixel coordinates The blue channel value at that location; pixel coordinates The grayscale value at the specified location. 0.2989, 0.5870, and 0.1140 are weighting coefficients for the human eye vision model. The cone cells in the human retina (responsible for perceiving color) have completely different sensitivities to different wavelengths of light: they are most sensitive to green light (G, approximately 555nm wavelength) → highest weight (≈58.7%); next most sensitive to red light (R, approximately 650nm wavelength) → medium weight (≈29.9%); and least sensitive to blue light (B, approximately 450nm wavelength) → lowest weight (≈11.4%). By using the above weighting coefficients, the computational complexity can be reduced and structural information can be highlighted.
[0012] After grayscale conversion, Gaussian smoothing is applied to the image to reduce the impact of image noise on subsequent edge detection and path extraction. ; in: After Gaussian smoothing, at pixel coordinates The final grayscale value at the location; The original grayscale image was offset The resulting pixel value; The Gaussian kernel function (weighting function) represents the offset. The weight value at the location; The relative coordinates within the convolution kernel; Let be the standard deviation of the Gaussian distribution. The window radius (or half-width) of the Gaussian kernel.
[0013] Thresholds are calculated using local windows, and integral images or accumulation techniques are introduced to optimize the calculation of local means. Adaptive binarization is then performed on the smoothed image. ; in: Indicates a local window area. The number of pixels in the window. It is the offset constant; Represents pixel coordinates The binarization threshold at the point, For any pixel coordinates within the window grayscale value, Used to iterate through all pixels within the window to calculate the average gray level; pixel coordinates grayscale value at that location pixel coordinates The binarization result at the location (1 for foreground, 0 for background).
[0014] In its specific implementation, this invention uses a fixed-size sliding window (e.g., 11×11) to perform local statistical calculations on the image. Let the input image size be H×W (H and W be the image height and width, respectively), and the window size be k×k (k is the window side length). Then, the time complexity of the traditional implementation is: O(H×W×k). 2 This invention optimizes the calculation of local mean by introducing integral images or accumulation techniques, enabling the window calculation of each pixel to be completed in constant time, thereby reducing the overall complexity to O(H×W).
[0015] The generation of multimodal data specifically includes: Generate a pseudo-depth map: ,in, For deep estimation network models, This represents the input RGB image. This represents the parameters of the depth estimation network model. This represents the generated pseudo-depth map, and , and These represent the height and width of the image, respectively; by generating a pseudo-depth map, the spatial layers (protrusions / concavities) of the image can be expressed, which is of guiding significance for the carving depth.
[0016] Generate pseudo-infrared image: ,in: and These are weighting coefficients. Represents a grayscale image. This represents the Laplacian operator (i.e., the high-frequency components of a grayscale image). This indicates a pseudo-infrared image, and , and These represent the height and width of the image, respectively; by generating a pseudo-infrared image, high-frequency textures can be enhanced, and engraving details can be strengthened.
[0017] Constructing multimodal data: This invention enables low-cost deployment by generating multimodal data from a single image. It involves packaging information from three completely different dimensions—visible light, depth, and infrared—into a unified multimodal dataset to serve as input for subsequent AI models / algorithms.
[0018] Step S2: Construct a gradient field based on multimodal data, construct a structure-guided weight function based on structural saliency, and perform weighted fusion of each modality image in the multimodal data according to the structure-guided weight function.
[0019] In a specific implementation of the present invention, step S2 specifically includes: S21. The multimodal data obtained in step S1 To ensure unified computation, the modal images of the multimodal data are converted into single-channel representations: , and These represent the height and width of the image, respectively.
[0020] S22. To characterize the structural information of the images, the spatial gradient is calculated for each modality image: ; And define the structural saliency function: ; in: These are the pixel coordinates of the image. and These are the partial derivatives (i.e., gradient values) in the horizontal and vertical directions, respectively. Indicates the first Modality in pixel coordinates Spatial gradient at that location Indicates the first Modality in pixel coordinates The structural saliency score at the location; in specific implementation of the present invention, the larger the gradient value, the more obvious the edge or texture of the region, which can be used to determine the degree of information contribution of the mode in the region.
[0021] S23. Based on structural saliency, construct a structure-guided weight function: ; Weight constraints: ; Weighted fusion of images from different modalities in multimodal data is performed based on a structure-guided weighting function: ; in: Indicates the first Modality in pixel coordinates The fusion weight at the point, Represents the fused image in pixel coordinates The value at that location, Indicates the first Pixel values of a modality Indicates the first Modality in pixel coordinates The structural significance score at the location, Indicates all modalities in pixel coordinates The sum of the structural significance scores at each location; Represents extremely small positive numbers (such as 10). −6 (), used to prevent the denominator from being zero; The number of modes (in this invention) (The value is 3). This invention constructs a structure-guided weighting function, which can automatically allocate weights based on local structural information to avoid information loss caused by manually setting fixed weights; and by weighting and fusing the advantageous information of each modality according to the structure-guided weighting function, it can simultaneously preserve structural information and texture details.
[0022] To avoid numerical overflow and ensure numerical stability, the fusion results are normalized: ; in, This represents the pixel values of the final output image after normalization. This represents the original pixel value obtained by weighted fusion. This represents the global minimum value of the fused image. This represents the global maximum value of the fused image. This represents the offset of the pixel value relative to the minimum value. This indicates the numerical dynamic range of the fused image.
[0023] Step S2 further includes: In S23, before weighted fusion, the images of each modality are normalized: ; in, For the first Pixel coordinates of the modality In the normalized pixel values Indicates the first Pixel values of a modality and They represent the first Minimum and maximum values of modal images. By performing normalization processing before weighted fusion, the data scale of different modalities can be unified, avoiding the dominance of a single modality's value in the fusion result.
[0024] In S22, spatial gradient calculation is achieved through discrete convolution. In specific implementations of this invention, the Sobel operator can be used for fast gradient approximation, and the kernel size is preferably 3×3. Simultaneously, vectorized computation (SIMD) or GPU parallel computation can be adopted.
[0025] In S23, to address the issue of the original gradient being susceptible to noise interference, a smoothing mechanism is introduced to improve structural saliency: ; in: Indicates Gaussian filtering. This represents the standard deviation of the Gaussian filter. Indicates the first Modal structural saliency score. This invention introduces a smoothing mechanism to the structural saliency, which can suppress isolated noise points and ensure structural continuity.
[0026] In S23, because the present invention performs stability processing on the denominator to control the numerical stability of the weight calculation when constructing the structure-guided weight function, that is: ; Therefore, the weights are also constrained: ; in, Indicates the first Modal fusion weights, Indicates the first Modal structural significance score This represents the sum of the structural significance scores for all modalities. Represents a very small positive number. Indicates the first Minimum weight of the modality. Indicates the first The maximum weight of the modality; It is a numerical constraint function used to constrain the input weight values (i.e., ) limited to Internally, by controlling the numerical stability of weight calculation and constraining the weights, numerical overflow and abnormal single-modal weights can be prevented.
[0027] In S23, when performing weighted fusion of the images of each modality of multimodal data, if insufficient regional structural information occurs: ; Then, the mean fusion strategy is adopted for fusion: ; Meanwhile, during the weighted fusion process, a pixel-by-pixel parallel approach is used for fusion calculation: ; Specific parallel strategies can be GPU thread-level parallelism (one thread per pixel) or multi-threaded block processing (multi-core CPU); where: This represents summing over all modes. Indicates the first Modality in pixel coordinates The structural significance score at the location, The threshold for structural significance (hyperparameter) is represented. Indicates the first Modal fusion weights, For the number of modes, Indicates the uniform weight value. Indicates the pixel coordinates of the merged image Pixel value at that location, Indicates the first Modality in pixel coordinates The fusion weight at the point, Indicates the first Pixel coordinates of the modality The normalized pixel values. This invention employs a mean fusion strategy when there is insufficient regional structural information, which can avoid weight instability and improve the smoothing effect of regions.
[0028] Step S3: Input the fused image into the enhancement network for detail enhancement and output the enhanced image.
[0029] In a specific implementation of the present invention, step S3 specifically includes: S31. Define the input and output of the enhancement network, where the input is the fused image obtained in step S2: The output is an enhanced image: ;in: The parameter is The neural network mapping function (i.e., the augmentation network). This represents a high-fidelity structural image used for subsequent path extraction. This represents the input fused image. express OK A two-dimensional real matrix of columns. Image height, This represents the image width.
[0030] S32. Network Structure Design: The enhanced network adopts an encoder-decoder structure with skip connections (U-Net-like structure): ; in, This indicates an encoder (multi-layer convolution + downsampling). This represents the bottleneck layer (dilated convolution / residual block). This represents the decoder (upsampling + convolution). This represents the complete augmented network, which can also be represented as... , This indicates a compound operator.
[0031] The encoder (E) is used to extract features from the input: ; Downsampling method: ; Among them, when hour, (The fused image input by the machine); The activation function is ReLU. Indicates the first Layer convolution kernel; For encoder number The output feature map of the layer, Indicates the first Layer bias, This represents the convolution operation. Indicates the total number of floors; This represents the downsampling operation function. Encoder No. The output feature map of the layer, For encoder number Output feature map of the layer.
[0032] The bottleneck layer (B) uses dilated convolution to expand the receptive field: ; in, This is the output feature map of the bottleneck layer. The activation function is ReLU. Indicates the expansion rate Hollow convolution, This represents the input feature map of the bottleneck layer. This represents the bias term of dilated convolution.
[0033] The decoder (D) is used to recover spatial resolution layer by layer: ; in, For decoder number The output feature map of the layer, This is the upsampling operation function. For decoder number The input feature map of the layer, This indicates a skip join operation. This represents the output feature map of the corresponding layer of the encoder, with "+" indicating a feature fusion operation. The decoder's execution logic is as follows: it upsamples layer by layer, with each layer using skip connections to fuse the detailed features corresponding to the encoder, ultimately restoring an enhanced image of the same size as the input image.
[0034] S33, Definition of Path Generation Operator Define the mapping operator from image to path: ,in: Extract the path operator (implemented by step S4). Represents the set of path points.
[0035] S34. Constructing the loss function Define the loss function: ,in, Indicates the total loss. and For loss weighting coefficients, To rebuild the losses, For edge consistency loss, For path continuity loss, This refers to tool constraint loss.
[0036] Reconstruction losses: ,in: and These represent the height and width of the input image, respectively. This represents the total number of pixels in the image and is used to normalize errors and eliminate the influence of images of different sizes. Represents the coordinates of all pixels in the image. Perform a summation operation, iterating through every pixel of the entire image; Indicates the enhanced image in pixel coordinates The pixel value at that location is a high-fidelity structural image output by the deep learning model; Represents a high-quality reference image in pixel coordinates The pixel value at that location is used as the baseline comparison data for the enhancement effect; This represents absolute value operation, used to calculate the difference between corresponding pixels in two images. This loss is also called L1 loss, which can effectively suppress the influence of outliers on the overall error.
[0037] Edge consistency loss: ,in: and These represent the height and width of the input image, respectively. This represents the total number of pixels in the image; This is a gradient operator, representing the calculation of spatial gradients in an image to extract edge and structural information. Indicates the enhanced image in pixel coordinates The gradient value at a given point represents the edge and structural features of the enhanced image; Represents a high-quality reference image in pixel coordinates The gradient value at that point is used as the baseline comparison data for the edge structure. This represents a summation operation. The edge consistency loss function value is used to measure the similarity between the enhanced image and the reference image in terms of edge and contour structure; the smaller the value, the better the structural consistency.
[0038] For the generation path of the enhanced image: Define the second-order difference of the path: Then the path continuity loss is: ;in: This represents the set of path points corresponding to the enhanced image, which is the initial path sequence extracted from the enhanced image; The path extraction operator represents a mapping function that generates paths from an image, transforming a two-dimensional image into an ordered sequence of path points. This represents the enhanced image output by the deep learning model, which serves as the input for path extraction. The second difference of the path point sequence reflects the degree of curvature change of the path and is a key indicator for measuring the smoothness of the path. and These are three consecutive path points in the path sequence, each a two-dimensional coordinate vector; This represents summing the second differences of all path points in the path sequence, and iterating through all valid points on the path; The norm operation (usually L2 norm) is used to calculate the magnitude of the second-order difference vector, quantifying the deviation of path points. This path continuity loss function value is used to penalize abrupt changes and sharp turns at path points to improve path smoothness; the smaller the value, the smoother and more continuous the path.
[0039] Define path curvature: ; Tool constraint loss: ,in: For the first The path curvature at each path point indicates the degree of curvature of the path at that point; the greater the curvature, the sharper the turn. and path point The first derivative value at that point represents the tangent component of the path at that point, which is approximately calculated by the difference between adjacent path points. and path point The second derivative value at that point represents the curvature change component of the path at that point, which is approximately calculated by the second difference between adjacent path points. This represents absolute value operations, ensuring that the curvature is non-negative. This is a normalization term used to normalize the vector length in the tangent direction, making the curvature result independent of scale. This indicates the minimum turning radius of the engraving tool. It is a fixed process parameter of the equipment and is determined by the tool type, such as carbide tools. Typically 2~5mm; This indicates the maximum curvature allowed by the tool; paths exceeding this value cannot be machined by the tool. To find the maximum value function, only if the path curvature Loss only occurs when the maximum allowable curvature is exceeded; the loss for paths that meet the constraints is 0. This represents the summation of curvature constraint losses over all path points in the path sequence, iterating through all points on the path. This tool constraint loss function value penalizes path curvature exceeding the tool's machining capabilities, forcing the model to output a machinable structure; a larger value indicates a path that is less compliant with machining constraints.
[0040] S35, Model Training Constructing training samples: Training samples can be obtained through high-resolution scan data or manually annotated augmented images; This represents the set of paired training samples used for model training, where each pair of samples contains a fused image. and corresponding high-quality reference images .
[0041] Parameter update: Gradient descent optimization is used: ,in: It is the set of trainable parameters for a deep learning model, including the weights and biases of each convolutional kernel, and is the object of model learning and optimization. This is an assignment update operation, indicating that the result of the calculation on the right is updated to the variable on the left. The learning rate controls the step size of parameter updates and is a key hyperparameter for model training. loss function (i.e., total loss) on model parameters The gradient represents the direction and magnitude of parameter adjustment, and is used to guide model optimization to reduce loss.
[0042] The overall training process is as follows: Input fused image To obtain an enhanced image Generate path Calculate the loss function Update the model parameters. Meanwhile, in the inference phase, only the following actions are performed during actual use: That is, it does not participate in the backpropagation of the path to ensure efficiency, where: The parameter is Neural network mapping function (enhanced network). This represents a high-fidelity structural image used for subsequent path extraction. This represents the input fused image.
[0043] This invention introduces a path generation operator into the loss function, so that the image enhancement result is directly affected by path continuity and processing constraints, thereby achieving direct coupling of path optimization and ensuring that the output result can be directly used for engraving processing.
[0044] Step S4: Extract paths and calculate curvature from the enhanced image to obtain a path set and a curvature sequence.
[0045] In step S4, the input is the enhanced image: The output target is a set of paths: ;in: This represents the enhanced image output by the deep learning model. express and A two-dimensional real matrix of columns. Image height, The width of the image is represented by the grayscale value of the corresponding pixel. This is the final set of paths, containing all individual sculpted paths in the image; The total number of independent paths (i.e., connected components) in the image is determined by the structural complexity of the image; For the first An independent path is a subsequence within a set of paths; For the first The total number of path points contained in the path; For the first The first in the path 1 path point; For the first The two-dimensional coordinates of each path point in the image pixel coordinate system.
[0046] In a specific implementation of the present invention, step S4 specifically includes: S41, Adaptive Binary Segmentation (Resistant to Uneven Brightness) Adaptive binary segmentation of the enhanced image is performed using a local statistical threshold (different from the segmentation in step S1, this is a dedicated segmentation for path extraction): ; in: pixel coordinates The adaptive binarization threshold at a given location is determined by the mean and standard deviation within the local window, and is used to address the problem of uneven brightness. In pixel coordinates local window centered Within the window, the average grayscale value of all pixels is set, and the preferred window size is 15×15. In pixel coordinates local window centered Within the range, the grayscale standard deviation of all pixels reflects the degree of brightness fluctuation in a local area; This is the contrast coefficient, typically ranging from [−0.2, 0.2], used to adjust the sensitivity of the threshold to local standard deviation. It can be fine-tuned according to the strength of the image texture. To enhance the image at pixel coordinates The grayscale value at that location; The resulting image after binary segmentation has pixel values of only 0 or 1, where 1 represents the foreground region (the contour / skeleton region corresponding to the carving path) and 0 represents the background region. Step S41 uses an adaptive threshold based on local mean and standard deviation for segmentation, which complements the binary segmentation in step S1 and is specifically designed for wood carvings and scenes with uneven texture intensity. By introducing the standard deviation term, the algorithm can automatically adapt to local brightness changes and stably extract contours in both high-contrast texture regions and low-contrast smooth regions, providing a high-quality binary image for subsequent skeletonization and path tracking.
[0047] S42. Refinement with topology preservation (skeletonization) Refine the binary region into a single-pixel-wide skeleton: ;in: The single-pixel wide skeleton image after skeletonization is the core basic data for path extraction, and only the centerline structure of the binary region is retained. The topology-preserving thinning operator, preferably the Zhang–Suen iterative thinning algorithm, is used in this invention. Its function is to shrink the contour of the binary region into a skeleton with a width of 1 pixel, while maintaining the connectivity and topology of the original region. The binary segmented image after S41 processing is the input data for skeletonization.
[0048] S43. Initialize connected components and paths, and perform sub-pixel refinement (to improve geometric accuracy). Extracting connected components: ; For each connected component, perform an ordered traversal (with endpoint priority and adjacency tracking) to generate an initial path: This yields a set of paths; where: This represents the extracted set of connected components, where each connected component represents an independent sculpted path skeleton in the image. This represents the total number of independent connected components (path skeletons) in the image; For the first Each independent connected component consists of a set of interconnected skeleton pixels; This represents the connected component analysis operator, which separates all independent, unconnected path skeletons from the skeleton image, providing data for subsequent path initialization. It is a path tracing operator used to connect a connected component. Convert into an ordered sequence of path points; This represents the output of the path tracing operator, which identifies the path from the first... The initial path point sequence generated by the connected components.
[0049] And perform sub-pixel correction on the path points of the initial path in the gradient field: , ,in: The pixel-level path points obtained above are two-dimensional coordinate vectors; path point The subpixel correction offset, which is a tiny offset vector obtained through optimization, determines the position of the refined path point. The assignment update operation means assigning the corrected coordinates to the original path points; This represents the offset that minimizes the value of the function on the right. The operators are used to find the optimal correction direction; Indicates enhanced image At point The gradient vector at that point reflects the edge strength and direction of the image at that point; path point The unit normal vector at the point points perpendicular to the path and is used to find the most significant edge location in the gradient field; ⋅ is the vector dot product operation, used to calculate the component of the gradient in the path normal direction; This is an L2 norm operation used to quantize the absolute value of gradient components. This invention performs sub-pixel level correction on path points in the gradient field, precisely snapping the path points to the true edge positions of the enhanced image, effectively reducing jagged edges caused by path extraction and significantly improving the geometric accuracy of the sculpted path.
[0050] S44. Curvature Calculation (Discrete Form) For discrete path points, the curvature is calculated using the three-point method or equivalent derivative form, thus obtaining a curvature sequence; the three-point method approximates the curvature calculation as follows: ; in: For the first The discrete curvature at each path point represents the degree of curvature of the path at that point; the greater the curvature, the sharper the turn. and For three consecutive adjacent path points in a discrete path point sequence, each is a two-dimensional coordinate vector; This represents the area of the triangle formed by the three path points, used to approximate the curvature of the path. and Both represent the Euclidean distance between two path points; Calculate curvature using equivalent derivative form: ; in: For the first The continuous curvature at each path point is the mathematical definition of the curvature of a continuous path function; and path point The first derivative of the coordinates represents the tangent component of the path at that point; and path point The second derivative of the coordinate represents the curvature change component of the path at that point; This represents absolute value operations, ensuring that the curvature is non-negative. This is a normalization term used to normalize the vector length in the tangent direction, making the curvature result independent of scale. Smoothing the curvature sequence: ; in, For the first The curvature value of each path point after smoothing is the result of noise reduction processing, which eliminates high-frequency noise caused by discrete calculation. path point The neighborhood window represents the set of adjacent path points participating in the smoothing calculation, and the window size is preferably 5 points (i.e., containing...). ); This indicates traversing all path points within the neighborhood window; For the neighboring region The Gaussian weight coefficients corresponding to each path point, with the weight varying with distance from the center. The distance decreases according to a Gaussian distribution to achieve a smooth filtering effect; For the neighboring region The original curvature values of each path point are the input data for smoothing calculations; This step involves summing the weighted curvature values of all path points within the neighborhood window to obtain the smoothed curvature. By performing one-dimensional Gaussian smoothing on the curvature sequence, this effectively suppresses high-frequency noise introduced during path discrete sampling and calculation, avoids misjudgments in subsequent machining constraint optimization due to abrupt curvature changes at a single point, ensures the stability of the curvature data, and provides a reliable geometric basis for subsequent tool constraint path optimization.
[0051] The complexity of step S4: Segmentation: O(HW) (Integral graph optimization); Skeletonization: O(HW); Path tracing: Curvature: Where H and W represent the height and width of the image, respectively, and O represents the time complexity. O(HW) means that the algorithm execution time is proportional to the total number of pixels in the image (linear complexity). For example, O(HW) (integral image optimization) means that by using integral image techniques, the original time complexity of O(H×W×k) is reduced to O(H×W×k). 2 The calculation of the local window mean is reduced to O(HW); This is to sum the number of path points across all paths (i.e., the total number of path points across all paths). This means that the time complexity is directly proportional to the total number of path points. For the first The number of path points contained in each independent path. Through step S4, the topology is preserved and an ordered path with computable curvature is obtained, thus providing direct geometric quantities for machining constraints.
[0052] Step S5: Use optimization strategies to process the path set and curvature sequence to obtain optimized paths.
[0053] In a specific implementation of the present invention, step S5 specifically includes: S51. Define machining constraints (tools and processes): Minimum radius of curvature: ; Minimum line segment length: (To avoid jitter), it is one of the important process constraints for path optimization, and it plays a constraining role in defining the maximum allowable curvature, curvature constraint reconstruction, corner rounding, etc. Maximum allowable deviation: Shape error); Define the objective function (multi-objective unification): ; in, Let be the set of path points to be optimized, which are the variables of this optimization problem; Represents the set of all possible path points In the process, find the optimal path that minimizes the objective function; The overall objective function value for path optimization incorporates losses from four dimensions: smoothness, fit, processing constraints, and complexity. and The weighting coefficients for each component loss are used to balance the importance of different optimization objectives, and their values are usually in the range of [0,1]. For path smoothing term loss, For path fitting term loss, Tool constraint loss, The loss is the path length / complexity regularization term.
[0054] Path smoothing term (suppressing high-frequency oscillations) loss: ;in: and These are three consecutive path points in the path sequence; The second difference of the path reflects the curvature change of the path; the larger the second difference, the less smooth the path. The square of the L2 norm is used to quantify the magnitude of the second difference; a larger value indicates more severe path oscillation. This involves summing the second-order difference losses over all points on the path. The path smoothing term is used to penalize high-frequency oscillations and sharp corners in the path, resulting in a smoother optimized path.
[0055] Path-fitting (without deviating from the original path) loss: ,in: These are the optimized path points; This is the original set of path points before optimization; Representing path points To the original path set The shortest Euclidean distance; It is the square of the distance, used to amplify the penalty effect for larger deviations; This involves summing the distance loss over all path points.
[0056] Tool constraint loss: ,in: Indicates when curvature Exceeding the maximum permissible curvature If the difference is true, it is taken; otherwise, it is 0. Indicates the first The curvature of each path point; This involves summing the losses over all path points. By incorporating path fit loss and tool constraint loss, we can ensure that the optimized path does not deviate excessively from the original path, thus guaranteeing the shape accuracy of the engraved pattern.
[0057] Path length / complexity regularization loss: ,in: and These are two adjacent path points in the path sequence; The Euclidean distance between adjacent path points; The total path length is calculated by summing the distances between all adjacent points along the path. This path length / complexity regularization loss is used to penalize the total path length, thereby reducing the number of path points while maintaining accuracy, thus lowering the complexity of the PLT file and processing time.
[0058] S52. A phased optimization strategy is adopted to process the path set and curvature sequence, wherein the phased optimization strategy includes: Phase A: Curvature Constraint Reconstruction For the specified segments, local refitting (circular arc / spline) is employed: ; in, Local path segments with excessive curvature are the targets for reconstruction and optimization. This is a spline fitting operator that uses circular arcs or cubic splines to refit the local path; The curvature of the fitted path segment must satisfy the following constraints. ; Indicates the first The curvature of each path point; The maximum allowable curvature of the tool is determined by the tool's minimum turning radius. ; For value assignment and updating, this means assigning the reconstructed path segment to the original local path. This invention ensures that the curvature of all path segments remains within the machinable range by reconstructing sharp turns that exceed the tool's machining capabilities.
[0059] Phase B: Adaptive Sampling (Point Compression) Non-uniform sampling based on curvature: ; in, Indicates the first The sampling step size between one path point and the next path point determines the point density of the path; This represents the sampling density control coefficient, which is an adjustable hyperparameter used to adjust the density of the path as a whole. Indicates the first The absolute value of curvature at each path point reflects the degree of curvature of the path; This represents a very small positive number, used to prevent the denominator from being zero. In this invention, the step size... With curvature Inversely proportional, it achieves non-uniform sampling with "large curvature (sharp turns) → dense sampling, small curvature (straight lines) → sparse sampling", which can significantly reduce the number of path points while ensuring accuracy.
[0060] Phase C: Douglas–Peucker constraint simplification (with error bounds): ; in, This represents the set of path points to be simplified. This represents the Douglas-Peucker path simplification operator, a classic polyline simplification algorithm; This represents the maximum permissible error (shape error) in the simplification process, i.e., the maximum deviation between the simplified path and the original path, used to control the degree of shape distortion; For assignment updates, this means assigning the simplified path set to the original path. By using Douglas-Peucker constraints for simplification, the shape error can be kept within a certain limit. Under the premise of further eliminating redundant path points, a more concise and efficient path sequence is generated.
[0061] Stage D: Corner rounding (manufacturability) Replace acute angles with rounded corners: ;
[0062] in: Representing path points acute angle corner; The arc segment used to replace the acute angle has a radius of [missing information]. ; This indicates the minimum turning radius of the engraving tool, which is determined by the tool model. This invention eliminates sudden stops and jitter during machining by replacing acute angles in the path with arcs that meet the tool radius requirements, ensuring the machinability and stability of the machining path.
[0063] S53. Convergence and Termination When satisfied When the convergence stops, the optimized path is obtained; where, It represents the change in the objective function value between two iterations, reflecting the degree of convergence of the path optimization; This represents the convergence threshold of the change in the objective function. At that point, it is considered that the optimization has converged; This is the maximum number of iterations in the optimization process, used to prevent the algorithm from getting stuck in an infinite loop. This invention ensures that the path optimization algorithm can find the optimal solution without iterating indefinitely by setting explicit stopping conditions.
[0064] The complexity of step S5: Local fitting: DP simplification: , shared equally. Among them: The time complexity of local fitting is proportional to the total number of points in the path. For the first The number of points on the path; To simplify the Douglas–Peucker algorithm, the amortized time complexity is calculated. This represents the total number of path points. This complexity theoretically proves the efficiency of the algorithm, demonstrating its good performance even when processing large-scale path data. Through step S5 above, the curvature is machinable, the path is continuous and jitter-free, the number of points is significantly reduced (making the file lighter), and the shape error is controllable.
[0065] Step S6: Generate the final PLT file.
[0066] In a specific implementation of the present invention, step S6 specifically includes: S61, Coordinate Mapping and Calibration Map pixel coordinates to device coordinates: ;in: and Indicates the scaling factor (determined by the actual size / resolution); and This indicates the offset of the origin (machine tool coordinate system).
[0067] S62. Path sorting (reducing empty trips) Solve for the path visit order to minimize the empty travel distance (approximate TSP): ; The preferred heuristic of this invention is the use of the "nearest neighbor + 2-opt" algorithm, which significantly reduces computational complexity while ensuring solution quality and quickly obtains the optimal or near-optimal path order. in: This indicates the path-visiting order that minimizes the total empty distance. This represents the summation of the empty distances over all adjacent paths; Represents a distance function, calculates the Euclidean or Manhattan distance between two path endpoints, and quantifies the distance traveled in space. Indicates the first The coordinates of the endpoint of the path; Indicates the first The starting coordinates of each path. By sorting the paths, the idle travel time during processing can be significantly reduced, improving overall processing efficiency.
[0068] S63, Set the raising and lowering strategies for the sword. For each path: Starting point: PU (Pen Up) for movement; Path: PD (Pen Down) drawing; The instructions are as follows: PU x1,y1 PD x2,y2 ... PU xn,yn Wherein: PU x1,y1 is the Pen Up command, indicating that the tool is raised and moved to the starting point (x1,y1) of the next path, without engraving; PD x2,y2 is the Pen Down command, indicating that the tool is lowered and drawing / engraving begins from the starting point (x2,y2); PU xn,yn is the command after machining is completed, the last path is drawn, and the tool is raised to the ending point (xn,yn); x1, y1, x2, y2, xn, and yn are all specific coordinate values in the machine tool coordinate system. This step S63, through standardized machining command format, clearly distinguishes between the two stages of "non-machining movement" and "engraving machining," ensuring that the equipment executes accurately according to the process requirements.
[0069] S64, Embedding Speed and Process Parameters Adaptive speed based on curvature (if device supports): ; in: For the first on the path The processing speed at each point is the feed rate of the equipment when executing that segment of the path; The maximum processing speed supported by the equipment is the rated process parameter of the equipment; It is an exponential function used to achieve nonlinear adjustment of velocity as curvature changes; The velocity attenuation coefficient controls the strength of the curvature's influence on velocity; it is an adjustable process parameter. No. The curvature of each path point; The value is the absolute value of the curvature, ensuring that the input is non-negative. In this invention, when the path curvature is large (sharp turns), the speed will decrease exponentially to avoid overcutting or processing vibration; when the curvature is small (straight lines), the speed can be increased to near its maximum value, balancing processing efficiency and quality.
[0070] S65. Numerical Quantization and Precision Control Quantize floating-point coordinates to device resolution: ; in: The quantized device coordinates are integer coordinate values that the device can directly recognize. and Represents the optimized floating-point coordinates of the path points (unit: mm); This indicates the device's minimum step distance (resolution), which is the minimum physical distance the device can move in a single step (e.g., 0.01mm). This indicates a floor function, converting floating-point coordinates into an integer number of steps that the device can execute. By controlling the quantization and precision of the values, it is possible to ensure that the path coordinates perfectly match the device's hardware resolution, avoiding machining errors or invalid commands caused by floating-point precision.
[0071] S66, PLT file generation and verification Generate PLT text stream: ; in: This indicates that the final generated PLT format text stream can be directly imported into the equipment's processing files; The splicing operator is used to combine the various components of a PLT file; The header of the PLT file contains metadata such as device identification information and unit definitions; A sequence containing all tool lifting (PU) and tool lowering (PD) machining instructions; This is the end of the PLT file, indicating the end of the file. Verification items: non-empty path, coordinate out-of-bounds check, continuity check.
[0072] The complexity of step S6: Path sorting: (Heuristic); Writing a file: Where: K is the total number of independent paths (connected components) in the image; The time complexity of the heuristic path sorting algorithm is shown, indicating that the algorithm's time consumption increases quadratically with the number of paths K. Due to the use of heuristic strategies (such as nearest neighbor + 2-opt), this complexity is more efficient than the brute-force solution complexity of the exact TSP, making it suitable for large-scale path data processing. This represents the total number of path points across all paths. The time complexity of the file write operation is proportional to the total number of points in the path and is linear, indicating that the algorithm is highly efficient in the data writing phase with no redundant computation.
[0073] This invention effectively realizes a complete technical chain from image processing to processable path generation, deeply integrating image enhancement and processing constraints. This significantly improves the practical application value of digitizing and intelligently manufacturing intangible cultural heritage, demonstrating significant technological advancement and engineering application value. Compared with existing technologies, this invention has at least the following beneficial effects: 1. Significantly improves detail retention: By introducing a structure-guided multimodal fusion mechanism and a deep learning enhancement model with edge consistency constraints, the ability to retain image details is significantly improved, which is especially suitable for the digital preservation of art forms such as wood carving and ceramic crafts. 2. Improved path continuity (avoiding breaks and jagged edges): By introducing path smoothing constraints and curvature control mechanisms, the continuity and smoothness of the generated path are significantly improved; 3. Reduce file complexity (path compression and optimization): By using a curvature adaptive sampling strategy, the number of path points can be effectively reduced while ensuring detail accuracy, thereby reducing the complexity of PLT files; 4. Directly meets carving requirements: A carving process constraint model is introduced, and physical processing conditions are integrated into the path generation process, making the final generated path not only "visible" but also "processable".
[0074] Based on the same inventive concept, this application also provides an apparatus corresponding to the method in Embodiment 1, as detailed in Embodiment 2.
[0075] Example 2 Please see the appendix Figure 2As shown, the present invention provides an image path generation device oriented towards carving processing constraints, the device comprising: The multimodal data generation module is used to input RGB images of artworks, preprocess the input RGB images, and generate multimodal data. The image fusion module is used to construct a gradient field based on multimodal data, construct a structure-guided weight function based on structural saliency, and perform weighted fusion of each modality image in the multimodal data according to the structure-guided weight function to obtain a fused image. The detail enhancement module is used to input the fused image into the enhancement network for detail enhancement and output the enhanced image. The enhancement network adopts an encoder-decoder structure with skip connections. Path generation operators are defined in the enhancement network, and a loss function is constructed for model training. The path extraction module is used to extract paths and calculate curvature in the enhanced image, resulting in a path set and a curvature sequence. The path optimization module is used to process the path set and curvature sequence using optimization strategies to obtain optimized paths. The file generation module is used to generate the final PLT file.
[0076] It should be noted that the multimodal data generation module of the present invention performs the same function as step S1, the image fusion module performs the same function as step S2, the detail enhancement module performs the same function as step S3, the path extraction module performs the same function as step S4, the path optimization module performs the same function as step S5, and the file generation module performs the same function as step S6. For details, please refer to the detailed description of Embodiment 1. The details of each module will not be described in detail here.
[0077] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for generating image paths oriented towards carving processing constraints, characterized in that, The method includes the following steps: Step S1: Input the RGB image of the artwork, preprocess the input RGB image, and generate multimodal data; Step S2: Construct a gradient field based on multimodal data, construct a structure-guided weight function based on structure saliency, and perform weighted fusion of each modality image in the multimodal data according to the structure-guided weight function to obtain a fused image; Step S3: Input the fused image into the enhancement network for detail enhancement and output the enhanced image. The enhancement network adopts an encoder-decoder structure with skip connections. Path generation operators are defined in the enhancement network, and a loss function is constructed for model training. Step S4: Extract paths and calculate curvature from the enhanced image to obtain a path set and a curvature sequence; Step S5: Use optimization strategies to process the path set and curvature sequence to obtain optimized paths; Step S6: Generate the final PLT file.
2. The image path generation method for carving processing constraints according to claim 1, characterized in that, The preprocessing of the input RGB image specifically includes: Convert the input RGB image to grayscale: , in, and Represents pixel coordinates The corresponding channel value, Represents pixel coordinates The grayscale value at that location; Perform Gaussian smoothing on the grayscale image; The threshold is calculated using a local window, and integral images or accumulation techniques are introduced to optimize the calculation of local means, and adaptive binarization is performed on the smoothed image. The generation of multimodal data specifically includes: Generate a pseudo-depth map: ,in, This represents a depth estimation network. This represents the input RGB image. Represents the parameters of the depth estimation network model; Generate pseudo-infrared image: ,in, and Indicates the weighting coefficient. Represents a grayscale image. Represents the Laplacian operator; Constructing multimodal data: .
3. The image path generation method oriented towards carving processing constraints according to claim 1, characterized in that, Step S2 specifically includes: S21. Convert each modal image in the multimodal data into a single-channel representation; S22. Calculate the spatial gradient for each modality image: ; And define the structural saliency function: ; in, These are the pixel coordinates of the image. and Let represent the partial derivatives in the horizontal and vertical directions, respectively. Indicates the first Modality in pixel coordinates Spatial gradient at that location Indicates the first Modality in pixel coordinates The structural significance score at the location; S23. Based on structural saliency, construct a structure-guided weight function: ; Weight constraints: ; Weighted fusion of images from different modalities in multimodal data is performed based on a structure-guided weighting function: ; in, Indicates the first Modality in pixel coordinates The fusion weight at the point, Indicates the pixel coordinates of the merged image The value at that location, Indicates the first Pixel values of a modality Indicates the first Modality in pixel coordinates The structural significance score at the location, Indicates all modalities in pixel coordinates The sum of the structural significance scores at each location, Represents a very small positive number. The number of modes; S24. Normalize the fusion results.
4. The image path generation method for carving processing constraints according to claim 3, characterized in that, In step S2: Before weighted fusion, the images of each modality are normalized; Spatial gradient calculation is achieved through discrete convolution; Introduce a smoothing mechanism to address structural saliency; When constructing the structure-guided weight function, constraints are also imposed on the weights; When performing weighted fusion of images from different modalities in multimodal data, if there is insufficient regional structural information, a mean fusion strategy is adopted for fusion. At the same time, during the weighted fusion process, a pixel-by-pixel parallel fusion calculation is performed.
5. The image path generation method oriented towards carving processing constraints according to claim 1, characterized in that, In step S3, constructing the loss function specifically involves: ,in, Indicates the total loss. and For loss weighting coefficients, To rebuild the losses, For edge consistency loss, For path continuity loss, This refers to tool constraint loss.
6. The image path generation method oriented towards carving processing constraints according to claim 1, characterized in that, Step S4 specifically includes: Adaptive binary segmentation of the enhanced image is performed using a local statistical threshold. The binary region is refined into a single-pixel-wide skeleton; Extract connected components, perform ordered traversal of each connected component to generate an initial path, obtain a path set, and perform sub-pixel correction on the path points of the initial path in the gradient field. For discrete path points, the curvature is calculated using the three-point method or equivalent derivative form to obtain a curvature sequence, which is then smoothed.
7. The image path generation method for carving processing constraints according to claim 1, characterized in that, Step S5 specifically includes: Define the machining constraints and objective function, where the machining constraints include the minimum radius of curvature, the minimum segment length, and the maximum allowable deviation; the objective function is: ; in, The set of path points to be optimized; Represents the set of all possible path points In the process, find the optimal path that minimizes the objective function; The overall objective function value for path optimization; and These are the weighting coefficients for the losses of each component; For path smoothing term loss, For path fitting term loss, Tool constraint loss, The loss is calculated using the path length / complexity regularization term; A phased optimization strategy is adopted to process the path set and curvature sequence. The phased optimization strategy includes four stages: curvature constraint reconstruction, adaptive sampling, Douglas-Peucker constraint simplification, and corner rounding. Once convergence is achieved, the optimized path can be obtained.
8. The image path generation method for carving processing constraints according to claim 1, characterized in that, Step S6 specifically includes: Coordinate mapping and calibration: Mapping pixel coordinates to device coordinates; Path sorting: Solving for the path visit order to minimize the empty movement distance; Set up the strategies for raising and lowering the sword; Embedding speed and process parameters; Numerical quantization and precision control; PLT file generation and verification.
9. An image path generation device oriented towards carving processing constraints, characterized in that, The device includes: The multimodal data generation module is used to input RGB images of artworks, preprocess the input RGB images, and generate multimodal data. The image fusion module is used to construct a gradient field based on multimodal data, construct a structure-guided weight function based on structural saliency, and perform weighted fusion of each modality image in the multimodal data according to the structure-guided weight function to obtain a fused image. The detail enhancement module is used to input the fused image into the enhancement network for detail enhancement and output the enhanced image. The enhancement network adopts an encoder-decoder structure with skip connections. Path generation operators are defined in the enhancement network, and a loss function is constructed for model training. The path extraction module is used to extract paths and calculate curvature in the enhanced image, resulting in a path set and a curvature sequence. The path optimization module is used to process the path set and curvature sequence using optimization strategies to obtain optimized paths. The file generation module is used to generate the final PLT file.