In this article we consider the problem of finding the visibility set from a given viewpoint given a set of known obstacles using a Partial Differential Equation (PDE). In principle, the visibility set is simply given by ray tracing and there are numerous algorithms for solving the visibility problem using explicit representations of the obstacles [CT97, DDTP00, AS96a, AS96b].
Finding the visibility set plays a crucial role in numerous applications including rendering, visualization [HZ00], etching [SA97], surveillance, exploration [VTS14], navigation [LTC06], and inverse problems, to only name a few. Specifically, in [CT05] the level set framework [OS88, Set99] developed in [TCO04] was extended to deal with the optimal placing of a single viewer or a group of viewers and -to- optimal path planning, where optimality is measured in terms of the volume of the visible region. More recently, in [LT18]
a convolutional neural network is proposed to determine the vantage points that maximize visibility in the context of surveillance and exploration, with the visibility sets of the training data being computed efficiently using the PDE formulation introduced in[TCO04]. For applications which involve optimization of the viewpoint, the discontinuity of the visibility can make optimization more difficult. The advantage of using level set/PDE methods is the improved regularity of the solution.
It is clear then that the ultimate goal of the work is inverse problems involving visibility. As is the case with inverse problems, a better understanding of the forward problem is essential for better results of the more challenging inverse problem. In this work, we focus our attention in the forward problem and do not go further and study the inverse problem. We propose a simple formulation of the visibility problem - the visibility set is the subzero level set of the solution of a nonlinear obstacle problem.
In [TCO04] the visibility problem is presented as a boundary value problem for a first order differential equation: the visibility set to a given viewpoint is given by where the function is the solution of
with . Here
is the characteristic function ofand is a signed distance function to the obstacles, positive outside the obstacles and negative inside. Despite the complex nature of the operator in (1), in [KT08] the visibility function
is shown to be the viscosity solution of an equivalent Hamilton-Jacobi type equation involving jump discontinuities in the Hamiltonian. A numerical scheme to solve this equation is presented and its convergence is established.
For our formulation, is still a signed distance function to the obstacles, but is instead negative outside and positive inside. Then the visibility set is given as where the function solves the following nonlinear first order local PDE
with . This is not only considerably simpler than (1), but can also be generalized to allow multiple viewpoints as we will show. Moreover, each sublevel set of is in fact the visibility set of the corresponding superlevel set of . Efficiencies then arise when the obstacles are given by the graph of a function (for example, heights of buildings). In this case, we can reduce the dimension of the problem, and compute the horizontal visibility set from a given height, using the level set representation. Similarly, if the superlevel set of represents the position of the obstacles at a certain time ( can for instance be the solution of an Eikonal equation), then the PDE needs to be solved only once and the visibility set at any given time can be extracted from the corresponding sublevel set.
The paper is organized as follows. In section 2, we characterize visibility sets as star-shaped envelopes. In section 3 we derive the new visibility PDE and its generalization to multiple viewpoints. In section 4 we present the numerical scheme, while in section 5 we establish its convergence. Finally, in section 6 we present both two-dimensional and three-dimensional examples of visibility sets computed using the new proposed PDE.
2. Star shaped sets and functions
In this section we give an interpretation of the visibility set from a given point as the star-shaped envelope with respect to the point . The definitions of star-shaped sets and envelopes are then extended to functions. Finally, we provide explicit formulas for the star-shaped envelopes of a function.
We star by recalling the definition of a star-shaped set.
We say the set is star-shaped with respect to if
A simple example of a star-shaped set is a convex set. Indeed, convex sets are star-shaped with respect to every point inside. Moreover, intersections of convex sets are convex, but unions are not. As a consequence there is a natural (outer) convex envelope, but not an inner one. On the other hand, star-shaped sets are closed under both intersections and unions, which means one can define two star-shaped envelopes (with respect to ) for sets, the inner and outer envelopes.
Given and , the outer star-shaped envelope of with respect to is the intersection of all star-shaped sets with respect to which contain . The inner star-shaped envelope of is the union of all star-shaped sets contained in it.
Looking at Figure 1, one immediately sees how the inner star-shaped envelope corresponds to the visibility subset of if there is an illumination source at the point . The remainder of is the invisible part. One the other hand, the outer star-shaped envelope minus corresponds to the least amount of obstacles which would need to be removed so that all of is visible from .
We now discuss star-shaped functions which are the main building block to characterize the visibility set as the solution of a nonlinear obstacle PDE. We write for the -sublevel set of a function and let be a star-shaped domain with respect to .
We say that the function is star-shaped with respect to if
|is star-shaped with respect to|
for all .
Notice the similarity to quasiconvex functions: is said to be quasiconvex if is convex for all .
We now characterize star-shaped functions with a zero-order condition.
A function is star-shaped with respect to if and only if
By definition, is star-shaped with respect to if and only if for all , is star-shaped with respect to . This is equivalent to the condition
for all all , which in turn is equivalent to (2). ∎
We use this result to describe the monotonicity of a star-shaped function.
Let be a function. Then is star-shaped with respect to if and only if is increasing along rays from to . Moreover, if is star-shaped with respect to , then is a global minimum of .
This follows immediately from Lemma 2.4. ∎
Next, in a similar way to star-shaped envelopes of a set, we define upper and lower star-shaped envelopes of a function with respect to a point .
Let be bounded by below. The lower star-shaped envelope of with respect to is defined as
while the upper star-shaped envelope is given by
We require that is bounded by below in order for the lower star-shaped envelope to be well defined since otherwise there would no star-shaped function with respect to bounded from above by .
We finish this section by proving the following simple explicit solution formulas for the star-shaped envelope of a function.
Let be bounded by below and define to be given by
with . Then is star-shaped with respect to and .
By the assumptions on , is well-defined. By construction, is increasing along rays from to , and so, by Proposition 2.5, is star-shaped with respect to . Moreover, it is clear that .
We want to show that . Suppose by contradiction that it is not. This means that there exists a star-shaped with respect to function with such that for some . Without loss of generality, assume that . We have and that there exists such that
Hence and therefore is not increasing along the ray from to . Finally, we invoke Proposition 2.5 to conclude that is not star-shaped with respect to , which leads to the desired contradiction. ∎
Intuitively, we can find by tracing the values from the boundary along rays to and taking the minimum of along the way.
Let and define to be given by
Then is star-shaped with respect to and .
From the definition of , it is clear that is increasing along rays from to , and so, by Proposition 2.5, is star-shaped with respect to . Moreover, , again by definition of .
We want to show that . Suppose by contradiction that it is not. This means that there exists a star-shaped with respect to function with such that for some . Without loss of generality assume . We have and that there exists such that
Hence , which means, just like in the proof of Proposition 2.7, that is not increasing along the ray from to . Hence is not star-shaped with respect to according to Proposition 2.5 and we have obtained our contradiction. ∎
This formula corresponds to the classic ray tracing algorithm to find the visibility set. We trace the values towards the boundary along rays from taking the maximum of along the way.
3. PDEs and Visibility
In this section, we present the new PDE formulation of visibility sets from a single viewpoint and its extension to multiple viewpoints. We start with a level set PDE interpretation for star-shaped envelopes. Given that the inner star-shaped envelope of a set corresponds to its visibility set, the PDE obtained computes the visibility set for each sublevel set. We then generalize it to multiple viewpoints.
3.1. Viscosity Solutions
Viscosity solutions [CIL92] provide the correct notion of weak solution to a class of degenerate elliptic PDEs which includes the PDEs considered here. We review it briefly here.
Let be the set of real symmetric matrices, and take to denote the usual partial ordering on , namely that is negative semi-definite.
The operator is degenerate elliptic if
For brevity we use the notation .
Definition 3.2 (Upper and lower semi-continuous envelopes).
The upper and lower semicontinuous envelopes of a function are defined, respectively, by
Definition 3.3 (Viscosity solutions).
Let . We say the upper semi-continuous (lower semi-continuous) function is a viscosity subsolution (supersolution) of in if for every , whenever has a local maximum (minimum) at ,
Moreover, we say u is a viscosity solution of if is both a viscosity sub- and supersolution.
For brevity we use the notation . In addition, when checking the definition of a viscosity solution we can limit ourselves to considering unique, strict, global maxima (minima) of with a value of zero at the extremum. See, for example, [Koi04, Prop 2.2].
We briefly discuss the regularity of the star-shaped envelopes. We start by observing that the star-shaped functions need not be continuous.
In one dimension, the function for and is star-shaped with respect to . In two dimensions, take and define as the characteristic function of the complement of , i.e., if and otherwise. Once again is star-shaped with respect to the origin, but it is not continuous. In fact, is lower semicontinuous.
As for the star-shaped envelopes of functions, the upper star-shaped envelope is continuous while the lower star-shaped envelope is only lower semicontinuous as it may be discontinuous at .
Let be bounded by below. Then is lower semicontinuous in and continuous in except at , while is continuous in . If is a global minimum of then is also continuous in .
Let and let . Then the lower and upper star-shaped envelopes are given by
A two-dimensional example is given in Figure 2: is given by the distance to two points and is chosen as a point on the level set of . The upper and lower envelopes are pictured. The lower one is discontinuous at . Replacing with leads to a function whose global minimum is attained at and therefore both star-shaped envelopes are continuous in this case. This is depicted in Figure 3.
3.3. A local PDE for star-shaped envelopes
We start by establishing a first order condition for star-shaped functions.
Suppose is differentiable. Then is star-shaped with respect to if and only if for all .
By the mean value theorem, given any there exists such that
Thus if is star-shaped with respect to to we obtain using Lemma 2.4
Taking the limit as leads to the desired inequality .
Now, suppose that for all . We argue by contradiction. Assume that is not star-shaped with respect to . Hence, by Lemma 2.4, there are and such that
Then, again by the mean value theorem,
for some . However, taking in leads to
We have the desired contradiction and so the proof is complete. ∎
We are interested in star-shaped functions that may not be differentiable since typically the visibility set has corners. Thus we need to characterize star-shaped functions in the weak sense. We will do so using viscosity solutions. Throughout the rest of this section let be a bounded star-shaped domain with respect to and denote its boundary by .
Suppose . Then is star-shaped with respect to if and only if is a viscosity subsolution of .
Suppose is star-shaped with respect to . Let be such that has a local maximum at . Without loss of generality assume that . Then we have in a neighborhood of . Since is star-shaped with respect to , is increasing along arrays from to by Proposition 2.5 and therefore
for . Hence, given the choice of ,
for sufficiently small. Since
for , we obtain as . This shows that is a viscosity subsolution of .
Suppose now that is a viscosity subsolution of and that is not star-shaped with respect to . Then there exists such that and with lying on the line segment from to . Without loss of generality assume that . We can then construct a linear such that and has a local maximum at with . But then
which contradicts our assumption. ∎
We can now finally write the PDEs for the upper and lower star-shaped envelopes of with respect to .
Let be bounded by below and let be the lower star-shaped envelope of with respect to . Assume is continuous. Then is the viscosity solution of the obstacle problem
along with boundary conditions on .
Let and let be the upper star-shaped envelope (visibility) of with respect to . Then is the viscosity solution of the obstacle problem
along with .
By definition the upper star-shaped envelope is given by
We observe that this is equivalent to
and so is the solution of
by a similar reasoning to the one in Proposition 3.7. Now, since the equation can be rewritten as
we conclude that is the solution of
as desired. ∎
3.4. Comparison Principle
An important property of elliptic equations, from which uniqueness follows, is the comparison principle that states that subsolutions lie below supersolutions. In addition, it also plays a crucial role when establishing the convergence of approximation schemes using the the theory of Barles and Souganidis [BS91], which we intend to do later on. However, in such setting, the comparison principle required is a strong comparison principle: The boundary conditions are satisfied in the viscosity sense. In general, such a comparison is only available when the solutions are continuous up to the boundary (see [CIL92] for more details).
We focus our attention in PDE (7) as it is the one we are most interested in: Its solution allows us to determine the visibility set. A strong comparison principle is however not satisfied: Notice that any function that is nonincreasing along any direction away from is a subsolution and thus given any supersolution we can always construct a subsolution that lies above it by adding a large enough constant. We can however circumvent this by requiring that the subsolution satisfies . This will also prove to be enough to establish convergence of our numerical scheme. Intuitively, imposing that the subsolution satisfies guarantees that lies below . This, together with the fact that the solution of (7) is the infimum of all supersolutions according to Perron’s method, is enough to reach the desired conclusion.
Suppose there exists such that by contradiction. Since is a supersolution (7),
where we used Perron’s characterization of and Proposition 2.8. In particular, we have and . Hence and by assumption on . Therefore there exists a linear function such that has a local maximum at with and . We have derived a contradiction with the assumption that is a subsolution of (7) and the proof is complete. ∎
3.5. Visibility from multiple viewpoints
We are now interested in the visibility set from multiple viewpoints where a point is consider visible if is seen by at least one viewpoint. We follow the same ideas as before, starting by generalizing the definition of star-shaped set.
We say that a set is star-shaped with respect to if
Suppose is differentiable and bounded by below. Then is star-shaped with respect to according to Definition 3.10 if and only if
The presence of the minimum in may not appear obvious at first, but it is crucial here. In order for a point to be visible from then must be increasing along the ray from to which guarantees that all the points along the ray will be in the visible set. Without the minimum in a point could be consider visible by first moving along a ray towards and then follow a different viewpoint.
In this case, is the solution of the following PDE
Despite being a non-local PDE, unlike the previous ones with a single viewpoint , we still have a fast solver available: The solution is given by
where is the solution of
This follows from noticing that
In addition, the following solution formula is also available
At this point, a natural question to ask is what other visibility definitions will lead to PDEs following the approach taken here. For instance, given viewpoints a point can be considered visible if (i) it is seen by at least two viewpoints; (ii) it is seen by or both and (iii) it is seen by all viewpoints. All these can be computed efficiently computed by first determining the visibility of each viewpoint and then taking the appropriate combination of maximums and minimums. However, determining a corresponding PDE following the approach considered here will in general fail. Consider for instance case (iii) where a point is visible if it is seen by all viewpoints. In this setting, one can no longer define star-shaped like sets as the visibility set may be disconnected (see Figure 4 for a simple example with two viewpoints). The fundamental difference is that it is no longer true that if a point is visible then all points along the ray from to the viewpoint are visible.
4. Convergent finite difference schemes
In this section, we discuss the numerical schemes used to solve the PDEs introduced in the previous section, focusing our attention on the visibility PDE (7). As we will see, the scheme proposed here is degenerate elliptic finite difference schemes for which there exists a well established convergence framework.
Before we begin we introduce some notation. For simplicity, we will assume we are working on the hypercube . We write . The domain is discretized with a uniform grid, resulting in the following spatial resolution:
where is the number of grid points used to discretize . We denote by the computational domain which in our case reduces to .
Our schemes are written as the operators , where is the set of grid functions . We assume they have the following form:
where corresponds to the value of u at points in .
4.1. Finite difference for the visibility PDE
For simplicity, we present the scheme in the two-dimensional setting. The generalization to higher dimensions is straightforward.
. Define the vectorfor . If is one of the four grid points enclosing , let . Otherwise, let denote the intersection between the line that passes through and and a line segment formed by 2 of the 8 neighbors of . Then and its upwind approximation is given by
is the piecewise linear Lagrange interpolant. The numerical scheme for the visibility PDE (7) is then given by
4.2. Fast sweeping solver
We implement a fast sweeping solver to compute the solutions of (9). Solving the equation for the reference variable, , leads to the update formula
where was defined in the previous section. Since all characteristic are straight lines and flow away from , the domain only needs to be swept once (but in a very specific ordering). For simplicity, we will assume that . Let denote the solution at where
Set such that (here the inequalities are interpreted component-wise). Set as well . The domain is then divided into four quadrants and each is swept in the following way:
, (sweeping bottom right square)
, (sweeping top right square)
, (sweeping bottom left square)
, (sweeping top left square)
Alternatively, the solver can be seen as a direct consequence of the solution formula (6).
5. Convergence of Numerical Solutions
In this section we recall the notion of degenerate elliptic schemes and show that the solutions of the proposed numerical scheme converges to the solutions of (7) as the discretization parameter tends to zero. The standard framework used to establish convergence is that of Barles and Souganidis [BS91], which we state below. In particular, it guarantees that the solutions of any monotone, consistent, and stable scheme converge to the unique viscosity solution of the PDE.
5.1. Degenerate elliptic schemes
Consider the Dirichlet problem for the degenerate elliptic PDE, , and recall its corresponding finite difference formulation:
where is the discretization parameter.
is a degenerate elliptic scheme if it is non-decreasing in each of its arguments.
The finite difference operator is consistent with if for any smooth function and ,
The finite difference operator is stable if there exists independent of such that if then .
Remark 5.2 (Interpolating to the entire domain).
The convergence theory assumes that the approximation scheme and the grid function are defined on all of . Although the finite difference operator acts only on functions defined on , we can extend such functions to via piecewise linear interpolation. In particular, performing piecewise linear interpolation maintains the ellipticity of the scheme, as well as all other relevant properties. Therefore, we can safely interchange and in the discussion of convergence without any loss of generality
5.2. Convergence of numerical approximations
Next we will state the theorem for convergence of approximation schemes, tailored to elliptic finite difference schemes, and demonstrate that the proposed scheme fits in the desired framework. In particular, we will show that the schemes are elliptic, consistent, and have stable solutions.
Proposition 5.4 (Convergence of approximation schemes [Bs91]).
Let denote the unique viscosity of the degenerate elliptic PDE with Dirichlet boundary conditions for which there exists a strong comparison principle. For each , let denote the solutions of , where the finite difference scheme is a consistent, stable and elliptic scheme. Then locally uniformly on as .
Now, we check that our scheme is consistent, stable and elliptic.
Lemma 5.5 (Consistency).
The scheme is consistent.
It is sufficient to show that
which follows immediately from a Taylor expansion argument and the definition of . ∎
Lemma 5.6 (Stability).
Suppose is bounded. Then the scheme is stable.
Since the solution satisfies
it follows that . ∎
Lemma 5.7 (Ellipticity).
The scheme is elliptic.
The term is trivially elliptic. Since belongs to the line segment of two grid points, is a convex combination of neighboring grid values and therefore is elliptic. Hence , being the minimum of two elliptic schemes, is also elliptic. ∎
In order to apply Proposition 5.4, our PDE must satisfy a strong comparison principle which is not the case here. However, inspecting the proof of Proposition 5.4 in [BS91], one notices that it is enough to show that in , where
This will follow from Proposition 3.9 by proving that . Indeed, due to the continuity of ,
6. Numerical results
In this section we present the numerical results. We focus on solving equation (7) as it is the one we are mainly interested since the sublevel sets of its solution provide us with the visibility set. We present results both in two and three dimensions.
We start with a simple example to show a numerical convergence test. We take as the viewpoint and consider as the obstacle function the cone and therefore each level-set of corresponds to a circle with center at the origin and a different radius. The exact solution was obtained using (6). The difference between the numerical solution and the exact solution in the norm is presented in Table 1, where we also confirm the expected first order convergence. Moreover, in Figure 5, we plot the level sets of both and the numerical solution, as well as their respective surface plots. As we can see, the visibility set is computed for each level set of .
In this example we are interested in computing the visibility set where we have four different obstacles: two squares with centers , and side lengths , respectively and two circles with origins , and radius . We achieve this by considering the obstacle function
and looking into the level set. We first solve (7) with and . We compute as well the visibility set with respect to when a point is consider visible if it is seen by any of the viewpoints and by both viewpoints simultaneous. The former corresponds to the solution of (8). All results are displayed in Figure 6.
We consider a simple three-dimensional example where the obstacle function is given by
It can be interpreted as the visibility set of a camera in the middle of two buildings. The results are displayed in Figure 7.
The Stanford 3D Scanning Repository provides a dataset of 35947 distinct points that form what is known as the “Stanford Bunny”. In this example we considered it as the obstacle by taking the function to be the signed distance function to the dataset points. The results are displayed in Figure 8.
In this article, we described a new simpler PDE to compute the visibility set from a given viewpoint given a set of known obstacles. We proposed a finite difference numerical scheme to compute its solution and showed its convergence. We discuss the generalization of the result to multiple viewpoints and present a PDE for the visibility set where a point is visible if it is seen by at least one of many viewpoints. Numerical examples of different visibility sets computed as the solution of the new proposed PDE in both two and three dimensions are presented.
This material is based upon work supported by the Air Force Office of Scientific Research under award number FA9550-18-1-0167. The second author thanks the hospitality of the Mathematics and Statistics department of McGill University during its visit where the work for this paper was carried out.
- [AS96a] Pankaj K. Agarwal and Micha Sharir, Ray shooting amidst convex polygons in 2d, Journal of Algorithms 21 (1996), no. 3, 508 – 519.
- [AS96b] Pankaj K. Agarwal and Micha Sharir, Ray shooting amidst convex polyhedra and polyhedral terrains in three dimensions, SIAM J. Comput. 25 (1996), no. 1, 100–116. MR 1374052
- [BS91] Guy Barles and Panagiotis E. Souganidis, Convergence of approximation schemes for fully nonlinear second order equations, Asymptotic Anal. 4 (1991), no. 3, 271–283. MR 92d:35137
- [CIL92] Michael G. Crandall, Hitoshi Ishii, and Pierre-Louis Lions, User’s guide to viscosity solutions of second order partial differential equations, Bull. Amer. Math. Soc. (N.S.) 27 (1992), no. 1, 1–67. MR 92j:35050
- [CT97] Satyan Coorg and Seth Teller, Real-time occlusion culling for models with large occluders, Proceedings of the 1997 Symposium on Interactive 3D Graphics (New York, NY, USA), I3D ’97, ACM, 1997, pp. 83–ff.
- [CT05] Li-Tien Cheng and Yen-Hsi Tsai, Visibility optimization using variational approaches, Commun. Math. Sci. 3 (2005), no. 3, 425–451.
- [DDTP00] Frédo Durand, George Drettakis, Joëlle Thollot, and Claude Puech, Conservative visibility preprocessing using extended projections, Proceedings of SIGGRAPH 2000 (July 2000), Held in New Orleans, Louisiana.
- [HZ00] Aaron Hertzmann and Denis Zorin, Illustrating smooth surfaces, 2000.
- [Koi04] Shigeaki Koike, A beginner’s guide to the theory of viscosity solutions, MSJ Memoirs, vol. 13, Mathematical Society of Japan, Tokyo, 2004. MR 2084272 (2005d:35002)
- [KT08] Chiu-Yen Kao and Richard Tsai, Properties of a level set algorithm for the visibility problems, Journal of Scientific Computing 35 (2008), no. 2, 170–191.
- [LT18] Louis Ly and Yen-Hsi Richard Tsai, Autonomous exploration, reconstruction, and surveillance of 3d environments aided by deep learning, CoRR abs/1809.06025 (2018).
- [LTC06] Yanina Landa, Richard Tsai, and Li-Tien Cheng, Visibility of point clouds and mapping of unknown environments, Advanced Concepts for Intelligent Vision Systems (Berlin, Heidelberg) (Jacques Blanc-Talon, Wilfried Philips, Dan Popescu, and Paul Scheunders, eds.), Springer Berlin Heidelberg, 2006, pp. 1014–1025.
- [Obe06] Adam M. Oberman, Convergent difference schemes for degenerate elliptic and parabolic equations: Hamilton-Jacobi equations and free boundary problems, SIAM J. Numer. Anal. 44 (2006), no. 2, 879–895 (electronic). MR MR2218974 (2007a:65173)
- [OS88] Stanley Osher and James A. Sethian, Fronts propagating with curvature-dependent speed: algorithms based on Hamilton-Jacobi formulations, J. Comput. Phys. 79 (1988), no. 1, 12–49.
- [SA97] J. A. Sethian and D. Adalsteinsson, An overview of level set methods for etching, deposition, and lithography development, IEEE Transactions on Semiconductor Manufacturing 10 (1997), no. 1, 167–184.
J. A. Sethian, Level set methods and fast marching methods
, second ed., Cambridge Monographs on Applied and Computational Mathematics, vol. 3, Cambridge University Press, Cambridge, 1999, Evolving interfaces in computational geometry, fluid mechanics, computer vision, and materials science. MR MR1700751 (2000c:65015)
- [TCO04] Y.-H. R. Tsai, L.-T. Cheng, S. Osher, P. Burchard, and G. Sapiro, Visibility and its dynamics in a pde based implicit framework, J. Comput. Phys. 199 (2004), no. 1, 260–290.
- [VTS14] Luca Valente, Yen-Hsi R. Tsai, and Stefano Soatto, Information-seeking control under visibility-based uncertainty, J. Math. Imaging Vis. 48 (2014), no. 2, 339–358.