/
Bitmap Image Vectorization using Potrace Algorithm Bitmap Image Vectorization using Potrace Algorithm

Bitmap Image Vectorization using Potrace Algorithm - PowerPoint Presentation

olivia-moreira
olivia-moreira . @olivia-moreira
Follow
375 views
Uploaded On 2018-09-25

Bitmap Image Vectorization using Potrace Algorithm - PPT Presentation

Graduation Project Graphics Editor Reference Potrace a polygonbased tracing algorithm Peter Selinger September 20 2003 ABSTRACT Our project Vectorization rastertovector conversion consists of analyzing a raster image to convert its pixels representation to a vector represe ID: 679180

pixel image polygon path image pixel path polygon vectorization pixels straight bitmap potrace step matrix curve closed vector line

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Bitmap Image Vectorization using Potrace..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Bitmap Image Vectorization using Potrace Algorithm

Graduation Project Graphics Editor

Reference = Potrace: a polygon-based tracing algorithm,Peter Selinger, September 20, 2003.Slide2

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…..)2Slide3

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. 3Slide4

Vectorization

Algorithms

Structural Vectorization of Raster Images . Potrace: a polygon-based tracing .4Slide5

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).5Slide6

Vectorization - Basics

Before

Vectorization

After

Vectorization

6Slide7

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 generationIn the second step, each path is approximated by an optimal polygon - Polygon GenerationIn 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.7Slide8

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

8Slide9

0

0

0000000011110000

1

0

0

1

0

0

0

0

0

1

1

0

0

0

0

1

1

1

1110010110

1

0

0

1

0

1

1

0

1

0

0

00110000011110000000000

9Slide10

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.10Slide11

0

0

0000000000000000

1

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

000000000

0

0

0

0

0

0

0

0

0

0

0

00000000000000000000000

11Slide12

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 infinity12Slide13

13Slide14

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.14Slide15

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.15Slide16

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 segments16Slide17

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.17Slide18

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.18Slide19

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

19Slide20

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*0For 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). 20Slide21

p1

p0

p3

p2

q2

q1

q0

q0=(1-a)*p0+a*p1

q2=(1-a)*p2+a*p3

q1=(1-a)*p1+a*p2

r1=(1-a)*q0+a*q1

r2=(1-a)*q1+a*q2

S=(1-a)*r1+a*r2

r1

r2

21Slide22

Vectorizer.io

.vectorization.org

.

online.rapidresizer

.

Graphics Editor

22Slide23

Before

After

23Slide24

Before

After

24Slide25

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.25Slide26

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.

26Slide27

27Slide28

28Slide29

29Slide30

References

http://potrace.sourceforge.net/potrace.pdf

http://potrace.sourceforge.net/potracelib.pdfhttp://fileadmin.cs.lth.se/cs/Personal/Michael_Doggett/pubs/buchanan12-vectorization.pdfList Of papers30Slide31

Thank You

Slide32