10
A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin Kansal Department of computer science IIT Delhi India, New Delhi [email protected] Prof. Subodh Kumar Department of computer science IIT Delhi India, New Delhi [email protected] ABSTRACT Linear gradients are commonly applied in non-photographic art-work for shading and other artistic effects. It is sometimes necessary to generate a vector graphics form of raster images comprising such art-work with the expec- tation to obtain a simple output that is further editable, say, using any popular vector editing software. Further, this vectorization process should be automatic with minimal user intervention. We present a simple image vectorization algorithm that meets these requirements by detecting linear gradient filled regions and reconstructing the vector definition using that information. It uses a novel interval gradient optimization scheme to derive large regions of uniform gradient. We also demonstrate the technique on noisy images. Keywords Image vectorization Gradient reconstruction Region detection (a) Original Image (b) Adobe Livetrace output (c) Inkscape output (d) Our output Figure 1: Comparison of diferent outputs. 1 INTRODUCTION The advent of new mobile and touch devices has mo- tivated designers to create and publish their content in vector format. Vector graphics represents 2D images in terms of mathematical elements like curves, contours, straight lines and other shapes, along with their at- tributes such as fill, stroke, transparency and so on. This is different from raster representation, which stores a color sample at each pixel center. Vector graphics sup- ports rasterization on the fly and therefore it can be viewed at different scales and resolutions without any artifacts. With the increasing demand for vector content, the need for converting raster images into vectors has also in- creased. This process is called Vectorization. We set out to obtain automatic vectorization with minimal human intervention even on potentially noisy images. Later re-rasterization of our vector representation should pro- duce the appearance of the original image at various scales. Further, for wide-spread usage, this vector rep- resentation should be in a standard form and be ed- itable. However, it is not easy for an algorithm to meet all these conditions for every image. In fact, these may be conflicting goals. For example, to match the vec- tor appearance with the original image, an algorithm might generate smaller patches due to which editing becomes difficult. Further, application of color gradi- ents for shading effects in a non-photographic image poses additional challenges to vectorization. In this case, the vectorization algorithm must derive the gradi- ent definition and use it to approximate the color infor- mation. Many algorithms, including commercial soft- ware [27, 1, 13], are unable to appropriately reconstruct such gradients. For example, they may approximate the gradients with patches of constant fill regions. (See Inkscape [13] and Adobe Illustrator [1] examples in fig- ures 1c and 1b respectively). A few others, including the one titled ARDECO [17], focus on computing the gradient. For example, ARDECO uses first and higher order gradients to store the color information. However, these techniques either generate too many vector patches or their 21st International Conference on Computer Graphics, Visualization and Computer Vision 2013 Communication papers proceedings 220 ISBN 978-80-86943-75-6

A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

A framework for detection of linear gradient filled regionsand their reconstruction for vector graphics

Ruchin KansalDepartment of computer

scienceIIT Delhi

India, New [email protected]

Prof. Subodh KumarDepartment of computer

scienceIIT Delhi

India, New [email protected]

ABSTRACTLinear gradients are commonly applied in non-photographic art-work for shading and other artistic effects. It issometimes necessary to generate a vector graphics form of raster images comprising such art-work with the expec-tation to obtain a simple output that is further editable, say, using any popular vector editing software. Further, thisvectorization process should be automatic with minimal user intervention. We present a simple image vectorizationalgorithm that meets these requirements by detecting linear gradient filled regions and reconstructing the vectordefinition using that information. It uses a novel interval gradient optimization scheme to derive large regions ofuniform gradient. We also demonstrate the technique on noisy images.

KeywordsImage vectorization Gradient reconstruction Region detection

(a) Original Image (b) Adobe Livetraceoutput

(c) Inkscape output (d) Our output

Figure 1: Comparison of diferent outputs.

1 INTRODUCTIONThe advent of new mobile and touch devices has mo-tivated designers to create and publish their content invector format. Vector graphics represents 2D images interms of mathematical elements like curves, contours,straight lines and other shapes, along with their at-tributes such as fill, stroke, transparency and so on. Thisis different from raster representation, which stores acolor sample at each pixel center. Vector graphics sup-ports rasterization on the fly and therefore it can beviewed at different scales and resolutions without anyartifacts.

With the increasing demand for vector content, the needfor converting raster images into vectors has also in-creased. This process is called Vectorization. We set outto obtain automatic vectorization with minimal humanintervention even on potentially noisy images. Laterre-rasterization of our vector representation should pro-duce the appearance of the original image at variousscales. Further, for wide-spread usage, this vector rep-resentation should be in a standard form and be ed-itable. However, it is not easy for an algorithm to meetall these conditions for every image. In fact, these maybe conflicting goals. For example, to match the vec-tor appearance with the original image, an algorithmmight generate smaller patches due to which editingbecomes difficult. Further, application of color gradi-ents for shading effects in a non-photographic imageposes additional challenges to vectorization. In thiscase, the vectorization algorithm must derive the gradi-ent definition and use it to approximate the color infor-mation. Many algorithms, including commercial soft-ware [27, 1, 13], are unable to appropriately reconstructsuch gradients. For example, they may approximatethe gradients with patches of constant fill regions. (SeeInkscape [13] and Adobe Illustrator [1] examples in fig-ures 1c and 1b respectively).

A few others, including the one titled ARDECO[17], focus on computing the gradient. For example,ARDECO uses first and higher order gradients tostore the color information. However, these techniqueseither generate too many vector patches or their

21st International Conference on Computer Graphics, Visualization and Computer Vision 2013

Communication papers proceedings 220 ISBN 978-80-86943-75-6

Page 2: A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

representations are so complex that their output cannotbe easily edited.

Vector graphics can be represented using an open vectorformat such as EPS, PDF, or SVG[28] or it could be aproprietary format (such as Adobe Illustrator or Corel).Among open formats, SVG is possibly the most widelyused vector format for web and digital media, which wehave chosen as our output. Nonetheless, the definitionof linear gradient is largely the same in all vector stan-dards modulo occasional minor differences. SVG spec-ifies linear color gradient as continuous smooth colortransition along a 2D direction from one given color ata known position to another. This direction is called theGradient Vector. The value of each pixel along the gra-dient vector may be calculated by linearly interpolatingthe two end colors. The gradient normal is orthogonalto the gradient vector. The color of each pixel on thegradient normal remains same. The SVG standard alsoallows fixing of more than two colors along the gradientvector, to form a smooth multi-color transition. Thesespecific points on the gradient vector with pre-definedcolor values are called Gradient Stops (See figure 2).

Figure 2: Linear Gradient defined by four gradientstops(C1, C2, C3 and C4). Notice the color along thegradient vector is defined by linear interpolation fromone stop to another but the color of the pixels along thegradient normal remains same.

We have developed an approach that can detect lineargradient filled regions as well as the gradient values.While the contributions of this paper are primarily ineffective recovery of regions with uniform gradient, forcompleteness we do also produce boundary curves andregions with uniform fill color where necessary. We donot target vectorization of photographic quality images,but rather art-design by artists. The distinguishing fea-ture of such images is that they contain relatively largeareas of uniform fill and gradients but suffer from noiseand other smoothing and post-processing artifacts.

Permission to make digital or hard copies of all or part ofthis work for personal or classroom use is granted withoutfee provided that copies are not made or distributed for profitor commercial advantage and that copies bear this notice andthe full citation on the first page. To copy otherwise, or re-publish, to post on servers or to redistribute to lists, requiresprior specific permission and/or a fee.

Figure 3: The complete pipeline

2 PREVIOUS WORKVectorization generally involves some form of imagesegmentation followed by a vector approximation foreach segment. Significant research in both vectoriza-tion and, more generally, image segmentation exists.The research in vectorization is done with various ob-jectives such as fitting smooth curves [15, 24, 2, 9],minimizing the number of colors used [29], preserv-ing editability [4] and matching appearance with input[17, 25, 16, 21]. Image segmentation prior to vector-ization is commonly based on edge detection [6], colorquantization [8, 11, 5] or a global optimization function[19, 18, 20] to reduce the overall energy.Early work in this field focused on line drawings and bi-tonal images [6, 9, 10]. These approaches are mainlybased on edge detection [6], thresholding [7, 14, 22,23], thinning [26] and contour tracing [12]. The ex-tracted line, image contour or region is represented byvector graphics primitives, e.g., curves and paths. Morerecent algorithms [17, 25, 16, 21, 29, 4, 15] deal withfull color images and their goal is to generate high fi-delity output.ARDECO[17], proposed by Lecot and Levy in 2006,tries to decompose the input image into patches. Eachpatch is approximated by a constant color, linear orhigher order gradient in order to minimize the overallenergy. The energy function in their approach is deter-mined by a boundary length function and a curve fit-ting term. The weighting of terms is controlled by userinput. Since the energy functional is quite generic, itcan handle images with fine details. At the same timeit often produces a large number of patches and conse-quently it is not possible to edit the final vector graphicseasily for post-editing. Further, for large gradient fill re-gions, it often fails to converge to any result. Also, dueto linear constraints the segment boundaries producedby them is often not smooth. Finally, the user needs toadjust several parameters by experimentation. Our al-gorithm is simpler than ARDECO as it considers onlyfirst order gradients. Further, our algorithm producesfewer regions so that a user can edit the image easily.Sun et al [25] introduced a vectorization approach us-ing Gradient Meshes. There, a gradient mesh is de-fined by a grid using topologically planar rectangular

21st International Conference on Computer Graphics, Visualization and Computer Vision 2013

Communication papers proceedings 221 ISBN 978-80-86943-75-6

Page 3: A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

Ferguson patches with mesh-lines. Control points ofthe mesh have three attributes: position, derivative andcolor. Their approach relies on user assistance for meshinitialization and placement. Recently, Lai, Hu andMartin, 2009 [16] improved that algorithm by gener-ating the gradient mesh automatically. The output ofgradient mesh is quite impressive and it can even beapplied to photographic images. However, the size oftheir representation is too unwieldy for further editing.Moreover, Gradient Mesh is not a standard primitiveand are hence less portable. They cannot be renderedor edited by standard tools.

Price and Barett [4] proposed an approach for inter-active image editing using object based vectorization.They allow the user to select an object and then graphcut is used recursively to form a hierarchical object tree.For each object they define a mesh by locating the cor-ner points and doing recursive subdivision. The result-ing mesh can be edited by various tools. However,the approach is designed to be driven by user manu-ally. Also, the algorithm does hot handle gradient re-construction, it only provides a better means of objectconstruction.

Diffusion curves[21] is a different approach to representsmooth shaded images. A diffusion curve partitions thespace through which it is drawn, defining different col-ors on either side. These colors may vary smoothlyalong the curve. In addition, the sharpness of the colortransition from one side of the curve to the other can becontrolled. Due to the limitations with Poisson equa-tions, the color variations in all raster images may notbe represented by this system, especially when the im-age has sparse features in some areas.

Xia et al [29] proposed a vector based representation inwhich the image is decomposed into non-overlappingtriangular patches with curved boundaries. The colorvariation over each triangular patch is approximatedwith a thin-plate spline for every color channel. Itallows them to approximate raster images with bothsmooth variations and curvilinear features. Although,the representation is powerful and compact, again ed-itability and portability is a concern.

A nice discussion of vector primitives related to colorgradients is provided by Pascal et al. [3]. They de-scribe various available techniques for construction andrendering of such vector primitives. They mention thecurrent methods of vector creation by hand as well asthrough vectorization. Some practical challenges andlimitations of these approaches are also explained.

Adobe live trace [1] and Vector magic [27] are popularcommercial applications, which are used for vectoriza-tion and produces standard vector graphics. Inkscape[13] is an open source tool which is also used for vec-torization and vector editing. However, none of thesepackages recognizes linear color gradients in the image

and therefore such regions are approximated by rectan-gular stripes (See figure 1).

3 OUR APPROACHFigure 3 depicts our pipeline. We start with a rasterimage. In our experiments all input images are 8-bitper-channel RGB images but the technique is indepen-dent of the color format. Like most vectorization ap-proaches, we first segment a filtered version of the im-age. Color discontinuity imposes segment boundaries.Next, for each segmented region we determine if it canbe represented by a linear gradient function. This de-cision is made by searching for a gradient value that issupported by all pixels of the region. In particular, wecalculate the range of gradient values supported by eachpixel. A global optimization across pixels of the regionthen determines the most plausible gradient for the re-gion. Finally, using this optimized gradient direction,we find the gradient stops within the region. In terms offigure 3, the main contributions of our algorithm are instages 4, 5 and 7.

For regions that cannot be represented using a lineargradient, we employ a color quantization approach tominimize the number of vector elements. Each region isthen vectorized using the potrace engine [24] (althoughany vectorization approach would suffice). Potrace isdesigned to generate smooth contours of the featureswhich works well with our pipeline. Each stage of thepipeline is described next.

3.1 Image SmoothingTo reduce the effect of noise in the image, we apply aGaussian blur of radius 3. It reduces the sharpness nearedges and produces a relatively smooth image.

3.2 Initial SegmentationAs a preprocessing step, we first perform image seg-mentation using a standard scheme. We have used meanshift segmentation followed by a flood fill, which givesus good result. although a more specialized segmenta-tion algorithm can also be employed.

3.3 Gradient ApproximationIn order to determine the gradient direction m we re-construct values from the given samples. However, wemust also consider that the input color values are im-precise due to noise, smoothing and rasterization. Dueto imprecise color values at pixel centers, we resort toan interval color scheme. In particular, if the color atpixel p input to this stage is c, we allow that the actualcolor is in the range [c− : c+], where c ∈ [c− : c+]. Forexample, if c only has rounding error, c− = c−0.5 andc+ = c+0.5.

If the gradient slope at pixel p is m, we expect the colorat the gradient normal p+k 1

m within a segment to be in

21st International Conference on Computer Graphics, Visualization and Computer Vision 2013

Communication papers proceedings 222 ISBN 978-80-86943-75-6

Page 4: A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

Algorithm 1 Find the slope range

1: procedure FINDRANGE(p,R). Calculate range ofslopes for pixel p over region R

2: p.range← /0 . Initialize the range of p asempty

3: S← Boundary pixels of R . Initialize vector Swith boundary pixels of R in such an order that allconsecutive pixels in S are neighbors in R

4: i← 05: c← p.color6: for i < S.size−1 do7: p1← S[i]8: p2← S[i+1] . Get two neighbor pixels

from S in p1 and p29: if [c− : c+]

⋂[p1.color, p2.color] 6= /0 AND

p.region = p1.region = p2.region then10: L1← line(p1, p) . Find line L1 passing

through p1 and p11: L2← line(p2, p)12: p′1← intersection(L1,R) . Find

intersection of L1 with R13: p′2← intersection(L2,R)14: if [c− : c+]⊆ [p′1.color, p′2.color] then15: p.range← [slope(L1),slope(L2)]16: break;17: end if18: end if19: i← i+120: end for21: end procedure

the interval [c− : c+] for all values of k within a range,if the input color at p is c. However, due to the ras-terization in the input image we may not have samplesavailable for any value of k.

We consider a contour around p and locate the normalline passing through p on this contour. For example,this contour can be a rectangle R. Our goal is to locatethe range [c− : c+] on R. Assuming color interpolationalong R, we find two samples p1 and p2 on R such thatthe color c1 at p1 and color c2 at p2 span the range [c− :c+], where p1 and p2 are the closest such pixels alongthe contour. In other words, [c− : c+] ⊆ [c1 : c2]. Weconjecture that the normal line intersects the rectanglebetween p1 and p2. As an aside, if one were to searchfor the exact value c reconstructed from samples near p1and p2, it would yield unreliable estimates for m that areoften inconsistent with the estimates of p’s neighbors.

If p is not on the boundary of its region, a pair (p1, p2)implies the existence of another pair (p′1, p′2) on the op-posite side of the rectangle. For pair (p1, p2), we formstraight lines by joining p1 and p, and similarly by join-ing p2 and p (Figure 4 explains this construction, seethe blue and red lines passing through p). The intersec-

Figure 4: The setup: A rectangular grid of pixels aroundp is considered. The color interval of pixel p, [c− : c+],lies in the colors at pixels p1 and p2. This implies thenormal direction through p, passes between p1 and p2.Consider lines joining p with p1 and p2 respectively.These lines intersect at the opposite side of the grid onp′1 and p′2. If [c− : c+] is spanned by the colors at p′1 andp′2, the normal directions is assumed to lie between thetwo solid lines. Additionally, the green dotted line isformed by fitting a line among all pixels whose colorsare similar to that of pixel p. This estimated slope isalso stored for each pixel p.

tions of these lines with the opposite boundary of rect-angle R provides the conjugate pair (p′1, p′2). Again, weneed not have samples available at p′1 and p′2, unlessR is symmetric about p. We reconstruct the color, re-spectively, c′1 and c′2 at positions p′1 and p′2 from theneighboring samples. If again [c− : c+] ⊆ [c′1 : c′2], itis evidence of the normal line passing between p′1 andp′2. If the slopes of lines p1 p′1 and p2 p′2 are 1

m1and 1

m2,

respectively, we say that pixel p favors a color gradi-ent in the range [m1 : m2] subject to the condition thatpairs (p1, p2) and (p′1, p′2) lie in the same image region.Please note that if the range [p′1 : p′2] is not tight and itssubset contains the color range [c− : c+], that subset isused instead to provide a tighter gradient range. Thisapproach is presented in algorithm 1.

Not the entire range of gradients [m1 : m2] is equally fa-vored by p. We also estimate the most favored gradientm′ and weight a value m ∈ [m1 : m2] by its differencefrom m′. To find m′, we compute the best fit line to thecolor values nearest c within R. In particular, we form aset of points S including every pixel within rectangle Rwith color within [c− : c+]. The calculation of favoredslope is explained in algorithm 2.

If a pixel does not produce a gradient range, either it isnot a part of a gradient filled region, or it cannot providecandidate gradients due to noise in the image. On theother hand, it is possible for a pixel to provide multiplegradient candidates due to noise. We include all rangesin the optimization process described next.

Every pixel pi of a presumed gradient fill region simi-larly produces its favored gradient m′i and slope range(mi1 ,mi2). We choose a single gradient value for theregion that best satisfies all ranges.

21st International Conference on Computer Graphics, Visualization and Computer Vision 2013

Communication papers proceedings 223 ISBN 978-80-86943-75-6

Page 5: A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

Algorithm 2 Find the favored gradient slope

1: procedure FINDGRADSLOPE(p,R) . Calculatefavored gradient slope of pixel p over region R

2: p.slope← nil3: Q← all pixels of R . Initialize vector Q with

all pixels of R4: i← 05: S← /06: for i 6= Q.size do . Loop on all pixels in Q7: q← Q[i]8: if p.color ∈ [q.color− : q.color+] AND

p.region = q.region then9: S← S

⋃{q}

10: end if11: i← i+112: end for13: if S 6= /0 then14: L← FitStraightLine(S)15: p.slope← slope(L)16: end if17: end procedure

Choice of this region R is important as it should be suf-ficiently large to have enough samples to reproduce thereliable gradient range and value. The size of region Rmay also vary on each pixel depending on the noise inthe image. Therefore, we choose rectangles of dynam-ically varying sizes whose dimensions are decided oneach pixel. We start with a size of 3x3, and keep onincreasing this region until the line fit error is below acertain threshold ε . Because of this dynamically sizedregion, our approach can handle different kinds of noisyimages sucessfully.

3.4 Gradient OptimizationAfter computing the favored gradients for each pixel pi,m′i and the range [mi1 : mi2 ], the final gradient mr for theregion should ideally lie in this range and as close tom′i as possible. We compute mr by optimizing acrossall pixels of the region. This optimization can be easilyposed and solved using a simple geometrical construc-tion.

We select a function which maximizes its potential ifthe selected gradient mr = m′i. This potential monoton-ically decreases as mr grows apart from m′i. One canselect a Gaussian or radial basis function as the weight,but a cosine-linear weight function provides the best re-sults. Given two line slopes m′ and m′′, the dot productof the vectors in their respective directions gives a pro-jection of a vector on another. By definition, the mag-nitude of the dot product of two unit vectors decreasesas the angle between them grows. We define our ob-jective function to maximize the sum of these dot prod-ucts. To do so, the value of objective function f (x) is

Figure 5: Gradient Stops Estimation: The shaded areais a gradient filled region while its bounding box ismarked as black rectangle.We draw lines from fourcorners of the bounding box parallel to gradient axis(shown in different colors), since the line passing fromtop-left corner (marked in blue) overlaps the maximumpixels of the region, it is used for gradient stops esti-mation. Two stops are generated where line hits thebounding box(C1 and C4) while two stops are gen-erated where line intersects the regions (C2 and C3).Also, note that value of C2 and C3 is determined by us-ing the pixel color at the respective location of imagewhile value of C1 and C4 is computed by extrapolationof C2 and C3 along the gradient axis.

computed by finding all pixels pi which have the range[mi1 : mi2 ] containing x and performing a summationover the dot products with their favoured slope m′i. i.e.f (x) = ∑

ni=0 |g(x, i)| where g(x, i) = x̂.m̂′i|mi1 ≤ x≤ mi2

and x̂ and m̂′i are two unit vectors in the direction of xand m′i respectively.

The linear optimization can be performed using anystandard technique like the dynamic system basedglobal optimization [19].

3.5 Gradient Stops EstimationWe use a heuristic approach to find the gradient stops. Ifwe draw lines parallel to the computed gradient vectormr from each corner of the bounding box of the regionas shown in Figure 5, the one with the largest overlapwith the region may be selected for stops estimation.We generate four color stops on the gradient vector, twoon each end points on the bounding box and two oneach intersection of this line with the region (See Figure5). If the points at C1 and C4 do not lie in the region,their colors may be estimated using extrapolation fromC2 and C3 as shown.

3.6 Color QuantizationSegmentation for the remaining colored regions of theimage is performed using color quantization [11]. Acolor palette of the given number of colors is first pre-pared, and then each pixel is assigned the index of colorpalette that it best matches. For our experiments we

21st International Conference on Computer Graphics, Visualization and Computer Vision 2013

Communication papers proceedings 224 ISBN 978-80-86943-75-6

Page 6: A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

have used an octree based color quantization approach[8, 5].

3.7 Contour Tracing

Tracing is the process of fitting curves that bound eachimage regions. After tracing, we obtain a set of curvesthat represent the image geometry. We employ the po-trace engine developed by Peter Schilinger [24] for thisoutline tracing. The same engine is also used by opensource vector drawing package Inkscape [13].

3.8 Final Vector Output

Once we obtain the curves outlining each image seg-ment, we apply fills to these curves and generate thefinal vector representation (in the SVG format). The re-gion color, as noted before, may be either a solid fillcolor obtained through quantization or a linear gradientproduced by the optimization algorithm.

4 RESULTS AND VALIDATIONS

We analyzed the vector output of our algorithm fromvarious prespectives like appearance, editability, accu-racy and error per pixel. Results are given below.

4.1 Appearance

We applied our approach to different non-photorealisticraster images and the results are presented in Figure 6.

4.2 Comparison with ARDECO

The implementation of ARDECO is publicly availableon the authors webpage. In figure 9 ARDECO pro-duced more than 1200 paths while our approach out-puts 4 paths only. This is because we perform an earlysegmentation and then apply gradient detection on thevarious segments. We are also able to handle noisy im-ages, as shown in figure 9 where the input image con-tains random RGB noise.

4.3 Editability

The output SVG can be easily edited using any standardvector graphics tool like Inkscape. Examples are shownin figure 7.

4.4 Accuracy

To measure the accuracy, we applied our algorithm toimages whose gradient direction and magnitude was al-ready known. The results are shown in figure 8.

Our Error Inkscape ErrorInput Gradient Solid Gradient Solid

6e 7.7 16.25 17.49 24.406k 11.4 13.2 18.64 21.316c 11.63 18.67 14.76 26.556i 15.64 25.14 26.20 44.86a 25.51 34.26 46.92 37.40

Table 1: We calculated the per pixel error for gradientand solid colored regions separately in our output andthen compared with the corresponding region error ininkscape.

4.5 Per Pixel ErrorTo analyze the per pixel error in our output, we raster-ized our vector output and then compared it with theoriginal image to compute root mean squared error perpixel. Table 1 compares the error in our gradient andsolid colored regions with the corresponding regionsin Inkscape output. Both Inkscape’s and our approachused a quantization palette size of 16 colors.

Table 1 shows that even the per pixel error for solid col-ored regions is low with our approach as compared toInkscape. This is due to the fact that our approach ex-cludes the gradient region while performing quantiza-tion, therefore with the same size of color palette, moreaccurate colors are represented.

The high per pixel error in output can be explained dueto the several factors:

1. Vector and raster spaces are not equivalent. Thepixel at location (x, y) in input image may not bepresent at the same exact location in the vectorspace.

2. Input image may contain small pixel level features,which are merged in larger regions during vectoriza-tion.

3. Vector output is optimized to be represented withfewer colors using some method of color minimiza-tion.

5 LIMITATIONS AND FUTURE WORKWe have proposed an algorithm to find gradient in im-ages that optimizes the gradient values across noisy pix-els. It mainly targets reconstruction of simple art draw-ings that can then be further edited or stylized. Theproposed algorithm works well when the linear gradi-ent in input image is specified by two color stops. Oth-erwise the the gradient region may be split into multi-ple smaller regions. This limitation can be easily han-dled by modifying the gradient stops estimation step toaccount for multiple color stops. Our approach mayalso not produce good results when the linear gradientis applied on small width regions, like linear gradient

21st International Conference on Computer Graphics, Visualization and Computer Vision 2013

Communication papers proceedings 225 ISBN 978-80-86943-75-6

Page 7: A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

on a single pixel wide curve, for it needs to find seg-ments with a few neighbors around its pixels. We be-lieve the algorithm can be easily adapted to handle non-linear gradients – for example a radial gradient. Ouralgorithm is designed to operate on each pixel indepen-dently, therefore it can parallelize well. Future workshould also include deriving vector graphics for videosand using the level of optimization in a feedback loopto refine the segmentation potentially producing evenfewer patches.

6 REFERENCES[1] Inc. Adobe Systems. Adobe illustrator cs5, 2010.[2] Autotrace. An open-source program for convert-

ing bitmap to vector graphics, 2004.[3] Pascal Barla and Adrien Bousseau. Gradient art:

Creation and vectorization. In Paul Rosin andJohn Collomosse, editors, Image and Video-BasedArtistic Stylisation, volume 42 of ComputationalImaging and Vision, pages 149–166. SpringerLondon, 2013.

[4] William A. Barrett and Alan S. Cheney. Object-based image editing. In Proceedings of the 29thannual conference on Computer graphics andinteractive techniques, SIGGRAPH ’02, pages777–784, New York, NY, USA, 2002. ACM.

[5] Dan S Bloomberg. Color quantization using oc-trees. 2008.

[6] J Canny. A computational approach to edge de-tection. IEEE Trans. Pattern Anal. Mach. Intell.,8(6):679–698, June 1986.

[7] Jung-Shiong Chang, Hong-Yuan Mark Liao,Maw-Kae Hor, Jun-Wei Hsieh, and Ming-YangChern. New automatic multi-level threshold-ing technique for segmentation of thermal im-ages. Image and Vision Computing, 15(1):23 –34, 1997.

[8] D. Clark. Color quantization using octrees. Dr.Dobb’s Journal, pages 54–57, Jan 1996.

[9] Dov Dori, Senior Member, and Wenyin Liu.Sparse pixel vectorization: An algorithm and itsperformance evaluation. IEEE Trans. PatternAnalysis and Machine Intelligence, 21:202–215,1999.

[10] Kuo-Chin Fan, Den-Fong Chen, and Ming-GangWen. A new vectorization-based approach tothe skeletonization of binary images. In ICDAR,pages 627–630. IEEE Computer Society, 1995.

[11] Michael Gervautz and Werner Purgathofer. A sim-ple method for color quantization: Octree quan-tization. In New Trends in Computer Graphics.Springer Verlag, Berlin, 1988.

[12] O. Hori and S. Tanigawa. Raster-to-vector conver-sion by line fitting based on contours and skele-

tons. In Document Analysis and Recognition,1993., Proceedings of the Second InternationalConference on, pages 353 –358, oct 1993.

[13] Inkscape. An open source linux/windows scalablevector graphics editor, 2010.

[14] Ralf Kohler. A segmentation system based onthresholding. Computer Graphics and Image Pro-cessing, 15(4):319 – 338, 1981.

[15] Johannes Kopf and Dani Lischinski. Depixelizingpixel art. In ACM SIGGRAPH 2011 papers, SIG-GRAPH ’11, pages 99:1–99:8, New York, NY,USA, 2011. ACM.

[16] Yu-Kun Lai, Shi-Min Hu, and Ralph R. Mar-tin. Automatic and topology-preserving gradientmesh generation for image vectorization. ACMTrans. Graph., 28(3):85:1–85:8, July 2009.

[17] Gregory Lecot and Bruno Levy. Ardeco: Auto-matic region detection and conversion. In Euro-graphics Symposium on Rendering, 2006.

[18] Musa Mammadov, Alexander Rubinov, and JohnYearwood. Dynamical systems described by re-lational elasticities with applications. ContinuousOptimization, pages 365–385, 2005.

[19] Musa A Mammadov. A new global optimizationalgorithm based on dynamical systems approach.In Proceedings of the 6th International Confer-ence on Optimization: Techniques and Applica-tions (ICOTA’ 04). Ballarat, Australia, 2004.

[20] University of Ballarat. Ganso library for opti-mization functions.

[21] Alexandrina Orzan, Adrien Bousseau, HolgerWinnemöller, Pascal Barla, Joëlle Thollot, andDavid Salesin. Diffusion curves: a vector rep-resentation for smooth-shaded images. In ACMSIGGRAPH 2008 papers, SIGGRAPH ’08, pages92:1–92:8, New York, NY, USA, 2008. ACM.

[22] Arnulfo Perez and Rafael C. Gonzalez. An itera-tive thresholding algorithm for image segmenta-tion. Pattern Analysis and Machine Intelligence,IEEE Transactions on, PAMI-9(6):742 –751, nov.1987.

[23] N. Ramesh, J.-H. Yoo, and I.K. Sethi. Threshold-ing based on histogram approximation. Vision,Image and Signal Processing, IEE Proceedings -,142(5):271 –279, oct 1995.

[24] Peter Selinger. Potrace: a polygon-based tracingalgorithm, 2003.

[25] Jian Sun, Lin Liang, Fang Wen, and Heung-YeungShum. Image vectorization using optimized gra-dient meshes. In ACM SIGGRAPH 2007 papers,SIGGRAPH ’07, New York, NY, USA, 2007.ACM.

[26] H. Tamura. A comparison of line thinning al-

21st International Conference on Computer Graphics, Visualization and Computer Vision 2013

Communication papers proceedings 226 ISBN 978-80-86943-75-6

Page 8: A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

gorithms from digital geometry viewpoint. InProceedings of the Fourth Int’l Joint Conf PatternRecognition. Kyoto, Japan, 1978.

[27] Inc. Vector Magic. Vector magic, 2010.[28] SVG working group. Svg format for vector graph-

ics.[29] Tian Xia, Binbin Liao, and Yizhou Yu. Patch-

based image vectorization with automatic curvi-linear feature alignment. In ACM SIGGRAPHAsia 2009 papers, SIGGRAPH Asia ’09, pages115:1–115:10, New York, NY, USA, 2009. ACM.

21st International Conference on Computer Graphics, Visualization and Computer Vision 2013

Communication papers proceedings 227 ISBN 978-80-86943-75-6

Page 9: A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

(a) (b) (c) (d)

(e) (f) (g) (h)

(i) (j) (k) (l)

(m) (n) (o) (p)

(q) (r)

Figure 6: The results with our approach. Original image is on the left and the final vector image is shown on right.

21st International Conference on Computer Graphics, Visualization and Computer Vision 2013

Communication papers proceedings 228 ISBN 978-80-86943-75-6

Page 10: A framework for detection of linear gradient filled regions and … · A framework for detection of linear gradient filled regions and their reconstruction for vector graphics Ruchin

(a) Editing the outputvector: Scaled the bodyparts.

(b) Editing the outputvector: Rotated the armlevers.

(c) Editing the outputvector: Removed a path.

(d) Editing the outputvector: The original lin-ear gradient color stops(as shown in figure 6)were towards red towhite. Using Inkscape,we edited the output sothat the gradient stopsare changed to blue andwhite.

Figure 7: Editing the final output.

(a) Original gradient di-rection: 1.0, color vary-ing from (255, 0, 0) to(255, 255, 0).

(b) Computed gradientdirection: 1.2, colorvarying from (255, 4, 0)to (255, 248, 0).

(c) Original gradientdirection:1.75 , colorvarying from (255, 0, 0)to (255, 255, 0).

(d) Computed gradientdirection:1.85 , colorvarying from (255, 8, 0)to (255, 242, 0).

(e) Original gradient di-rection: 0, color varyingfrom (255, 0, 0) to (255,255, 0).

(f) Computed gradientdirection: 0, color vary-ing from (255, 2, 0) to(255, 252, 0).

(g) Original gradient di-rection: ∞, color vary-ing from (255, 0, 0) to(255, 255, 0).

(h) Computed gradientdirection: ∞, color vary-ing from (255, 2, 0) to(255, 251, 0).

Figure 8: Comparison of computed gradient with original known gradient in image.

(a) Input noisy Image. (b) Ardeco output:1200 smallpatches.

(c) Our output: Only fourpatches.

Figure 9: Noisy images and comparison with ARDECO.

21st International Conference on Computer Graphics, Visualization and Computer Vision 2013

Communication papers proceedings 229 ISBN 978-80-86943-75-6