A method for painting with nails

By grayscale and jitter processing of the input pictures, combined with a single-chip microcomputer and RAMPS 1.4 expansion board, a nail painting method based on jitter algorithm is realized, solving the problem of not real-life painting in the existing technology, and achieving efficient Real-life painting effect.

CN116100985BActive Publication Date: 2025-02-14ZHEJIANG SCI-TECH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310108651.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-14
Publication Date
2025-02-14
Estimated Expiration
2043-02-14

AI Technical Summary

Technical Problem

The prior art has not yet implemented a physical drawing method based on a jitter algorithm.

Method used

By grayscale processing and jitter algorithm processing of the input images, binary grayscale images are generated, and nail gun path is calculated using a monolithic microcomputer and RAMPS 1.4 expansion board, and stepper motor drivers and nail guns are controlled for painting.

Benefits of technology

The pictures processed by the jitter algorithm are realized in the form of nails, achieving the physical production effect after technical processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure HDA0004075951060000011
    Figure HDA0004075951060000011
  • Figure HDA0004075951060000021
    Figure HDA0004075951060000021
  • Figure HDA0004075951060000031
    Figure HDA0004075951060000031
Patent Text Reader

Abstract

The invention discloses a method for painting with nails, which comprises the following steps: inputting a picture, converting the input image; performing data conversion to obtain a binary array with the same number of rows and columns; performing nail gun path calculation according to the binary array read and parsed by a single-chip microcomputer; calculating mechanical arm motion data according to the nail gun path data; and controlling the corresponding stepper motor movement according to the mechanical arm motion data by a stepper motor driver; when the stepper motor movement reaches the movement result, the information is transmitted from the stepper motor driver to a RAMPS 1.4 expansion board in reverse, and finally returned to the single-chip microcomputer; after the movement result is returned, the single-chip microcomputer controls a relay, and connects the nail gun through the relay to realize nailing; judging whether the nail drawing is completed, if so, entering the motor reset and ending; if not, returning and looping the above steps, so that the picture processed by the dithering algorithm can be presented in the form of nails, and physical production can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an applied painting method, more specifically, to a method applied to nail painting, belonging to the field of nail painting creation methods based on dithering algorithms. Background Art

[0002] The dithering algorithm is to mix various colors so that users can see colors that do not actually exist on the screen. Usually, dithering means that the binary image formed after the grayscale image is processed by dithering can simulate the grayscale changes of the original image, so that the human eye can feel the continuous changes of grayscale.

[0003] The early dithering technology used an array of black and white dots to replace a grayscale pixel in the original image, and the number of white dots reflected the grayscale level of the pixel. This method essentially traded space for grayscale. With the expansion of applications, this technology has now been applied to the display of color digital images.

[0004] There is currently no method for painting with real objects based on dithering algorithms. Summary of the invention

[0005] In order to solve the above-mentioned problems in the prior art, the present invention provides a method for nail painting, which has technical characteristics such as being able to realize simple processing of input images and output corresponding nail paintings.

[0006] In order to achieve the above object, the present invention is implemented by the following technical solutions:

[0007] A method for painting on nails, the painting method comprising the following steps:

[0008] Step 1: Input the image, the image should be RGB image with aspect ratio of 1:1 and color mode of 8 bits or above;

[0009] Step 2: Use the algorithm to convert the input image into a binary grayscale image;

[0010] The step of converting the input image using an algorithm comprises:

[0011] 1) Use the image grayscale processing algorithm to convert the color image into a grayscale image;

[0012] 2) converting the converted grayscale image into a binary grayscale image using a dithering algorithm;

[0013] Step 3: Perform data conversion on the binary grayscale image obtained in step 2 to obtain a binary array with the same number of rows and columns;

[0014] Step 4: Read and parse the obtained binary array through a single-chip microcomputer; calculate the nail gun path based on the read and parsed binary array through the single-chip microcomputer;

[0015] The calculation of the nail gun path requires the preset canvas margin n1, which is the distance between the edge of the canvas and the first nailing point, and the robot arm step constant n2. According to the binary array described in step 3, the nail gun path is calculated in coordinate form, and the calculation result is the nail gun path data; wherein, the canvas is a nailing panel;

[0016] Step 5: The RAMPS 1.4 expansion board connected to the single-chip microcomputer calculates the robot arm motion data according to the nail gun path data, and the robot arm motion data includes the stepper motor drive parameters;

[0017] Step 6: According to the robot arm motion data, the RAMPS 1.4 expansion board controls the corresponding stepper motor movement by connecting the stepper motor driver;

[0018] Step 7: When the stepper motor reaches the movement result, the information is sent from the stepper motor driver to the RAMPS1.4 expansion board and finally returned to the single-chip microcomputer;

[0019] Step 8: After the motion result is returned, the single-chip microcomputer controls the relay and connects the nail gun through the relay to achieve nailing;

[0020] Step 9: Determine whether the nail drawing is completed, if yes, proceed to step 10; if no, return and loop through steps 4 to 8;

[0021] Step 10: Reset the motor, and it's over.

[0022] Preferably, in step 2, the image grayscale processing algorithm obtains the R, G, B values ​​of each pixel and then calculates a grayscale value, and uses this grayscale value to replace the original R, G, B values ​​of the pixel; the dithering algorithm mixes various colors so that the user sees colors that do not actually exist on the screen.

[0023] Preferably, in step 3, there are only two colors, black and white, in the binary grayscale image; the data conversion method is to define the black pixels of the binary grayscale image as 1 and the white pixels as 0, and to obtain a binary array with the same number of rows and columns based on the number and position of pixels in the binary grayscale image.

[0024] Preferably, the RAMPS 1.4 expansion board is connected to two stepper motor drivers, which are respectively connected to the Y-axis stepper motor and the X-axis stepper motor, the Y-axis stepper motor is connected to the nailing panel through the Y-axis mechanical arm, the X-axis stepper motor is connected to the nail gun through the X-axis mechanical arm, the nail gun is connected to the single-chip microcomputer through a relay, and the stepper motor driver controls the moving position to ensure that during the nailing process, the nailing panel is used as a reference, and the nail gun moves relative to the nailing panel in the X-axis and Y-axis planes.

[0025] Preferably, in step 8, 1 is set as the nailing point and 0 is set as the blank point. The single-chip microcomputer controls the current on and off to drive out the nail according to the corresponding point. The nailing process directly skips the 0 point and works normally at the 1 point. The path uses the nailing panel as a reference. The nail gun moves relative to the nailing panel in the X-axis and Y-axis planes, and drives out nails in a sequence from top to bottom and from left to right.

[0026] Preferably, the image grayscale processing algorithm includes an image grayscale processing algorithm based on human eye perception.

[0027] Preferably, the dithering algorithm is any one of an ordered dithering method, a Floyd–Steinberg dithering method, and a Jarvis dithering method.

[0028] Preferably, the single-chip microcomputer is an Arduino Mega2560 development board, and the single-chip microcomputer and the RAMPS 1.4 expansion board transmit information via an SPI communication protocol.

[0029] Preferably, the stepper motor driver model is A4988, and the stepper motor driver and the stepper motor are connected by a control circuit.

[0030] Preferably, the nail gun is connected to the single-chip microcomputer via a control circuit.

[0031] Beneficial effect: With respect to the prior art, this application can present the image processed by the dithering algorithm in the form of nails, which is a physical production after technical processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 It is a flow chart of the present invention.

[0033] Figure 2 It is a diagram of an implementation example of nail gun path calculation in a binary array of the present invention.

[0034] Figure 3 This is a diagram of an implementation example of nail gun path calculation in a 5*5 binary array in Example 1.

[0035] Figure 4 It is a schematic diagram of the circuit structure of the present invention. DETAILED DESCRIPTION

[0036] The following is in conjunction with the instruction manual Figure 1-4 , the present invention is further illustrated, but the present invention is not limited to the following embodiments.

[0037] The invention relates to a method for applying a dithering algorithm to nail painting, through which a simple processing of an input image and a corresponding nail painting can be realized.

[0038] The electronic components involved in the present invention include but are not limited to a single-chip microcomputer (Arduino Mega2560 development board), a RAMPS 1.4 expansion board (RepRap Arduino Mega Pololu Shield 1.4), a stepper motor driver (including but not limited to A4988), etc.

[0039] Component Description:

[0040] 1. A single-chip microcomputer, also known as a single-chip microcomputer, is a microcomputer that integrates the main computer functional components such as the central processing unit (CPU), random access memory (RAM), read-only memory (ROM), and input / output ports (I / O) on a single integrated circuit chip.

[0041] 2. For details of RAMPS1.4 expansion board, please refer to the existing public technical description, web link: https: / / wenku.baidu.com / view / dc67900f925f804d2b160b4e767f5acfa1c7839c.html?_wkts_=1676017692581, and https: / / reprap.org / wiki / RAMPS_1.4 / zh_cn). RAMPS1.4 expansion board is an Arduino expansion board with powerful upgrade capabilities and expansion modular design. It connects to the Arduino Mega platform and provides a large number of expansion interfaces including stepper motor driver interfaces.

[0042] 3. Stepper motor driver (including but not limited to A4988) (refer to the webpage introduction https: / / wenku.baidu.com / view / dc67900f925f804d2b160b4e767f5acfa1c7839c.html?_wkts_=1673348066470 and https: / / reprap.org / wiki / RAMPS_1.4 / zh_cn), stepper motor driver A4988 is an actuator that converts electrical pulses into angular displacement. When the stepper driver receives a pulse signal, it drives the stepper motor to rotate a fixed angle (called "step angle") in the set direction, and its rotation runs step by step at a fixed angle. The angular displacement can be controlled by controlling the number of pulses, so as to achieve the purpose of accurate positioning; at the same time, the speed and acceleration of the motor rotation can be controlled by controlling the pulse frequency, so as to achieve the purpose of speed regulation and positioning.

[0043] In order to achieve simple processing of input images and output corresponding nail paintings, the present invention provides a nail painting method based on a dithering algorithm, which comprises the following steps:

[0044] Step 1: Input the image with a 1:1 aspect ratio and 8-bit or higher RGB color mode;

[0045] Step 2: Use an algorithm to convert the input image, which includes using an image grayscale processing algorithm to convert the color image into a grayscale image, and then using a dithering algorithm to convert the converted grayscale image into a binary grayscale image.

[0046] 1) Image grayscale processing algorithm The image grayscale processing algorithm converts any color image into grayscale. The additive three primary colors of color images are red, green, and blue. Mixing the primary colors in different proportions can produce other new colors. This primary color system is often called the "RGB color space", which is a color system composed of red (R), green (G), and blue (B). When these three primary colors are superimposed together in equal proportions, they become gray. In digital photography, computer-generated images, and colorimetry, a grayscale image is an image in which the value of each pixel is a single sample that represents only a certain amount of light; that is, it only carries intensity information. A grayscale image is a black and white or gray monochrome image composed entirely of gray shades. The contrast ranges from the weakest black to the strongest white.

[0047] The basic steps of image grayscale processing are: after obtaining the R, G, B values ​​of each pixel, use the grayscale algorithm to calculate a grayscale value, and use this grayscale value to replace the original R, G, B values ​​of the pixel.

[0048] There are several image grayscale processing algorithms, including but not limited to image grayscale processing algorithms based on human eye perception (reference Algorithm 2 - Based on human eye perception formula webpage introduction

[0049] https: / / zhuanlan.zhihu.com / p / 31840238). The human eye has different degrees of perception of different light. There are several types of cone photoreceptor cells in the human eye that can distinguish colors, which are most sensitive to yellow-green, green and blue-violet light respectively. Although the cone cells in the eyeball are not the most sensitive to red, green and blue, the bandwidth of light that can be sensed by the cone cells of the naked eye is very large, and red, green and blue can also independently stimulate the photoreceptors of these three colors. The degree of human perception of red, green and blue is: green>red>blue. This type of algorithm sets a weight for each color according to the degree of human perception of light. For example, the commonly used Gray=(Red*0.299+Green*0.587+Blue*0.114)

[0050] 2) Dithering algorithm (reference material: https: / / en.wikipedia.org / wiki / Dither) The dithering algorithm is to mix various colors so that users can see colors that do not actually exist on the screen. The usual dithering means that the binary image formed after the grayscale image is dithered can simulate the grayscale changes of the original image, so that the human eye can feel the continuous changes of grayscale. The early dithering technology used an array of black and white dots to replace a grayscale pixel in the original image, and the number of white dots reflected the grayscale level of the pixel. This method essentially exchanges space for grayscale. With the expansion of applications, this technology has now been applied to the display of color digital images.

[0051] The dithering algorithms of the present application include but are not limited to ordered dithering, Floyd–Steinberg dithering, and Jarvis dithering.

[0052] Take the Floyd–Steinberg dithering method (reference Floyd–Steinberg dithering https: / / en.wikipedia.org / wiki / Floyd%E2%80%93Steinberg_dithering) as an example. The algorithm implements dithering using error diffusion, which means that it pushes (adds) the residual quantization error of a pixel to its neighboring pixels for later processing. It spreads according to a distribution (displayed as a map of neighboring pixels): The algorithm scans the image from left to right and from top to bottom, quantizing pixel values ​​one by one. Each time, the quantization error is transferred to neighboring pixels, while not affecting already quantized pixels. Therefore, if some pixels have been rounded down, the next pixel is more likely to be rounded up, so that on average, the quantization error is close to zero.

[0053] Step 3: Convert the binary grayscale image. In a binary grayscale image, there are only two colors, black and white. The data conversion algorithm defines the black pixels of the binary grayscale image as 1 and the white pixels as 0. Based on the number and position of the pixels in the binary grayscale image, a binary array with the same number of rows and columns is obtained;

[0054] Step 4: Convert the binary grayscale image into a binary array;

[0055] Step 5: Read and parse the obtained binary array through a single-chip microcomputer (Arduino Mega2560 development board); calculate the nail gun path based on the read and parsed binary array through the single-chip microcomputer (Arduino Mega2560 development board).

[0056] The calculation of the nail gun path requires pre-setting the canvas (i.e., nailing panel) margin n1, i.e., the distance between the edge of the canvas (i.e., nailing panel) and the first nailing point, and the robot arm step constant n2. According to the binary array described in step 5, the nail gun path is calculated in coordinate form.

[0057] Example 1: As shown in the 5*5 binary array in the figure below, with the upper left corner edge of the canvas (i.e., nailing panel) as the origin (0,0), according to the number of rows and columns and the set canvas (i.e., nailing panel) margin n1, with the canvas margin n1 and the robot arm step constant n2, establish x, y coordinates, form the corresponding 0-1 coordinate system, and calculate the nail gun path.

[0058] Step 6: The calculation result of step 5 is the nail gun path data; the RAMPS 1.4 expansion board (RepRap Arduino Mega Pololu Shield 1.4) connected to the single-chip microcomputer (ArduinoMega2560 development board) calculates the robot arm motion data based on the nail gun path data.

[0059] The RAMPS 1.4 expansion board (RepRapArduino Mega Pololu Shield 1.4) connected to the single-chip microcomputer (Arduino Mega2560 development board) is connected to the stepper motor driver (including but not limited to A4988), and the stepper motor driver (including but not limited to A4988) is connected to the stepper motor.

[0060] The single-chip microcomputer (Arduino Mega2560 development board) can obtain the corresponding robot arm motion data, i.e., the stepper motor drive parameters (such as number of revolutions, time, etc.), based on the nail gun path data and the corresponding Arduino library.

[0061] Step 7: Based on the robot arm motion data, this data can be transmitted to the stepper motor driver (including but not limited to A4988) through the RAMPS 1.4 expansion board (RepRap Arduino Mega Pololu Shield 1.4) connected to the single-chip microcomputer (Arduino Mega2560 development board);

[0062] Step 8: When the stepper motor reaches the movement result, the information is sent from the stepper motor driver (including but not limited to A4988) to the RAMPS 1.4 expansion board, and finally returned to the single-chip microcomputer (Arduino Mega2560 development board). Specifically: the stepper motor driver (A4988) connected to the RAMPS 1.4 expansion board converts the robot arm movement data into electrical signals, provides drive current, and controls the corresponding motor movement. For an introduction to the driver (A4988), see

[0063] https: / / baijiahao.baidu.com / s?id=1746476583318632729&wfr=spider&for=pc introduction.

[0064] Step 9: The single-chip microcomputer (Arduino Mega2560 development board) controls the relay after the motion result is returned, and connects the nail gun to nail;

[0065] like Figure 2 As shown, 1 is the nailing point, 0 is the blank point, and the single-chip microcomputer (ArduinoMega2560 development board) controls the current on and off to drive the nail according to the corresponding point. The nailing process directly skips the 0 point (blank point) and works normally at the 1 point (nail point). With the nailing panel as a reference, the nail gun moves relative to the nailing panel in the X-axis and Y-axis planes, and drives the nails from top to bottom and from left to right.

[0066] like Figure 2 As shown, with the nailing panel as a reference, nails are driven out at a, b, c, d, e, f, g, h, i, and j in the order of (0,0)→a→b→c→d→e→f→g→(0,0). The nail gun starts from the origin (0,0), passes through a(n1+0*n2,n1+0*n2), moves 4*n2 along the X axis after driving out the nail, and arrives at b(n1+4*n2,n1+0*n2), moves 4*n2 along the Y axis after driving out the nail, moves -2*n2 along the X axis to arrive at c(n1+2*n2,n1+1*n2), and so on. After reaching point j and driving out the nail, the drawing is completed, and the nail gun is reset to the origin (0,0).

[0067] Step 10: Determine whether the nail drawing is completed, if yes, proceed to step 11; if no, then return and loop through steps 5 to 9;

[0068] Step 11: Reset the motor, end. See the process Figure 1 .

[0069] The nail painting method based on the dithering algorithm provided by the present invention, a single-chip microcomputer (Arduino Mega 2560 development board) and a RAMPS 1.4 expansion board transmit information through an SPI (Serial Peripheral Interface) communication protocol.

[0070] In the nail painting method based on the dithering algorithm provided by the present invention, a stepper motor driver (including but not limited to A4988) and a stepper motor are connected by a control circuit.

[0071] In the nail painting method based on the dithering algorithm provided by the present invention, the stepping motor and the robotic arm are connected by a mechanical structure, and the mechanical structure is a conventional linkage structure, and the mechanical structure assists the motor-driven robotic arm structure; as for the mechanical structure of the robotic arm, the large top panel and the nail gun, it is a conventional connecting rod structure, etc. The mechanical structure is not a necessary technical feature of the present application and is not described in detail. Based on the technical solution of the present application, those skilled in the art can make conventional substitutions.

[0072] The nail drawing method based on the jitter algorithm provided by the present invention comprises X-axis and Y-axis mechanical arms connected to the nail gun and the nailing panel respectively to control their positions to ensure that during the nailing process, the nailing panel is used as a reference and the nail gun moves relative to the nailing panel in the X-axis and Y-axis planes.

[0073] In the nail painting method based on the dithering algorithm provided by the present invention, the nail gun connected to the mechanical arm is connected to a single-chip microcomputer (Arduino Mega2560 development board) by a control circuit, and the control circuit is a conventional circuit.

[0074] The nail drawing method based on the dithering algorithm provided by the present invention controls a relay to control the on-off of a circuit by a single-chip microcomputer (Arduino Mega2560 development board), and connects a nail gun to nail accordingly; and determines whether the nail drawing is completed by the single-chip microcomputer (Arduino Mega2560 development board).

[0075] Finally, it should be noted that the present invention is not limited to the above embodiments, and there are many variations. All variations that can be directly derived or associated with the content disclosed by ordinary technicians in this field should be considered as the protection scope of the present invention.

Claims

1. A method for painting on nails, characterized in that The drawing method includes the following steps: Step 1: Input the image, the image should be RGB image with aspect ratio of 1:1 and color mode of 8 bits or above; Step 2: Use the algorithm to convert the input image into a binary grayscale image; The step of converting the input image using an algorithm comprises: 1) Use the image grayscale processing algorithm to convert the color image into a grayscale image; 2) converting the converted grayscale image into a binary grayscale image using a dithering algorithm; Step 3: Perform data conversion on the binary grayscale image obtained in step 2 to obtain a binary array with the same number of rows and columns; Step 4: Read and parse the obtained binary array through a single-chip microcomputer; calculate the nail gun path based on the read and parsed binary array through the single-chip microcomputer; The calculation of the nail gun path requires the preset canvas margin n1, which is the distance between the edge of the canvas and the first nailing point, and the robot arm step constant n2. According to the binary array described in step 3, the nail gun path is calculated in coordinate form, and the calculation result is the nail gun path data; wherein, the canvas is a nailing panel; Step 5: Calculate the robot arm motion data according to the nail gun path data through the RAMPS1.4 expansion board connected to the single-chip microcomputer, and the robot arm motion data includes the stepper motor drive parameters; Step 6: According to the robot arm motion data, the RAMPS1.4 expansion board controls the corresponding stepper motor motion by connecting the stepper motor driver; Step 7: When the stepper motor reaches the movement result, the information is transmitted from the stepper motor driver to the RAMPS 1.4 expansion board and finally returned to the single-chip microcomputer; Step 8: After the motion result is returned, the single-chip microcomputer controls the relay and connects the nail gun through the relay to achieve nailing; Step 9: Determine whether the nail drawing is completed, if yes, proceed to step 10; if no, return and loop through steps 4 to 8; Step 10: Reset the motor, end; In step 3, the binary grayscale image only has two colors, black and white. The data conversion method is to define the black pixels of the binary grayscale image as 1 and the white pixels as 0, and obtain a binary array with the same number of rows and columns according to the number and position of pixels in the binary grayscale image. The RAMPS1.4 expansion board is connected to two stepper motor drivers, which are respectively connected to the Y-axis stepper motor and the X-axis stepper motor. The Y-axis stepper motor is connected to the nailing panel through the Y-axis mechanical arm, and the X-axis stepper motor is connected to the nail gun through the X-axis mechanical arm. The nail gun is connected to the single-chip microcomputer through a relay. The stepper motor driver controls the moving position to ensure that during the nailing process, the nail gun moves relative to the nailing panel in the X-axis and Y-axis planes with the nailing panel as a reference. In step 8, 1 is set as the nailing point and 0 is set as the blank point. The single-chip microcomputer controls the current on and off to drive the nail according to the corresponding point. The nailing process directly skips the 0 point and works normally at the 1 point. The path is based on the nailing panel as a reference. The nail gun moves relative to the nailing panel in the X-axis and Y-axis planes and drives the nails from top to bottom and from left to right. The dithering algorithm is any one of the ordered dithering method, the Floyd–Steinberg dithering method, and the Jarvis dithering method; In step 2, the image grayscale processing algorithm obtains the R, G, B values ​​of each pixel and then calculates a grayscale value, and uses this grayscale value to replace the original R, G, B values ​​of the pixel; the dithering algorithm mixes various colors to make the user see colors that do not actually exist on the screen; The image grayscale processing algorithm includes an image grayscale processing algorithm based on human eye perception; The single-chip microcomputer is an Arduino Mega2560 development board, and the single-chip microcomputer and the RAMPS1.4 expansion board transmit information through the SPI communication protocol.

2. A method for painting on nails according to claim 1, characterized in that: The stepper motor driver model is A4988, and the stepper motor driver is connected to the stepper motor via a control circuit.

3. The method for painting on nails according to claim 1, characterized in that: The nail gun is connected to the single-chip microcomputer via a control circuit.

Citation Information

Patent Citations

  • Drawing method, device and system based on mechanical arm and rivet gun

    CN110524549A

  • Printing system and printing method

    CN113407127A