Scalable Visibility Color Map Construction in Spatial Databases
Abstract
Recent advances in 3D modeling provide us with real 3D datasets to answer queries, such as “What is the best position for a new billboard?” and “Which hotel room has the best view?” in the presence of obstacles. These applications require measuring and differentiating the visibility of an object (target) from different viewpoints in a dataspace, e.g., a billboard may be seen from two viewpoints but is readable only from the viewpoint closer to the target. In this paper, we formulate the above problem of quantifying the visibility of (from) a target object from (of) the surrounding area with a visibility color map (VCM). A VCM is essentially defined as a surface color map of the space, where each viewpoint of the space is assigned a color value that denotes the visibility measure of the target from that viewpoint. Measuring the visibility of a target even from a single viewpoint is an expensive operation, as we need to consider factors such as distance, angle, and obstacles between the viewpoint and the target. Hence, a straightforward approach to construct the VCM that requires visibility computation for every viewpoint of the surrounding space of the target, is prohibitively expensive in terms of both I/Os and computation, especially for a real dataset comprising of thousands of obstacles. We propose an efficient approach to compute the VCM based on a key property of the human vision that eliminates the necessity of computing the visibility for a large number of viewpoints of the space. To further reduce the computational overhead, we propose two approximations; namely, minimum bounding rectangle and tangential approaches with guaranteed error bounds. Our extensive experiments demonstrate the effectiveness and efficiency of our solutions to construct the VCM for real 2D and 3D datasets.
I Introduction
Recent advances in largescale 3D modeling have enabled capturing urban environments into 3D models. These 3D models give photorealistic resembling of urban objects such as buildings, trees, terrains etc. and are widely used by popular 3D mapping services, e.g., Google Maps, Google Earth, and Bing Maps. The increasing availability of these realistic 3D datasets provides us an opportunity to answer many reallife queries involving visibility in the presence of 3D obstacles. For example, a tourist may check the visibility of a new year firework event from different locations in the surrounding areas so that he can pick a good spot to enjoy it; an apartment buyer may want to check visibility of nearby seabeach and mountains from various available apartments; and an advertising company may wish to determine visibility of their existing billboards from surrounding areas and find a suitable location for a new billboard accordingly.
In this paper, we investigate efficient techniques to answer the underlying query required by the above applications: computing visibility of an object (e.g., firework event, billboard) from the surrounding continuous space, or that of the surrounding space from a source viewpoint. Our target applications treat visibility as a continuous notion—e.g., a billboard may be more visible from one location than another, depending on factors such as distance, viewing angle, and obstacles between the viewpoint and the target. We therefore use a visibility function that provides realvalued visibility measures of various points in the (discretized) 3D space, where the visibility measure of a point denotes its visibility from the viewpoint or to the target object. Thus, the answer to our target query is essentially the visibility measures for every point in the 3D space. The result can be graphically represented as a heat map, by assigning colors to various points according to their visibility measures. We call this a visibility color map (VCM) of the space for a given target or for a given viewpoint.
Recent works have shown how database techniques can enable efficiently answering various types of visibility queries in the presence of obstacles. Various nearest neighbor (NN) queries consider visibility of objects [1, 2, 3]; for example, the visible nearest neighbor query [1] finds the nearest neighbors that are visible from the source. However, these works, like various other computer graphics works [4, 5, 6, 7, 8, 9], treat visibility as a binary notion: a point is either visible or not from another point. In contrast, in our target applications, visibility is a continuous notion. Recently, Masud et al. proposed techniques for computing continuous visibility measure of a target object from a particular point in 3D space (e.g., computing visibility of a billboard from a given location) [10]. On the contrary, our target applications require visibility calculation from or of a continuous space where there is no specific viewpoint.
One straightforward way to generate a VCM is to descretize the 3D space and to use the techniques in [10] to compute visibility measure for each discrete point in the space. However, this can be prohibitively expensive. For example, discretizing the surrounding space into 1000 points in each dimension would give a total of points in the 3D space; and computing visibility measure for each point by using techniques in [10] would take 128 days! The huge cost comes from two sources: (i) computing the visibility measure based on the distance and angle from all viewpoints, which is computationally expensive and (ii) accessing a large set of obstacles from the database, which is I/O expensive.
We address the above challenges with a threestep solution that uses several novel optimizations to reduce computational and I/O overhead. First, we partition the dataspace into a set of equivisible cells, i.e., all points inside a cell have equal visibility of the target object in terms of visual appearance. We exploit the key observation that when a lens (e.g., a human eye) sees an object without any obstacles, it cannot differentiate between its visual appearances from a spatially close set of points within an angular resolution (or spatial resolution) of arcminutes ( degrees) [11]. Thus, we can safely prune the visibility computation for a large number of viewpoints within the angular or spatial resolution without affecting viewer’s perception. This optimization significantly reduces the computation cost, as we can compute only one visibility measure for each cell.
In the next step, we consider the effect of obstacles. We compute visible regions, the regions in the space from where the target object is completely visible in the presence of obstacles. In the final step, we assign visibility measures to these regions from the corresponding cells by spatial joins. Both steps are I/O and computation intensive. For example, they both require retrieving a large number of cells and obstacles from the spatial database. To reduce I/O costs, we employ various indexing techniques to incrementally retrieve a small number of obstacles and cells near the target object. These steps also require performing many computationally expensive operations such as polygon intersections of irregularshaped regions and cells. To reduce such costs, we represent regions with regular shaped polygons in a quadtree. We also propose two approximations that further reduce the cost while providing guaranteed small error bounds.
We have evaluated the performance of our solution with real 3D maps of two big cities. We compare our solution with a baseline approach that divides the space into a regular shape grid of 500 cells in each dimension and computes visibility from each grid cell. The baseline approach results into more than 30% error while requiring about 800 times more computation time and six orders of magnitude more I/O than our solution. Hence, in the baseline approach, dividing the space into more cells for more accuracy is not feasible for practical applications. On the other hand, our approach provides efficient and effective solution.
In summary, we make the following contributions:

We formulate the problem of efficiently constructing a visibility color map (VCM) in the presence of obstacles in 2D and 3D spaces.

We propose an efficient solution to construct a VCM. The solution uses various novel optimizations to significantly reduce the computational and I/O overhead compared to a baseline solution.

We propose two approximations with guaranteed error bounds and reduced computation to construct the VCM.

We conduct extensive experiments in two real datasets to show the effectiveness and efficiency of our approaches.
Ii Problem Formulation and Preliminaries
Iia Problem Formulation
The construction of a visibility color map (VCM) can be seen from two perspectives: targetcentric VCM and viewercentric VCM. The construction of a targetcentric VCM involves determining how much a given target is visible from every point^{1}^{1}1We have used point and viewpoint interchangeably. of the space. On the other hand, a viewercentric VCM involves determining how much visible each point in the surrounding space is from a given viewer’s location.
In both cases, we need to compute visibility and produce a color map of the space where each point of the space is assigned a color value that corresponds to the visibility measure of that point.
Definition II.1
Visibility Color Map (VCM)
Given a dimensional dataspace and a set of obstacles, the VCM is a color map , where for each point , there exists a color . The color corresponds to the visibility of a given target object from x in case of targetcentric VCM and the visibility of x from a given viewer’s location in case of viewercentric VCM. Here, is normalized between and .
Without loss of generality, we limit our discussion to the construction of targetcentric VCM in the subsequent sections. However, our solution is also applicable to the viewercentric VCM construction, as explained in Section IVB.
The core of computing a VCM is computing visibility of the target from various points in the space. The most common measure of visibility (or, the perceived size) of an object is the visual angle [12], which is the angle imposed by the viewed object on a lens. The visual angle mainly depends on the characteristics of the viewing lens as well as the distance, angle, and obstacles between the viewer and the target [13].
IiB Factors Affecting Visibility
IiB1 Relative Position of the Lens and the Target
The perceived visibility of a target object mainly depends on the relative position the viewing lens and the target. For a specific target, the visibility varies with the change of distance and angle between the lens and the target.
Distance: If the distance between a target and a lens increases, the perceived size of becomes smaller. This is because the visual angle imposed by an object decreases with the increase of the distance between that object and the viewer. As shown in Fig. 1, is a target object of length and the position of a lens is . When the midpoint of is at an orthogonal distance from , the visual angle is calculated using the following formula [14],
(1) 
Angle: The perceived size of a target depends on the angle between the lens and [15]. If an object is viewed from an oblique angle, the perceived size of that object becomes smaller than the original size. For the equidistant positions of the lens from , the visual angle varies for different values of . Let be a line of length . A line connecting a point and the midpoint of , creates an angle with . If , the perceived size of from a nominal distance is same as the original length, . Otherwise, according to the concept of oblique projection [15], the perceived length of from is
(2) 
Thus, if we consider the effects of both distance and angle between the target and the lens, the visual angle can be expressed as . In Fig. 1, the visibility of the target of length is the visual angle imposed at the lens . As in this case , so the visual angle is . If , then is .
Besides the relative position of the lens, the visibility of a target is also affected by the presence of obstacles.
IiB2 Obstacles
To show the effect of obstacles on the visibility, we first define the term point to point visibility.
Definition II.2
Point to point visibility. Given two points and a set of obstacles in a space, and are visible to each other if and only if the straight line connecting them, , does not cut through any obstacle, i.e., .
Based on the definition of point to point visibility, we formally define the obstructed region as:
Definition II.3
Obstructed region. Given a set of obstacles, a bounded region , and a target , the obstructed region is the set of points where for each point , (i) is in and (ii) is not point to point visible to all points of .
The obstructed region contains viewpoints from where the target object is not completely visible. Thus, we only need to measure the visibility for the viewpoints residing outside the obstructed region that form the visible region, and assign colors to these viewpoints of the visible region according to the defined visibility measure (i.e., visual angle).
Iii Constructing a VCM
To construct a VCM for a given target , we need to determine the visibility of from all discrete points in the surrounding space in the presence of a set of obstacles. We represent visibility of each point with a color , which is proportional to the visibility of from x. We use the terms visibility measure and color interchangeably.
One naïve approach to compute a VCM is to compute visibility of from every single viewpoint . Depending on how finely we discretize the space , there can be a large number of points, making the process prohibitively expensive. The high overhead of this naïve approach comes due to the expensive visibility computation from a large number of points and expensive I/O operations to retrieve a large collection of obstacles from a spatial database.
To address these problems, we propose an efficient solution to construct a VCM. The key insights of our solution come from the following two observations. First, human eye cannot visually differentiate a target from viewpoints in close proximity of each other, which eliminates the necessity of computing visibility for all viewpoints in the surrounding space. Second, in most cases, only a small subset of obstacles affect visibility of the target, and thus retrieval of all obstacles is redundant. Such redundancy can be avoided by using various indexing techniques.
In the rest of the section, we describe how we exploit these observations and propose an efficient approach to compute a VCM with reduced computational and I/O overhead. Our approach consists of three steps:

First, we partition the space into several equivisible cells in the absence of obstacles exploiting the limitations of human vision. This enables us to compute one single visibility measure for each cell. This significantly reduces computational overhead in contrast to computing the color of each discrete viewpoint (Section IIIA).

Second, we compute the effect of obstacles and divide the surrounding space into a set of visible regions such that the target is completely visible from a viewpoint if and only if it is within a visible region. To reduce the I/O overhead, we index all obstacles and incrementally retrieve only the potential obstacles that can affect the visibility of the target (Section IIIB).

Finally, we join colors computed in the first step (that ignores obstacles) and visible regions computed in the second step to compute a VCM, i.e., colors of different parts of the space in the presence of obstacles. To reduce I/O overhead of retrieving results from the first two steps, we employ various indexes (Section IIIC).
For ease of explanation, we assume a 2D space and a target with the shape of line in the subsequent sections. However, our approach is applicable to any target shapes in 2D and 3D spaces. Table I lists the notations that we use.
Notation  Meaning 

The target object.  
A set of b obstacles =.  
The visual angle imposed in a lens by .  
The angular resolution of a lens.  
The angle between and the line connecting the lens and the midpoint of . 
Iiia Partitioning Space into Equivisible Cells
As mentioned before, the ability of a human eye (or a lens) to distinguish the variation of small details of a target of size is limited by its angular resolution . To exploit this observation, we partition the space into a set of equivisible cells {}. Each cell is constructed in a way so that the deviation in visibility of from the viewpoints inside a cell, measured as visual angle , is not visually perceivable. Hence for any two points , visibility from and is perceived as same if,
(3) 
Note that visibility is a symmetric measure: visibility of a target at location from a viewer (i.e., the lens) at location is the same as that of a target at from location . Thus, visibility of a target from the surrounding space is the same as visibility of the space from ’s location. Therefore, in computing visibility of from the space, we consider the viewer at the target’s location and compute visibility of the space from that location.
Since the value of visual angle depends on the distance and angle between the lens and the target, the partitioning is done in two steps: distance based partition and angle based partition.
IiiA1 Distance Based Partition
As the perceived size of varies with the change of distance between and the viewer’s location, our aim is to find a set of distances, , where for each pair of points between and , , the variation of the perceived visibility from and is less than or equal to the angular resolution . Note that, since visibility varies as deviates from (as explained in Section IIB1), we set as the default value for the distance based partitioning.
Partitioning starts from the near point distance , as a lens cannot focus on any object that is nearer than [16]. Initially, the visual angle from the distance is calculated using Equation 1. Then, starting from , the value of the visual angle is decreased by the amount of at each step and the corresponding is calculated. When the imposed visual angle from a distance is less than , the distance based partitioning process terminates as for any point farther than (i.e., ), the perceived visibility is indistinguishable to the viewing lens. So, we have a set of distances where every range is a distance based partition. Fig. 2 shows the distance based partitions for a target , where is the near point distance and the distance based partitions are , , and so on.
At this stage, we assign a single color for every distance based partition . However, every point in a distance based partition does not perceive the same visibility of the target, e.g., two viewpoints at a same distance partition may have different perceived visibility due to different viewing angles. Thus, in the next section we incorporate the effect of viewing angle and partition the space into equivisible cells.
IiiA2 Angle Based Partition
For each distance based partition , , we get numbers of angle based partitions , , where the value of is different for each distance based partition. The visibility of every point of a partition is considered as the same. We call such a partition an equivisible cell (or, just cell in short).
As the change in perceived length due to change in is symmetric with respect to both the parallel and normal axes of the object plane, we compute the angle based partitions only for the first quadrant. The partitions in other quadrants are then obtained by reflecting the partitions of the first quadrant. The procedure of angle based partitioning is as follows:
(i) For each distance based partition , the angle based partitioning starts by initializing , , and , where the size of is . The visual angle is calculated for using Equation 1 where . Here is the average value of distances and , i.e., .
(ii) At each step of the angle based partitioning for , the perceived size is calculated for visual angle and distance using Equation 1, where , e.g., , for . The angle , for which is perceived, is computed using Equation 2, e.g., , for . The visual angle is obtained for the change in by the amount of , so is updated as . Thus we get an angle based partition for at each step.
(iii) When the perceived visual angle , the angle based partitioning process for a distance based partition terminates.
The above process is repeated for each distance based partition and finally we get the set of cells where , . Fig. 2 shows the anglebased partitions for three distancebased partitions , , and for a target object .
After both partitioning steps are done, we compute visibility (i.e., color) of each cell. Since all viewpoints within a cell have the same visibility, we assign the color of the entire cell as the visibility of the center of the cell to the target .
Note that we have not considered the effects of obstacles yet. A caveat of this is that in the presence of obstacles, the target may not be visible from an entire cell or parts of a cell even if the cell is assigned a good visibility value. We address this next by considering the effect of obstacles.
IiiB Computing the Effects of Obstacles
Given a target object and a set of obstacles, we would like to determine the set of visible regions surrounding such that is completely visible from a viewpoint if and only if is inside a visible region.
A naïve approach to determine the effects of obstacles is to retrieve all obstacles of and calculate the corresponding changes in the visibility. But this approach is prohibitively costly in terms of both I/O and computation, especially in the presence of a large number of obstacles. Moreover, considering all obstacles in the database is wasteful as only a relatively small number of obstacles around affect visibility. To efficiently retrieve this small number of obstacles around , we index all obstacles in an R*tree [17], a variation of Rtree [18]. An R*tree consists of a hierarchy of Minimum Bounding Rectangles (MBRs), where each MBR corresponds to a tree node and bounds all the MBRs in its subtree. Data objects (obstacles, in our case) are stored in leaf nodes.
A recent work [10] has developed a technique to determine the obstacles that affect the visibility of the target from a specific viewpoint. On the contrary, we need to compute the visible region of the whole space instead of a specific viewpoint with respect to a target. Thus, we cannot adopt the computation of the visible region from [10]. Our approach to compute the visible region in the presence of large number of obstacles is as follows.
Initially the set of visible regions contains the region of that is covered only by the field of view (FOV) with respect to the target . As shown in Fig. (a)a, is the region bounded by the points , , , and where and are the corner points of . Here, FOV=, the usual FOV of the human eye [19]. Initially, the set of obstructed regions is the region of that is outside the FOV. As cannot be viewed from the region outside the FOV, the obstacles residing in this region is discarded from consideration.
Next, we refine the set and the set by considering one obstacle at a time. The obstacle retrieval starts from the root node of the R*tree. Only the nodes that intersect with a region in are incrementally retrieved from the R*tree according to their nondecreasing distances from . If the retrieved node is an MBR, its elements are further discovered. For example, in Fig. (a)a, when the MBR is accessed, its elements , and are further discovered. If the retrieved node is an obstacle , the regions in and are updated according to the effect of . We term the effect of a single obstacle on visibility as the shadow of , .
Definition III.1
Shadow of an obstacle , . is the region formed by the set of points , where for any point of , there is at least a point on such that the line segment joining and either intersects or touches .
From each point of the , is either completely or partially obstructed. The boundary of a shadow contains exactly two straight lines, which are tangents between the obstacle and the target. If these lines are rays, not the line segments that meet each other, then the region is unbounded. If is unbounded, we consider only the portion that is bounded by the given region . In Fig. (a)a, The shadow of is (shown with black shade), the region bounded by and the points and .
While updating the and for the shadow of a retrieved obstacle, there are three cases to be considered:
(i) If the obstacle or its shadow does not overlap with any obstructed region of , we exclude from and include it in . In Fig. (a)a, obstacle is the first obstacle retrieved according to its nondecreasing distance from . As there is no other obstructed region to be overlapped with or its shadow (shown as the black region), is now excluded from and included in .
(ii) If or overlaps with one or more obstructed regions of , we combine these regions and into a single obstructed region and discard this region from . Let be the set of and the obstructed regions that overlap with . To combine the regions in , we determine the leftmost tangent line and the rightmost tangent line of all the shadows of such that the region bounded by , and the union of the shadows of enclose all the obstructed regions of . This shadow resembles the combined effect of the obstacles that are included in . We replace the regions of from with this combined region and discard it from . As an example, in Fig. (a)a, the shadow (shown with dotted lines) of the next retrieved obstacle overlaps with the existing obstructed region (shown with black shade). Here, the leftmost tangent line and the rightmost tangent line of these obstructed regions are the line connecting , and the line connecting , , respectively. The region enclosed by these two lines and the union of the shadows is discarded from . Similarly, the next retrieved obstacle overlaps with . The shadows combined for obstacle , , and is shown in black shade in Fig. (b)b, where the shadow of is shown with dotted lines.
(iii) If is entirely inside any obstructed region, it will not contribute to the visibility. So we discard from consideration. In Fig. (b)b, the effect of obstacle is not calculated as it is entirely inside the current obstructed region.
Note that, the visible region includes viewpoints from where the target is entirely visible. This approach is suitable for applications like placement of billboards, where partial visibility of the target from a viewpoint does not make sense. There can be some applications that require finding the viewpoints from where a target is partially visible. We leave computing the partial visible viewpoints as the scope of the future study.
IiiC Merging Cells with Visible Regions
In the final step of producing a VCM, we combine colors computed in the first step (that ignores obstacles) and visible regions computed in the second step to compute color of each cell in the presence of obstacles. Intuitively, all obstructed regions are assigned color zero (representing zero visibility), while all visible regions are assigned colors from their corresponding cells. This requires taking intersection (spatial join) of all cells and visible regions.
The above process can be expensive for two reasons. First, visible regions are usually irregular polygons and intersecting them with cells incurs high computational overhead due to the complex shapes of the polygons. We address this by storing each polygon as a set of regular shapes (rectangles) with a quadtree [20]. Second, the number of cells can be quite large and intersecting visible regions with all cells can be expensive. We address this by indexing the cells in an R*tree and intersecting each visible region only with its overlapping cells. We describe these optimizations below.
IiiC1 Indexing Visible Regions
We index visible (and obstructed) regions in a 2D (3D) space with a quadtree (octree). Quadtrees (Octrees) partition a 2D (3D) space by recursively subdividing it into four quadrants (eight octants) or blocks. Initially the whole space is represented with a single quadtree block. In the visible region computation phase, when a region is obstructed due to a retrieved obstacle, a quadtree block is partitioned into four equal blocks if it intersects with the obstructed region. The partitioning continues until (i) a quadtree block is completely visible, or (ii) completely obstructed, or (iii) the size of a block is below a threshold value . The threshold size is determined from the partitioning phase. If the set of the boundary points of an equivalence cell is , the minimum distance between any two opposite boundaries over all cells is specified as , i.e.,
where, points are points of opposite boundaries.
As is the minimum size of a cell obtained in the partitioning phase and the deviation in the perceived visibility for a blocksize less than is not distinguishable due to angular resolution of a lens, dividing a quadtree block into size smaller than for more accuracy is redundant.
Fig. (a)a shows the quadtree of the obstructed region (black blocks) and visible region (white blocks inside FOV). After the quadtree is constructed, we start assigning color to each of its blocks. We get the VCM after all the blocks are assigned colors. The blocks that fall in the obstructed region are assigned zero visibility. The remaining blocks (i.e., visible region) are assigned colors based on the colors of their corresponding cells, as described next.
IiiC2 Indexing Cells and Constructing VCM
For each quadtree block with unassigned color, we need to find all overlapping cells in order to find its color. To expedite this process, we index cells with an R*tree that we call the colortree. Leaf nodes in the colortree represent cells and nonleaf nodes represent MBRs containing the shapes of their children nodes. Then, for each quadtree block, we run a range query on the colortree. The color for an unassigned quadtree block is obtained by calculating the intersection of the spatial region of that block and the cells from the colortree. If the quadtree block intersects with a single cell of the color partition, the block is assigned the color of that cell. If a quadtree block intersects with multiple cells, in a 2D (3D) space we further divide that block into four (eight) equal blocks. The division is continued until either a block intersects with a single cell or the size of a block is below the threshold value (Section IIIC1). The process terminates when all quadtree blocks of the visible region are colored according to the visibility measure. Fig. (b)b shows the resulting VCM constructed by combining the color partitions of Fig. 2 and the quadtree of Fig. (a)a.
The steps of constructing a VCM are shown in Algorithm 1. Lines 1.61.9 shows accessing the colortree nodes. If an accessed node is an MBR, its elements are further discovered from the colortree (Lines 1.211.22). If the accessed node is a leaf node, the quadtree nodes that are not colored yet and intersects with this node are either colored or partitioned further (Lines 1.151.20). Finally, the colored quadtree is returned as the complete VCM.
Since the color partition results in complex shaped cells (e.g., curves), it is computationally expensive to combine these shapes with the quadtree blocks of visible region. Thus, we propose two approaches to approximate color partition cells.
Iv Extensions
In this section, we discuss a few extensions to our basic algorithm described in the previous section.
Iva Approximation of Partitions
The algorithm in the previous section partitions the space according to the relative distance and angle between the lens and the target. Based on these parameters, the cells are bounded by arcs and straight lines. To construct the VCM, we need to compute the intersection of these cells with the quadtree blocks. The process is computationally expensive due to the complex shape of the cells and the target.
To address this, we introduce two approximations that reduce the computational overhead at the cost of small bounded errors: (i) minimum bounding rectangle (MBR) of a cell and (ii) tangents of the arcs of a cell. For the ease of explanation we analyze errors for targets with regular shapes, e.g., lines without loss of generality. For such targets, the complex shaped partitions are bounded by two arcs and two straight lines. Here we discuss the approximations of color partitions and the maximum error resulting from these approximations.
MBR Approximation
An approach to approximate the curves of a cell is to enclose the cell using its MBR where the area covered by the cell is approximated by the area covered by the enclosing MBR. This is illustrated in Fig. (a)a, where a cell consists of two concentric arcs and (centered at a corner of the target) of radius and , respectively. is the MBR of this cell. Let and create and angles (in degrees) at the center respectively. We denote the area of the MBR as . So the area bounded by the cell, is . Hence the area that gets wrong color due to this MBR approximation is (shaded region in Fig. (a)a).
Error Bound Analysis. For targets with regular shapes such as lines (Fig. 2), the largest cell that can yield the maximum possible error consists of two half circles centered at a corner point of the target. Hence we formulate the maximum error bound by referring to Fig. (b)b. Here, we want to approximate the area of a cell bounded by two half circles and centered at , a corner point of target of length . Here, and belong to distance based partition and , respectively. We approximate by taking its MBR, . So, the darkly shaded region is wrongly colored for MBR approximation. The lightly shaded region is wrongly colored too, but it is considered for distance based partition i.e., for cell . As the total error is calculated incrementally for each cell, so the error for this lightly shaded region is calculated only once for the cell . Let, and be the radii of and , respectively. Hence, the width of cell is . The farthest distance from to any point of the MBR is . So the points of the MBR that fall within the distance and from point , get wrongly colored with the ’s color. From Equation 1 we get that the width of the distance based partitions increase with the increase of the distance between the target and the partition. So the maximum number of distance based partitions in that can be wrongly colored is .
For each distance based partition, corresponding angle based partitions are calculated by taking the angle from the midpoint of the target. So only the angle based partitions that fall within the range (, ) can lie in the darkly shaded region. Let there are such angle based partitions in total. As the difference in visual angle in consecutive partitions is , the maximum variation in color for a cell is, . So when the total number of partitions is and the area of th cell is , the total error in coloring is:
(4) 
Tangential Approximation
We obtain another approximation approach by taking tangents in the midpoints of the two arcs that encloses a cell. Here the area enclosed by two arcs is approximated by the area enclosed by the tangents at their midpoints. In Fig. (c)c the cell is bounded by arcs and centered at a corner of the target . We take two tangents and of and at their midpoints and , respectively. So we want to approximate the area bounded by these two arcs with the trapezoid . Let, the angles created at by and are and (in degrees). If we color the trapezoid instead of the cell, the region that gets wrong color is the shaded region of Fig. (c)c. Let the area of the trapezoid be , the radius of is , the midpoint of is , and the length of is . Then the length of is . The area of the segment bounded by and , is . If the area of the trapezoid is , then the area of the shaded region is . According to this tangential approximation the region that is wrongly colored due to cell is this shaded region with area .
Error Bound Analysis. In case of MBR approximation the cell bounded by two half circles is approximated by an enclosing MBR, while for tangential approximation that cell is approximated by a rectangle bounded by the tangents of those two half circles. Referring to Fig. (b)b, the cell bounded by arcs and is approximated by rectangle and rectangle for MBR and tangential approaches, respectively. In this figure, is the midpoint of and the farthest distance from to any point inside the approximated cell is . So the points inside the darkly shaded region are wrongly colored. As the width of the distance based partitions relates inversely to the distance between the target and the partition (Equation 1), the maximum number of distance based partitions in that can be wrongly colored is . In case of angle based partitioning, only the angle based partitions that fall within the range (, ) can lie in the darkly shaded region inside the rectangle . Let there are such angle based partitions in total. As the difference in visual angle in consecutive partitions is , the maximum variation in color for a cell is, . So when the total number of partitions is and the area of th cell is , the total error is:
(5) 
In the above sections, we discussed our approach to construct targetcentric visibility color map. The approach is same for the viewercentric visibility color map with an additional initialization step. The details of viewercentric VCM is discussed below.
IvB Viewercentric VCM
A viewercentric VCM is constructed by calculating the visibility of the surrounding space for a given viewpoint and a set of obstacles. Unlike the targetcentric VCM where a particular target is specified, in case of the viewercentric VCM, a particular viewer position is specified. To measure the visibility using Equation 1 and Equation 2 in case of the viewercentric VCM, first we need an initial value of the size of a target from the given information.
The visibility of any point farther than a distance is not visually distinguishable if the perceived visual angle of that point is less than the angular resolution from (Section IIIA1). Based on this fact, we assume a circular region of radius centered at to construct the VCM of only, as the visibility of the points outside are not distinguishable by a viewer at . Using Equation 1, we calculate the size of a target for which visual angle is perceived at distance . After taking as the size of the target, the steps of our approach discussed for the targetcentric VCM is applied in the same manner to construct the viewercentric VCM.
IvC Incremental Processing
During the computation of the VCM, we have assumed that the field of view (FOV), i.e., the orientation of the viewpoint or the target is fixed. At a particular orientation or gaze direction, only the extents of the space that is inside the FOV, is visible. With the change in viewing direction, some areas that were previously outside the FOV become visible. In this case, we do not need to compute the full VCM each time, rather we can incrementally construct the VCM by computing for the newly visible parts only.
In the incremental process, the only information that varies is the gaze direction. So, as a preprocessing step we can construct the colortree and the visible region quadtree in the above discussed method by considering the FOV as . A VCM is then constructed by combining the colortree and the quadtree for a particular gaze direction. When the gaze direction changes, only the uncolored quadtree blocks that are now included in the visibility region are assigned colors. Hence the colortree and the quadtree are constructed only once. This reduces the computational complexity to a great extent by avoiding same calculations repetitively. From our conducted experiments we also observe that the processing time required to combine the colortree and the quadtree is much smaller than the processing time required to construct the visibility region quadtree for a dataset of densely distributed large number of obstacles (Section VC1 and VD1). So for such cases we can significantly improve the performance of our proposed solution by adopting the preprocessing strategy.
V Experimental Evaluation
We evaluate the performance of our proposed algorithm for constructing the visibility color map (VCM) with two real datasets. Specifically, at first we compare our approach with a baseline approach that approximates the total space into a regular grid and compute visibility from the midpoint of each grid cell, and then we compare our two approximation algorithms, i.e., MBR approximation () and tangential approximation () with the exact method (). The algorithms are implemented in C++ and the experiments are conducted on a core i5 2.40 GHz PC with 3GB RAM, running Microsoft Windows 7.
Va Experimental Setup
Our experiments are based on two real datasets: (1) British^{2}^{2}2http://www.citygml.org/index.php?id=1539 representing 5985 data objects obtained from British ordnance survey^{3}^{3}3http://www.ordnancesurvey.co.uk/oswebsite/indexA.html and (2) Boston^{4}^{4}4http://www.bostonredevelopmentauthority.org/BRA_3D_Models/3Ddownload.html representing 130,043 data objects in Boston downtown. In both datasets, objects are represented as 3D rectangles that are used as obstacles in our experiments. For both datasets, we normalize the dataspace into a span of square units. For 2D, the datasets are normalized by considering axis value as 0. All obstacles are indexed by an R*tree, with the disk page size fixed at 1KB.
Parameter  Range  Default 

Angular Resolution ()  1, 2, 4, 8, 16  4 
Minimum Block Size ()  1, 2, 4, 8, 16  1 
Query Space Area ()  0.05, 0.10, 0.15, 0.2, 0.25  0.15 
Field of View ()  60, 120, 180, 240, 300, 360  120 
Length of Target ()  0.05, 0.10, 0.15, 0.2, 0.25  0.15 
Dataset Size ()  5k, 10k, 15k, 20k, 25k 
The experiments investigate the performance of the proposed solutions by varying five parameters: (i) angular resolution () in arcminutes, (ii) the threshold of the quadtree block size () as the multiple of the calculated minimum size (as explained in Section IIIC1), (iii) the area of the space () as the percentage of the total area, (iv) field of view () in degrees, and (v) the length of the target () as the percentage of the length of total dataspace. We have also varied the dataset size using both Uniform and Zipf distribution of the obstacles. The range and default value of each parameter are listed in Table II. In concordance with human vision, the default values of and are set as arcminutes [11] and [19], respectively. The minimum threshold of quadtree block size as calculated in Section IIIC1 is used as the default value of . The default values of other parameters are set to their median values.
The performance metrics that are used in our experiments are: (i) the total processing time, (ii) the total I/O cost, and (iii) the error introduced by the two approximations: and . We calculate the approximation error as the deviation from the color map of , i.e.,
(6) 
Here is the color of th cell in , is the color of th cell in or , and is the area of the th cell.
For each experiment, we have evaluated our solution for the target at 100 random positions and reported their average performance. We have conducted extensive experiments using two datasets for both 2D and 3D spaces. Since, 2D dataspace is a subset of 3D dataspace and most of the real applications involve 3D scenario, we omit the detailed results of 2D due to the brevity of presentation.
VB Comparison with the Baseline
The performance improvement of our approach over the baseline approach is measured in terms of the total processing time required for computing the VCM. In the naïve approach, we need to compute visibility of the target from infinite number of points to construct the VCM as every point in the dataspace acts as a viewpoint. Even discretizing the surrounding space into 1000 points in each dimension would give a total of points in the 3D space. We observe that the time required for such computation using British and Boston datasets are approximately 74 days and 128 days, respectively. As such naïve approach is trivial, we can further improve it by dividing the dataspace into cubic cells in 3D and choose the visibility from the middle point of each cell to represent the visibility of that entire cell. In the rest of the paper we refer to this approach as the baseline approach to construct the VCM. The comparison between the baseline approach and our proposed solution is presented in Table III in terms of total processing time and introduced error. In this case the parameters are set to their default values (Table II). We observe that when compared to , for British dataset the baseline approach runs 818 times slower and introduces % error, while for Boston dataset the baseline approach runs 837 times slower and introduces % error.
Dataset  Baseline  

Total time  Error (%)  Total time  
British  58hrs  30.33%  253.07s 
Boston  61hrs  31.76%  245.26s 
VC Performance in 2D
In this section, we present experimental results for 2D datasets.
VC1 Effect of
Dataset  Method  Error (%)  

1  2  4  8  16  
British  2.0  1.64  4.25  4.42  5.38  
0.01  0.01  0.01  3.64  3.91 
In this experiment, we vary the value of as 1, 2, 4, 8, and 16 arcminutes and measure the total processing time and I/Os for British datasets (Fig. 8). We also present the errors resulted in the two approximations (Table IV).
For British dataset, on average and are 65% times and 17% times faster than , respectively. In general, with the increase in , the cell size increases and the number of total partition in the dataspace decreases. Moreover, larger yields fewer branching in the visibility region quadtree. So, with the increase in , total processing time and I/O cost decrease rapidly for both datasets. The total I/O cost is composed of (i) cost of partitioning the total dataspace to form the colortree, (ii) cost of retrieving obstacles to form visibility region quadtree, and (iii) cost of combining the colortree and quadtree to form the VCM. As these three costs hardly differ for all three approaches, they result into similar I/O cost. On the other hand, as with the increase in , the area of partition cells () gets larger, the estimated error increases for both and (Equation 6). The average errors introduced in and are 3.5% and 1.5%, respectively.
VC2 Effect of
Dataset  Method  Error (%)  

1  2  4  8  16  
British  0.01  2.74  9.29  12.59  12.83  
0.01  0.77  4.37  6.26  7.54 
In this experiment, we vary the quadtree block size () as 1, 2, 4, 8, and 16 times of the minimum threshold of a quadtree block. The results are presented in Fig. 9 and Table V.
For British dataset, is approximately 2.3 times faster than both and . As explained earlier, and yield I/O costs similar to . On average, and introduce 7.5% and 3.8% errors, respectively. These amounts of errors do not have noticeable impact on many practical applications. We observe from Equation 1 that the cells generated near the target are very small. Therefore the approximations of the cells close to the target are almost similar to the corresponding exact cells. The cell size increases with the increase of distance and a significant portion of errors is introduced for these distant cells. As the visibility of the target from distant cells is insignificant in most of the cases, the error in such cells is tolerable.
In general, with the increase in , the introduced errors in and increase as a larger quadblock size approximates the cells with lesser accuracy. But with the increase in , the total processing time and I/O cost reduce significantly. Hence for applications that can tolerate reduced accuracy, a large can result into better performance.
VD Performance in 3D
In this section, we present the experimental results for 3D British and Boston datasets by varying different parameters.
Dataset  Method  Error (%)  

1  2  4  8  16  
British  4.56  8.02  8.11  10.46  15.25  
4.1  7.63  7.76  8.89  13.89  
Boston  3.31  5.03  8.02  9.12  10.05  
3.12  4.70  7.62  8.57  9.79 
VD1 Effect of
In this experiment, we vary the value of as 1, 2, 4, 8, and 16 arcminutes and measure the total processing time and I/Os for British and Boston datasets (Fig. 10). We also present the errors resulted in the two approximation methods (Table VI).
For British dataset, on average and run only 5% and 3% faster than , respectively. The difference in I/O cost, i.e., the number of pages accessed is also negligible among the three methods. As discussed earlier in Section III the three methods differ only in the final phase, i.e., combining the outcome of previous two steps to produce the VCM. As we consider only full visibility of the target object from a partition cell, a huge number of cells in the dataspace fall into the obstructed region. So in the final phase the three solutions perform similarly as they have to combine the same colortree and visible region quadtree. The average errors introduced in and are 9% and 8%, respectively.
Although the results for both British and Boston datasets follow similar pattern, Boston dataset causes much smaller I/O and computational cost. Because, in case of the densely populated Boston dataset, most of the obstacles are pruned rapidly during the visible region quadtree formation. So there are lesser number of visibility computation and page access to construct VCM in Boston dataset. The processing time of is on average 8% faster than that of and . The average error introduced in is 7%, whereas the more accurate yields 6% error.
The I/O costs in the obstacle retrieval phase are same in all three methods. Thus in subsequent sections, we show only the I/O cost required to combine the quadtree and the colortree (i.e., the final phase of constructing the VCM).
Dataset  Method  Error (%)  

1  2  4  8  16  
British  8.11  9.31  10.15  11.83  14.96  
7.76  9.00  9.86  11.05  12.72  
Boston  8.02  9.08  9.38  9.82  11.03  
7.62  8.82  9.06  8.98  10.29 
VD2 Effect of
In this experiment, we vary the quadtree block size as 1, 2, 4, 8, and 16 times of the minimum threshold of a quadtree block and show the results in Fig. 11 and Table VII.
For British dataset, the computational and I/O costs are similar for all three methods, e.g., on average runs only 3% faster than . Because, similar to the case of varying , the three phases of constructing VCM differ slightly for these methods. The average error introduced in and is about 10%. The results derived from Boston dataset are similar to that of British dataset. runs about 3% faster than both and . The average errors introduced in the approximation methods are about 9%.
As the errors introduced by two approximations show similar trends for , FOV, and , we show only the total processing time and the I/O cost in the subsequent sections.
VD3 Effect of
In this experiment, we vary the query area as 5%, 10%, 15%, 20%, and 25% of the total dataspace (Fig. 12(a)(b)). In case of British dataset, and run 5% and 3% faster than , respectively. For Boston dataset, runs 5% faster than both and . The I/O cost and the total processing time increase for all three methods with the increase in , as we need to consider higher number of cells and higher number of obstacles to construct the VCM. As the I/O cost is similar for all three methods, we show only the total processing time.
VD4 Effect of FOV
In this experiment, we vary the field of view (FOV) as 60, 120, 180, 240, 300, and 360 degrees for British and Boston datasets (Fig. 13). When FOV is set to , the FOV covers the surrounding space in all directions. We observe that the processing time and I/Os increase with the increase of FOV, which is expected.
Like the previous cases, the total processing time and I/O cost are similar for all three methods. For British and Boston dataset, runs 3% and 4% faster than both and , respectively. With the increase of FOV from 60 to 360 degrees, the total processing time of increases by nearly 40% and 46% for British and Boston dataset, respectively. On the other hand, the I/O costs increase 33% and 31% for British and Boston dataset, respectively.
VD5 Effect of
In this experiment, we vary the length of target as 5%, 10%, 15%, 20%, and 25% of the total length of the dataspace. In general, with the change in , no significant change in performance is observed for any of the datasets (not shown).
VD6 Effect of varying
In this experiment we vary the number and distribution of obstacles and measure the performance of our approximation methods in terms of I/O cost, total processing time, and approximation errors. We vary as a set of 5k, 10k, 15k, 20k, and 25k obstacles while keeping the other parameters at their default values. We consider both Uniform (U) and Zipf (Z) distributions of the obstacles.
In general, as the number of obstacles increases, the area of the dataspace gets more obstructed. So during the final phase of VCM construction (i.e., combining colortree and visible region quadtree), computational costs and I/O costs get reduced. Consequently, the overall costs decrease with the increase in for both Uniform and Zipf distribution. In case of Uniform and Zipf distributions, as the number of obstacles is varied from 5k to 25k, the total processing time decreases nearly 40% and 20%, respectively for all three methods. On the other hand, the I/O costs decrease approximately 18% and 17% with the increase of for Uniform and Zipf distributions, respectively.
Vi Related Works
The notion of visibility is actively studied in different contexts: computer graphics and visualization [4, 9] and spatial databases [1, 2, 3]. Most of these techniques consider visibility as a binary notion, i.e., a point is either visible or invisible from another point.
Via Visibility in Computer Graphics and Visualization
In computer graphics, the visibility map refers to a planar subdivision that encodes the visibility information, i.e., which points are mutually visible [4]. Two points are mutually visible if the straight line segment connecting these points does not intersect with any obstacle. If a scene is represented using a planar straightline graph, a horizontal (vertical) visibility map is obtained by drawing a horizontal (vertical) straight line through each vertex of that graph until intersects an edge of the graph or extends to infinity. The edge is horizontally (vertically) visible from . A large body of works [5, 6, 7, 8, 9] construct such visibility maps efficiently.
Given a collection of surfaces representing boundaries of obstacles, Tsai et al. considers visibility problem as determining the regions of space or the surfaces of obstacles that are visible to an observer [21, 22]. They model visibility as a binary notion and find the light and dark regions of a space for a point light source.
Above methods involve the computation of visible surfaces from a viewpoint and do not consider visibility factors such as angle and distance to quantify the visibility of a target object.
ViB Visibility in Spatial Queries
Visibility problems studied in spatial databases usually involve finding the nearest object to a given query point in the presence of obstacles. In recent years, several variants of the nearest neighbor (NN) queries have been proposed that include Visible NN (VNN) query [1], Continuous Obstructed NN (CONN) query [2], and Continuous Visible NN query [3].
Nutanong et al. introduce an approach to find the NN that is visible to a query point [1]. A CNN query finds the NNs for a moving query point [23]. Gao et al. propose a variation of CNN; namely, a CONN query [2]. Given a dataset , an obstacle set , and a query line segment in a 2D space, a CONN query retrieves the NN of each point on according to the obstructed distance.
The aforementioned spatial queries find the nearest object in an obstructed space from a given query point where query results are ranked according to visible distances from that query point. Instead of quantifying visibility as a nonincreasing function from a target to a viewpoint, they label a particular point or region as either visible or invisible. But for constructing a VCM of the entire space, such binary notion is not applicable.
Recently the concept of maximum visibility query is tossed in [10] that considers the effect of obstacles during quantifying visibility of a target object. They measure the visibility of a target from a given set of query points and rank these query points based on the visibility measured as the visible surface area of the target.
Vii Conclusion
In this paper, we have proposed a technique to compute a visibility color map (VCM) that forms the basis of many reallife visibility queries in 2D and 3D spaces. A VCM quantifies the visibility of (from) a target object from (of) each viewpoint of the surrounding space and assigns colors accordingly in the presence of obstacles. Our approach exploits the limitation of a human eye or a lens to partition the space into cells in the presence of obstacles such that the target appears same from all viewpoints inside a cell.
Our proposed solution significantly outperforms the baseline approach by at least times and six orders of magnitude in terms of computational time and I/O cost, respectively for both datasets. Our conducted experiments on real 2D and 3D datasets demonstrate the efficiency of our approximations, and . On average, the approximations and improve the processing time by 65% and 17% over , respectively and require almost similar I/O costs. Both of and improve the efficiency of by introducing only 9% and 5% error on average.
References
 [1] S. Nutanong, E. Tanin, and R. Zhang, “Incremental evaluation of visible nearest neighbor queries,” TKDE, vol. 22, pp. 665–681, 2010.
 [2] Y. Gao and B. Zheng, “Continuous obstructed nearest neighbor queries in spatial databases,” in SIGMOD, 2009, pp. 577–590.
 [3] Y. Gao, B. Zheng, W.C. Lee, and G. Chen, “Continuous visible nearest neighbor queries,” in EDBT, 2009, pp. 144–155.
 [4] Algorithms and Theory of Computation Handbook.
 [5] J. Bittner, “Efficient construction of visibility maps using approximate occlusion sweep,” in SCCG, 2002, pp. 167–175.
 [6] J. Grasset, O. Terraz, J. Hasenfratz, D. Plemenos et al., “Accurate scene display by using visibility maps,” in SCCG, 1999.
 [7] T. Keeler, J. Fedorkiw, and S. Ghali, “The spherical visibility map,” ComputerAided Design, vol. 39, no. 1, pp. 17–26, 2007.
 [8] P. Wonka, “Visibility in computer graphics,” EPB Planning and Design, vol. 30, pp. 729–755, 2003.
 [9] A. Stewart and T. Karkanis, “Computing the approximate visibility map, with applications to form factors and discontinuity meshing,” in EGWR, 1998, pp. 57–68.
 [10] S. Masud, F. M. Choudhury, M. E. Ali, and S. Nutanong, “Maximum visibility queries in spatial databases,” in ICDE, 2013.
 [11] C. Rao, E. Wegman, and J. Solka, ser. Handbook of Statistics, 2005, vol. 24.
 [12] J. Baird, Psychophysical analysis of visual space. Pergamon Press London, 1970.
 [13] D. McCready, “On size, distance, and visual angle perception,” Attention, Perception, & Psychophysics, vol. 37, no. 4, pp. 323–334, 1985.
 [14] P. Kaiser, The joy of visual perception. York University, 1996.
 [15] K. Morling, Geometric and Engineering Drawing, 3rd ed.
 [16] B. H. Walker, Optical Engineering Fundamentals, 2nd ed.
 [17] N. Beckmann, H.P. Kriegel, R. Schneider, and B. Seeger, “The R*tree: an efficient and robust access method for points and rectangles,” in SIGMOD, 1990, pp. 322–331.
 [18] A. Guttman, “Rtrees: a dynamic index structure for spatial searching,” in SIGMOD, 1984, pp. 47–57.
 [19] D. Atchison and G. Smith, “Optics of the human eye,” 2000.
 [20] H. Samet, “The design and analysis of spatial data structures.” AddisonWesley, MA, 1990.
 [21] Y. Tsai, L. Cheng, S. Osher, P. Burchard, and G. Sapiro, “Visibility and its dynamics in a pde based implicit framework,” Journal of Computational Physics, vol. 199, no. 1, pp. 260–290, 2004.
 [22] L. Cheng and Y. Tsai, “Visibility optimization using variational approaches,” Communications in Mathematical Sciences, vol. 3, no. 3, pp. 425–451, 2005.
 [23] Y. Tao, D. Papadias, and Q. Shen, “Continuous nearest neighbor search,” in VLDB, 2002, pp. 287–298.