Download presentation
Presentation is loading. Please wait.
Published byDouglas Cameron Modified over 6 years ago
1
Bitmap Image Vectorization using Potrace Algorithm
Graduation Project Graphics Editor Reference = Potrace: a polygon-based tracing algorithm, Peter Selinger, September 20, 2003.
2
ABSTRACT : Our project Vectorization (raster-to-vector conversion) consists of analyzing a raster image to convert its pixels representation to a vector representation The basic assumption is that such a vector representation is more suitable for further interpretation of the image to get an image larger or smaller than the Real size without any loss in quality like a digital image. throw image processing. In the other hand we allow the user to make some filters on the images using a kernal matrix and same processing to image like(blur, sharpen…..) 2
3
What is the difference between vector? and bitmap images
Bitmap (or raster): images are stored as a series of tiny dots called pixels. Each pixel is actually a very small square that is assigned a color, and then arranged in a pattern to form the image. When you zoom in on a bitmap image you can see the individual pixels that make up that image. Vector : vector images are not based on pixel patterns, but instead use mathematical formulas to draw lines and curves that can be combined to create an image from geometric objects such as circles and polygons. 3
4
Vectorization Algorithms
Structural Vectorization of Raster Images . Potrace: a polygon-based tracing . 4
5
Comparison between Structural Vectorization and a polygon based vectorization technique ?
both taken from the same source image (a) Polygon based vectorization produces images with high visual fidelity (c), but results in complex topography (b). Structural vectorization extracts dominant strokes (d), and line width information. While not as visually accurate as polygon vectorization, strokes and widths are nevertheless able to represent the source image (e). 5
6
Vectorization - Basics
Before Vectorization After Vectorization 6
7
Steps involved in POTRACE algorithm
Potrace – stands for polygon trace – tracing closed surfaces through polygon construction , the various steps are as follows… The first step, the bitmap is decomposed into a number of paths, which form the boundaries – Path generation In the second step, each path is approximated by an optimal polygon - Polygon Generation In the third step, each polygon is transformed into a smooth outline- Smoothening In an optional fourth step, the resulting curve is optimized by joining consecutive Bezier curve segments together where this is possible. 7
8
Path Generation: Turn policies :
pixels meet at an edge we orient this edge so that the black pixel is to its left and the white pixel is to its right. This edge defines a path of length one. We then continue to extend this path in such a way that each new edge has a black pixel on its left and a white pixel on its right, relative to the direction of the path. In other words, we move along the edges between pixels, and each time we hit a corner, we either go straight or turn left or right, depending on the colors of the surrounding pixels as. We continue until we return to the vertex where we started, at which point we have defined a closed path 8
9
1 9
10
Path Generation Every time we have found a closed path, we remove it from the graph by inverting all the pixel colors in its interior. This defines a new bitmap, to which we apply the algorithm recursively until there are no more black pixels left. of the Potrace algorithm. Look at each path independently. 10
11
1 11
12
Despeckle Despeckling is done to remove closed paths which may have been due to noise formed during scanning The turdsize parameter can be used to “despeckle” the bitmap to be traced, by removing all curves whose enclosed area is below the given threshold. its useful range is from 0 to infinity 12
13
13
14
Straight line generation
The Figure Below shows some examples of straight and non-straight paths. Note that in this figure, the dots represent vertices in the path, which lie at the corners, not at the centers, of the pixels of the original bitmap. The squares shown are not pixels, but rather neighborhoods of path points. 14
15
Straight line generation after path generation:
Given two points z0 = (x0,y0) and z1 = (x1,y1) Function max-distance: d(z0,z1)=max(|x1-x0|,|y1-y0|) Given a non-closed path ‘p’ a line segment a b approximates the path if d(v0,a) <= 1/2, d(vn,b) <=1/2, and for each i = 1,2,3…,n-1, there exists some point ci on ab such that d(vi,ci) <=1/2. 15
16
Formation of segments Once straight lines are constructed, the next step would be to form segments We now want to construct a polygon from straight lines of the closed path p. We say that there is a possible segment from each subpath with vertices from I to j , If the subpath can be extended by one point in either direction and still be straight. After forming segments ,the next step would be to connect them to form a closed polygon Here the algorithm decides between a sub – optimal & optimal polygon An optimal polygon is one which has lesser number of segments 16
17
Smoothening: In a preliminary step, we adjust the position of the vertices of the polygon to fit the original bitmap as best as possible. In the main step, we calculate corners and curves based on the lengths of adjacent line segments and the angles between them. 17
18
Corner detection and smoothing:
We use the parameter α just calculated to perform corner detection and to determine the final curve from bi−1 to bi . There are two cases. If α 6 1, then we draw a smooth Bezier curve at this vertex, as shown in Figure 8(a)–(c). If α > 1, there is no convex Bezier curve connecting bi−1 and bi and tangent to Li . In this case, we have detected a corner and we connect bi−1 and bi via two straight line segments that meet at ai. 18
19
Smoothening z1=(1-a)*z0+a*0 z2=(1-a)*0+a*z3
Consider 4 points z0,z1,z2,z3 Consider the following Bezier equation for smoothing between the points z0,z1,z2,z3 b=(1-a)*z10+a*z2 19
20
Curve optimization The purpose of this section is to make a simple, yet useful observation about Bezier curves. Recall that a Bezier curve is given by one control points (0)and by the parametric z1=(1-a)*z0+a*0 For the purposes of our analysis, we restrict ourselves to the case where the straight lines through z0z1 and through z3z2 intersect at a point o (i.e., they are not parallel). 20
21
q0=(1-a)*p0+a*p1 q1=(1-a)*p1+a*p2 q2=(1-a)*p2+a*p3 r1=(1-a)*q0+a*q1
S=(1-a)*r1+a*r2 p1 q1 p2 r1 r2 q0 q2 p0 21 p3
22
Vectorizer.io . online.rapidresizer. .vectorization.org
22 .vectorization.org Graphics Editor
23
Before After 23
24
Before After 24
25
Filters: Introduction:-
The trick of image filtering is that you have a 2D filter matrix, and the 2D image. Then, for every pixel of the image, take the sum of products. Each product is the color value of the current pixel or a neighbor of it, with the corresponding value of the filter matrix. The center of the filter matrix has to be multiplied with the current pixel, the other elements of the filter matrix with corresponding neighbor pixels. 25
26
How does this matrix relate to image processing?
An image is just a 2-dimensional matrix of numbers, or pixels. Each pixel is represented by a number - depending upon the image format these numbers can vary: for an 8 bit RGB image each pixel has a red, green, and blue component with a value ranging from 0 to 255. A kernel works by operating on these pixel values using straightforward mathematics to construct a new image. Lets take the above kernel and do some math: for each pixel, center the kernel over the pixel, multiply the kernel values times the corresponding pixel values, and add the result - this final value is the new value of the current pixel. 26
27
27
28
28
29
29
30
References List Of papers http://potrace.sourceforge.net/potrace.pdf
tt/pubs/buchanan12-vectorization.pdf List Of papers 30
31
Thank You
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.