Image Processing using Voronoi diagrams - Semantic Scholar

4 downloads 66068 Views 702KB Size Report
Center for Neuroscience,. Image and Signal Proc. ... set of pixels from the image as Voronoi sites or generators, .... we call this movement a short step. We have ...
Conf. on Image Proc., Comp. Vision, and P. R. | IPCV'07 |

485

Image Processing using Voronoi diagrams1 Alondra Martínez Dept. of Mathematics University of Oriente Santiago de Cuba, Cuba

Jennifer Martínez2 Department of Telecommunications University of Oriente Santiago de Cuba, Cuba

Abstract – In this paper we present some techniques for obtaining non-photorealistc images with the aid of Voronoi diagrams, such as stained-glass images. We also show examples of their potential applications, including lossy image compression, and progressive and adaptive visualization of bitmap format images. Keywords: Mosaicing.

Image

compression,

Voronoi

diagram,

Hebert Pérez Center for Neuroscience, Image and Signal Proc. University of Oriente Santiago de Cuba, Cuba

directed approaches and Homogenuos-color-regiondirected approaches. The first ones result in a non-uniform collocation of Voronoi generators in a way that both the site density as well as the effort for the effective collocation is greater in the areas with finer details. The other approach consists of decomposing the image according to color in homogeneous polygonal regions, and then a set of sites is chosen inside each region, for the purpose of approximating this by one or several Voronoi cells.

1.1

1

Introduction

Several commercial applications dedicated to image processing offer choices for obtaining a non-photorealistic artistic effect known as stained-glass or mosaicing. You get, as a result, a mosaic-type image with the appearance of a stained-glass window. The artistic value of the mosaic depends of the thoroughness on which the tiny tiles or crystals are disposed, and the ability of absorbing the particularities of the original image which directly affects the beauty of the final piece. These aspects are usually omitted by commercial software. We propose obtaining the stained-glass effect by selecting a set of pixels from the image as Voronoi sites or generators, and constructing the Voronoi diagram associated to them; then each Voronoi cell is refilled with the color of the corresponding site, thus becoming a tile or crystal. The resulting image is designated as “Voronoi mosaic” or “Voronoi image”. You obtain a “good” Voronoi mosaic if the selection of the pixels that will operate as Voronoi generators is also “good”. It is easy to verify that if the generators are chosen with a uniform distribution inside the image the mosaic loses much of the desirable characteristics from the original image. Finding new ways to improve the results of the mosaicing operation, now with the assistance of Voronoi diagrams, is one of the fundamental purposes of this work. The proposed methods are classified into two groups: Contour1 2

Ricardo Quirós Dept. of Information Systems and Languages University Jaume I Castellón, Spain

Image compression

A Voronoi mosaic can be used as a compressed representation of certain bitmap image: taking advantage of the property that a Voronoi cell is completely determined by the corresponding site, the information that describes an entire tile in the mosaic is contained in one single pixel (the Voronoi site). As the Voronoi mosaic is completely determined by the set of generators and their corresponding colors, this information could be stored in a single file and then we could reconstruct the image in an approximate way; we get this way a lossy compression method. For the Voronoi mosaic to be a “good” compressed representation a compromise between the amount of necessary information to characterize it and the adjustment level to the image that it approximates is established. The larger the number of generators of the Voronoi mosaic, the better it will show the distinguishing features of the original image. If every pixel is chosen as a generator, then the image will be exactly described; nevertheless an excessive amount of sites is not desirable, for it would make the file too large.

1.2

Other applications

Mosaic construction techniques using Voronoi diagrams can be also useful for adaptive visualization: a way of representing images that does not require showing all the information, but only a certain amount, determined beforehand in a dynamic context. It is eventually unnecessary to show high resolution images, perhaps

This work has been partially supported by grant TIN2005-08863-C03 of the Spanish Ministry of Science and Education Corresponding address: [email protected]

486

Conf. on Image Proc., Comp. Vision, and P. R. | IPCV'07 |

because the image remains for a short time on the screen (potentially useful on graphic animations), or because the resolution of the visualization device is lower than the one provided by the data. The resolution level depends on the user and it will correspond to the amount and arrangement of the Voronoi sites. If we get a sequence of images with increasing levels of resolution, then we talk about progressive visualization: a way of representing images in stages. At the first stage a very rough approximation of the image is shown, then a better resolution is provided on each subsequent stage until the complete bitmap is revealed. Progressive visualization can be useful when we want to download images from Internet. This process is time-consuming, and it may happen that, after a long wait, the image does not look as you expected. It is then desirable to have a quick view of the image, even with low resolution; so that we can interrupt the downloading process at an early stage if the image is not the desired one. If Voronoi generators are organized by levels in a hierarchical structure, corresponding with the gradual increase of the image quality, we just have to visualize each Voronoi mosaic, from the less revealing to the one which is coincident with the reference image.

2

The methods

2.1 2.1.1

Contour-directed approaches Placing the sites by levels

The strategy basically consists of placing the Voronoi sites in a non uniform way, and then capturing the properties of the sensible zones, those where color variations are very significant, raising the density of those sites which characterize them. In order to do so, a contour detection process is carried out previously, and in every small portion of the image the amount of sites is taken to be proportional to the gradient. Contour points are grouped by levels, the first level corresponding to the coarsest contours, and the last level to the finest ones. Voronoi sites are also arranged by levels: Collocation of a Voronoi site on level l is determined by the number of pixels in a certain vicinity of the site which belong to l-th set of edge points or to some inferior level. The probability of a site to be effectively chosen increases proportionally to the amount of neighboring pixels that satisfied this condition. So, when moving along the site levels and constructing the mosaic, we progressively achieve a better approximation of the original image. Algorithm Input: A bitmap image B

A collection U of n thresholds on decreasing order Output: Collocation of Voronoi sites by levels over B

Procedure: Detect the contour points in B and group them by levels; (*After this step we will have an integer matrix on which the value of l at position (i, j) indicates a contour point corresponding to l-th level. Pixel x belongs to level l if its gradient exceeds the threshold ul ( 1 ≤ l ≤ n ) *) for each level of points of contour l do for each pixel x do if x hasn’t been chosen as generator then begin if x is a contour point of level lx and lx ≤ l then P:= 0; else P=(number of integers minors or equal that one ε-vicinity of x) ( total number of points pertinent to the ε-vicinity of x)

Choose x as generador of level l with probability P; end

Notice that choosing a generador for the l-th level is nondeterministic, and there are some parameters whose variation may affect the result of the algorithm. A special attention deserves the initial collection of thresholds, for it determines the groups of contour pixels, which in turn have a big impact on the performance of the algorithm. To a lesser extent, both the size and shape of the considered vicinity can also influence the probability of selection of a site. Nevertheless, these parameters are managed in a way that is transparent to the user, who ultimately must only specify the error margin in the approximation, and the other parameters will be readjusted to reach the desired degree of likeness. To estimate the quality of each Voronoi image the following formula was used, which expresses the difference of colors, pixel by pixel, between the two images:

∑ ∑ ∑ (P(Vx , y , c ) − P(Ox , y , c ) )

2

E color

=

x

y

c

∑ ∑ ∑ (P(Ox , y , c ) )

2

x

y

c

where ( x, y ) ranges over all the pixels, c over the three color components (red, green, and blue), and P (Vx , y , c ) and P ( Ox , y , c ) denote the intensities in component c, of pixel ( x, y ) , of the Voronoi mosaic and the reference image respectively. For the visualization of the Voronoi mosaic by levels it is very convenient to generate the Voronoi diagram incrementally. Therefore, an incremental algorithm was implemented, following the directions of Sugihara and Iri

Conf. on Image Proc., Comp. Vision, and P. R. | IPCV'07 |

487

[8]. With that algorithm, the necessary local modifications to build a new Voronoi region every time a new generator arrives can be done in constant time on the average. This algorithm also provides adequate numerical robustness, to guarantee a topologically consistent Voronoi mosaic.

To calculate a Voronoi region in an exact way the movements of their site and the surrounding sites would have to be considered. However, since we would have to keep in mind the movement of the site in all directions, the computational cost would be huge.

2.1.2

Notice that to find the deviation ϕ when a Voronoi region moves, even if the movement of neighboring sites is ignored, it is necessary to calculate the new status of each pixel of the mosaic, or at least of those that belong to it or to some of its adjacent regions. To approximate the change in the Voronoi region the strategies given in [4] were used. As the calculation of ϕ is approximate, after several iterations, some places can eventually vibrate inside certain regions, which jeopardizes convergence. This inconvenience is dealt with in our implementation.

Readjusting the sites

The site adjustment method consists of two processes: the model generation process, and the modification process. In the first one the mosaic is generated automatically, building the Voronoi diagram from an arbitrary arrangement of initial sites. In the second one we move these sites in an appropriate way and the necessary transformations are executed, trying to capture those features of the original image that are not yet revealed. Let ϕ be a function that measures the difference between the Voronoi image and the reference image (in particular we use Ecolor). In the modification process the sites are moved locally, seeking to decrease the value of ϕ. This process is repeated until a termination criterion is satisfied. On each iteration the movement of a site is limited to its eight adjacent pixels; a site only moves if, when reconstructing the Voronoi mosaic, the new value of ϕ is smaller. To accelerate the process, the movement of the sites is carried out in two stages. In the first one we determine approximately the topological changes in the Voronoi regions, thus providing a tentative new location for each site. All the sites are simultaneously moved to decrase the ϕ-value. The global features of the reference image are captured this way. Then, we consider the variation of each Voronoi region if its generator is moved independently from the rest in the optimal direction. These movements lead to local adjustments of the mosaic.

After the optimum movement of one or several sites has been determined, the algorithm proceeds to generate the new Voronoi diagram and its corresponding mosaic, now in an exact way, although it means a slight deviation of the value already estimated for ϕ. The movement of a site p is small enough so that p remains in its current region V(p); we call this movement a short step. We have the following result: Let N1(p) be the group of neighboring sites of p, those sites q such that V(p) and V(q) share an edge. Similarly, Ni(p) = N1(Ni-1(p)) - (Ni-1(p) ∪ Ni-2(p) ∪ ... ∪ N1(p) ∪ {p}), denotes the i-th layer of sites around p. We have proved that, if p moves in short steps, the only cells possibly affected by this movement belong to N1(p) and N2(p). In the worst case, these are all the cells, but on the average they are a constant number [6].

2.2 2.2.1

Fig 1. Reference image, initial Voronoi mosaic, the mosaic after capturing the global features and the mosaic after the local adjustments.

Homogeneous-color-region approaches Hierarchical Voronoi mosaic

This approach consists of constructing the Voronoi mosaic starting from a hierarchical Voronoi diagram (HVD), appropriately coloring the regions of this diagram to get the crystals. A hierarchical Voronoi diagram is a geometric structure that can be achieved constructing the usual Voronoi diagram associated to an initial set of sites, then we take another group of generators and construct a new Voronoi diagram inside each region of the first diagram; that is, for each region R, we only consider the points that are inside it, and “cut out” the regions of the Voronoi diagram for these points so that they are completely contained in R. This process is repeated in a recursive way, creating a new Voronoi diagram inside each region of the hierarchical diagram corresponding to the superior level. In [5] we formally present the hierarchical Voronoi diagram and describe an incremental algorithm for its construction.

488

Conf. on Image Proc., Comp. Vision, and P. R. | IPCV'07 |

The generators need to be structured hierarchically, previously organized so they potentially lead to the progressive improvement of the mosaic, in order to guarantee a correct description of the most important features in the image.

2.2.2

Post-subdivision Voronoi mosaic

Now the Voronoi mosaic will be constructed with the aim of approximating a given subdivision or tessellation of the image. This tessellation is obtained by segmenting the image in convex regions of homogeneous color. Then, we try to interpret this structure of edges and vertices as the graph of a Voronoi Diagram. In the development of this strategy we can identify three important steps: Segmentation of the image, Subdivision in convex regions and Search for the generators. Segmentation of the image An image segmentation process is carried out, following [7], which decomposes the image in significant units that are in fact visual regions grouped in terms of color similarity. As a result, pixels are labeled with a value indicating their ownership to a certain region, and a symbolic representation of the existent topological relationships among the different regions is also given. Regions are guaranteed to be polygonal. Subdivision in convex regions

Fig 2. Hierarchical Voronoi diagram for four set of sites. When building the hierarchical Voronoi diagram those sites which are located on an edge or outside any region of the diagram corresponding to the level immediately above will be overlooked. But the great advantage resides in that we can also decide whether or not to take into account the generators belonging to a clipped region, taking the following approach: a region should be divided if, when considering it as the union of its subregions, the measure of the difference between the original image and the mosaic considerably diminishes; this means that we can avoid placing many sites in regions of homogeneous colors of the image, that is to say, those areas formed by pixels of the same color or very similar colors, for which it suffices to choose only one site. Somewhat, the heterogeneous regions will be subdivided, concurring to their continuous approximation through multiple Voronoi regions. The purpose is to go refining with each new collection of sites the description of those image areas with finer detail, but it clearly requires a continuous computation effort, caused by sub-diagram generation, as well as evaluation of the degree of likeness between the mosaic and the reference image, even though when these operations are carried out regionally.

Once we have concluded the identification and extraction of significant regions, a process of depuration and transformation of undesirable areas is executed (for example, areas with holes). This process outputs a decomposition of the image in convex regions, described by means of a planar graph, and represented by a well-known data structure: the Doubly Connected Edge List (DCEL). For further details consult [2]. Search of the generators If the decomposition or initial tesselation happens to be a Voronoi diagram, we are in presence of the so called Inverse Voronoi Problem (IVP) that consists of finding the location of the sites. However, this is not always the case, which leads to the formulation of the Generalized Inverse Voronoi Problem (GIVP), that consists of looking for a set of points S, such that the Voronoi diagram associated to it contains all the vertices and edges of the initial subdivision (and possibly additional vertices and edges). Notice that the number of sites per cell is no longer limited to one, but a cell Ci of the initial tesselation will be the union of one or several Voronoi cells in the diagram associated to S, that is:

C i = V ( pi1 ) U V ( pi 2 ) U ... U V ( pik ) . A solution for GIVP always exists. An important factor in our applications is the size of S: the smaller it is, the smaller will be the number of cells in the Voronoi diagram associated to S.

Conf. on Image Proc., Comp. Vision, and P. R. | IPCV'07 |

We have designed and implemented an algorithm to solve the GIVP; this algorithm generates in the worst case a number of sites that is linear in the number of edges of the initial tessellation G = (V, E), provided that the smallest angle is fixed. A detailed discussion is offered in [1], where correctness and completeness of the algorithm is proved, and some experimental results of its performance are given. With this approach we can guarantee that, when constructing the Voronoi mosaic, many of the significant elements of the reference image will be well represented.

489

(13n+6G+11)/1024 KB, where n represents the quantity of definition levels to be represented, and G the total number of generators. Decoding: Decoding amounts to recovering the points stored in the .VOR file and building the associated Voronoi mosaic, i.e. to generate either the Voronoi diagram incrementally, or the hierarchical Voronoi diagram, and to properly color their regions. Post-processing:

2.2.3

The compression technique .VOR

Now, the main idea is to use the Voronoi mosaic as a lossy compressed representation of a reference image in bitmap format. Fig. 2 describes the encoding and decoding processes of the image:

Apply a mask to soften contours and reduce possible abrupt color changes near the edges of the Voronoi diagram.

3 Original Image

Preprocessing

Encoded

Compress ed File

Compress ed File

Decoded

Postprocessing

Decoded Image

Results and discussion

3.1

Image compression using the Voronoi diagram

Fig 3. Diagram of the compression process. Pre-processing: Depending on the chosen approach for the construction of the Voronoi mosaic: 1. Carry out the operations of localization of significant elements in the reference image (border detection, segmentation in uniform-color regions). 2. Find an appropriate location of the sites, and store for each site its position and color of the associated pixel. Remark 1: Strategies 2.1.2 and 2.2.1 demand the active generation of the Voronoi diagram and the hierarchical Voronoi diagram respectively.

Remark 2: The approximation error and/or compression ratio can be specified a priori, either automatically or manually. If so, it is necessary to estimate a priori the quantity of sites that are required to describe the original image with the desired accuracy.

Encoding: We have devised a file data structure (the .VOR format), based on the Voronoi mosaic technique, which is described in [2]. The disk space occupied by a VOR file is

Fig.4. Construction of the Voronoi mosaic by levels. The figures in this section show the different strategies at work. A difficulty observed in experiments is that the Ecolor function is not reliable for measuring the similarity between images. We can easily find a pair (image, mosaic) for which the difference measured with E-color is very low, and yet, the visual quality of the Voronoi image does not

490

Conf. on Image Proc., Comp. Vision, and P. R. | IPCV'07 |

correspond to it, or on the contrary, the mosaic is “good” and the E-color value is large.

TABLE I COMPARATIVE REVIEW TO IMAGES FROM FIGURE 8

3.2

Progressive Visualization

The mosaics of Image 9 were constructed with the Voronoi technique based on the arrangement of sites in priority levels, the four first images correspond to the four different levels, finally the bitmap image is completely revealed.

Fig.5. Construction of the Voronoi mosaic with site readjustment. (a) Initial distribution of sites; (b) Voronoi image associated to (a); (c) movement of the sites; (d) Voronoi image associated to (c). The image compression tests were carried out with three images (see Fig. 8 and Table I), achieving very good compression ratios, superior to those achieved by other compression methods. The visual quality of the image is acceptable, but not yet comparable, for example, with the one provided by the JPEG method; however.

Fig.7. Comparison between Voronoi mosaics with different resolution. Fig.6. Construction of the hierarchical Voronoi mosaic.

Conf. on Image Proc., Comp. Vision, and P. R. | IPCV'07 |

491

4

Fig.8. Images compressed in .VOR format (left: bmp image; right: vor image).

Fig 9. Progressive visualization.

References

[1] G. Aloupis, H. Pérez-Rosés, G. Pineda-Villavicencio y P. Taslakian. “Fitting Voronoi Diagrams to Planar Tesselations”, unpublished manuscript. [2] D. Calero-Reyes, R Toledano-Gómez. “Algorithms for segmenting images in regions of homogeneous color, and construction of a Voronoi tesselation for image compression ”. Term paper (in Spanish). University of Oriente, Santiago de Cuba, 2005. [3] C. Cruz-Reyes. “Voronoi Diagrams in 2D. Some Applications”. Term paper (in Spanish). University of Oriente, Santiago de Cuba, 2003. [4] Y. Dobayashi, T. Haga, H. Johan, T. Nishita (2002). "A Method for Creating Mosaic Images Using Voronoi Diagrams". In I. Navazo y Ph. Slusallek (eds.): Proceedings of the EUROGRAPHICS 2002. [5] A.Martínez-Arias “Incremental Construction of Voronoi Diagrams. Possible Applications”. Term paper (in Spanish). University of Oriente, Santiago de Cuba, 2004. [6] J. Martínez-Mojicar “The Inverse Voronoi Problem and its Applications”. Term paper (in Spanish). University of Oriente, Santiago de Cuba, 2004. [7] Y. Sánchez Pérez “Segmenting Images in Regions of Homogeneous Color ”. Term paper (in Spanish). University of Oriente, Santiago de Cuba, 2005. [8] K. Sugihara and M. Iri. “Construction of the Voronoi Diagram for ‘One Million’ Generators in Single– Precision Arithmetic”. Proceedings of the IEEE. pp. 1471 – 1484. Sept. 1992.