Embroidery texture generation techniques guided by directional flow

Through the image edge tangent flow and multi-process processing embroidery texture generation method, the traditional embroidery texture simulation is solved, and efficient generation in different images and texture processing scenes is achieved, and visual quality and processing efficiency are improved.

CN118967904APending Publication Date: 2024-11-15HUNAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410935395.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

Traditional embroidery texture simulation methods have the problem that texture simulation is not realistic enough and the effect is not natural enough. In addition, deep learning methods require a large amount of data, making it difficult to adapt to different image and texture processing scenarios.

Method used

Using the embroidery texture generation method based on image edge tangent flow (ETF) and multi-process processing, it generates natural and delicate embroidery textures through data preprocessing, texture simulation and brightness mapping, including data acquisition, data preprocessing, texture simulation, and multi-process Processing and brightness mapping steps.

Benefits of technology

It improves the visual quality and processing efficiency of embroidered textures, is suitable for large-scale image processing, and has high flexibility and can enhance the aesthetics and artistic effects of images without changing the original color.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118967904A_ABST
    Figure CN118967904A_ABST
Patent Text Reader

Abstract

The invention provides an embroidery texture generation technology based on an edge tangent flow (ETF) and multi-process processing, and relates to an embroidery texture generation method based on the Edge TangentFlow (ETF) and the multi-process processing. And reading the image file, converting the image file into a grey-scale map and generating a noise image. On one hand, through an ETF algorithm, a smooth direction flow corresponding to an original image is obtained, and a direction mask is generated. On the other hand, the shadow between the embroidery threads is simulated by distributing different gray values on each row of pixels. A plurality of processes are created, each process corresponds to one direction mask, and stroke information is recorded and returned to the host process. Creating a plurality of processes again, grouping the stroke information through directions and transmitting the stroke information to the sub-processes; and each sub-process generates strokes according to the stroke information, draws the strokes on a Gaussian noise background canvas, and returns to the canvas after texture enhancement. And creating an initial Gaussian noise background canvas in the main process, receiving and superposing the gray canvas generated by each process, and finally mapping the synthesized gray texture as a brightness layer to the original color image to obtain a final effect picture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image processing and texture generation, in particular to an embroidery texture generation technology based on image directional flow and multi-process processing. Background Art

[0002] As a traditional handicraft technique, embroidery is often used in clothing, home textiles and artworks for its unique texture effect, which has high aesthetic value and cultural significance. With the development of modern industry, the inheritance and development of traditional embroidery is facing risks such as difficulty in skill inheritance, limited market demand and shortage of manual talents. We must make full use of digital technology to promote the protection, inheritance and innovation of traditional crafts.

[0003] Traditional embroidery texture simulation methods mainly rely on the direct application of graphics and algorithms, including algorithmic generation of stitch paths, simulation modeling and rendering of embroidery threads, and linear style simulation of embroidery. These methods have problems such as unrealistic texture simulation and unnatural embroidery effects.

[0004] With the rise of deep learning technology, embroidery texture simulation methods have also ushered in new development directions. Some methods use CNN and CycleGAN to solve the problem of embroidery image-to-image translation. Some methods create paired embroidery datasets for the first time and propose end-to-end embroidery style generation based on GAN. Some methods use attention modules for unsupervised embroidery synthesis. These methods often require learning a large amount of data.

[0005] In the face of these challenges, the present invention aims to provide a novel embroidery texture generation technology, which can generate realistic embroidery texture effects on digital images through image analysis, texture simulation and innovative algorithm design. Summary of the invention

[0006] 1. Technical issues to be resolved

[0007] The purpose of the present invention is to provide a novel embroidery texture generation technology, which can simulate embroidery effects more naturally and be effectively applied to different image and texture processing scenarios.

[0008] (II) Technical solution

[0009] The present invention provides an embroidery texture generation method based on image edge tangent flow (ETF) and multi-process processing, comprising:

[0010] Data acquisition, uses standard images (such as .png, .jpg) as input, including digital photos and graphic design drafts.

[0011] Data preprocessing, input color image, convert it to grayscale image, apply random noise to get the corresponding noise image.

[0012] Save the direction mask, input the noisy image, calculate and get the vector direction of each pixel in the image through the ETF algorithm. Divide the image into different direction segments, generate and save each direction segment mask.

[0013] Texture simulation, pixel-level grayscale value simulation of the shadow lines between embroidery threads.

[0014] Multi-process processing, each sub-process corresponds to a direction segment, and the stroke information of each angle is recorded in parallel through the sub-process. Each stroke includes information such as the starting point, end point, grayscale and width. Then, the drawing of all strokes in each direction is processed in parallel and returned to the main process.

[0015] Brightness mapping and comprehensive processing, the main process receives and superimposes the grayscale texture of all directional segments, and maps the grayscale value as brightness to the original color image. Adjust the mapped brightness layer to ensure that the texture details are clearly visible in the final image. This process not only improves the dynamic range of the image, but also enhances the depth and detail perception of the image.

[0016] In some embodiments of the present invention, the step of saving the direction mask comprises:

[0017] Calculate the directional flow. Define a class named ETF, which implements the Edge TangentFlow (ETF) algorithm for generating and processing the directional field of an image. First, input the parameters such as the noise image to be processed noisy_img, the number of directions dir_num, the kernel radius kernel_radius, and the number of iterations iter_time. Adjust the size of the input image according to its size, ensure that the longest side of the image is a fixed value of pixels (such as 512 pixels), and expand the edge of the image to prevent boundary problems in the convolution operation, and normalize the image. Then, the Sobel operator is used to calculate the x and y direction gradients, gradient amplitudes, and normalized gradients of the image, and then the gradient direction is calculated and rotated 90° counterclockwise to obtain the edge tangent direction. Next, combined with the three weight kernels, the gradient direction of each pixel is updated through the convolution operation, and the gradient direction of each pixel is iteratively refined to make the overall directional flow smoother. Finally, the final gradient direction of each pixel is calculated and normalized.

[0018] Save the direction mask. Resample the processed gradient direction to the original image size and calculate the gradient direction angle of each pixel. Generate masks according to the number of directions dir_num, each mask represents a direction segment within a certain range. Save the generated direction mask to the specified output path.

[0019] In some embodiments of the present invention, the implementation of the texture simulation technology includes:

[0020] Define a distribution matrix D, which calculates the average grayscale value mean and variance var of each row of pixels based on the grayscale value and width of the line, thereby controlling the color depth of each row of pixels of the line. Use the Gaussian function to generate a Gaussian noise background canvas. The function receives the size, mean and variance of the matrix as input, and outputs a random array that conforms to the specified normal distribution to simulate the randomness and irregularity of natural textures. Define a Getline function to create a Gaussian noise canvas based on the provided grayscale distribution matrix and line length, generate simulated lines, and use an exponential decay method to adjust the line edge pixels to make the line edge smoother. In summary, a natural grayscale texture stroke can be obtained.

[0021] In some embodiments of the present invention, the multi-process processing of obtaining stroke information includes:

[0022] Image preprocessing. For a certain subprocess, the mask of the direction segment is rotated so that the actual stroke direction of the image corresponding to the direction segment is vertically downward. At the same time, the input grayscale image is also rotated according to the same angle to maintain the consistency of the image content and the direction mask. The rotated grayscale image is processed by histogram equalization to enhance its contrast and make the stroke features more prominent. Then the image is quantized and the grayscale level is divided into n intervals, each of which represents the grayscale level of a stroke. In addition, the Canny edge detection algorithm is used to identify the edges in the image and generate a mask.

[0023] Generate strokes. Traverse each quantization level and apply a mask to each level. These masks are generated by the previous quantization step and identify the stroke area of ​​the corresponding grayscale level. For each mask, traverse each row of pixels and calculate its intersection with the direction mask to obtain the starting position (begin) and ending position (end) of each stroke in each row of pixels. At the same time, determine whether there are pixels with edge segment masks of 1 between begin and end. If there are pixels, segment them and obtain the new end as the end point of the first segment and the new begin as the starting point of the second segment.

[0024] Record stroke information. Record the detailed information of each stroke, including its rotation angle angle, grayscale grayscale, starting row row, width period, starting point begin, and end point end, into the stroke_temp collection, add it to the stroke_sequence collection, and return it to the main process.

[0025] In some embodiments of the present invention, the design of multi-process processing of stroke drawing includes:

[0026] Pass in stroke information. Use parallel processing strategy to render strokes at each angle, group all stroke information in stroke_sequence set according to angle, and pass them to different subprocesses. The passed in information includes: rotation angle angle, grayscale grayscale, starting row row, width period, starting point begin, end point end, and the stroke length length = end-begin can be obtained from it.

[0027] Generate and render the canvas. In each child process, first generate a Gaussian noise background canvas of the same size as the original image, and then rotate the canvas according to the angle value to match the angle at which the stroke is applied. For each stroke, first calculate the grayscale distribution (mean, var) of each row of pixels of the stroke through the distribution matrix D according to its grayscale. Then call the Getline function to generate a line based on the grayscale distribution and the stroke length. The line is added to the canvas with row as the starting row, width as period, starting point as begin, and end point as end. If the line length is less than the preset threshold (for example, 1000 pixels), the line is directly drawn to the corresponding area on the canvas. For longer lines, additional processing is performed to ensure that they match the canvas size to prevent image distortion. And so on, all strokes saved in this direction are drawn on the canvas. Finally the canvas is rotated back to its original orientation and after all strokes are processed the canvas and mask are rotated back to their original orientation and cropped to their original size and an emboss filter is applied to enhance the texture giving the lines more depth and depression.

[0028] Synthesize the final canvas. Each subprocess generates a texture canvas of the direction segment, and the main process also generates an initial Gaussian noise background canvas, receives these grayscale canvas results, and synthesizes them into a final canvas. Use `np.minimum` to ensure that the grayscale values ​​are correctly processed during synthesis, simulating the natural overlapping effect of overlapping strokes. Map the synthesized canvas to the brightness layer of the original color image by adjusting the brightness (V) channel in the HSV color space of the image. This allows the brightness value of the grayscale image to be directly applied to the color image, thereby enhancing the overall brightness and visual effect of the image without changing the color of the original image. The final result is displayed on the interface and saved as a .jpg file for further use or display.

[0029] (III) Beneficial effects

[0030] Compared with the prior art, the embroidery texture generation technology of the present invention has at least the following advantages:

[0031] 1. Based on the guidance of noise images and directional flow, directional embroidery textures can be generated more naturally and delicately, improving the visual quality.

[0032] 2. Multi-process processing greatly improves the speed and efficiency of image processing and is suitable for large-scale image processing tasks.

[0033] 3. Innovatively simulate the shadows between embroidery threads instead of embroidery threads, and can adjust the look and feel according to different images and design requirements, such as texture width, depth, grayscale quantization quantity, etc., with high flexibility.

[0034] 4. By mapping the grayscale image into brightness information, the color information of the original color image is retained, while the texture effect is increased, thereby enhancing the aesthetics and artistic effect of the image. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 The present invention is a flowchart of an embroidery texture generation technology according to an embodiment of the present invention.

[0036] Figure 2 This is a preprocessed image according to an embodiment of the present invention.

[0037] Figure 3 This is a direction field annotation diagram of an embodiment of the present invention.

[0038] Figure 4 This is a directional mask diagram according to an embodiment of the present invention.

[0039] Figure 5 This is a texture simulation diagram of an embodiment of the present invention.

[0040] Figure 6 This is a diagram of the stroke information acquisition process of an embodiment of the present invention.

[0041] Figure 7 The code for obtaining stroke information according to an embodiment of the present invention is shown.

[0042] Figure 8 This is a texture generation map according to an embodiment of the present invention.

[0043] Fig. 9 The code for texture generation according to an embodiment of the present invention is shown.

[0044] Fig.10 This is a texture mapping effect diagram of an embodiment of the present invention.

[0045] Fig.11 This is the final effect diagram of the embodiment of the present invention.

[0046] Fig.12 Other data effect diagrams of embodiments of the present invention. DETAILED DESCRIPTION

[0047] The invention provides an embroidery texture generation technology based on edge tangent flow (ETF) and multi-process processing, and adopts a desktop development program to build a platform for embroidery texture generation for different images. The image file is read, converted into a grayscale image and a noise image is generated. Through the ETF algorithm, the smooth direction flow corresponding to the original grayscale image is obtained and a direction mask is generated. The visible area of ​​each mask contains all pixels of the vector direction in the direction interval. At the same time, the shadow texture between the embroidery threads is simulated. Then, multiple processes are created, each process corresponds to a direction mask, and the stroke information is recorded in a set in each process and returned. Multiple processes are created again, and the sets are grouped based on the direction and passed to the child process. In each child process, the corresponding strokes are generated according to the stroke information, distributed on a Gaussian canvas set in advance, and returned to the canvas after further texture enhancement using a filter. An initial Gaussian noise background canvas is also created in the main process, and the grayscale canvas results generated by each process are received and synthesized into a final canvas. Finally, the synthesized canvas is mapped to the original color image as a brightness layer to obtain the final image result.

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

[0049] In one aspect of the present invention, a novel embroidery texture generation technology is provided. Figure 1 It is a technical flow chart of an embodiment of the present invention, such as Figure 1 As shown, the technology includes the following steps: image preprocessing 1, calculating and saving direction mask 2, texture stroke simulation 3, parallel acquisition of stroke information 4, parallel processing of stroke distribution 5 and brightness mapping and comprehensive processing 6. Image preprocessing 1: Get and convert the input image into a grayscale image, and apply random noise at the same time. Calculate and save direction mask 2: Use the ETF algorithm to calculate and optimize the direction of each pixel in the image to form a continuous and smooth direction flow. According to the calculated direction flow, generate the corresponding direction mask and save it as an image file to guide the subsequent stroke generation. Texture stroke simulation 3: Simulate the shadow lines between the embroidery thread and the embroidery thread. Parallel acquisition of stroke information 4: Assign different direction masks to different sub-processes. Each process processes a group of strokes in a specific direction, including the starting line, starting point, end point, grayscale value and angle of the stroke. Parallel processing of stroke drawing 5: Pass the stroke information group to the created process and render it on the canvas predefined by the sub-process. This step also involves texture generation and texture enhancement. Brightness mapping and comprehensive processing 6: The rendered canvas is synthesized and mapped as a brightness layer to the original color image. This is done by adjusting the brightness channel of the HSV color space to enhance the visual effect of the image.

[0050] Next, combine Figures 2 to 10 A detailed description of each module is given.

[0051] Image preprocessing 1, first obtain the original color image and convert it into a grayscale image. In this process, random noise is also added to the image to increase the delicateness of the generated texture and provide a basis for subsequent texture processing. Figure 2 As shown, from left to right are the original color image, grayscale image and noise image.

[0052] Calculate and save the direction mask 2, such as Figure 3 As shown in Figure 1, the Edge Tangent Flow (ETF) algorithm is used to calculate and optimize the direction of each pixel in the image to form a continuous and smooth directional flow. Figure 4 As shown in the figure, according to the parameter dir_num, the directional flow result is divided into dir_num directional segments, and directional masks are generated and saved respectively. The arrows next to the mask in the figure represent the median value of each directional segment, which represents the vector direction of all pixels whose value in the mask is 1. Each mask is rotated by a certain angle so that the direction of all visible pixels in each directional mask is vertically downward, which can guide the subsequent stroke generation step line by line to ensure that the stroke is carried out in the correct direction.

[0053] Texture stroke simulation 3, pixel-level grayscale texture simulation of the gaps (shadows) between embroidery threads. Figure 5 As shown, suppose we want to simulate lines with a width of 7 and a length of 10, then these lines can be represented by a grayscale matrix with 7 rows and 10 columns. The grayscale value of the middle row of stripes is the grayscale value parameter grayscale passed in. The grayscale value decreases row by row from the middle to the top and bottom. Then, the lines in each column are attenuated so that the grayscale value in the middle is smaller than the two ends, smoothing the edges and increasing the light and dark effects. Set a specific distribution matrix D, which calculates the mean and variance of the grayscale values ​​of each row of pixels based on a given grayscale level and period. According to the grayscale value, width and length of the passed-in line, the distribution matrix D is used to create a line image through Gaussian noise, and the line edges are attenuated to smooth the image edges and improve the visual effect. By calling the Getline function, a new stroke can be obtained.

[0054] Parallel processing of stroke information 4, such as Figure 6As shown in the figure, a method for a sub-process in a multi-process to process stroke information is demonstrated. The direction mask is rotated by a certain angle so that the vector directions of all visible pixels are vertically downward, and then the grayscale image is rotated. On the one hand, histogram equalization and quantization operations are performed to obtain grayscale masks with different grayscale quantization levels; on the other hand, its edge segment mask is obtained. Each grayscale mask is intersected with the direction mask in turn, and each row of pixels is traversed to obtain the starting point (begin) and end point (end) of the continuous white area of ​​each row of pixels. At the same time, it is determined whether there are pixels with an edge segment mask of 1 between begin and end. If there are pixels, segment them and obtain a new end as the end point of the front segment, and a new begin as the starting point of the back segment to obtain the stroke information. Figure 7 Shows the overall framework code.

[0055] Parallel processing of stroke drawing 5, such as Figure 8 As shown in the figure, multi-process technology is used to generate stroke information in each direction in parallel. Each process processes a set of strokes in a specific direction. In each sub-process, an initial Gaussian noise background canvas is generated, the canvas is rotated, and grayscale strokes are generated for each stroke information and added to the corresponding position of the canvas. After all strokes are processed, the canvas is rotated back to the original direction and cropped to the original size. Finally, an embossing filter is applied to enhance the texture effect, where the depth value in the kernel is a negative number, so that the lines can be concave, giving the entire image a stronger three-dimensional sense. Fig. 9 Shows the overall framework code.

[0056] Brightness mapping and comprehensive processing 6, such as Fig.10 As shown in Figure 1, the rendered and completed canvas is mapped onto the original color image as a brightness layer. This process is completed by adjusting the brightness channel in the HSV color space, which not only enhances the visual effect of the image, but also retains the color information of the original image.

[0057] The final effect is as follows Fig.11 shown. Fig.12 Another rendering is shown.

[0058] In summary, the novel embroidery texture generation technology of the present invention acquires images through data and performs multi-process texture processing on pixels in different vector directions in the pattern. Finally, the brightness mapping and adjustment are completed, so that the image adds more artistic levels while maintaining the original visual effect. The requirements for computer processing speed and resources are reduced, and the efficiency and practicality are improved.

[0059] So far, the embodiments of the present disclosure have been described in detail in conjunction with the accompanying drawings. It should be noted that the implementation methods not shown or described in the drawings or the body of the specification are all forms known to ordinary technicians in the relevant technical field and are not described in detail. In addition, the above definitions of each element and method are not limited to the various specific structures, shapes or methods mentioned in the embodiments, and ordinary technicians in the field can simply change or replace them.

[0060] "Comprising" does not exclude the presence of elements or steps not listed in a claim. "A" or "an" preceding an element does not exclude the presence of a plurality of such elements.

[0061] In addition, unless the steps are specifically described or must occur in sequence, the order of the above steps is not limited to the above list, and can be changed or rearranged according to the required design. And the above embodiments can be mixed and matched with each other or with other embodiments based on design and reliability considerations, that is, the technical features in different embodiments can be freely combined to form more embodiments.

[0062] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for generating embroidery texture based on image edge tangent flow (ETF) and multi-process processing, comprising the steps of: Data acquisition: Get standard image files (such as .png, .jpg format) as input. These images can be digital photos or graphic design drafts. Data preprocessing: convert the input color image into a grayscale image and apply random noise to assist in the subsequent calculation of the direction field; Calculate and save the direction mask: Apply the Edge Tangent Flow algorithm to the noisy image, and generate a binary direction mask representing the dominant embroidery direction for each region in the image based on the smooth direction flow output; Texture simulation: Generate and apply simulated embroidery threads with specific distribution and shades between embroidery threads according to grayscale and line width; Multi-process processing: parallel processing of stroke information and drawing in each direction to improve processing efficiency and output quality; Brightness mapping and comprehensive processing: The obtained complete grayscale texture map is mapped to the original color image as brightness.

2. The embroidery texture generating method according to claim 1, wherein: Data preprocessing also includes color correction and brightness adjustment of color images to optimize image quality and enhance the effect of subsequent processing.

3. The embroidery texture generating method according to claim 1, wherein: The texture simulation step further includes filtering the generated simulated lines so that the lines have a concave feeling and more realistically simulate the texture effect of the gaps between the embroidery threads.

4. The embroidery texture generating method according to claim 1, wherein: Multi-process processing can significantly improve the efficiency and output quality of image processing. The design is based on a multi-process architecture, where each process is responsible for processing a directional segment of the image independently. This design allows multiple image processing tasks to be executed in parallel, each task processing a specific direction of the image, thereby effectively utilizing the computing power of multi-core processors. In particular, parallel optimization is performed for the image rendering process to ensure that each process can complete the rendering work of its assigned image portion in the shortest time, and finally all parts are quickly synthesized into a complete image output.

5. In the multi-process processing method according to claim 4, the multi-process acquisition of stroke information further comprises traversing each quantization level of the grayscale image, applying a binary mask to each level, and identifying the stroke area corresponding to the grayscale level. For each mask, the intersection with the direction mask is calculated, and the start and end positions of the stroke are determined by the continuous white area in each row of pixels. At the same time, the edge mask is retrieved as a node segmentation line segment, thereby ensuring that the stroke is laid out along the natural edge of the image, enhancing the naturalness and accuracy of the edge texture.

6. The embroidery texture generating method according to claim 1, wherein: The texture image generated by each processing unit is used as a brightness mapping layer. This step involves converting the grayscale values ​​of the texture image directly into brightness information, which is used to adjust and enhance the brightness layer of the original image. A further step is to adjust the mapped brightness layer to ensure that the texture details are clearly visible in the final image. This process not only improves the dynamic range of the image, but also enhances the depth and detail perception of the image.