Research on Vectorization of Embroidery Images Consisting of Straight Lines & Circular Arcs

A novel method for inputting embroidery images is presented. The method can convert BMP image format to DXF graphics format automatically. Firstly, the embroidery image is captured by a scanner; secondly, the image will be converted to a graphics by means of image processing and multinomial fitting algorithm; finally, a special graphics file will be created to be the DXF graphics format. Test results using this method showed that the algorithm achieved a good quality and improved the efficiency of inputs greatly.


Introduction
With the development of CAD technique currently, the vectorization becomes a focus of researches in many fields such as CAD and so on, which makes graphics inputs from human computer interaction technique to computer input automatically.In this way, vectorization can not only save memory but also improve the intelligent level and the efficiency of graphics inputs.Thus the vectorization becomes one novel method to solve the prevalence and application of the CAD technique and has an important theoretical and practical significance.Now the computer embroidery CAD system (Diao Hongquan, 2003) is prevalent in the world.Its strongpoint is the precision of the input .But the cost is very high and the efficiency is low.The paper presents a novel method which is to take images captured by scanner as inputs .A graphics can be acquired by a digital image which is preprocessed.The cost is low and the efficiency is relatively high.This paper introduces briefly BMP format and DXF format at first, then the course of vectorization which has four steps.Firstly, a BMP image is captured by a scanner.Secondly, the image is preprocessed for removing noise.Thirdly, lines and circular arcs are followed automatically.Finally, the paper presents fittings of lines and circular arcs and pick-ups of characteristic points and realizations of vectorization.

Raster image and vector graphics
This paper introduces the raster format and vector format briefly.A raster image is considered a matrix which has some elements.Each element corresponds with a pixel.The structure of BMP images has four-part: BIT-MAPFILEHEADER, BITMAP INFOHEADER, RGBQUAD and an array to store a matrix.This array stores datum from the bottom to the top of an image.The number of byte in one row must be the multiple of 4.The total number of byte in one drawing lies on the number of color and the width of pixel.A vector graphic is constituted by some lines and circular arcs and so on.Each element saves only some characteristic points.For example, start points and end points of straight lines and the centre of a circle, radius, start and end angles of circular arcs.Saving all points in vectors is unnecessary.

Preprocessing images
Before vectoring images, we should preprocess images: image segmentation, image simplification and image removing noise.Image segmentation is to divide images into some special parts.We divide images according to the hue, which reduces the complexity of image processing and increases conversion speed, so the next method can be taken: Conversion RGB multicolor space to HIS multicolor space: (2 ) /( ) H0 is the value of hue that should be taken as the threshold of picking up datum.Although it isn't strict with the colors information of vector graphics, it is necessary to save its color features.The array-PrcBmp[256][] saves datum of each color, which brings much convenience.An improved Hilditch arithmetic (Song Xiaoyu, 2000) is adopted in the image simplification.The methods of shrinking, expanding and flowing are good for image to remove noise.The expanding is combined with the shrinking repeatedly to remove noise in the bi-level image.

Automatic follow
Following vector is required before a vector is recognized.The aim of follow is to pick up the outline of brink.A main task is that the image preprocessed is saved into chains of datum which is the most original datum.Recognition and pick-up later are based on the datum.The pixel information of images can be seen clearly from the result of images preprocessed.The scheme is under the condition of Visual C++ 6.0.The object-oriented technique is used for saving chains of datum.The method of chain-in-chain in Visual C++ 6.0 is adopted: Step1 When all points in the image are processed completely in this way, the automatic follow is finished.The image is divided into many layers according to the different colors.The lists of same color are saved in one layer.

Fitting and picking up
The fitting of straight lines & circular arcs is necessary to judge whether a list above is a straight line or a circular arc (Hori O, 1993).METHOD of LEAST SQUARE (Zou Shuyi, 1999) is presented to fit the straight lines & circular arcs in the paper.Some characteristic points represent the shape of vectors.The pick-ups of characteristic points are the key to fitting vectors.

Fitting straight lines & picking up characteristic points
METHOD of LEAST SQUARE is adopted to compute the extremum.The equation for straight line is: Ax +y+ C=0.At first we judge whether a list-point can make up of a line or not.When the slope of the line is ||-A|| <1, the vertical coordinate i y of the point ( i x , i y ) is subtracted from the corresponding vertical coordinate on the equation.The result's square is a standard to measure the line equation.METHOD of LEAST SQUARE of curve is shown as follows:

Fitting circular arcs & picking up characteristic points
METHOD of LEAST SQUARE added to the least radial error fits circular arcs.The method can revise datum during the course of automatic follow.The result is global optimum.We have a hypothesis that the distances between the points on circular arcs and on the list-point are the least .The equation of circular arc is x y and ( , x y) are the coordinates of starting and ending points and partial derivatives to 0 0 , & x y R are supposed to be zero.When the 0, 0 ( , ) f x y R is the minimum, the fitting of circle is optimum.Under this condition, 0, 0 , x y R starting angle and ending angle are the characteristic points of the circular arcs.

Output of vector
The ultimate aim for vectorization is that the current drawing can be used by some software for computers to process vector graphics.That is to say, the output format must be the format that some software can recognize.DXF format is one of them.A whole DXF file is made up from six SECTION and one end tag which is HEADER, TABLES, BLOCKS, ENTITIES and END OF FILE.One vector graphics can be saved if these characteristic points are found.A line saves only starting and ending points while the fitting of circular arcs uses the method of perpendicular bisector.A line segment L0 is connected with another line L1.The two line segments are on the same list-point and are considered the seeds of a circular arc.The point P1 is the intersection of the two perpendicular bisectors.The point is considered the approximate centre of the circle.The average of distances between the centre and all the apexes of the list-point is considered the approximate radius.When the next line segment L2 is connected with L1, we repeat the task above.If the new radius and the center of a circle are near to the last ones, the line L2 belongs to the circle arc.This task continues until the circle arc breaks.The values of distance between every centre of a circle and all sides are computed.
If a variance between one average value and the values correspondingly is the least, the centre and radius are characteristic points of the circle arc.The layer of color in table section is added in the DXF file and the final graphics consists of many color layers automatically.The result is realized as follows (Fig. 2).

Conclusion
A scanner is an equipment of input for two-dimensional graphics.The paper presents an automatic vectorization algorithm for embroidery images.The algorithm realized an automatic conversion from raster image to vector graphics which is efficient and adaptive.To some extent, the method has an applicable value.Currently the system is on the developing state and doesn't have a mature product, but it must have a bright market future.
: The class CColor can classify the drawing according to the color of points.The function JudgeIfPointBelong(int hue) is to judge whether the hue of the current point is saved or not.If it isnotsaved, we can add the hue of the point to the hue-line through the function AddHue(int hue) and set layerlist[i] to be true.Otherwise, goes to Step2.Step2: The class CLineListClass processes the current point.One struct(tagLineElem) which is structured by the class CListClass is a double-direction list.The function JudgeIfPointBelong (PointElem* Point) judges whether the point belongs to the current list-line or not.If not, the function AddList(PointElem point) add the point to the list-line.Otherwise, goes to Step3.Step3: The class CListClass processes the current point.The function JudgeIfPointBelong(PointElem* Point) judges whether the point belongs to the current list-point or not.If yes, the function AddList(PointElem point) adds the point to the list-point.
According to it, the partial derivatives to A, C are equal to zero and the minimum of δ and the value of A, C can derive from these equations.The experimental data of the error ε is predicted to 0.02.If δ ε ≥ , the list-point cannot make up a line.If δ ε ≤ , it can do.The starting and ending points of automatic follow are the characteristic points of the line.If ||A|| >1, x & y are interchanged in the equation above.

Figure
Figure 1.Whole Process of Vectorzation