Hosiery machine pattern file generation method, apparatus, device, and medium
By adjusting the size and converting the color of the original pattern image, the correspondence between the shuttle mark and the color is determined, which solves the problem of low efficiency in generating pattern files for sock knitting machines and achieves efficient generation of pattern files.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHAO MINGDE INTELLIGENT CONTROL EQUIPMENT CORP LTD
- Filing Date
- 2023-06-27
- Publication Date
- 2026-05-29
AI Technical Summary
Existing methods for generating pattern files for sock knitting machines require users to manually draw pattern images, resulting in low efficiency in pattern file generation.
By acquiring the user-selected original pattern image and the number of pattern colors, the size is adjusted and the colors are converted to determine the correspondence between the target shuttle identifier and the color, and a pattern file is generated.
It improves the efficiency of generating pattern files, reduces the number of manual drawing steps, and increases the overall efficiency.
Smart Images

Figure CN116863000B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the textile field, and in particular to a method, apparatus, equipment, and medium for generating pattern files for sock knitting machines. Background Technology
[0002] With the development of technology and the improvement of people's living standards, people have increasingly higher requirements for the patterns on socks. Generally, users create pattern files, which are then input into sock knitting machines. The sock knitting machines then knit socks with the corresponding patterns according to the pattern files.
[0003] In existing technology, users use plate-making software to create flower pattern files. In the flower pattern creation interface, they manually draw the flower pattern image using colors provided by the software. The flower pattern creation interface is a grid-like interface, with each grid corresponding to a pixel in the flower pattern image. Users select the desired color from the colors provided by the software to fill the grid, thereby drawing the flower pattern image. The software can then generate the corresponding flower pattern file.
[0004] In summary, existing methods for generating pattern files for sock knitting machines require users to manually draw the pattern images, resulting in low efficiency in generating pattern files. Summary of the Invention
[0005] This application provides a method, apparatus, device, and medium for generating pattern files for sock knitting machines, which solves the problem that existing methods for generating pattern files for sock knitting machines require users to manually draw the patterns, resulting in low efficiency in generating pattern files.
[0006] In a first aspect, embodiments of this application provide a method for generating pattern files for a sock knitting machine, including:
[0007] In response to the user's operation of generating a flower pattern file, obtain the original flower pattern image selected by the user and the number of flower pattern colors;
[0008] The original flower pattern image is resized to obtain the process flower pattern image;
[0009] Based on the number of flower colors, the process flower image is color-converted to obtain the target flower image;
[0010] For each color in the target flower pattern image, a target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color;
[0011] Based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier, a pattern file is generated.
[0012] In one specific embodiment, adjusting the size of the original flower pattern image to obtain the processed flower pattern image includes:
[0013] Determine whether the user has entered a target size;
[0014] If the user inputs the target size, the size of the original flower pattern image is adjusted to the target size to obtain the process flower pattern image;
[0015] If the user does not input the target size, then determine whether the size of the original flower pattern image exceeds the preset size;
[0016] If the size of the original flower pattern image exceeds the preset size, the size of the original flower pattern image is adjusted to the preset size to obtain the process flower pattern image.
[0017] In one specific embodiment, the step of color-converting the process flower pattern image according to the number of flower pattern colors to obtain the target flower pattern image includes:
[0018] Based on the number of flower pattern colors, randomly generate a base color for that number of flower pattern colors;
[0019] For each pixel in the process flower pattern image, the reference color corresponding to the pixel is determined based on the color data of the initial color corresponding to the pixel and the color data of the reference color of the number of flower pattern colors.
[0020] For each pixel in the process flower pattern image, the initial color corresponding to the pixel is replaced with the base color corresponding to the pixel to obtain the target flower pattern image.
[0021] In one specific embodiment, the method further includes:
[0022] In response to the user's color adjustment operation, obtain the color compensation value;
[0023] The target flower pattern image is updated based on the color compensation value to obtain the updated target flower pattern image;
[0024] Accordingly, for each color in the target flower pattern image, determining the target shuttle identifier based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and establishing a correspondence between the target shuttle identifier and the color, includes:
[0025] For each color in the updated target flower pattern image, a target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color.
[0026] Accordingly, generating a pattern file based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier includes:
[0027] Based on the updated target pattern image, and the correspondence between each color in the updated target pattern image and the target shuttle identifier, a pattern file is generated.
[0028] In one specific embodiment, the method further includes:
[0029] Edge extraction is performed on the updated target flower image to determine the edge pixels in the updated target flower image;
[0030] Anti-aliasing is applied to all edge pixels to obtain the target flower image after a second update;
[0031] Accordingly, for each color in the target flower pattern image, determining the target shuttle identifier based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and establishing a correspondence between the target shuttle identifier and the color, includes:
[0032] For each color in the target flower pattern image after the second update, the target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color;
[0033] Accordingly, generating a pattern file based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier includes:
[0034] Based on the updated target pattern image and the correspondence between each color in the updated target pattern image and the target shuttle identifier, a pattern file is generated.
[0035] In one specific embodiment, after determining a target shuttle identifier for each color in the target flower pattern image based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and establishing a correspondence between the target shuttle identifier and the color, the method further includes:
[0036] In response to the user's shuttle adjustment operation, obtain the shuttle identifier to be replaced corresponding to each color in the target flower pattern image;
[0037] For each color in the target flower pattern image, replace the target shuttle identifier corresponding to the color with the shuttle identifier to be replaced corresponding to the color;
[0038] Accordingly, generating a pattern file based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier includes:
[0039] Based on the target pattern image and the correspondence between each color in the target pattern image and the shuttle identifier to be replaced, a pattern file is generated.
[0040] Secondly, embodiments of this application provide a device for generating pattern files for a sock knitting machine, comprising:
[0041] The acquisition module is used to respond to the user's operation of generating a flower pattern file and to acquire the original flower pattern image and the number of flower pattern colors selected by the user.
[0042] Processing module, used for:
[0043] The original flower pattern image is resized to obtain the process flower pattern image;
[0044] Based on the number of flower colors, the process flower image is color-converted to obtain the target flower image;
[0045] For each color in the target flower pattern image, a target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color;
[0046] Based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier, a pattern file is generated.
[0047] Thirdly, embodiments of this application provide an electronic device, including:
[0048] Processor, memory, communication interface;
[0049] The memory is used to store the executable instructions of the processor;
[0050] The processor is configured to execute the method for generating pattern files for a sock knitting machine according to any one of the first aspects by executing the executable instructions.
[0051] Fourthly, embodiments of this application provide a readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method for generating pattern files for a sock knitting machine as described in any of the first aspects.
[0052] Fifthly, embodiments of this application provide a computer program product, including a computer program, which, when executed by a processor, is used to implement the method for generating pattern files for a sock knitting machine as described in any of the first aspects.
[0053] The method, apparatus, device, and medium for generating pattern files for sock knitting machines provided in this application obtain an original pattern image and the number of pattern colors. Then, the size of the original pattern image is adjusted, and the target pattern image is obtained by color conversion based on the number of pattern colors. Next, based on the color data of each color in the target pattern image and the color data corresponding to multiple preset shuttle identifiers, the shuttle identifier corresponding to each color is determined. Finally, a pattern file is generated based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier. This solution effectively improves the efficiency of pattern file generation by adjusting the size of the original pattern image, converting its colors, and determining the correspondence between colors and target shuttle identifiers. Attached Figure Description
[0054] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0055] Figure 1a A flowchart illustrating an embodiment of the method for generating pattern files for a sock knitting machine provided in this application;
[0056] Figure 1b A schematic diagram of the flower pattern setting interface provided in this application;
[0057] Figure 1c The interface diagram showing the correspondence between colors and shuttles provided in this application;
[0058] Figure 2 A flowchart illustrating Embodiment 2 of the method for generating pattern files for a sock knitting machine provided in this application;
[0059] Figure 3 A flowchart illustrating Embodiment 3 of the method for generating pattern files for a sock knitting machine provided in this application;
[0060] Figure 4 A flowchart illustrating Embodiment 4 of the method for generating pattern files for a sock knitting machine provided in this application;
[0061] Figure 5 A flowchart illustrating Embodiment 5 of the method for generating pattern files for a sock knitting machine provided in this application;
[0062] Figure 6 A schematic diagram of the structure of an embodiment of the sock knitting machine pattern file generation device provided in this application;
[0063] Figure 7 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation
[0064] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments made by those skilled in the art under the guidance of these embodiments are within the scope of protection of this application.
[0065] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0066] With the development of technology, there are more and more types of sock knitting machines, and all kinds of sock knitting machines need to operate according to pattern files.
[0067] The pattern file includes the pattern image, the correspondence between each color in the pattern image and the shuttle identifier, and the operating data for each shuttle, including needle selection data, valve data, etc. During the weaving of socks, the corresponding shuttle can be determined based on the color in the pattern image, and then, combined with the operating data of that shuttle, the weaving of that color can be completed.
[0068] The creation of pattern files is typically done by users using plate-making software. In the pattern creation interface of the software, users manually draw the pattern image using the colors provided by the software. The pattern creation interface is a grid-like interface, with each grid corresponding to a pixel in the pattern image. Users select the desired color from the colors provided by the software to fill the grid, thus creating the pattern image. The software then generates the corresponding pattern file.
[0069] Therefore, the existing methods for generating pattern files for sock knitting machines require users to manually draw pattern images, resulting in low efficiency in generating pattern files.
[0070] To address the problems existing in the prior art, the inventors, during their research on methods for generating pattern files for sock knitting machines, discovered that existing images can be used to generate pattern files to improve generation efficiency. This involves adjusting the size and converting the colors of existing images to determine the correspondence between the converted colors and the shuttle markings. Finally, based on the adjusted and converted image and the correspondence between the converted colors and the shuttle markings, the pattern file can be generated, effectively improving the generation efficiency. Based on the above inventive concept, the sock knitting machine pattern file generation scheme of this application was designed.
[0071] The execution subject of the method for generating pattern files for sock knitting machines in this application can be a computer, or a terminal device, server, or other device. This application does not limit it. The following explanation uses a computer as an example.
[0072] The following describes the application scenarios of the method for generating pattern files for sock knitting machines provided in this application.
[0073] For example, in this application scenario, a user finds an image, namely the original pattern image, and wants to weave socks with an image that has been processed from the original pattern image.
[0074] Users generate flower pattern files on their computers by selecting the original flower pattern image in the flower pattern settings interface, and then choosing the desired number of flower patterns, color depth, and target size. The computer then obtains the user-selected original flower pattern image, color depth, and target size.
[0075] The original flower pattern image is then resized to the target size. The resized image is then color-converted according to the number of colors in the flower pattern to obtain the target flower pattern image. The number of color types in the target flower pattern image is equal to the number of colors in the flower pattern.
[0076] Next, based on the color data of each color in the target pattern image and the color data corresponding to multiple preset shuttle identifiers, the target shuttle identifier corresponding to each color is determined. Finally, based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier, a pattern file is generated.
[0077] Users can input pattern files into the sock knitting machine, and the machine can then knit socks with the target pattern image.
[0078] It should be noted that the above scenario is only an example of an application scenario provided by the embodiments of this application. The embodiments of this application do not limit the actual form of the various devices included in the scenario, nor do they limit the interaction method between devices. In the specific application of the solution, it can be set according to actual needs.
[0079] The technical solution of this application will now be described in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0080] Figure 1a This is a flowchart illustrating an embodiment of the method for generating pattern files for a sock knitting machine provided in this application. This embodiment describes how a computer adjusts the size and converts the colors of an acquired original pattern image to obtain a target pattern image, then determines the target shuttle identifier corresponding to each color in the target pattern image, and finally generates a pattern file. The method in this embodiment can be implemented through software, hardware, or a combination of both. Figure 1a As shown, the method for generating pattern files for this sock knitting machine specifically includes the following steps:
[0081] S101: In response to the user's operation of generating a flower pattern file, obtain the original flower pattern image and the number of flower pattern colors selected by the user.
[0082] When a user wants to generate a pattern file from an image, they can do so through the pattern settings interface displayed on the computer. For example, Figure 1b This is a schematic diagram of the flower pattern setting interface provided in this application, such as... Figure 1b As shown, the pattern settings interface includes buttons and input boxes for setting the number of pattern colors, a slider for setting color compensation values, an input box for setting the target size, and an image box for selecting the original pattern image. Users generate pattern files within this interface by first entering the original pattern image in the image box, and then, based on their needs and the number of colors their knitting machine can produce, clicking a button for converting from two colors to seven colors, or entering the number of pattern colors in the custom color conversion input box. Users can also enter the height and width in the target size input box.
[0083] In this step, after the user generates a pattern file on the pattern settings interface, the computer responds to the user's operation by obtaining the original pattern image and the number of pattern colors selected by the user.
[0084] S102: Adjust the size of the original flower pattern image to obtain the process flower pattern image.
[0085] In this step, after the computer obtains the original flower pattern image and the number of flower patterns and colors, in order to improve the generation efficiency and meet the user's needs, the size of the original flower pattern image needs to be adjusted to obtain the process flower pattern image.
[0086] Specifically, determine whether the user has entered the target dimensions; that is, determine whether the user has entered the height and width.
[0087] If the user inputs a target size, it means the user has set the size they need. Then, the target size is obtained, which is the height and width input by the user. The size of the original floral image is adjusted to the target size to obtain the process floral image.
[0088] If the user does not input a target size, in order to improve conversion efficiency, it is determined whether the size of the original flower pattern image exceeds the preset size.
[0089] It should be noted that the predicted size includes the predicted height and the preset width. The method for determining whether the size of the original pattern image exceeds the preset size can be: if the height of the original pattern image is greater than the preset height, or the width of the original pattern image is greater than the preset width, then the size of the original pattern image exceeds the preset size; if the height of the original pattern image is less than or equal to the preset height, and the width of the original pattern image is less than or equal to the preset width, then the size of the original pattern image does not exceed the preset size. Alternatively, the method can be: if the product of the height and width of the original pattern image is greater than the product of the preset height and preset width, then the size of the original pattern image exceeds the preset size; if the product of the height and width of the original pattern image is less than or equal to the product of the preset height and preset width, then the size of the original pattern image does not exceed the preset size. The preset width can be 350 pixels, 400 pixels, 450 pixels, etc., and the preset height can be 4000 pixels, 500 pixels, 550 pixels, etc. This application embodiment does not limit the preset height, preset width, preset size, or the method for determining whether the size of the original pattern image exceeds the preset size; these can be set according to actual conditions.
[0090] If the original pattern image exceeds the preset size, it means the original pattern image is too large. To improve the efficiency of pattern file generation, the size of the original pattern image will be adjusted to the preset size to obtain the final pattern image. If the size of the original pattern image does not exceed the preset size, no adjustment will be made.
[0091] It should be noted that the method for adjusting the size of the original flower pattern image can be the nearest neighbor interpolation method, the bilinear interpolation method, the cubic convolution method, etc. This application embodiment does not limit the method for adjusting the size of the original flower pattern image, and can be selected according to the actual situation.
[0092] S103: Based on the number of flower colors, perform color conversion on the process flower image to obtain the target flower image.
[0093] In this step, after the computer obtains the process flower pattern image, since the user has set the number of flower pattern colors, the process flower pattern image is color-converted according to the number of flower pattern colors to obtain the target flower pattern image.
[0094] Based on the number of flower pattern colors, a base color can be randomly determined. Then, for each pixel in the process flower pattern image, the color that is closest to the pixel's color among the base colors can be determined and replaced to obtain the target flower pattern image.
[0095] It should be noted that after the computer obtains the target flower pattern image, it can be displayed in the image input box of the flower pattern settings interface, allowing users to view the effect of the color conversion. If the user needs to perform the color conversion again, they can click one of the buttons for two-color to seven-color conversion in the flower pattern settings interface, or re-enter the number of flower pattern colors in the custom color conversion input box. The computer can then perform the color conversion on the process flower pattern image again based on the number of flower pattern colors to obtain the target flower pattern image.
[0096] S104: For each color in the target flower pattern image, determine the target shuttle identifier based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and establish a correspondence between the target shuttle identifier and the color.
[0097] In this step, after the computer obtains the target pattern image, it is necessary to determine the correspondence between the colors in the pattern image and the shuttle markings during the operation of the sock knitting machine.
[0098] For each color in the target flower pattern image, the target shuttle identifier is determined based on the color data of that color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and that color.
[0099] Specifically, for each target color in the target flower pattern image, the color data (RGB value) of that target color is determined, and the RGB value is converted into primary color coordinates to obtain the corresponding primary color coordinates. Similarly, based on the color data corresponding to each preset shuttle marker, the primary color coordinates corresponding to each preset shuttle marker are determined. Then, the coordinate distances between the primary color coordinates of the target color and the primary color coordinates of each preset shuttle marker are calculated, and the preset shuttle marker with the smallest coordinate distance is taken as the target shuttle marker.
[0100] For example, there are 5 preset shuttle markers, A, B, C, D, and E, and their corresponding primary color coordinates are (R1, G1, B1), (R2, G2, B3), (R3, G3, B3), (R4, G4, B4), and (R5, G5, B5), respectively. For a target color, its corresponding primary color coordinates are (R0, G0, B0), and the coordinate distances between these target color coordinates and the primary color coordinates of each preset shuttle marker are D1, D2, D3, D4, and D5, respectively. Since D3 is the smallest among D1-D5, preset shuttle marker C is chosen as the target shuttle marker.
[0101] S105: Generate a pattern file based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier.
[0102] In this step, after the computer obtains the correspondence between each color in the target pattern image and the target shuttle mark, it can display the color-to-shuttle correspondence interface. After the user checks that the correspondence is correct, they click the OK button, and the computer generates the pattern file based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle mark.
[0103] For example, Figure 1c The interface diagram showing the correspondence between colors and shuttles provided in this application is as follows: Figure 1c As shown, the color-to-shuttle mapping interface includes each color in the target pattern file, the corresponding target shuttle identifier for each color, and the color corresponding to the target shuttle identifier. A dropdown menu is located to the right of each shuttle identifier, allowing users to reset the corresponding shuttle identifier.
[0104] It should be noted that when generating the pattern file, the running data of each shuttle is also required. The running data of each shuttle can be user-defined, default, or obtained from a third-party device.
[0105] The method for generating pattern files for a sock knitting machine provided in this embodiment first adjusts the size of the original pattern image to obtain a process pattern image after obtaining the user-selected original pattern image and the number of pattern colors. Then, based on the number of pattern colors, the process pattern image undergoes color conversion to obtain a target pattern image. Next, the correspondence between each color in the target pattern image and the target shuttle identifier is determined, and then the pattern file is generated by combining the target pattern image. Compared to the prior art that manually draws the pattern image and then generates the pattern file, this solution effectively improves the efficiency of pattern file generation by adjusting the size of the original pattern image, converting its colors, and determining the correspondence between colors and the target shuttle identifier.
[0106] Figure 2 This is a flowchart illustrating a second embodiment of the method for generating pattern files for a sock knitting machine provided in this application. Based on the above embodiments, this application describes how a computer performs color conversion on a process pattern image to obtain a target pattern image. For example... Figure 2 As shown, the method for generating pattern files for this sock knitting machine specifically includes the following steps:
[0107] S201: Based on the number of flower patterns and colors, randomly generate a base color.
[0108] In this step, after the computer obtains the process flower pattern image, since the user has set the number of flower pattern colors, it first randomly generates the number of flower pattern colors and the base color.
[0109] Optionally, users can choose the number of pattern colors and base colors, and then the computer will obtain the number of pattern colors and base colors selected by the user.
[0110] S202: For each pixel in the process pattern image, determine the reference color corresponding to the pixel based on the color data of the initial color corresponding to the pixel and the color data of the reference color of the number of pattern colors.
[0111] In this step, after the computer obtains the reference color, for each pixel in the process pattern image, it determines the reference color corresponding to that pixel based on the color data of the initial color corresponding to that pixel and the color data of the reference color of the number of pattern colors.
[0112] Specifically, for each pixel in the process pattern image, the color data of the initial color corresponding to that pixel is determined, that is, the RGB value. The RGB value of the initial color is then converted into primary color coordinates to obtain the primary color coordinates corresponding to that initial color. Similarly, based on the color data of each reference color, the primary color coordinates corresponding to each reference color are determined. Then, the coordinate distances between the primary color coordinates corresponding to the initial color and the primary color coordinates corresponding to each reference color are calculated. The reference color corresponding to the smallest coordinate distance is taken as the reference color corresponding to that pixel.
[0113] S203: For each pixel in the process flower pattern image, replace the initial color corresponding to the pixel with the base color corresponding to the pixel to obtain the target flower pattern image.
[0114] In this step, after the computer obtains the base color corresponding to each pixel in the process pattern image, it replaces the initial color corresponding to that pixel with the base color corresponding to that pixel to obtain the target pattern image.
[0115] The method for generating pattern files for sock knitting machines provided in this embodiment determines the number of pattern colors and a base color, and then replaces the color of each pixel in the process pattern image with the base color to complete the color conversion. This ensures that the number of colors in the target pattern image matches the knitting machine's spinning capacity and also meets user needs, thereby improving the user experience.
[0116] Figure 3 This is a flowchart illustrating a third embodiment of the method for generating pattern files for a sock knitting machine provided in this application. Based on the above embodiments, this application describes how a computer updates a target pattern image according to a user-set color compensation value, and then uses the updated target pattern image to generate a pattern file. Figure 3 As shown, the method for generating pattern files for this sock knitting machine specifically includes the following steps:
[0117] S301: In response to the user's color adjustment operation, obtain the color compensation value.
[0118] After the computer obtains the target flower pattern image, it can be displayed in the image input box of the flower pattern settings interface, allowing users to view the effect of the color conversion. If users need to fine-tune the colors of the target flower pattern image, they can drag the slider to set the color compensation value on the flower pattern settings interface.
[0119] In this step, the computer responds to the user's color adjustment operation and obtains color compensation values; the color compensation values include red compensation values, green compensation values, and blue compensation values, and the compensation values can be positive numbers, negative numbers, or 0.
[0120] S302: Update the target flower pattern image based on the color compensation value to obtain the updated target flower pattern image.
[0121] In this step, after the computer obtains the color compensation value, it updates the target flower pattern image based on the color compensation value to obtain the updated target flower pattern image.
[0122] For each pixel in the target flower pattern image, add the corresponding compensation value to the RGB value of the base color corresponding to that pixel, that is, add the red value to the red compensation value, the green value to the green compensation value, and the blue value to the blue compensation value. Then, generate the corresponding color based on the new RGB value to obtain the updated target flower pattern image.
[0123] S303: For each color in the updated target pattern image, determine the target shuttle identifier based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and establish a correspondence between the target shuttle identifier and the color.
[0124] S304: Generate a pattern file based on the updated target pattern image and the correspondence between each color in the updated target pattern image and the target shuttle identifier.
[0125] It should be noted that steps S303-S304 are similar to steps S104-S105 in Embodiment 1, and will not be described again here.
[0126] The method for generating pattern files for sock knitting machines provided in this embodiment obtains the color compensation value set by the user and then updates the target pattern image, which effectively improves the display effect of the target pattern image and enhances the user experience.
[0127] Figure 4 This is a flowchart illustrating Embodiment 4 of the method for generating pattern files for a sock knitting machine provided in this application. Based on the above embodiments, this application describes the process of using a computer to perform anti-aliasing processing on the edge pixels of the updated target pattern image to obtain a second-updated target pattern image, and then using the second-updated target pattern image to generate a pattern file. For example... Figure 4 As shown, the method for generating pattern files for this sock knitting machine specifically includes the following steps:
[0128] S401: Perform edge extraction on the updated target flower pattern image to determine the edge pixels in the updated target flower pattern image.
[0129] In this step, after the computer obtains the updated target flower pattern image, in order to further improve the display effect, edge extraction can be performed on the updated target flower pattern image to determine the edge pixels in the updated target flower pattern image.
[0130] It should be noted that the edge extraction method can be the Canny edge detection method, or the Sobel operator edge detection method, the Prewitt operator edge detection method, etc. This application does not limit the edge extraction method, and it can be selected according to the actual situation.
[0131] S402: Perform anti-aliasing on all edge pixels to obtain the target flower image after secondary update.
[0132] In this step, after the computer identifies the edge pixels in the updated target flower pattern image, it performs anti-aliasing on all edge pixels to obtain the second updated target flower pattern image.
[0133] It should be noted that the anti-aliasing method can be super-sampling anti-aliasing (SSAA), multi-sampling anti-aliasing (MSAA), coverage-sampling anti-aliasing (CSAA), etc. The embodiments of this application do not limit the anti-aliasing method, and can be selected according to the actual situation.
[0134] S403: For each color in the target pattern image after the second update, determine the target shuttle identifier based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and establish a correspondence between the target shuttle identifier and the color.
[0135] S404: Generate a pattern file based on the updated target pattern image and the correspondence between each color in the updated target pattern image and the target shuttle identifier.
[0136] It should be noted that steps S403-S404 are similar to steps S104-S105 in Embodiment 1, and will not be described again here.
[0137] It should be noted that this application can not only update the target flower pattern image using the above method to obtain a second-updated target flower pattern image, and then use the second-updated target flower pattern image to generate a flower pattern file, but also update the target flower pattern image using the above method to obtain a first target flower pattern image, and then use the first target flower pattern image to generate a flower pattern file. Furthermore, it can continue to update the first target flower pattern image using the method in Embodiment 3 to obtain a second target flower pattern image, and then use the second target flower pattern image to generate a flower pattern file.
[0138] The method for generating pattern files for sock knitting machines provided in this embodiment improves the display effect of the target pattern image and enhances the user experience by performing edge extraction and anti-aliasing processing on the updated target pattern image and updating the target pattern image again.
[0139] Figure 5 This is a flowchart illustrating Embodiment 5 of the method for generating pattern files for a sock knitting machine provided in this application. Based on the above embodiments, this embodiment describes how the computer replaces the target shuttle identifier corresponding to each color in the target pattern image according to the user-selected shuttle identifier to be replaced, thereby generating a pattern file. For example... Figure 5 As shown, the method for generating pattern files for this sock knitting machine specifically includes the following steps:
[0140] S501: In response to the user's shuttle adjustment operation, obtain the shuttle identifier to be replaced for each color in the target pattern image.
[0141] After the computer identifies the target shuttle marker and establishes a correspondence between the target shuttle marker and the color in the target pattern image, the computer can display a color-to-shuttle correspondence interface. When the user needs to adjust the shuttle marker corresponding to the color, they can click the drop-down box to the right of the shuttle marker and select the desired shuttle marker.
[0142] In this step, the computer responds to the user's shuttle adjustment operation by obtaining the user-selected shuttle identifier for each color in the target pattern image.
[0143] S502: For each color in the target pattern image, replace the target shuttle identifier corresponding to the color with the shuttle identifier to be replaced corresponding to the color.
[0144] In this step, after the computer obtains the shuttle identifier to be replaced for each color in the target flower pattern image, it replaces the target shuttle identifier corresponding to that color with the shuttle identifier to be replaced for that color.
[0145] S503: Generate a pattern file based on the target pattern image and the correspondence between each color in the target pattern image and the shuttle identifier to be replaced.
[0146] It should be noted that this step is similar to step S105 in Embodiment 1, and will not be described again here.
[0147] The method for generating pattern files for sock knitting machines provided in this embodiment generates pattern files based on the shuttle identifier selected by the user, making the pattern files more in line with user needs and updating the sock patterns to meet user requirements, thereby improving the user experience.
[0148] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0149] Figure 6 This is a schematic diagram of the structure of an embodiment of the sock knitting machine pattern file generation device provided in this application; as shown below. Figure 6 As shown, the pattern file generation device 60 for the sock knitting machine includes:
[0150] The acquisition module 61 is used to respond to the user's operation of generating a flower pattern file and to acquire the original flower pattern image and the number of flower pattern colors selected by the user.
[0151] Processing module 62 is used for:
[0152] The original flower pattern image is resized to obtain the process flower pattern image;
[0153] Based on the number of flower colors, the process flower image is color-converted to obtain the target flower image;
[0154] For each color in the target flower pattern image, a target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color;
[0155] Based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier, a pattern file is generated.
[0156] Furthermore, the processing module 62 is specifically used for:
[0157] Determine whether the user has entered a target size;
[0158] If the user inputs the target size, the size of the original flower pattern image is adjusted to the target size to obtain the process flower pattern image;
[0159] If the user does not input the target size, then determine whether the size of the original flower pattern image exceeds the preset size;
[0160] If the size of the original flower pattern image exceeds the preset size, the size of the original flower pattern image is adjusted to the preset size to obtain the process flower pattern image.
[0161] Furthermore, the processing module 62 is specifically used for:
[0162] Based on the number of flower pattern colors, randomly generate a base color for that number of flower pattern colors;
[0163] For each pixel in the process flower pattern image, the reference color corresponding to the pixel is determined based on the color data of the initial color corresponding to the pixel and the color data of the reference color of the number of flower pattern colors.
[0164] For each pixel in the process flower pattern image, the initial color corresponding to the pixel is replaced with the base color corresponding to the pixel to obtain the target flower pattern image.
[0165] Furthermore, the processing module 62 is also used for:
[0166] In response to the user's color adjustment operation, obtain the color compensation value;
[0167] The target flower pattern image is updated based on the color compensation value to obtain the updated target flower pattern image;
[0168] For each color in the updated target flower pattern image, a target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color.
[0169] Based on the updated target pattern image, and the correspondence between each color in the updated target pattern image and the target shuttle identifier, a pattern file is generated.
[0170] Furthermore, the processing module 62 is also used for:
[0171] Edge extraction is performed on the updated target flower image to determine the edge pixels in the updated target flower image;
[0172] Anti-aliasing is applied to all edge pixels to obtain the target flower image after a second update;
[0173] For each color in the target flower pattern image after the second update, the target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color;
[0174] Based on the updated target pattern image and the correspondence between each color in the updated target pattern image and the target shuttle identifier, a pattern file is generated.
[0175] Furthermore, the processing module 62 is also used for:
[0176] In response to the user's shuttle adjustment operation, obtain the shuttle identifier to be replaced corresponding to each color in the target flower pattern image;
[0177] For each color in the target flower pattern image, replace the target shuttle identifier corresponding to the color with the shuttle identifier to be replaced corresponding to the color;
[0178] Based on the target pattern image and the correspondence between each color in the target pattern image and the shuttle identifier to be replaced, a pattern file is generated.
[0179] The sock knitting machine pattern file generation device provided in this embodiment is used to execute the technical solution in any of the aforementioned method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0180] Figure 7 This is a schematic diagram of the structure of an electronic device provided in this application. Figure 7 As shown, the electronic device 70 includes:
[0181] Processor 71, memory 72, and communication interface 73;
[0182] The memory 72 is used to store the executable instructions of the processor 71;
[0183] The processor 71 is configured to execute the technical solutions in any of the foregoing method embodiments by executing the executable instructions.
[0184] Optionally, the memory 72 can be either standalone or integrated with the processor 71.
[0185] Optionally, when the memory 72 is a device independent of the processor 71, the electronic device 70 may further include:
[0186] Bus 74, memory 72 and communication interface 73 are connected to processor 71 through bus 74 and complete communication with each other. Communication interface 73 is used to communicate with other devices.
[0187] Optionally, the communication interface 73 can be implemented using a transceiver. The communication interface is used to enable communication between the database access device and other devices (e.g., clients, read-write databases, and read-only databases). The memory may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk drive.
[0188] Bus 74 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, only one thick line is used in the diagram, but this does not indicate that there is only one bus or one type of bus.
[0189] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0190] The electronic device is used to execute the technical solutions in any of the foregoing method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0191] This application also provides a readable storage medium storing a computer program thereon, which, when executed by a processor, implements the technical solutions provided in any of the foregoing embodiments.
[0192] This application also provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the technical solutions provided in any of the foregoing method embodiments.
[0193] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0194] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method for generating pattern files for a sock knitting machine, characterized in that, include: In response to the user's operation of generating a flower pattern file, obtain the original flower pattern image selected by the user and the number of flower pattern colors; The original flower pattern image is resized to obtain the process flower pattern image; Based on the number of flower colors, the process flower image is color-converted to obtain the target flower image; The step of color-converting the process flower image according to the number of flower colors to obtain the target flower image includes: Based on the number of flower pattern colors, randomly generate a base color for that number of flower pattern colors; For each pixel in the process flower pattern image, based on the RGB value of the initial color corresponding to the pixel and the RGB value of the reference color among the flower pattern colors, the RGB value of the initial color corresponding to the pixel is converted to obtain the three primary color coordinates corresponding to the RGB value of the initial color of the pixel, and the RGB value of the reference color among the flower pattern colors is converted to obtain the three primary color coordinates corresponding to the RGB value of the reference color among the flower pattern colors. The coordinate distance between the three primary color coordinates corresponding to the RGB value of the initial color of the pixel and the three primary color coordinates corresponding to the RGB value of the reference color among the flower pattern colors is calculated, and the reference color corresponding to the smallest coordinate distance is determined as the reference color corresponding to the pixel. For each pixel in the process flower pattern image, the initial color corresponding to the pixel is replaced with the base color corresponding to the pixel to obtain the target flower pattern image; For each color in the target flower pattern image, a target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color; Based on the target flower pattern image and the correspondence between each color in the target flower pattern image and the target shuttle identifier, a flower pattern file is generated; It also includes: obtaining a color compensation value in response to the user's color adjustment operation; The target flower pattern image is updated based on the color compensation value to obtain the updated target flower pattern image; For each color in the updated target flower pattern image, a target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color. Based on the updated target pattern image, and the correspondence between each color in the updated target pattern image and the target shuttle identifier, a pattern file is generated.
2. The method according to claim 1, characterized in that, The step of resizing the original flower pattern image to obtain the processed flower pattern image includes: Determine whether the user has entered a target size; If the user inputs the target size, the size of the original flower pattern image is adjusted to the target size to obtain the process flower pattern image; If the user does not input the target size, then determine whether the size of the original flower pattern image exceeds the preset size; If the size of the original flower pattern image exceeds the preset size, the size of the original flower pattern image is adjusted to the preset size to obtain the process flower pattern image.
3. The method according to claim 1, characterized in that, The method further includes: Edge extraction is performed on the updated target flower image to determine the edge pixels in the updated target flower image; Anti-aliasing is applied to all edge pixels to obtain the target flower image after a second update; Accordingly, for each color in the target flower pattern image, determining the target shuttle identifier based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and establishing a correspondence between the target shuttle identifier and the color, includes: For each color in the target flower pattern image after the second update, the target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color; Accordingly, generating a pattern file based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier includes: Based on the updated target pattern image and the correspondence between each color in the updated target pattern image and the target shuttle identifier, a pattern file is generated.
4. The method according to claim 1, characterized in that, After determining the target shuttle identifier for each color in the target flower pattern image based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and establishing a correspondence between the target shuttle identifier and the color, the method further includes: In response to the user's shuttle adjustment operation, obtain the shuttle identifier to be replaced corresponding to each color in the target flower pattern image; For each color in the target flower pattern image, replace the target shuttle identifier corresponding to the color with the shuttle identifier to be replaced corresponding to the color; Accordingly, generating a pattern file based on the target pattern image and the correspondence between each color in the target pattern image and the target shuttle identifier includes: Based on the target pattern image and the correspondence between each color in the target pattern image and the shuttle identifier to be replaced, a pattern file is generated.
5. A device for generating pattern files for a sock knitting machine, characterized in that, include: The acquisition module is used to respond to the user's operation of generating a flower pattern file and to acquire the original flower pattern image and the number of flower pattern colors selected by the user. Processing module, used for: The original flower pattern image is resized to obtain the process flower pattern image; Based on the number of flower colors, the process flower image is color-converted to obtain the target flower image; For each color in the target flower pattern image, a target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color; Based on the target flower pattern image and the correspondence between each color in the target flower pattern image and the target shuttle identifier, a flower pattern file is generated; The processing module is specifically used to randomly generate a base color based on the number of flower pattern colors. For each pixel in the process flower pattern image, based on the RGB value of the initial color corresponding to the pixel and the RGB value of the reference color among the flower pattern colors, the RGB value of the initial color corresponding to the pixel is converted to obtain the three primary color coordinates corresponding to the RGB value of the initial color of the pixel, and the RGB value of the reference color among the flower pattern colors is converted to obtain the three primary color coordinates corresponding to the RGB value of the reference color among the flower pattern colors. The coordinate distance between the three primary color coordinates corresponding to the RGB value of the initial color of the pixel and the three primary color coordinates corresponding to the RGB value of the reference color among the flower pattern colors is calculated, and the reference color corresponding to the smallest coordinate distance is determined as the reference color corresponding to the pixel. For each pixel in the process flower pattern image, the initial color corresponding to the pixel is replaced with the base color corresponding to the pixel to obtain the target flower pattern image; The processing module is also used to obtain a color compensation value in response to the user's color adjustment operation; The target flower pattern image is updated based on the color compensation value to obtain the updated target flower pattern image; For each color in the updated target flower pattern image, a target shuttle identifier is determined based on the color data of the color and the color data corresponding to multiple preset shuttle identifiers, and a correspondence is established between the target shuttle identifier and the color. Based on the updated target pattern image, and the correspondence between each color in the updated target pattern image and the target shuttle identifier, a pattern file is generated.
6. An electronic device, characterized in that, include: Processor, memory, communication interface; The memory is used to store the executable instructions of the processor; The processor is configured to execute the method for generating pattern files for a sock knitting machine according to any one of claims 1 to 4 by executing the executable instructions.
7. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for generating pattern files for a sock knitting machine as described in any one of claims 1 to 4.
8. A computer program product, characterized in that, The method includes a computer program, which, when executed by a processor, is used to implement the method for generating pattern files for a sock knitting machine as described in any one of claims 1 to 4.