cfl Copyright by Darrell Roy Hougen, 1994 ESTIMATION OF SHAPE, LIGHTING, AND REFLECTIVITY FROM STEREO AND SHADING INFORMATION BY DARRELL ROY HOUGEN B.S., Iowa State University of Science & Technology, 1986 M.S., University of Illinois at Urbana-Champaign, 1988 THESIS Submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy in Computer Science in the Graduate College of the University of Illinois at Urbana-Champaign, 1994 Urbana, Illinois ESTIMATION OF SHAPE, LIGHTING, AND REFLECTIVITY FROM STEREO AND SHADING INFORMATION Darrell Roy Hougen, Ph.D. Department of Computer Science University of Illinois at Urbana-Champaign, 1994 Narendra Ahuja, Advisor This thesis is concerned with the combined use of stereo and shading information for the purpose of three-dimensional surface shape estimation. The applicability, resolution, and accuracy of each individual method is examined and compared with that attainable in a combined approach. Integration is examined from standard and stochastic perspectives. The standard approach involves use of stereo information as an initial estimate of the surface shape from which parameters of the shading method such as the light source direction can be estimated. Issues of lighting and reflectivity estimation are addressed and solutions are advanced. In particular, general methods for estimation of the light source distribution and reflectance map are proposed and tested. Colored lighting and color variant reflectance functions are examined as possible sources of additional shape information. A statistical approach to surface shape estimation called `shape from appearance' is also advanced. In this approach, stereo information is used indirectly as a source of statistical information. It is shown that through a scale change the resulting statistical model can be used to achieve higher resolution than is achievable through the direct use of stereo information. iii To Jing, Clarinda, and Conrad iv ACKNOWLEDGMENTS Thanks are due to my advisor, Narendra Ahuja, without whom none of this would have been possible. Thanks are also due to Stephen Omohundro for providing me with ideas and Bob Craig for providing me with a program for computing non-negative least squares solutions. Special thanks are also due to my wife, Jing, for her love and support. v TABLE OF CONTENTS Page 1 INTRODUCTION AND MOTIVATION : : : : : : : : : : : : : : : : : : 1 1.1 The Challenge : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 1.2 Methods of Shape Estimation : : : : : : : : : : : : : : : : : : : : : : : : 1 1.3 Novelties : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 3 1.3.1 Integration of stereo and shading information : : : : : : : : : : : 3 1.3.2 Error analysis : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 4 1.3.3 Segmentation and albedo computation : : : : : : : : : : : : : : : 5 1.3.4 Estimation and use of the light source distribution : : : : : : : : : 5 1.3.5 Estimation and use of the reflectance map : : : : : : : : : : : : : 6 1.3.6 Shape from color shading : : : : : : : : : : : : : : : : : : : : : : : 6 1.3.7 Shape from appearance : : : : : : : : : : : : : : : : : : : : : : : : 6 2 BASIC THEORY OF STEREO VISION : : : : : : : : : : : : : : : : : : 8 2.1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8 2.2 Stereo Imaging Geometry : : : : : : : : : : : : : : : : : : : : : : : : : : 9 2.2.1 Coplanar camera geometry : : : : : : : : : : : : : : : : : : : : : : 10 2.2.2 Variable camera geometry : : : : : : : : : : : : : : : : : : : : : : 11 2.3 Determination of Image Correspondences : : : : : : : : : : : : : : : : : : 15 2.3.1 Area based approaches to correspondence : : : : : : : : : : : : : : 16 2.3.2 Graph matching approaches to correspondence : : : : : : : : : : : 18 2.4 Conclusions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 19 3 BASIC THEORY OF SHAPE FROM SHADING : : : : : : : : : : : : 21 3.1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 21 vi 3.2 Basic Radiometry : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 21 3.2.1 Image formation : : : : : : : : : : : : : : : : : : : : : : : : : : : 22 3.2.2 Calculating scene radiance : : : : : : : : : : : : : : : : : : : : : : 24 3.2.3 The reflectance map : : : : : : : : : : : : : : : : : : : : : : : : : 26 3.3 Reflectance Functions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 27 3.3.1 Lambertian reflectance : : : : : : : : : : : : : : : : : : : : : : : : 27 3.3.2 Ideal specular reflectance : : : : : : : : : : : : : : : : : : : : : : : 28 3.3.3 Diffuse reflectance from a dieletric material : : : : : : : : : : : : : 29 3.3.4 Specular reflectance : : : : : : : : : : : : : : : : : : : : : : : : : : 32 3.3.5 Combined reflectance functions : : : : : : : : : : : : : : : : : : : 33 3.4 Light Source Estimation : : : : : : : : : : : : : : : : : : : : : : : : : : : 33 3.4.1 Estimation of the direction of a single source : : : : : : : : : : : : 33 3.4.2 Estimation of the directions of three light sources : : : : : : : : : 34 3.4.3 Statistical estimation of the light source direction : : : : : : : : : 36 3.5 Shape from Shading : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 38 3.5.1 Characteristic strip approach : : : : : : : : : : : : : : : : : : : : 38 3.5.2 Variational approaches : : : : : : : : : : : : : : : : : : : : : : : : 40 3.5.3 Discrete approach : : : : : : : : : : : : : : : : : : : : : : : : : : : 43 3.5.4 Optimal control and related approaches : : : : : : : : : : : : : : : 46 3.5.5 Other approaches : : : : : : : : : : : : : : : : : : : : : : : : : : : 49 3.6 Conclusions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 51 4 RESOLUTION AND ACCURACY : : : : : : : : : : : : : : : : : : : : : 52 4.1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 52 4.2 Resolution : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 53 4.2.1 Resolution for a single camera in two dimensions : : : : : : : : : 53 4.2.2 Resolution for stereo cameras in two dimensions : : : : : : : : : : 55 4.2.3 Resolution for a single camera in three dimensions : : : : : : : : : 56 4.2.4 Resolution for stereo cameras in three dimensions : : : : : : : : : 56 vii 4.3 Accuracy : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 58 4.3.1 The accuracy of focus based methods : : : : : : : : : : : : : : : : 59 4.3.2 The accuracy of stereo based methods : : : : : : : : : : : : : : : 61 4.3.3 The accuracy of shading based methods : : : : : : : : : : : : : : 66 4.4 Conclusions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 67 5 INTEGRATION OF STEREO AND SHADING : : : : : : : : : : : : : 68 5.1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 68 5.2 Algorithmic Considerations : : : : : : : : : : : : : : : : : : : : : : : : : 69 5.3 Component Algorithms : : : : : : : : : : : : : : : : : : : : : : : : : : : : 71 5.3.1 Stereo algorithm : : : : : : : : : : : : : : : : : : : : : : : : : : : 71 5.3.2 Image segmentation algorithm : : : : : : : : : : : : : : : : : : : : 73 5.3.3 Depth segmentation algorithm : : : : : : : : : : : : : : : : : : : : 75 5.3.4 Albedo computation algorithm : : : : : : : : : : : : : : : : : : : 76 5.3.5 Source from shading algorithm : : : : : : : : : : : : : : : : : : : : 79 5.3.6 Reflectance map algorithm : : : : : : : : : : : : : : : : : : : : : : 80 5.3.7 Shape from shading algorithm : : : : : : : : : : : : : : : : : : : : 80 5.4 Experimental Results : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 82 5.5 Conclusions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 82 6 ESTIMATION OF THE LIGHT SOURCE DISTRIBUTION : : : : : 85 6.1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 85 6.2 Determination of the Source Distribution from Shading : : : : : : : : : : 87 6.3 Representation of the Source Distribution : : : : : : : : : : : : : : : : : 89 6.4 Methods of Solving for the Source Distribution : : : : : : : : : : : : : : : 90 6.5 Shape from Shading Using Multiple Sources : : : : : : : : : : : : : : : : 92 6.6 Integration of Shape from Stereo and Shading : : : : : : : : : : : : : : : 93 6.7 Experimental Results : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 93 6.7.1 Tests of the source estimation methods : : : : : : : : : : : : : : : 94 6.7.2 Tests of the shape estimation methods : : : : : : : : : : : : : : : 98 viii 6.7.3 Tests of the integrated shape recovery system : : : : : : : : : : : 100 6.8 Conclusions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 102 7 ESTIMATION AND USE OF THE REFLECTANCE MAP : : : : : 104 7.1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 104 7.2 Adaptive Polynomial Modelling : : : : : : : : : : : : : : : : : : : : : : : 105 7.2.1 Types of models : : : : : : : : : : : : : : : : : : : : : : : : : : : : 106 7.2.2 Roughness penalty : : : : : : : : : : : : : : : : : : : : : : : : : : 107 7.2.3 Stopping criteria : : : : : : : : : : : : : : : : : : : : : : : : : : : 108 7.2.4 Robust estimation : : : : : : : : : : : : : : : : : : : : : : : : : : 108 7.3 Shape from Shading Algorithm : : : : : : : : : : : : : : : : : : : : : : : 110 7.3.1 Objective function minimization approach : : : : : : : : : : : : : 110 7.3.2 Optimal control approach : : : : : : : : : : : : : : : : : : : : : : 111 7.3.3 Coordinate systems : : : : : : : : : : : : : : : : : : : : : : : : : : 114 7.4 Integration of Component Algorithms : : : : : : : : : : : : : : : : : : : : 115 7.5 Experimental Results : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 116 7.6 Conclusions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 118 8 THEORY OF COLOR SHADING : : : : : : : : : : : : : : : : : : : : : : 127 8.1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 127 8.2 Color Reflectance Maps : : : : : : : : : : : : : : : : : : : : : : : : : : : : 128 8.2.1 Color dependency on light source variation : : : : : : : : : : : : : 128 8.2.2 Color variation of standard reflectance functions : : : : : : : : : : 129 8.3 Source Estimation from Color Shading : : : : : : : : : : : : : : : : : : : 133 8.3.1 Estimation of the direction of a single source : : : : : : : : : : : : 133 8.3.2 Determination of the source distribution from color shading : : : 134 8.4 Shape from Color Shading : : : : : : : : : : : : : : : : : : : : : : : : : : 135 8.4.1 Recovery of a Lambertian surface : : : : : : : : : : : : : : : : : : 135 8.4.2 Variational approach : : : : : : : : : : : : : : : : : : : : : : : : : 138 8.4.3 Discrete approach : : : : : : : : : : : : : : : : : : : : : : : : : : : 139 ix 8.4.4 Local shape from color shading : : : : : : : : : : : : : : : : : : : 140 8.5 Conclusions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 144 9 SHAPE FROM APPEARANCE : : : : : : : : : : : : : : : : : : : : : : : 145 9.1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 145 9.2 Algorithm Overview : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 146 9.3 Associative Modelling : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 150 9.3.1 Choosing features : : : : : : : : : : : : : : : : : : : : : : : : : : : 151 9.3.2 Conditional density : : : : : : : : : : : : : : : : : : : : : : : : : : 152 9.3.3 Scaling to increase power : : : : : : : : : : : : : : : : : : : : : : : 153 9.4 Associative Mapping : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 154 9.5 Surface Estimation : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 155 9.6 Experimental Results : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 157 9.6.1 Model estimation : : : : : : : : : : : : : : : : : : : : : : : : : : : 157 9.6.2 Surface estimation : : : : : : : : : : : : : : : : : : : : : : : : : : 158 9.7 Conclusions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 159 REFERENCES : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 171 VITA : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 178 x 1 INTRODUCTION AND MOTIVATION This chapter paints in broad strokes the various challenges of computer vision and the solutions presented in this thesis. The following chapters review the basic theory of computer vision and describe the novel contributions of this research in greater detail. 1.1 The Challenge The everyday world is filled with objects, each possessing a unique shape or form, each having unique properties, each useful in myriad ways to the reasoning agent. In the quest to build machines capable of interacting with that environment, methods for the automatic determination of object utility, and thus of object shape and other properties, becomes a central focus of investigation. Special emphasis is given to the recovery of shape due to its close connection to object utility. However, knowledge of other object properties is also useful and desirable. In the domain of vision, the task becomes one of determining the shape and other properties of objects from images of the environment. In this context, viewing geometry, lighting, surface coloration and reflectance are all important issues requiring careful consideration, each contributing to the complex process of image formation. Thus, the challenge, in its most basic form, is to develop methods for the automatic extraction of useful information from images of the environment. This thesis addresses that basic theme with an emphasis on separation and recovery of surface shape, coloration, reflectance and lighting from images. 1.2 Methods of Shape Estimation Given the great utility of shape information, it is natural to seek methods by which such information can be directly recovered from images of the environment without de1 tailed consideration of the physical processes by which images are formed. Thus, it is not surprising that a wide range of methods using only geometric information and depending upon simple hypotheses about scene appearance have been developed and tested. Such methods include those usually referred to as stereo and motion and might be labelled geometric methods or image comparison based methods for depth recovery. In each case, elements from two or more images are compared, and a depth estimate is obtained from calculations that depend only upon geometric considerations. Knowledge of scene lighting, surface coloration, and reflectance is not used and attempts may be made to avoid problems caused by a lack of such knowledge. Geometric methods of shape recovery are appealing due mainly to their simplicity. However, such methods suffer from a number of limitations including a lack of matchable elements, low resolution, and low accuracy. The limitations of geometric methods are considered further in chapter 4. In addition, it is shown that such limitations can only be circumvented through detailed consideration of the image formation process. Methods of shape estimation that are based on a detailed consideration of the image formation process may be called physics based methods or single image methods and include methods such as shape from shading and shape from texture. The concentration in this thesis is on the method of shape from shading and a new but closely related method called shape from appearance. Shape from shading has traditionally been of mainly academic interest for a number of reasons. Despite the superficial simplicity of basic shape from shading theory, there are a number of hidden problems embodied in a lack of knowledge of such scene characteristics as lighting, surface coloration, and surface reflectivity. Such complex scene properties must be known in order for the basic equations of shading to be applicable. In addition, it has been only recently that robust algorithms for shape recovery from shading have been developed. This has made it difficult to carry out shape estimation experiments even in the presence of detailed knowledge of scene properties. However, the superior accuracy afforded by shading information makes it deserving of further consideration. This thesis discusses some of the problems of shading and suggests that many of them 2 can be addressed by an approach in which both shading and geometric stereo information are combined. 1.3 Novelties The combined use of geometric and physical information forms the basis of new approach to the problem of three-dimensional shape estimation and is motivated by the complementary nature of the various information sources. Moreover, in addition to providing more robust and widely applicable techniques for surface shape estimation, the present approach has provided the opportunity to study scene properties such as lighting, reflectivity, and surface coloration. The solutions to such problems have applications beyond the goal of shape estimation in domains such as graphics and virtual reality. The following sections give a brief overview of the novel contributions of this research and provide a preview of the entire thesis. 1.3.1 Integration of stereo and shading information Several methods have been developed for solving the shape estimation problem. Each method is based on the use of a single type of information such as that provided by stereo or shading methods when used individually. However, there are significant benefits to be realized from an integrated approach to surface estimation. One of the most widely studied of the comparison based methods of surface estimation is stereo [35, 63]. It is well known that absolute depth can be accurately estimated for highly textured surfaces using stereo methods. However, small variations in surface shape cannot be recovered because of limits on the resolvability of densely spaced image features. Moreover, many real surfaces possess large featureless regions for which stereo methods are inaccurate. In addition, the accuracy of stereo decreases quadratically with increasing depth. Shape from shading is one of the most widely studied methods of estimating surface shape from a single irradiance pattern [42]. Unfortunately, it is difficult to obtain satis3 factory results from images of real scenes without a good initial estimate of the surface shape, scene lighting, and object reflectivity. In addition, errors tend to accumulate across an image leading to large errors in overall surface shape. Moreover, most real scenes do not satisfy a requirement of shape from shading that the albedo be the same everywhere. Integrating stereo and shape from shading has several advantages [9, 12, 52, 43]. The initial depth estimate provided by stereo can be used to provide the initial conditions and light source information that are required by shape from shading, thus eliminating the need for human intervention. Stereo systems can operate in highly textured regions and at the boundaries between different colored regions where shape from shading systems cannot operate. Conversely, shape from shading methods can be used in large featureless regions where stereo methods are inaccurate. Therefore, an integrated system has the potential of operating under a wider range of conditions than either stereo alone or shape from shading alone. For stereo systems, errors in surface shape may be locally large but are independently distributed so that global errors in surface shape are not cumulative. Conversely, shape from shading can be quite accurate in resolving small variations in surface shape if the boundary conditions are known. Therefore, integration presents the possibility of obtaining both global accuracy and high resolution. 1.3.2 Error analysis A chapter is devoted to a theoretical comparison of stereo, motion, focus, and shading methods. It is shown that shading information provides better resolution and better accuracy than the other methods. Resolution is a measure of the image area available per unit object surface area and is a determinant of the level of detail that can be resolved by a given method. In a setup in which multiple images of a particular scene patch are used to determine its depth, such as stereo and motion, the resolution is determined by the minimum resolution available from any pair of views. For both single and multiple image methods, resolution decreases with 4 increasing depth at a linear rate. However, for multiple image methods, resolution also goes to zero as the distance to the object goes to zero. The exact decrease in resolution as a function of viewing parameters is given in the thesis and the point of maximum resolution for stereo is given. In addition, it is argued that the general sparseness of features further degrades the resolution of focus, stereo, and motion based methods. Accuracy is the inverse of the expected error magnitude. It is shown that the expected error magnitude for shading methods increases only linearly with the distance to the object but that the error increases with the square of the distance for the other three methods. In addition, it is shown that as the distance goes to zero, the error produced by triangularization methods becomes large. The optimal target distance for such methods is derived. 1.3.3 Segmentation and albedo computation In order to use stereo and shading together, it is useful to be able to handle images in which there are several uniformly colored objects. Current shading methods work in regions of uniform coloration while stereo methods work best at the boundaries between such regions where there are rapid changes in coloration. This thesis details two new methods of albedo calculation. The first is based on use of the image irradiance equation. The second involves solution of a linear least squares problem involving pairs of brightness values taken from each side of each inter-region boundary. 1.3.4 Estimation and use of the light source distribution Traditional approaches to shape from shading are limited by the assumption of a single light source. Only one other approach has been proposed and that was limited to three light sources. This thesis provides a general solution to the calculation of the light source distribution given an initial estimate of the surface shape which may be provided by stereo. The 5 solution is linear and thus easy to compute. In addition, several algorithms for computing shape from shading are modified to use a general light source distribution. 1.3.5 Estimation and use of the reflectance map The appearance of a uniformly colored surface is determined by its shape, reflectance function, and the distribution of illumination. However, all the information about the reflectance function and distribution of illumination that is necessary and useful for surface shape estimation is contained in the reflectance map. This thesis describes a method of estimating the reflectance map involving the use of adaptive polynomial models. Since such models are linear in the coefficients, the solution is easy to compute. In addition, several shape from shading algorithms are modified to use a general reflectance map. 1.3.6 Shape from color shading Although color has previously been used for image segmentation, it has only been recently that the relationship of color to shape has been recognized. This thesis shows that color and shape are related for many standard reflectance functions and that this relationship can potentially be exploited for the recovery of surface shape. Several existing shape from shading algorithms are modified for use on color images and are discussed in terms of practical applicability. In addition, a direct local method of shape recovery is presented and discussed. 1.3.7 Shape from appearance This section introduces a new method of estimating the shapes of objects from their visual appearance. The method is a generalization of shape from shading and as such shares its qualities of high resolution and high accuracy. The shape from appearance method involves generation of a statistical model relating surface shape to appearance. The first step in obtaining the model is the association of 6 examples of surface shape provided by a stereo program with corresponding image examples. The relationship may be represented as an associative model or, if the relationship is particularly simply, as an associative map. In the latter case, estimation of the mapping function is viewed as a regression problem. For simplicity, polynomial models are used to represent the function making the estimation linear. It is shown that through a scale change, the estimated model can be made more accurate than the program that produced the examples. The improvement in accuracy that can be obtained in this manner is dependent upon the accuracy of the method that produced the examples and the base accuracy of the associative method which is related to the accuracy of shape from shading methods. A method of determining the shape of a previously unseen surface using the estimated model is derived. It is shown that through a clever choice of surface representation, the estimation of the surface height map can be made a linear process. 7 2 BASIC THEORY OF STEREO VISION 2.1 Introduction This chapter covers the basic theory of stereo vision including common geometric models and a review of methods for matching regions and points. Stereo vision has a long history relative to the age of the computer vision field and is one of the simplest and most commonly used methods of determining depth. The determination of depth from a pair of stereo images is accomplished by matching images of common scene elements. Once the matching is completed, the three-dimensional position of each point is determined solely on the basis of geometric considerations. Knowledge of camera positions, orientations, and internal geometric parameters make possible the triangulation of points in the scene. The matching of common scene elements is difficult for many reasons. A given scene element generally projects to a pair of image elements having similar but not identical appearances. The differences arise from geometric distortion, focus related blurring, and variations in the intensity of the light reflected in the direction of each camera. Therefore, reliable matching requires similarity measures that are robust to the expected changes in appearance. Once common elements have been identified, their positions must be accurately determined in order for depth to be accurately recovered. Chapter 4 examines some related limitations of geometric methods. The problem of establishing correct correspondences has been addressed by many authors. The following is a list of some of the ideas that have been developed for attacking the problem. Marr and Pogio [62] developed a cooperative algorithm to solve the correspondence problem using uniqueness and smoothness constraints. Grimson [33] modified the algorithm of Marr and Poggio through the incorporation of a figural conti8 nuity constraint designed eliminate unreliable matches by setting a minimum edge length for matching. Barnard and Thompson [5] used the similarity of regions surrounding preselected points to establish an initial match and a relaxation labelling technique to iteratively improve the matches on the basis of a local continuity property. Medioni and Nevatia [65] have considered the matching of straight edge segments to obtain a robust, sparse estimate of disparity. Pollard, Mayhew, and Frisby [78] set a limit on the gradient of the disparity to eliminate mismatches. Ayache and Faverjon [3] have matched edge segments using a graph matching approach to enforce consistency. Hoff and Ahuja [35] fit local surface patches to point sets to enforce surface smoothness and continuity. Figural continuity was enforced through the explicit use of edge contours of surface patches. Abbott and Ahuja [1] have combined stereo with focus and vergence information in an active vision approach to find surface discontinuities and achieve greater robustness. Das and Ahuja [18, 19] have considered partially blurry images that exist in scenes with large depth ranges. Focus information and coarse stereo estimates were used as compensatory factors. Gennert and Yuille [32] have considered combining intensity and edge information into a matching process using an energy function minimization approach. Lew, Huang, and Wong [59] used a learning algorithm to determine the optimal features for matching. Shah [88] has used a diffusion approach in which discontinuities and half occlusions are explicitly represented. Clearly, there are many possible approaches to solving the problem. The following sections explain the basic approaches and the interested reader is referred to the above references for more detail. 2.2 Stereo Imaging Geometry Common geometric models assume the existence of a pair of pinhole cameras with planar imaging surfaces. Often, the images are assumed to be coplanar. This assumption 9 greatly simplifies the geometry but restricts the experimental configurations that may be considered. More generally, the focal points of the cameras are assumed to be linked by a common baseline and to rotate in the same plane. This plane is allowed to rotate about the baseline. In some cases, the baseline is also allowed to rotate about a fixed axis. These are the elements of the pan, tilt, vergence model described in the second following section. The following section describes the simple, coplanar model. 2.2.1 Coplanar camera geometry This section describes the geometry of a stereo camera system with coplanar images. This derivation is similar to that given by Rodr'iguez and Aggarwal [81] although a righthanded coordinate system is used here. Figure 2.1 shows the geometric configuration of a pair of pinhole cameras with coplanar image planes. The position of a point in the world coordinate system is denoted, (x; y; z), while points in the left and right image planes are denoted (XL; YL) and (XR; YR), respectively. In world coordinates, the origins of the left and right images are (0; 0; \Gamma f ) and (B; 0; \Gamma f ), respectively, where f is the common focal length of the two cameras and B is the baseline. The corresponding focal points of the left and right cameras are located at (0; 0; 0) and (B; 0; 0), respectively. For any point in the field of view of the two cameras, the corresponding image points are found by extending a line from that point, through each focal point, to the point of intersection with the corresponding image plane. Considering similar triangles, it can be shown that the perspective projection equations are XL f = x z XR f = x \Gamma B z YL f = y z YR f = y z Solving these four equations for the position of the point in world coordinates, it can readily be seen that x = BXLD y = BYLD z = BfD where D = XL \Gamma XR is the disparity. These equations are mainly of use when the target is far away so that the viewing cones have significant overlap when the cameras are 10 x z y L R XX L R Y Y p pL R O ff B p(x,y,z) Figure 2.1 Coplanar imaging geometry. Cameras of focal length f are separated by a distance B along the x-axis. parallel. Unfortunately, the accuracy of stereo decreases rapidly with distance as shown in chapter 4. Therefore, it is useful to consider imaging models in which the cameras are allowed to rotate and converge on a nearby point. 2.2.2 Variable camera geometry This section describes the geometry of a stereo head in which the camera system is free to pan and tilt and in which each camera is free to verge separately. The derivation presented here is similar to that given by Abbott [2]. Figure 2.2 shows the geometric configuration of a stereo head composed of a pair of pinhole cameras that are connected by a rigid base of length, B. Each camera is assumed 11 Ly xL yR xRzLYL X L X R zR YRz W xW yW B F Rga Lgp p p L R ff Figure 2.2 Convergent imaging geometry. The focal points of cameras of focal length f are separated by a distance B. The left and right cameras face at angles flL and flR, respectively. to be attached to one end of the base by a rotational vergence joint with one degree of freedom. The joints have parallel rotation axes that are perpendicular to the baseline and each axis passes through the focal point of one camera. The base is assumed to be connected to a tilt unit whose axis is aligned with the baseline. The tilt unit is further attached to a pan unit whose axis is perpendicular to the baseline. For convenience, the origins of the stereo head and world coordinate frames are both taken to be at the bisector of the baseline. The head coordinate system has its xh axis aligned with the baseline and pointing in the direction of the right camera and its yh axis parallel to the axes of the vergence joints. The zh axis is defined to make the 12 coordinate system right handed. The rotational transformation from world coordinates to head coordinates is found by first applying the rotation about the pan axis and then the rotation about the tilt axis. Let be the pan angle and o/ be the tilt angle. Then head coordinates are related to world coordinates by0 BBBBB @ xh yh zh 1CCC CCA = 0BBB BB@ 1 0 0 0 cos(o/ ) sin(o/ ) 0 \Gamma sin(o/ ) cos(o/ ) 1CCC CCA 0BBB BB@ cos() 0 sin() 0 1 0 \Gamma sin() 0 cos() 1CCC CCA 0BBB BB@ xw yw zw 1CCC CCA Due to the special properties of rotation matrices, the world coordinates can be found in terms of head coordinates by simply changing the signs of the angles and the order in which the matrices are applied. Therefore, the inverse transformation is given by0 BBBBB @ xw yw zw 1CCC CCA = 0BBB BB@ cos() 0 \Gamma sin() 0 1 0 sin() 0 cos() 1CCC CCA 0BBB BB@ 1 0 0 0 cos(o/ ) \Gamma sin(o/ ) 0 sin(o/ ) cos(o/ ) 1CCC CCA 0BBB BB@ xh yh zh 1CCC CCA If the rotation axes are not precisely aligned with the baseline and its bisector, then rotation of the joints will introduce a translation into the transformation. Incorporation of a translation is straightforward and is not covered here. For more details, see Abbott [2]. Once the transformation from world coordinates to head coordinates and its inverse are known, it is possible to work exclusively in head coordinates. The left and right cameras have coordinate frames denoted (xL; yL; zL) and (xR; yR; zR), respectively. The origin of each coordinate frame is assumed to be at the focal point of the corresponding camera and the optical axes of the left and right cameras are assumed to point in the \Gamma zL and \Gamma zR directions, respectively. The yL and yR axes of the cameras are aligned with the yh axis of the head and the xL and xR axes are chosen to make the coordinate systems right handed. Each image plane also has a coordinate system which is conveniently written in terms of homogeneous coordinates. Let (uXL; uYL; u), and (vXR; vYR; v) be homogeneous image coordinates for the left and right cameras, respectively. The homogeneous image coordinates are related to homogeneous camera coordinates, (xL; yL; zL; 1) and (xR; yR; zR; 1) 13 by the left and right projection matrices, PL and PR, where PL = PR = 0BBB BB@ 1 0 0 0 0 1 0 0 0 0 1 0 1CCC CCA The relationships between head coordinates and left and right camera coordinates involve both a rotation and translation which are captured in the form homogeneous rotation matrices, AL and AR, respectively. Let flL and flR be the left and right camera facings where a facing is defined to be the angle between the z coordinate of the camera and the z coordinate of the head. If both cameras are facing directly forward, flL = flR = 0. In terms of the facings, the left and right homogeneous rotation matrices may be written AL = 0BBB BBBBB @ cos(flL) 0 sin(flL) B cos(flL)=2 0 1 0 0 \Gamma sin(flL) 0 cos(flL) \Gamma B sin(flL)=2 0 0 0 1 1CCC CCCCC A and AR = 0BBB BBBBB @ cos(flR) 0 sin(flR) \Gamma B cos(flR)=2 0 1 0 0 \Gamma sin(flR) 0 cos(flR) B sin(flR)=2 0 0 0 1 1CCC CCCCC A Combining the above transformations, the relationships between head coordinates and image coordinates may be summarized as XL = PLALxh and XR = PRARxh where the bold symbols are intended to indicate the corresponding vectors. 14 In order to obtain the depth of a point in head coordinates, it is necessary to solve the above equations for zh. After some laborious calculations it is possible to show that0 BBBBB @ \Gamma (sLXL + cL) (cLXL \Gamma sL) \Gamma (sRXR + cR) (cRXR \Gamma sR) (sLYL \Gamma sRYR) \Gamma (cLYL \Gamma cRYR) 1CCC CCA 0B@ xh zh 1CA = 0BBB BB@ B(sLXL + cL)=2 \Gamma B(sRXR + cR)=2 \Gamma B(sLYL + sRYR)=2 1CCC CCA where sL; sR; cL; cR are shorthand for the sines and cosines of the left and right facings. The first two of these equations are sufficient to get a unique answer or all three equations can be used to find a least squares solution. Since the results of stereo processing are to be used in conjunction with shape from shading, it is useful to have the results in terms of one of the camera coordinate frames. Simple manipulations yield zL = sLxh + cLzh + BsL2 and zR = sRxh + cRzh \Gamma BsR2 The next section briefly overviews methods of matching common elements from two or more images. 2.3 Determination of Image Correspondences For the triangulation methods described in the previous section to be useful, it is necessary to find corresponding scene elements in two different images. The problem of finding such correspondences may be divided into two broad classes which differ primarily in the order of operations. In the first approach, often referred to as the area based or intensity based approach, a region centered at each interesting point of one digital image is compared with a predetermined set of regions from a second image and in each case the optimal match is chosen. In the second approach, interesting points are first identified in both images and the best match involving both point sets is sought. The second approach transforms the image correspondence problem into a graph matching problem and may 15 be referred to as the graph matching approach. The next two sections overview existing theory of both approaches. 2.3.1 Area based approaches to correspondence Area based approaches to the correspondence problem are those approaches in which a match is attempted between every point or every `interesting' point of one image and a predetermined set of candidates in the other image. The term `area based' arises from the fact that the `areas' or regions surrounding each of the candidate points in the two images are compared in order to isolate the best match. In its simplest form, an area based algorithm proceeds as follows: One image is arbitrarily selected to be the `scan image' and the other image is designated to be the `search image'. The scan image is scanned in a predetermined order, generating a sequence of points. Each point of the sequence is compared with every point within some region surrounding the point with the same coordinates in the search image. Each comparison generates a `match value' and the point in the search image receiving the highest match value is declared the best match for the point from the scan image. The following is pseudo code for the matching algorithm. for (x1; y1) in I1 do for jx2 \Gamma x1j ! b1 and jy2 \Gamma y1j ! b2 do m = match value(I1(x1; y1); I2(x2; y2)) if m is best so far, then (x; y) = (x2; y2) output `(x; y) matches (x1; y1)'. The above procedure generates a match for every point of the scan image but not every point of the search image. The search image may contain unmatched points and points with multiple matches in the scan image. The procedure is not symmetric. This may or may not be a drawback. If a dense depth map is required, it is preferable to use the scan image. If more than one dense depth map is required, the procedure can be repeated with the roles of the images reversed. 16 There are numerous possible criteria for matching candidate points. One of the most common is the cross-correlation coefficient. In [2] it is defined to be ae = [P b=2 i=\Gamma b=2 P b=2 j=\Gamma b=2 I1(x1 + i; y1 + j)I2(x2 + i; y2 + j)]2 [Pb=2i=\Gamma b=2 I1(x1 + i; y1 + j)][Pb=2j=\Gamma b=2 I2(x2 + i; y2 + j)] where the denominator is a normalization factor that may be omitted. Another common criterion for matching is the sum of squared differences or SSD. The SSD is defined to be SSD = b=2X i=\Gamma b=2 b=2X j=\Gamma b=2 (I1(x1 + i; y1 + j) \Gamma I2(x2 + i; y2 + j))2 where the match window is assumed to be a square of size b \Theta b. There are a couple of changes that can be used to make SSD more computationally efficient. First, replacing the square with and absolute value operation saves one multiplication. In this case, it is convenient to write SAD for sum of absolute differences. Second, an object called a sum-array can be used to make the calculation more efficient. The sum-array has been used by Omohundro and has recently been reported by Ross [82]. A sum-array is formed from an ordinary array by keeping a running total of the rows and columns as one proceeds from the upper left corner to the bottom right. Then, the sum of the entries in any rectangle in the original array is found by subtracting the values at the upper right and lower left corners of the rectangle from those of the lower right and upper left corners in the sum-array. This procedure makes it possible to calculate the sum of the values in any rectangle in constant time. The sum array is useful to the matching problem because it allows the squared or absolute differences to be computed only once for each offset, thereby significantly reducing the time-complexity of the algorithm. The correspondence measures listed above are sensitive to the overall illumination level which may change as a function of the viewing angle and camera parameters and is not particularly important to the identity of the scene points. Therefore, the correspondence measures can be made more reliable through the use of certain kinds of image 17 preprocessing operations which eliminate or reduce the dependency on the overall light level. An easy method of reducing the D-C component of a signal is through the use of derivative operators. However, derivative operators may also increase the noise level. To obtain a satisfactory balance of noise and constant term suppression, a band pass filter is suggested in which a certain amount of smoothing is performed prior to derivative estimation. In addition to the above considerations, it should be noted that the disparity will generally be much more closely aligned with one coordinate axis of the image than the other. Because computation of the disparity is the primary goal, localization of the features along the disparity axis is more important than localization in the orthogonal direction. Consequently, it is more useful to compute derivatives in the disparity direction than in any other. 2.3.2 Graph matching approaches to correspondence In the graph matching approach to stereo correspondence, interesting points are identified in both images of the stereo pair and a best overall match is sought for the selected point sets. In the simplest case, no information about the appearance of the points is preserved. Thus, the matching step reduces to a pure graph matching problem in which the positions of the points and other geometric information is used to constrain the matching process. A typical graph matching algorithm operates as follows. Both images are scanned for interesting points. This generally involves computing the value of some interest operator at each point in each image. Once the interest value of each point is known, the most interesting points in each image are chosen. Generally, a preset number of points is selected from each image. Once the points of interest have been selected, the two points sets are matched. Matching of point sets is generally done on the basis of geometric constraints. The initial assignment of matches may be done on the basis of appearance, followed by a 18 step in which improvements based on geometric constraints are computed [5]. The set of possible matches may be limited by a maximum distance threshold. In this context, it is desirable to use the epipolar constraint to limit the set of possible candidate matches. Once the candidate matches have been established, geometric constraints must be used to obtain the final solution. The most obvious constraint is that the matching must be one-to-one. That is, each point in one set can have at most one match in the other. Some points from each set may be unmatchable. Other constraints include the ordering constraint and similarity of disparity. Along an epipolar line, the ordering of points in the two images must be the same. Similarity of disparity is often used in a relaxation style approach to determining correct matches [5]. Hoff and Ahuja fit surfaces to sets of neighboring points and use the fact that all points must be on some surface to eliminate incorrect matches [35]. Both graph matching and area based approaches have relative advantages and disadvantages. Graph matching approaches tend to make better use of geometric information, while sometimes ignoring information about appearance that is considered to be of primary importance in area based approaches. Graph matching approaches tend to give sparse depth estimates, making them unsuitable for shape determination. However, area based approaches may also be inaccurate in regions where the image brightness varies slowly. Rudimentary area based approaches may also be confused by a shift in image brightness but this can be compensated using various prefiltering operations. One serious problem with the graph matching approach is that the points of one set may not contain the best matches for points of the other. 2.4 Conclusions The introductory section of this chapter listed myriad possible variations to the basic methods. The continued proliferation of such approaches indicates that the problem has not yet been adequately addressed. Conversely, however, new approaches show only 19 marginal improvements over older methods indicating that theoretical limits may be hampering improvement. The overwhelming requirement of stereo methods is that clearly distinguishable features be present in the images and that such features be as dense as possible. So far, however, no index of distinguishability has been developed nor has any theory been developed giving the relationship between density and distinguishability or indicating expected performance on images of typical scenes. Further limitations of stereo methods result from geometric distortion and lighting variations that occur between images. Although many authors have referred to these problems, the systematic effect of such interference has not been quantified. 20 3 BASIC THEORY OF SHAPE FROM SHADING 3.1 Introduction A single image of a scene is formed by a complex sequence of processes starting with the emission of light from a light source and culminating with the formation of an image on a sensor. This chapter examines the image formation process and reviews some of the basic methods for obtaining shape from an image of a shaded surface. Although the discussion of radiometry is completely general, the reflectance functions and shape from shading methods discussed in this chapter are limited to monochromatic images. Some of the same methods are revisited and extended to color images in chapter 8. 3.2 Basic Radiometry This section discusses the image formation process. Several factors contribute to the appearance of an image. These include the spatial and spectral distributions of the light sources, the reflectance functions of the surfaces visible in the scene and the physical properties of the imaging system. Much of this discussion follows that given by Horn and Sjoberg [38]. The quantity of interest in computer vision is the image irradiance. The image irradiance is the power (or flux) per unit area arriving at the image plane and determines the response levels of the image sensors. The image irradiance, denoted E(*) is a function of the wavelength of the light incident upon the sensor. A sensor with spectral response function, Q(*), has a response I = Z E(*)Q(*)d* where I is the image brightness or image intensity. If several sensors with differing sensor response functions, Qj(*), are present, then a color image is formed with each channel 21 having response given by Ij = Z E(*)Qj (*)d* In this case, the image is represented as a vector of response levels, I. 3.2.1 Image formation In order to determine the image irradiance, E(*), it is convenient to work backwards from the image to the underlying physical causes. Clearly, the image irradiance depends strongly upon the internal structure of the camera. To simplify this discussion, the simple camera model of Horn and Sjoberg [38] is used here. The camera model is illustrated in figure 3.1. It consists of a single transparent lens of diameter d that focuses light from the scene on a planar image surface. The optical axis is perpendicular to the image plane and the lens is a distance f in front of the image plane. Objects in the scene are assumed to be in focus so that rays drawn from a particular point on a scene object arrive at a single point on the image plane. It is assumed that the camera does not block any rays from the scene to the front of the lens or from the lens to the image plane. Thus, vignetting is ignored. Let ffiAO be the area of a patch on the object located at the point xO = (xO; yO; zO) and let ffiAI be the area of the image of the patch located at xI = (xI ; yI; \Gamma f ) on the image plane. Here, the origin of the coordinate system is taken to be at the center of the lens. Let the angle between pO and the optical axis be ff and let ` be the angle between pO and the normal to the surface. Equating solid angles, it can be seen that ffiAO cos ` z2O = ffiAI cos ff f 2 The power (flux) arriving at the lens aperture from a patch of size, ffiAO, is given by ffi\Phi = ffiAO Z \Omega Lrd\Omega where Lr is the radiance reflected in the direction of the aperture and \Omega is the projected solid angle of the aperture. Radiance is defined to be power per unit area per unit 22 dO ri qq dI v nl a z f d Figure 3.1 Single lens camera model. A surface patch of area ffiO is projected to an image region with area ffiI. projected solid angle. Image irradiance is flux per unit image area and is given by E = ffi\Phi =ffiAI Combining the above equations, it can be seen that E = (zO=f )2 cos ff Z ! Lr cos `0 cos ` d! where ! is the (nonprojected) solid angle subtended by the lens and `0 is the angle between a line from the center of the object patch to a point on the lens and a line parallel to the optical axis. The above integral can be evaluated under some mild assumptions. First, if the size of the lens is small in comparison to the distance to the object, then `0 ss ` and 23 cos `0= cos ` ss 1. Furthermore, if the reflected radiance is assumed to be a slowly varying function of the emittance angle, then Lr can be taken outside the integral. Under these assumptions, the integral is simply equal to the solid angle subtended by the lens. This solid angle is approximately the foreshortened area of the lens, (ss=4)d2 cos ff, divided by the square of the distance from the object patch to the lens, (zO= cos ff)2. Therefore, the image irradiance is given by, E = (ss=4)(d=f )2 cos4 ffLr The principle conclusion of this derivation is that the image irradiance is proportional to the scene radiance. Therefore, if the scene radiance can be determined, the image brightness will be known. 3.2.2 Calculating scene radiance In the previous section, it was shown that image irradiance is proportional to scene radiance. In this section, the factors contributing to scene radiance are examined. Let (`i; OEi) and (`r; OEr) describe the directions of the incident and reflected light in a local coordinate system erected on a surface patch of interest. The coordinate system is illustrated in figure 3.2. The radiance of a particular surface patch in the scene is determined by the incident irradiance, Ei(`i; OEi; *) and the reflectance function, fr(`i; OEi; `r; OEr; *), of the surface patch. The surface reflectance function, fr(`i; OEi; `r; OEr; *), is sometimes called the "Bidirectional Reflectance-Distribution Function" or BRDF [38] and describes an intrinsic property of the surface. The BRDF is dependent upon the material composition of the surface and its microstructure. The material composition of a surface is determined chemically, by the proportions of various types of atoms and molecules present. The microstructure is determined by the microscopic shape of the surface and is related to the treatment the surface receives at the time of formation such as polishing or chemical treatments. Examples of generic reflectance functions are given in sections 3.3 and 8.2. 24 f i f r q i q r d w i d w r x y n z Figure 3.2 Local coordinate system defined relative to the local surface normal. Incident light from the direction (`i; OEi) is reflected in the direction (`r; OEr). Let ffi!i be a small solid angle in the direction (`i; OEi) subtending a portion of the source. Let ffi!r be a small solid angle in the direction (`r; OEr). The BRDF is given as the ratio of the reflected power per unit projected solid angle to the incident power. Using this definition, some manipulation of radiometric quantities shows that the reflected radiance in the direction (`r; OEr) due to the incident irradiance, Ei, from the direction (`i; OEi) is given by ffiLr(`i; OEi; `r; OEr; *) = fr(`i; OEi; `r; OEr; *)ffiEi(`i; OEi; *) Therefore, knowledge of the BRDF makes it possible to calculate the reflected radiance and hence the image irradiance from knowledge of the surface irradiance. Going one step further, the reflected radiance can be calculated directly in terms of the source radiance, Lr(`r; OEr; *) = Z \Omega i fr(`i; OEi; `r; OEr; *)Li(`i; OEi; *)d\Omega i 25 where \Omega i is the projected solid angle of the light source viewed from the surface patch. 3.2.3 The reflectance map In many applications of the foregoing radiometric theory, the primary quantity of interest is the surface shape represented by the surface normal, ^n, or, equivalently, the gradient, rz, of the surface height function. In such cases, the lighting and camera parameters are considered fixed and it makes sense to introduce a representation of the image formation process in which only the surface shape is explicit. The reflectance map, introduced by Horn and Sjoberg [38], allows the image formation equations to be written purely as a function of the gradient of the surface height function. It should be noted that the reflectance map representation is only valid under the assumption of orthographic projection. This is not a serious restriction considering the fact that the viewing rays are nearly parallel for a typical camera and that shape from shading techniques cannot recover absolute depth in any case. To understand how it is possible to simplify the above equations, it is useful to first consider writing the surface reflectance function in camera coordinates rather than in the coordinate system of the local surface patch. This can be accomplished by writing the direction of the normal and the direction of the light source in camera coordinates. Let (`n; OEn) and (`s; OEs) be the polar and azimuthal angles in camera coordinates of the normal vector and light source direction. Under the assumption of orthographic projection, the incident and exitant directions may be written, (`i(`n; OEn; `s; OEs); OEi(`n; OEn; `s; OEs)) and (`r(`n; OEn); OEr(`n; OEn)). The exact transformations can be found from trigonometric relations and are given in [38]. Consequently, the surface reflectance function may be written, ~fr(`n; OEn; `s; OEs). Since the incident radiance is not dependent on the direction of the surface normal, it may be written ~Li(`s; OEs). Furthermore, the the reflected radiance may be written ~Lr(`n; OEn). The reflected radiance is now given by ~Lr(`n; OEn) = Z \Omega ~fr(`n; OEn; `s; OEs) ~Li(`s; OEs)d\Omega 26 Clearly, there are other ways to represent this result. Rather than using the direction of the surface normal, it is common to use the normal itself. It is also common to use the image irradiance rather than the scene radiance. So, for example, the image irradiance equation might be written, E(x; y) = R( ^n(x; y)) where R is the reflectance map. The reflectance map summarizes all the information about the image formation process that related to surface shape and effectively `hides' the other information. This is useful for the problem of surface shape recovery that is discussed later. Since the gradient of the surface height function may be obtained from the surface normal and vice versa, it is also common to write E(x; y) = R(p; q) where p = zx and q = zy. For monochromatic images, the image brightness is nearly equivalent to the image irradiance. Indeed, it is easy to forget that the image irradiance is a function of wavelength while the brightness is not. Therefore, it is sometimes useful to write E(*) = R( ^n; *) and to reserve the symbol I to represent a color image formed using multiple spectral filters. 3.3 Reflectance Functions This section discusses several common reflectance functions, each of which may be useful in computer vision. 3.3.1 Lambertian reflectance The Lambertian reflectance function is one of the simplest and most commonly used reflectance functions. The Lambertian reflectance function is meant to capture the behavior of a diffuse reflector and is based on the assumption that incident light is reflected equally in all directions [38]. Stated another way, it is assumed that a diffusely reflecting surface appears equally bright from all directions. In this case, the Bidirectional Reflectance Distribution Function, fr, is a constant. 27 Determination of fr is accomplished by setting the integral of the reflected radiance, Lr, equal to some fraction, ae, of the incident irradiance, Ei, aeEi = Z \Omega r Lrd\Omega r = Lrss From the fact that fr = Lr=Ei it is easy to deduce that fr = ae=ss. If ae = 1 then fr = 1=ss. If ae(*) is a function of wavelength, then so is fr. The quantity ae is sometimes referred to as the albedo or color of the surface. Using the computed value of the BRDF, it is possible to determine the reflected radiance given a particular distribution of incident radiance. If a surface is illuminated by a distant point source, or equivalently, a collimated source, in the direction (`i; OEi) then the reflected radiance is given by Lr = aess Li cos `i where the cos `i represents the forshortening of the surface patch as seen from the source. This is the cosine law introduced by Lambert. In the case of an extended source, the above equation must be integrated over the hemisphere of possible incident directions. Using the above equations, it is easy to compute the image irradiance, E = aeLi cos `i " 14 ( df )2 cos4 ff# Note that the quantity in square brackets depends only upon the camera parameters and therefore is independent of the scene under consideration. Therefore, it is common to replace it by a constant or to ignore it completely with the implicit understanding that the image irradiance has been rescaled by the appropriate amount. For some algorithms, it may be important to actually do the rescaling. However, it will be assumed in what follows that scaling has already been performed. 3.3.2 Ideal specular reflectance Another common and simple reflectance model is that of perfectly specular reflectance. In this case, the surface is assumed to behave like a mirror. To calculate the reflected 28 radiance, a plane, called the plane of incidence, is erected that contains the incident ray and local surface normal. All incident light is assumed to be reflected in this plane along a ray making an angle with the local surface normal equal to that made by the incident ray but on the opposite side of the normal. Mathematically, this statement can be written Lr(`r; OEr) = Li(`r; OEr + ss) If only a fraction of the light is reflected, the rest being absorbed or transmitted, then it is possible to give an expression for the image irradiance, which is, in abbreviated notation, E = aeLi(`r; OEr + ss) The reflectance function (BRDF) of this surface can be written fr = ffi(`i \Gamma `r)ffi(OEi \Gamma OEr + ss)sin ` i cos `i where ffi(\Delta ) is the Dirac delta function. The normalization constant in the denominator is an artifact of spherical coordinates. 3.3.3 Diffuse reflectance from a dieletric material Although the Lambertian model is intended to be a model of diffuse reflectance, a better model of diffuse reflection from a dieletric material has been proposed by Wolff [96]. The Wolff model is illustrated in figure 3.3. In the Wolff model, light that is incident upon a dielectric material is transmitted from the air, through the interface, and into the material where it is scattered by subsurface colorant particles. After interacting with the colorant particles, some of the light is emitted into the air in the direction of the viewer. Each time light passes through the material interface it is refracted by an amount predicted by Snell's law and attenuated by an amount predicted by the Fresnel equations. Within the material, the diffuse scattering equation of Chandrasekhar applies. Combining the Fresnel coefficients and diffuse scattering equation yields the following 29 qi~ qr~ qi qr Colorant Interface Dielectric Air n n Figure 3.3 Diffuse reflection from a dielectric material. Light is refracted and attenuated as it enters the material, scattered by subsurface colorant particles, and again refracted and attenuated as it exits the material. diffuse reflectance equation, Lr(`i; OEi; `r; OEr; *) = Li(`i; OEi; *)[1 \Gamma F (`i; n; *)] cos `icos ~` i C(cos ~`i; cos ~`r; *)[1 \Gamma F ( ~`r; 1=n; *)] where Lr is the reflected radiance, Li is the incident radiance, F is the Fresnel reflection coefficient, and C is the Chandrasekhar diffuse scattering coefficient. The incident direction is (`i; OEi) and (`r; OEr) is the direction in which the light is reflected. From the figure it can be seen that the quantities ~`i and ~`r are the internal angles corresponding the external angles, `i and `r respectively. The angles are related by Snell's law so that sin ~`i = (1=n) sin `i and sin ~`r = (1=n) sin `r where n is the index of refraction of the material. The factor cos `i= cos ~`i arises from consideration of projected solid angles. Note that reflectance law does not depend upon angles OEi or OEr implying that it is symmetric about the surface normal. The Fresnel coefficients are composed of two terms, one normal and the other parallel to the plane of incidence. A good reference is that of Lorrain and Corson [60]. The 30 normal component, FN , and parallel component, FP , are given by FN (`i; ~`i) = 8!: n1 n2 cos(`i) \Gamma _r1 _r2 cos( ~`i) n1 n2 cos(`i) + _r1 _r2 cos( ~`i) 9=;2 FP (`i; ~`i) = 8!: n1 n2 cos( ~`i) \Gamma _r1 _r2 cos(`i) n1 n2 cos( ~`i) + _r1 _r2 cos(`i) 9=;2 where _r1 and _r2 are the magnetic permeabilities of the materials. The total power is given by, F = (1=2)(FN + FP ). The Chandrasekhar diffuse scattering coefficient is given by the following expression, C(a; b) = ae4ss aa + b H(a)H(b) where H is the Chandrasekhar H-function. The Chandrasekhar H-function can be approximated to nth order by the following expression, H(a) = 1a 1 \Delta \Delta \Delta an \Pi ni=1(a + ai) \Pi j(1 + ^ja) where ai is the ith positive zero of the Legendre polynomial, P2n(a), and ^j is the j positive root of the associated characteristic equation, nX k=1 cjae 1 \Gamma ^2j2 = 1 More details are given by Wolff [96]. Clearly the above expression is quite complex. However, Wolff has provided the following simplification, accurate for large values of the single scattering albedo, Lr(`i; OEi; `r; OEr; *) = %(*)Li(`i; OEi; *)[1 \Gamma F (`i; n; *)] cos `i[1 \Gamma F ( ~`r; 1=n; *)] where % is the diffuse albedo defined by % = ae4ss H(cos ~`i)H(cos ~`r)cos ~` i cos ~`r The key is that % is nearly constant for all values of the incident and reflectance angles. Thus, the final BRDF appears as a Lambertian reflectance function bracketted by two Fresnel coefficients describing the behavior of the light as it enters and exits the material through the interface. 31 3.3.4 Specular reflectance A good model of specular reflectance is given by Cook and Torrance [15]. The CookTorrance model includes both diffuse and specular terms, but the specular term introduced by Torrance and Sparrow [92] is of primary interest here. Unlike the ideal specular reflectance model introduced earlier, most shiny materials reflect light which is not in perfect alignment with the specular direction. This is a result of the fact that even very smooth surfaces are rough at some scale. In the CookTorrance approach, this effect is modelled through the use of a microfacet distribution function. In addition, the model accounts for the effects of shadowing and masking of microfacets by other microfacets through the use of a geometric attenuation factor. A Fresnel attenuation factor is also included in the model. Combining the above components, the specular part of the Cook-Torrance reflectance function can be written Lr( ^n; ^l) = Li(^l; *)ae(*)( ^n \Delta ^l) F ( ^n \Delta ^l; *)DG( ^n; ^l)ss( ^n \Delta ^v)( ^n \Delta ^l) where F is the Fresnel reflection coefficient, D is the microfacet distribution function and G is a geometric attenuation factor. As usual, ^n is the unit surface normal, ^l is a unit vector in the direction of the light source, and ^v is the unit viewing vector. The microfacet distribution function used here is that proposed by Beckmann and Spizzichino [7] and reported by Watt [95], D = 1m2 cos4 ff exp "\Gamma tan 2 ff m2 !# where m is the root mean square slope of the microfacets. In addition, ff is the angle between the normal to the microfacet and mean surface normal. The angle ff can be found from cos ff = ^n \Delta ^h where ^h = (^l + ^v)=jj^l + ^vjj is the bisector of the light source and viewing rays. The geometric attenuation factor, G, has been derived by Blinn [10] and is given by G = min (1; 2( ^n \Delta ^h)( ^n \Delta ^v)(^v \Delta ^h) ; 2( ^n \Delta ^h)( ^n \Delta ^l)(^v \Delta ^h) ) 32 The second term describes attenuation due to masking of reflected light and the third term describes attenuation due to shadowing of incident light. 3.3.5 Combined reflectance functions Many materials, such as dieletrics, exhibit both specular and diffuse reflection. In such cases, some fraction of the light is reflected specularly and some fraction of the remainder is reflected diffusely. Thus, it makes sense to combine a diffuse model and a specular model from the list above to create a new hybrid model. Let fs be the CookTorrance specular BRDF and let fd be the diffuse reflectance model of Wolff. Then a reasonable reflectance model is given by, Lr(`i; OEi; `r; OEr; *) = Li(`i; OEi; *)[flfs(`i; OEi; `r; OEr; *) + (1 \Gamma fl)fd(`i; OEi; `r; OEr; *)] where fl is an arbitrary constant determining the fraction of light reflected by each process. Recently, Wolff [97] has shown that for many materials, fl can be determined from physical constants. Combined reflectance maps are revisited in chapter 8 which covers the role of color in computer vision. 3.4 Light Source Estimation In the following section on shape from shading, it is assumed that the light source position is known. However, for many applications, such as autonomous robotics, the light source position or distribution may not be known. This section presents some methods of estimating the light source position. 3.4.1 Estimation of the direction of a single source A method for estimating the direction of a single source using an estimate of the surface height function has been proposed by Brooks and Horn [13]. It is based on minimization of departure from the image irradiance equation. 33 Consider the following functionalZ Z (E(x; y) \Gamma ( ^n(x; y) \Delta l))2dxdy where l is a vector encoding the direction and strength of the light source. In previously used notation, l = Li(^l)^l. Differentiation with respect to the light source vector yields the following equation describing the condition for a minimumZ Z (E \Gamma ^n \Delta l) ^ndxdy = 0 Using the relation, ( ^n \Delta l) ^n = ( ^nT l) ^n = ^n( ^nT l) = ( ^n ^nT )l the above expression can be rearranged to solve for l. The solution is l = ^Z Z ^n ^nT dxdy* \Gamma 1 Z Z E ^ ndxdy This equation can be used to solve for the light source vector using the initial surface estimate provided by stereo. 3.4.2 Estimation of the directions of three light sources A method for estimation of the directions and intensities of up to three light sources under the assumption that reflectance function of the surface is Lambertian has been proposed by Yang and Yuille [98]. The technique is appealing because no estimate of the surface height function is required. The only requirement is that the occluding contour of the smooth object be known. However, there are practical problems in the implementation of the theory. The image plane components of the direction are determined by examining the brightness of the occluding contour. The third component is determined by finding points of maximal brightness on the surface. Under orthographic projection, the normal to the image of the boundary of a smooth object is the same as the corresponding object normal. Let ^n = (n1; n2; 0) be the normal to the image of the object boundary and let l = (l1; l2; l3) be a light source. Then, under the assumption of unit albedo, the brightness is given by E = ^n \Delta l = n1l1 + n2l2. Thus, 34 the brightness on the boundary is independent of the z-component of the light source vector. Each boundary normal and corresponding brightness measurement produces one equation constraining the light source position. If multiple sources are present, multiple local solutions will also exist. The boundary can be subdivided into regions along which a fixed set of sources is visible. At a segment boundary, either a source becomes invisible or a new source becomes visible. Due to the assumption of Lambertian reflectance, a fixed set of sources can be treated as a single source within the segment. E = mX i=1 ^ n \Delta li = ^n \Delta mX i=1 li = ^n \Delta l0 where l0 = Pmi=1 li. The combined sources within each segment are referred to by Yang and Yuille as virtual sources. A solution exists for each virtual source. Yang and Yuille suggest the use of a Hough transform to obtain all of the solutions. Alternately, one could use a least median of squares technique. In estimating the image plane components of the light source vectors, there is no inherent limitation on the number of light sources that may be considered. However, using the method of Yang and Yuille, the z-components can be recovered for a maximum of only up to three light sources and only if the their directions are sufficiently different. If a local maximum of the image brightness function exists, then that can be used to compute the z-component of the direction of a single light source from the equation, E = jjljj, given that the image plane components are already known. If there are multiple sources, then the local maximum can only be used if the minimum angle between sources is ss=2 thereby assuring the condition that the local maximum is the result of exactly one source. Yang and Yuille also suggest the use of active vision to make the recovery of more sources possible. Serious practical problems with the method described above result from the fact that it is highly dependent upon object boundaries. Since such boundaries are typically difficult to find accurately and due to the fact that boundaries contain very few pixels in real images, it is unlikely that the method will be very accurate when applied to 35 real images. In addition, the method only provides for the recovery of up to three well separated light sources and therefore cannot capture the effects of distributed light sources. 3.4.3 Statistical estimation of the light source direction Statistical methods for estimation of the direction of a single light source have been proposed by Pentland [73] and Lee and Rosenfeld [54]. Both methods are based on an assumption about the distribution of surface normals and do not depend upon knowledge of the surface height function. This makes such methods especially appealing since it is often difficult to obtain an accurate estimate of the surface shape prior to the application of shading analysis. Both statistical methods for estimation of the light source direction are based on the assumption that surface normals are isotropically distributed. This assumption holds for a sphere and is a reasonable assumption when there is a large collection of randomly oriented objects in the scene. Under the assumption of a Lambertian reflectance function, the image irradiance equation may be written E(x; y) = ae ^n \Delta ^l where ae is the albedo of the surface, ^n is the surface normal, and ^l is the light source direction. Taking the directional derivative in the direction OE yields, EOE = ae \Theta ((n1)OEl1 + (n2)OEl2 + (n3)OEl3) where, for any a, the notation aOE is meant to indicate ax cos OE + ay sin OE. Pentland [73] has shown that under the assumption of isotropy, the expected value of (n3)OE is zero and that h(n1)OEi = ^ cos OE and h(n2)OEi = ^ sin OE where ^ is the mean surface curvature. From this it follows that hEOEi = (l1 cos OE + l2 sin OE)ae^ Although Pentland [73] proposed to use directional derivatives along many directions to estimate the unknowns in a least squares formulation, Lee and Rosenfeld [54] have noted 36 the fact that the use of more than two directions does not increase the robustness of the estimate. Letting OE = 0 and OE = ss=2 yields hExi = l1ae^ and hEyi = l2ae^ so that the tilt of the illuminant direction, o/L, is given by o/L = arctan( hEyihE xi ) Lee and Rosenfeld [54] have obtained the above result by directly modelling the the probability density function associated with the slant, oe, and tilt, o/ , of the surface. Under the assumption of isotropy, it can be shown that the surface normal has a density function given by f (oe; o/ ) = (sin2 oe)=(2ss). Using this density function to evaluate the expected values of Ex and Ey yields the above result. Pentland [73] has also shown through more tedious calculations that k j ae^ = qhE2OEi \Gamma (hEOEi)2 From this, it is possible to conclude that l1 = hExi=k, l2 = hEyi=k and l3 = (1 \Gamma l21 + l22)1=2 so that the light source direction vector is completely determined. Lee and Rosenfeld [54] have proposed a method for estimating the slant angle that does not depend upon knowledge of the variance of the derivative of the image intensity. Unfortunately, their result is a transcendental equation for oeL, the solution of which is not discussed. Another model for statistical estimation of the light source direction, which puts constraints on the local surface geometry, is discussed by Zheng and Chellappa [100]. None of the of the proposed methods considers use of a prior probability density on the light source direction. Moreover, all such methods are currently restricted to Lambertian reflectance functions and simple albedo models. Therefore, it appears that much more research could be done in this area. 37 3.5 Shape from Shading Obtaining shape from shading is a matter of inverting the image formation equations. Despite the formidable complexity of the image formation process, simplifications are possible which make the solution tractable in some cases which are good approximations to the conditions that occur in simple real scenes. This section reviews some of the basic ideas that have been explored in the past. The rest of the thesis concentrates on generalizing the ideas presented here and in the previous section. 3.5.1 Characteristic strip approach The characteristic strip approach introduced by Horn [36] represents the first general solution to the problem of obtaining surface shape from an image of a shaded object. The theory has recently been extended by Bruss [14], Saxberg [86], and Oliensis [68] who have derived several existence and uniqueness results and reexamined the nature of characteristic strip solutions to the shape from shading problem. This section reviews the basic approach, following Horn's derivation as given in [42]. In order to simplify the discussion, attention is restricted to the case of orthographic projection, thereby insuring the validity of the image irradiance equation introduced in section 3.3. For reference, the image irradiance equation is written E(x; y) = R(p; q) where E is the image irradiance, x and y are both image and world coordinates, R is the reflectance map, and (p; q) = (zx; zy) is the gradient of the surface height function, z(x; y). If the surface height, z, is known at a point (x; y), then the change in height, ffiz, that occurs as the result of taking a small step (ffix; ffiy) is given by ffiz = pffix + qffiy 38 As position on the surface varies, the gradient also changes. The change in the gradient that occurs as the result of the step (ffix; ffiy) may be written ffip = rffix + sffiy and ffiq = sffix + tffiy where r = zxx; s = zxy = zyx and t = zyy are the second partial derivatives of the surface height function. The values of r; s and t are found by differentiating the image irradiance equation to obtain Ex = rRp + sRq and Ey = sRp + tRq In the particular case that the step in the image is proportional to the gradient of the reflectance map it is possible to write ffix = Rpffi, and ffiy = Rqffi, for a small increment ffi,. Using this choice of the image step it can be seen that ffip = Exffi, and ffiq = Eyffi, Therefore, the surface height and gradient can be recovered for a step that is taken in the direction of the gradient of the reflectance map. In the limit of zero step size, the differences become differentials and the equations for updating the surface can be written as a set of five ordinary differential equations .x = Rp, .y = Rq, .z = pRp + qRq .p = Ex, .q = Ey Therefore, the surface height can be recovered along a particular curve originating at a given surface point. The curve is called a characteristic curve and the recovered strip of surface is called a characteristic strip. In order to obtain a complete surface, it is necessary to know the surface height in a small neighborhood of a singular point. A singular point is defined to be a point of maximal brightness in the reflectance map. Given knowledge of the surface height 39 function in a neighborhood of a singular point, it is possible to construct characteristic strips radiating from the singular point. Unfortunately, the above method of surface estimation is plagued by several difficulties. Among them are the fact that errors tend to accumulate along the length of the characteristic strips and that neighboring characteristic strips are not connected. The result is a set of characteristic strips in which large errant variations exist between neighboring strips. It is even possible for strips to cross. The above difficulties can be partially alleviated by a method that Horn calls sharpening. The sharpening process consists of growing several characteristic strips in parallel, enforcing the conditions that .z = p .x + q .y and E(x; y) = R(p; q) along curves parallel to the advancing characteristic strips. While the method of sharpening greatly improves the results, it does not alleviate all of the difficulties. Many surfaces have multiple singular points, some of which may be higher on the surface than the characteristic strips that originate at another singular point. Therefore, it may be necessary to start the surface recovery process from more than one point and combine the partial surfaces along seams. In addition, the surface recovered by the characteristic strip method is known at irregularly spaced points. As a consequence, surface interpolation is required to make graphing and other uses possible. While none of the above limitations is insurmountable, it is natural to seek methods that are more naturally suited to two-dimensional surface recovery. The following sections address efforts to develop such methods. 3.5.2 Variational approaches The variational approach to shape from shading has been used by several authors including Ikeuchi and Horn [46], Horn [39], Horn and Brooks [40], and Frankot and Chellappa [26]. The variational approach is designed to alleviate problems with the characteristic strip approach. As mentioned in the previous section, a serious limitation of the characteristic strip approach is the fact that each strip is computed individually so that the final collection of strips may not form a valid surface. Although this problem can 40 be partially alleviated through sharpening, it is desirable to have a method in which the surface is treated as a two-dimensional function sampled by a discrete, two-dimensional grid. The variational approach gets its name from the fact that a chosen objective function is minimized using variational methods. Several objective functions have been proposed by Horn and his students. Ikeuchi and Horn proposed the use of a special coordinate system called the stereographic coordinate system to make the inclusion of boundary information possible [46]. Horn and Brooks accomplished this end by making the reflectance function a function of the normal vector [40]. However, Oliensis has shown that the two-dimensional shape of the boundary does not constrain the shape of the surface [68]. Early attempts to define objective functions resulted in systems of equations in which the components of the gradient field were decoupled. This made it possible to obtain gradient fields that did not correspond to any surface. To solve this problem, Horn has suggested an objective function in which the surface height is explicitly included. This derivation follows that given by Horn in [42]. Consider minimizing the following criterion function defined as an integral over the image, Z Z [(E(x; y) \Gamma R(p; q))2 + *(p2x + p2y + q2x + q2y) + _((zx \Gamma p)2 + (zy \Gamma q)2)]dxdy The first term of the criterion function penalizes departure from the image irradiance equation. The second term is a smoothing term written as a penalty on the squared variation of the components of the gradient field. The third term is designed to enforce integrability by penalizing the departure of the components of the gradient field from their defined values in terms of an underlying surface. Initially, it may appear strange that it is necessary to define three separate functions, p(x; y); q(x; y) and z(x; y) and that in general (p; q) 6= (zx; zy). It should be noted, 41 however, that attempts to directly minimize the integral of (E(x; y) \Gamma R(zx; zy))2 result in degenerate and essentially meaningless solutions. On the other hand, solutions that minimize the integral of (E(x; y) \Gamma R(p; q))2 without the integrability term tend to result in vector fields which do not correspond to any surface. Minimization of the integral given above yields a surface and gradient field that are close, though the gradient of the surface need not be exactly equal to the components of the gradient field. The Euler equations corresponding to the above criterion function are found to be *r2p = \Gamma (E \Gamma R)Rp \Gamma _(zx \Gamma p) *r2q = \Gamma (E \Gamma R)Rq \Gamma _(zy \Gamma q) r2z = px + qy There is one Euler equation for each unknown image function. Together, they form a set of coupled second order differential equations. An iterative solution to the above set of equations can be found by making a suitable discrete approximation of the Laplacian. If the Laplacian of the surface height function, r2z is approximated by (r2z)ij = _zij \Gamma zij where _zij is a suitable weighted average of neighboring values of zij and if similar approximations are made for r2p and r2q then the update equations can be written (* + _)pn+1ij = (*_pnij + _(zx)nij ) + (Enij \Gamma Rnij)(Rp)nij (* + _)qn+1ij = (*_qnij + _(zy)nij ) + (Enij \Gamma Rnij)(Rq)nij zn+1ij = _znij \Gamma ((px)nij + (qy)nij) The equations, as written, illustrate a Jacobi update scheme. Other schemes such as simultaneous overrelaxation (SOR) may be implemented by using current values on the right hand side of the equation or local averages rather than old values. In addition, Horn has argued that it is beneficial to use a local linear approximation of the reflectance map in order to avoid local minima of the criterion function. Many more details and suggestions are given by Horn [42]. The next section overviews a method for avoidance of gradient field decoupling based on the use of discrete approximations of the derivative. 42 3.5.3 Discrete approach The direct approach or discrete approach to shape from shading was proposed by Leclerc and Bobick [52] as a method of completely avoiding the problem of gradient field decoupling by defining the criterion function directly in terms of the height field. This section describes a shape from shading algorithm that is based on the direct height from shading method of Leclerc and Bobick [52] but which incorporates the derivative calculations based on offset grids given in Horn [42]. In addition, the method presented here contains additional penalty terms designed to prevent decoupling of adjacent surface elements. The resulting hybrid method has been found to perform better than either foregoing method and can be easily converted into a multiple light source method as is done in chapter 6. In the direct height from shading method of Leclerc and Bobick the surface height (or depth) is represented as a discrete array fzijg and the objective function to be minimized is given by Q = X ij (1 \Gamma fl)(E ij \Gamma R(pij ; qij))2 + fl(u2ij + v2ij) where E is the image irradiance, R is the reflectance function, and p; q; u and v are functions of the surface height variables fzijg. The variables, p and q are approximations to the derivatives zx and zy respectively. The variables u and v are approximations to the second derivatives zxx and zyy respectively. The parameter fl is used to control the amount of smoothing and is treated as a continuation parameter that is gradually reduced to zero. For simplicity, the albedo is assumed to be unity. In the original formulation, p; q; u and v are the symmetric first and second finite differences of the surface height variables, fzijg: pij = 12 (zi+1;j \Gamma zi\Gamma 1;j) qij = 12 (zi;j+1 \Gamma zi;j\Gamma 1) uij = zi+1;j \Gamma 2zi;j + zi\Gamma 1;j vij = zi;j+1 \Gamma 2zi;j + zi;j\Gamma 1 43 The above formulation lends itself to efficient numerical solutions as has been confirmed in our laboratory. In addition, it has been found to be very stable in comparison with algorithm of Horn which seems sensitive to image noise and errors in the light source direction. Unfortunately, the particular choice of derivative approximations leads to unnecessarily large errors in the final surface estimate. These errors result from the use of the symmetric finite difference approximation to the first derivative. The symmetric first finite difference, as written above, does not contain information about the relative heights of adjacent grid elements. In one dimension, this results in two independent chains of height estimates that do not communicate with each other. In two dimensions, there are four independent sets of estimates arranged in disconnected grids. The smoothing term does contain information about the relationships between adjacent pixels so that when the smoothing parameter is large, the method works reasonably well. However, as the smoothing term approaches zero a pattern of alternating dark and light colored pixels, a "checkerboard" pattern, emerges in the reconstructed image. Even for relatively large values of the smoothing parameter, ridges may develop in the depth map. To avoid the difficulties associated with symmetric differences mentioned above, the derivative approximations of Horn [42], based on staggered grids, are used here and a `twist error' is introduced. The quantities pij ; qij and Eij are defined on a grid that is aligned with the input image. The quantities zij; uij and vij are defined on a grid that is one row and one column larger than the input image and offset by one half pixel. In this case, the definitions of the derivatives are, pij = 12 (zi+1;j+1 + zi+1;j \Gamma zi;j+1 \Gamma zi;j) qij = 12 (zi+1;j+1 \Gamma zi+1;j + zi;j+1 \Gamma zi;j) uij = 12 (pi;j + pi;j\Gamma 1 \Gamma pi\Gamma 1;j \Gamma pi\Gamma 1;j\Gamma 1) vij = 12 (qi;j \Gamma qi;j\Gamma 1 + qi\Gamma 1;j \Gamma qi\Gamma 1;j\Gamma 1) Note that because the smoothing term was never a problem, it is still possible to use the definitions of u and v given by Leclerc and Bobick. 44 In the modified version of the direct height from shading method the objective function to be minimized is given by Q = X ij (1 \Gamma fl)(Eij \Gamma R(pij ; qij))2 + fl(u2ij + v2ij + t2ij) where t is a 'twist error'. The 'twist' is defined by ti;j = zi;j \Gamma zi;j+1 \Gamma zi+1;j + zi+1;j+1. The gradient of the objective function is given by the following expression @Q @zi;j = \Gamma 2(1 \Gamma fl) 0X k=\Gamma 1 0X l=\Gamma 1( Ei+k;j+l \Gamma Ri+k;j+l) @Ri+k;j+l@z i;j + 2fl 0X k=\Gamma 1 0X l=\Gamma 1 ui+k;j+l @ui+k;j+l@z i;j + v i+k;j+l @v i+k;j+l @zi;j + ti+k;j+l @ti+k;j+l @zi;j where Rij is an abbreviation for R(pij ; qij). Evaluating the partial derivatives of the reflectance function yields, @Ri\Gamma 1;j\Gamma 1 @zi;j = 1 2 (Rp)i\Gamma 1;j\Gamma 1 + 1 2 (Rq)i\Gamma 1;j\Gamma 1 @Ri\Gamma 1;j @zi;j = 1 2 (Rp)i\Gamma 1;j \Gamma 1 2 (Rq)i\Gamma 1;j @Ri;j\Gamma 1 @zi;j = \Gamma 1 2 (Rp)i;j\Gamma 1 + 1 2 (Rq)i;j\Gamma 1 @Ri;j @zi;j = \Gamma 1 2 (Rp)i;j \Gamma 1 2 (Rq)i;j where Rp and Rq are the partials of R with respect to its arguments, (Rp)ij means Rp(pij ; qij) and (Rq)ij means Rq(pij ; qij). The derivatives of u, v, and t may be represented by the following stencils, @ui+k;j+l @zij = 1 4 \Theta 1 -2 1 2 -4 2 1 -2 1 @vi+k;j+l @zij = 1 4 \Theta 1 2 1 -2 -4 -2 1 2 1 @ti+k;j+l @zij = 1 4 \Theta 1 -1 -1 1 The shape from shading method described in this section has been found to be faster and more reliable than the method of Horn and more accurate than the method of Leclerc and Bobick, requiring only two or three iterations to reduce fl to its minimum value. However, its performance on many images of real scenes is not robust. 45 3.5.4 Optimal control and related approaches An optimal control approach to shape from shading has been proposed by Dupuis and Oliensis [23] and a similar approach has been proposed by Rouy and Tourin [83]. A generalized and simplified approach has been proposed by Bischel and Pentland [8]. The optimal control approach is closely related to the method of characteristic strips and is considerably more robust than the approaches mentioned previously. 3.5.4.1 Optimal control approach Dupuis and Oliensis examined the case of illumination coincident with the viewing direction. If the albedo is assumed to be equal to one and the surface is assumed to be Lambertian, the image irradiance equation becomes, E(x; y) = R(p; q) = 1p1 + p2 + q2 In this special case, the gradient of the reflectance map is proportional to the gradient of the surface height function, making a solution easier. More precisely, Rp = \Gamma p(1 + p2 + q2)3=2 Rq = \Gamma q(1 + p2 + q2)3=2 In section 3.5.1 it was shown that the characteristic strips could be found by setting .x = Rp and .y = Rq. Since the derivative is with respect to an arbitrary parameter, the equations can be rescaled so that given the above definition of R the characteristic strips are given by .x = \Gamma p and .y = \Gamma q. This identification motivates a particular choice of cost function for the optimal control formulation of the solution. As a first step, it is useful to rearrange the image irradiance equation, placing it in eikonal form, V (x; y) j 1(E(x; y))2 \Gamma 1 = (rz(x; y))2 where V (x; y) is defined as a function of the image irradiance. Now consider a `particle' initially located at (x; y) moving in the image plane in response to control parameters 46 (u; v) according to .x = u and .y = v. It should be clear that with the proper scaling, u = \Gamma p and v = \Gamma q. The control parameters and thus the gradient of the surface are chosen to minimize a cost function for the trajectory of the particle, U (x; y; o/ ) = inf(u;v) ae 12 Z o/ 0 u 2(t) + v2(t) + V (x(t); y(t))dtoe where the infimum is over all piecewise continuous functions, u; v, on [0; o/ ]. The reason for the above choice of cost function is that this particular cost function can be identified with the surface height function, as shown below. Therefore, a dynamic programming solution of the optimal control problem results in a solution for the surface height function. The optimal control at time zero, t = 0, can be found by considering an infinitesimal part of the trajectory starting at time zero. Let ffio/ be small. Then the minimum cost function can be written U (x; y; o/ ) = inf(u;v) ( 12 Z ffio/ 0 u 2(t) + v2(t) + V (x(t); y(t))dt + U (x(ffio/ ); y(ffio/ ); o/ \Gamma ffio/ )) The first term is the infinitesimal cost incurred during the time 0 ^ t ^ ffio/ while the second term is the cost incurred for the rest of the trajectory. Expanding the above to first order and taking the limit as ffio/ ! 0 yields @U (x; y; o/ ) @o/ = inf(u(0);v(0)) ( 1 2 (u 2(0) + v2(0) + V (x; y)) + @U (x; y; o/ ) @x u(0) + @U (x; y; o/ ) @y v(0)) where u(0) and v(0) are the values of the controls at time zero. The optimal controls are found by performing the indicated minimization which yields u(0) = \Gamma @U (x; y; o/ )@x , v(0) = \Gamma @U (x; y; o/ )@y and @U (x; y; o/ ) @o/ = 1 2 24V (x; y) \Gamma @U (x; y; o/ ) @x ! 2 \Gamma @U (x; y; o/ ) @y ! 235 The final equation is beginning to look very much like the image irradiance equation. To eliminate the time dependency, define U (x; y) = limo/!1 U (x; y; o/ ) 47 Then, the above equation becomes @U (x; y) @x ! 2 + @U (x; y)@y ! 2 = V (x; y) which is identical to the image irradiance equation. Therefore, as the time gets large, the cost function approaches the surface height function. Note that in view of the fact that the cost function approaches the surface height function, the limit must exist. 3.5.4.2 General approach Bischel and Pentland [8] have simplified the solution theory through the introduction of a minimum downhill principle which states that surface information is only to be passed from higher surface points to lower surface points, downhill, along those paths that lead least downhill. Here, higher and lower are defined relative to the light source in the case of single source or more generally in terms of the reflectance map. Note that given only shading information there is an ambiguity in the local surface shape at singular points (points of maximum brightness) of the image. The surface at such points may be locally convex, concave or saddle shaped. However, the method of Bischel and Pentland always chooses the solution that leads to a locally convex surface except when information is propagated towards the singularity from another singularity higher on the surface. The highest singularity is always convex. This is not necessarily a limitation since other information is always required to resolve the ambiguity. In the research reported in this thesis, stereo information is used to resolve ambiguities indirectly. For another approach to resolving ambiguities, see Oliensis and Dupuis [69]. Consider moving towards the point (x; y) from a neighboring point in the direction ss + OE. The slope oe(OE) corresponds to the directional derivative of the surface in the direction OE and is given by oe(OE) = cos(OE)p + sin(OE)q where (p; q) = (zx; zy). Initially, the gradient of the surface is unknown. Therefore, the slope in the direction OE must be chosen to fulfill the brightness equation, E(x; y) = R(p; q). If the point (x; y) has brightness, E, then (p; q) = (p(ffE); q(ffE)) for some ffE where ffE parameterizes the level curve at level E of the reflectance map. As shown by Bischel and Pentland [8], the choice of ffE which 48 maximizes oe(OE) = cos(OE)p(ffE) + sin(OE)q(ffE) leads to the correct surface shape. The slope is always a positive distance from the peak of the reflectance map, ensuring algorithm convergence. Applying the minimum downhill principle and propagating information from neighboring points towards (x; y) the update equation for the surface becomes, zt+1(x; y) = sup OE [z t(x + ds cos(OE); y + ds sin(OE)) \Gamma dsoe(OE)] at every point except those singular points that are specified in advance. In order for the surface to remain consistent, the height of a singular point is allowed to increase or remain fixed but not decrease. The height of a singular point can increase only if there is another singular point that is higher on the surface. From the update equation, it is clear that z must always be lower than at least one neighbor. Therefore, the maximum height of the surface is bounded by the height of the highest singular point. Again, height is specified relative to the maximum of the reflectance map. One drawback of the optimal control approach and other related approaches is that it is difficult to enforce boundary conditions even when they are known. Moreover, it is difficult to combine this approach with information from other modules of an integrated system. One solution is given in chapter 7. 3.5.5 Other approaches There are also other approaches to the recovery of shape from shading which depend upon simplifying assumptions such as restrictions on surface shape and restrictions on the form of the reflectance map. Often, these restrictions are applied only locally, leading to more general iterative techniques. In all of the previously reported methods, it was necessary to integrate one or more differential equations to obtain a surface. The reason for this requirement is that shading information does not completely constrain the local orientation of a surface. However, Pentland [74], Lee and Rosenfeld [54], and Ferrie and Levine [24] have shown that under 49 various restrictions on the admissible surface shape, the surface is completely constrained by local information. Methods of local shading analysis are based on the that fact. Pentland [74] showed that under the assumption of local sphericity, the assumption that the principle curvatures are equal, it is possible to recover the orientation, albedo, and light source direction, at any given point of a Lambertian surface from the image intensity and its first and second derivatives at that point. Lee and Rosenfeld [54] have shown that for a Lambertian surface two surface points have the same tilt in the light source coordinate system if and only if their corresponding image gradients are the same. In addition, expressions were derived for the albedo and the slant and tilt directions that involve only the first derivatives of the image intensity. Ferrie and Levine [24] have shown that if the light source direction and albedo are known, it is possible to recover the orientation of the surface at any given point from the image intensity and its first derivatives whenever the following condition holds, f 2u \Gamma f 2v fufv = fuu \Gamma fvv fuv In this equation, (u; v; w = f ) are coordinates related to (x; y; z) by a rotation that causes w to point in the light source direction. Under the assumption that the albedo and source intensity are both unity, it can be shown that under the above assumption, the slant is given by oe = cos\Gamma 1(I) and the tilt is in the same direction as the gradient of I. Once the orientation of the surface has been computed at each point, various methods may be used to obtain a surface height map. Various authors have also considered restrictions on the form of the reflectance map. In particular, the case in which the reflectance map is linear in the surface gradient, R(p; q) = a + bp + cq, has been extensively studied [37]. Recently, Pentland [75, 76] has shown that this problem can be conveniently solved using Fourier techniques. A more general technique is based on the assumption that the surface can be locally modelled by a linear sum of basis functions. Pong, Haralick, and Shapiro [79] have used a local quadratic surface model in an approach that leads to a nonlinear optimization problem that can be solved by the Marquardt method. Lee and Kuo [56, 57] have 50 developed a solution in which a linearized version of the equations is repeatedly solved on a triangular mesh to iteratively reach a solution. Most existing techniques for obtaining shape from shading assume the existence of a single smooth surface. However, recent work by Malik and Maydan [61] has sought to generalize the solution to piecewise smooth surfaces. This work attempts to bridge the gap between the type of line drawing interpretation introduced by Waltz [94] and shape from shading. 3.6 Conclusions This chapter has overviewed basic radiometric theory and some of the more common methods for making use of that theory for estimation of the light source direction and surface shape. It can be seen from an examination of the methods presented in this chapter that there are still many unanswered questions. Up to this point, no mention has been made of methods for estimating the types of complex lighting distributions that occur in the real world. Nor has anything been said about estimation of the surface reflectance function or reflectance map. A treatment of these problems is given in the following chapters. 51 4 RESOLUTION AND ACCURACY 4.1 Introduction Algorithms for three-dimensional shape estimation can be compared on the basis of the resolution and accuracy that they provide. Resolution is a measure of the amount of sensor area that is available to represent a given amount of area in the scene. It varies with the distance to the scene and is important for quantifying the amount of geometric distortion introduced by multiple image methods such as stereo and motion. Such methods rely upon multiple views of a scene in which the resolution may vary as a function of position leading to a lower effective resolution. This chapter contains derivations of expressions for the effective resolution obtained by single and multiple view methods. It is shown that the resolution of all methods decreases at an asymptotically quadratic rate but that effective resolution of stereo and related methods also approach zero as the base angles are reduced to zero. Consequently, the optimal resolution is obtained for some finite depth which is derived. Accuracy is taken to be the inverse of the expected error magnitude. The accuracy of stereo, motion and focus methods has previously been studied by several researchers. McVey and Lee [64] showed that accuracy decreases at an approximately quadratic rate for the case of parallel cameras. Verri and Torre [93] showed through a series of approximations, that accuracy decreases with the square of depth in the nonparallel case. Blostein and Huang [11] considered quantization error and derived an expression for the error distribution for a pair of parallel stereo cameras. Rodr'iguez and Aggarwal [81] derived an expression for the expected value of the range error. Das and Ahuja [20] derived accuracy results for stereo, vergence, and focus methods. Bajcsy, Krotkov, and Mintz [4] also derived stereo and focus accuracy results. 52 All of the above results can be seen with some manipulation to be consistent with inverse square laws for stereo and focus accuracy. However, not all of the results are intuitively accessible or completely general. In this paper, it is shown that the quadratic decrease in the accuracy of stereo and focus methods is an easy consequence of the depth estimation equations. In addition, it is shown that for stereo the expected error does not monotonically decrease with increasing baseline so that an optimal baseline exists for a given application. These results are compared with the accuracy of shading which decreases at a linear rate with distance. 4.2 Resolution Resolution in three-dimensions is the amount of image area that corresponds to a unit area of a scene. However, it is instructive to first consider a two-dimensional equivalent, the length of a line in the image that corresponds to a line of unit length in a scene. 4.2.1 Resolution for a single camera in two dimensions Figure 4.1 shows the viewing geometry for a single camera in two-dimensions. The image plane is represented as a `nearly' straight line and a pair of viewing rays delineate the ends of a short segment tangent to the scene. The viewing rays intersect the image in points separated by a distance ffiI. The corresponding object segment has length ffiO. The focal length of the camera is f and the distance to the object is z. The angle between the viewing rays is ffi and ` is the angle between the first viewing ray and a normal to the surface. For real cameras, the solid angle subtended by the aperture is generally small. As a consequence, the angle between any given viewing ray and the optic axis is also small. Because the sine of a small angle is nearly equal to that angle the resolution at the center of the image is representative of the entire image. Therefore, a satisfactory approximation in two dimensions may be obtained by setting ffiI = f ffi. 53 d Od + dz y z d I ff z q Figure 4.1 Resolution in two dimensions. A line on the object of length ffiO is projected to a line of length ffiI in the image. If the camera aperture is small, then the image plane may be treated as a spherical section. Using the above relation and the fact that for a small angle ffi the relationship ffiO cos(`) = zffi is approximately valid, it is possible to write @I @O = f cos(`) z which is exact in the limit of infinitesimal ffi. The above expression is the resolution for a particular scene geometry. To obtain the mean resolution, some assumption about typical scene characteristics must be made. A reasonable assumption in the absence of other information is that surface facets are randomly distributed over all orientations. Since half of the orientations correspond to surface facets that cannot be viewed because their normals are more than 90o from 54 the viewing direction, it is simpler to restrict consideration to those facets which are viewable. Later, the overall resolution can be divided by a factor of two if desired. For the two-dimensional case under consideration the mean resolution is given by R = @I@O = 1ss Z ss=2 \Gamma ss=2 f cos(`)d` z = 2f ssz 4.2.2 Resolution for stereo cameras in two dimensions In a stereo camera arrangement, the resolution of the two identical cameras will be different. Since, the maximum frequency at which features can be resolved is determined by the minimum of the resolutions of the two cameras, it makes sense to take as the resolution the quantity @I @O = min( f sin(fiL \Gamma `) zL ; f sin(fiR + `) zR ) where the minimum is over positive arguments. For simplicity, assume that the camera base angles are the same. This will make it possible to derive the mean resolution for an object located on the bisector of the baseline. Given that fiL = fiR = fi, the resolution becomes @I @O = f sin(fi) z min(sin(fi \Gamma `); sin(fi + `)) which may be written @I @O = f sin(fi) z 8???????? !????? ???: 0 if ` ^ \Gamma fi sin(fi \Gamma `) if \Gamma fi ^ ` ^ 0 sin(fi + `) if 0 ^ ` ^ fi 0 if fi ^ ` The mean resolution may be computed as above. Since the integral is symmetric, it can be evaluated on either set of limits. For the lower set of limits, the mean resolution is given by RS = @I@O = 2f sin(fi)ssz Z 0 \Gamma fi sin(fi \Gamma `)d` = 2f sin(fi)ssz (1 \Gamma cos(fi)) 55 Rewriting in terms of the baseline, B, and depth, z, yields RS = 2fssqz2 + B2=4 0@1 \Gamma B=2qz2 + B2=4 1A From this expression it can be seen that the two-dimensional, horizontal resolution decreases linearly with depth for large values of z and also goes to zero as z goes to zero. By setting @RS=@z = 0 it is possible to show that RS is maximized when z = p3B=2 which corresponds to a base angle, fi = 60o, or an apex angle, ff = 60o. The maximum value of RS is RS = f =(ssB). At the same distance, a single image technique has a resolution, R = 4f =(p3ssB). Consequently, the resolution of the single image technique is more than twice that of the stereo technique at the point of maximum resolution for the latter. 4.2.3 Resolution for a single camera in three dimensions Let \Omega be the solid angle subtended by a surface patch, ffiO, which projects to an image region, ffiI. Again, assume that the angle between the viewing ray and the optical axis is small so that ffiI = f 2\Omega . Further, for a small solid angle, \Omega it is possible to show that ffiO cos(`) = z2\Omega so that @I @O = f 2 cos(`) z2 holds in the limit of infinitesimal \Omega . If surface facets are distributed randomly over all visible orientations then the mean resolution is given by R = @I@O = f 2 2ssz2 Z 2ss 0 Z ss=2 0 cos(`) sin(`)d`dOE = f 2 2z2 This result is very similar to that obtained in the two-dimensional case. However, the resolution now decreases quadratically with distance. 4.2.4 Resolution for stereo cameras in three dimensions Calculation of the stereo resolution in three dimensions proceeds in the same manner as in the two dimensional case. However, the geometry is somewhat more complex. 56 f q~ b ~ ~ bz v Figure 4.2 Visible hemisphere. The lightly shaded section is invisible to the viewer. The dark section is a spherical triangle used to determine the relations between the relevant angles. The diagram in figure 4.2 shows the hemisphere of surface normal directions that are visible from a camera with optical axis coincident with the z-axis of the world coordinate system. If the view vector is equal to v for some v not equal to z, then part of the original hemisphere will no longer be visible. The lightly colored sector of the hemisphere illustrates the region that is visible from z but not from v. The rest of the hemisphere is visible from both z and v. If the two cameras are displaced equally in opposite directions, then equal sectors will be removed on opposite sides of the hemisphere. The view vector v corresponds to a particular base angle, fi, shown as the arc between z and the lightly shaded sector. If fi = 90ffi, v is coincident with z. If fi = 0ffi, then v is perpendicular to z. In order to calculate the resolution, it is convenient to consider the spherical triangle shown as the darkly shaded region of the hemisphere. The spherical 57 triangle has sides, ~fi; ~`; ss=2 and a relevant internal angle, ~OE where ~fi = ss=2 \Gamma fi. The angle, ~` is the integration limit used in the subsequent calculation and delineates the nonoccluded portion of the hemisphere. The angle, OE = ss \Gamma ~OE is the other integration variable. Using a law of cosines for spherical triangles, it is possible to write cos(ss=2) = cos( ~fi) cos(~`) + sin( ~fi) sin(~`) cos( ~OE) After some manipulation, this reduces to tan(~`) = cos(OE) cot( ~fi) As previously, it is only necessary to evaluate half of the symmetric integral. In this case the resolution is given by RS = @I@O = f 2 sin2(fi) ssz2 Z ss=2 \Gamma ss=2 Z ~` 0 cos(`) sin(`)d`dOE After some lengthy manipulations, it is possible to show that this reduces to RS = f 2 2(z2 + B2=4) 0@1 \Gamma B=2q z2 + B2=4 1A This is similar to the result obtained in the two-dimensional case. Setting @RS@z = 0 it is possible to show that RS is maximized when z = p5B=4 which corresponds to a base angle, fi = 29:2o, or an apex angle, ff = 121:6o. The maximum value of RS is RS = 8f 2=(27B2). At the same distance, a single image technique has a resolution, R = 8f 2=(5B2) which is nearly 5 times as great. Although the performance rates are more comparable at larger distances, the rapid increase in the expected error magnitude for stereo more than cancels out any relative gain in resolution. 4.3 Accuracy There are two aspects to calculation of the expected error magnitude of a given method. First, the source of the errors in terms of quantization limits and errors and spatial sampling rate must be examined. Then the effect of such errors on the algorithm 58 performance must be calculated. This chapter covers the latter aspect of the problem. Determining the source of the errors is necessary for making absolute comparisons but is not required for determining the behavior of the various algorithms. 4.3.1 The accuracy of focus based methods The basic equation relating depth to the focus parameters of a camera is usually written, 1 z + 1 v = 1 f where z is the distance from the first principle plane to the object, v is the distance from the second principle plane to the image plane when the object is in sharp focus and f is the focal length of the lens. Errors in estimating depth from focus arise from errors in knowledge of the focal length, f , and errors in calculation of the sharp focus distance v. Errors in f are generally not serious as such errors are systematic and can be removed by careful calibration. Moreover, such errors are consistent across an image and therefore do not cause shape errors but rather just an overall error in depth. Conversely, however, errors in v are caused by failure to correctly determine the point of maximum image sharpness and are therefore critical to the functioning of any focus based shape estimation method. Solving the basic equation for the depth gives z = f vv \Gamma f Using this equation and ignoring errors in the focal length, the error magnitude is given by \Delta z = @z@v \Delta v = \Gamma f 2 (v \Gamma f )2 \Delta v To make this result more intuitive, it is useful to eliminate v, leaving the result in terms of z and f . From the basic equation, it can be seen that v = f z=(z \Gamma f ) so that the error magnitude can be rewritten as \Delta z = \Gamma (z \Gamma f ) 2 f 2 \Delta v 59 ~a 0v v\Delta A r v a Figure 4.3 Radius of the blur circle. A lens with aperture A produces a blur circle of radius r when image plane is shifted a distance \Delta v from the sharp focus distance. In order to eliminate \Delta v, note that \Delta v can be written in terms of quantities that can be measured in the image. Specifically, \Delta v is related to the error that occurs in estimation of the point at which the radius of the blur circle is zero. This is the point at which the criterion function used to determine focus is maximized. So it is useful to relate the error in v to the radius of the blur circle. Figure 4.3 illustrates the relationship between the radius of the blur circle and \Delta v for a lens with aperture of size A. Using similar triangles and referring to the figure, it can be seen that tan( ~ff) = r\Delta v = A2v 60 where v = v0 + \Delta v and v0 is the distance at which the radius of the blur circle is zero. Solving for v yields v = v01 \Gamma 2r=A Using the fact that v0 = f z=(z \Gamma f ), the error in v can be written \Delta v = @v@r \Delta r = 2f zA(z \Gamma f ) \Delta r for r = 0. Therefore, the error in z due to an error in determining the point at which the blur circle has radius zero is given by \Delta z = 2 zf \Gamma z 2 Af \Delta r It can be seen that the error is proportional to z2 but inversely proportional to the size of the aperture and the focal length. 4.3.2 The accuracy of stereo based methods In the case of focus, the principle error measure is the error in depth, \Delta z. However, in the case of stereo, errors in x and y are also important, especially if the baseline is very large. The errors in each coordinate are derived in the following section. Following that is a derivation of the optimal accuracy. 4.3.2.1 Positional errors The accuracy of stereo based methods depends upon the accuracy to which features can be localized in the two images. Let \Delta XL; \Delta YL; \Delta XR; \Delta YR be the errors in the left and right images. If the aperture of the camera is small or if attention is restricted to the region near the center of the image, then there is a simple relationship between the image errors and the errors in the directions of the viewing rays. Figure 4.4 shows the geometry for a camera system in which rotation about the tilt axis of the two cameras is coupled, yielding a single rotation angle, ', but the vergence angles are free to change separately and are denoted fiL and fiR. In this case, the vergence angle errors are given in terms of the horizontal image errors by \Delta fiL = \Delta XL=f 61 ~ ~ z z b b z z R L R L a Top View x B y Side View z j Figure 4.4 Stereo imaging geometry. The focal points of the cameras are separated by a baseline of length B. The base angles of the left and right cameras are fiL and fiR respectively and the entire head is tilted at an angle OE. 62 and \Delta fiR = \Delta XR=f where f is the focal length of the cameras which are assumed to be identical. The error in the tilt angle is related to the vertical image errors by \Delta ' = (\Delta YL + \Delta YR)=(2f ). Using the above relations, it is possible to derive formulas for the errors in the spatial position coordinates, (x; y; z). It can be seen from the figure that x = B cos(fiL) sin(fiR)sin(fi L + fiR) y = B sin(fiL) sin(fiR) cos(')sin(fi L + fiR) z = B sin(fiL) sin(fiR) sin(')sin(fi L + fiR) From this, the errors in each of the three coordinates may be calculated. Taking them in order, \Delta x = @x@fi L \Delta fi L + @x@fi R \Delta fi R = B(\Gamma sin(fiR) cos(fiR)\Delta fiL + sin(fiL) cos(fiL)\Delta fiR)(sin(fi L) cos(fiR) + sin(fiR) cos(fiL))2 = \Gamma " x 2(B \Gamma x) Bpy2 + z2 + (B \Gamma x)py2 + z2 B # \Delta XL f + " x(B \Gamma x) 2 Bpy2 + z2 + xpy2 + z2 B # \Delta XR f The final expression has been written in terms of the spatial position coordinates in order to make intuitively clear the way in which the error changes as a function of spatial position. From the above expression, it can be seen that the error in x increases rapidly, ie., at a rate proportional to x3, for points far from the bisector of the baseline. In addition, the error in x increases linearly with py2 + z2 for large py2 + z2 and is proportional to 1=py2 + z2 when py2 + z2 is small. Calculation of the error in y yields the following, \Delta y = @y@fi L \Delta fi L + @y@fi R \Delta fi R + @y@' \Delta ' = ypy2 + z2 " x 2 + y2 + z2 B ! \Delta XL f + (B \Gamma x)2 + y2 + z2 B ! \Delta XR f # \Gamma z \Delta YL + \Delta YR2f ! 63 From this it can be seen that in general the error in y is proportional to x2 for large x, proportional to y2 for large y, and proportional to z3=2 for large z. Calculation of the error in z yields the following, \Delta z = @z@fi L \Delta fi L + @z@fi R \Delta fi R + @z@'\Delta ' = zpy2 + z2 " x 2 + y2 + z2 B ! \Delta XL f + (B \Gamma x)2 + y2 + z2 B ! \Delta XR f # +y \Delta YL + \Delta YR2f ! From this expression it can be seen that the error in z is proportional to x2 for large x, proportional to y3=2 for large y and proportional to z2 for large z. Further insight into the above results can be gained by looking at the case in which the scene point is assumed to lie on the line x = B=2; y = 0. In this case the errors reduce to \Delta x = " B 2 8z + z 2 # \Gamma \Delta XL + \Delta XR f ! \Delta y = \Gamma z \Delta YL + \Delta YR2f ! \Delta z = " B4 + z 2 B # \Delta XL + \Delta XR f ! From this it can be seen that the error in x is proportional to z for large z and inversely proportional to z when z is small. The error in y is proportional to z. The error in z is proportional to z2 for large z. In addition, it should be noted that the error in x is proportional to B2 for large B or small z and the error in z is proportional to B for large B but inversely proportional to B for small B. Therefore, the baseline should be neither too large nor too small for the given application. 4.3.2.2 Optimal accuracy In order to derive the optimal accuracy, an overall error measure is required. Two obvious choices are the mean squared error and the minimax, expected squared error. 64 Let the errors, \Delta XL; \Delta YL; \Delta XR; \Delta YR be independent and identically distributed with variance oe2. Define, "2 = (\Delta x)2 + (\Delta y)2 + (\Delta z)2. Then, restricting attention to the case in which x = B=2; y = 0, the mean squared error is given by h"2i = " B 2 8z + z 2 # 2 2oe2 f 2 + z2oe2 f 2 + " B 4 + z2 B # 2 2oe2 f 2 The depth at which stereo accuracy is maximized is found by solving 0 = @h" 2i @z = 4oe2 f 2 " \Gamma B2 64z3 + 5z 4 + 2z3 B2 # for z. The solution is, z = qp2 \Gamma 1B=2 ss :322B. This corresponds to an apex angle of approximately 114:5ffi and indicates that a very large base is desirable to minimize errors and thus maximize accuracy. However, this result ignores the effects of occlusions and problems with feature matching in the presence of highly sloped surfaces and is primarily of interest for cases in which a few easily distinguishable features are available for matching. The minimax expected squared error is the minimum length attained by the longest axis of the error ellipsoid. If attention is restricted to the case in which x = B=2; y = 0, then the axes of the error ellipsoid are aligned with the coordinate axes and the calculation is reduced to finding the value of z for which the maximum of h(\Delta x)2i; h(\Delta y)2i and h(\Delta z)2i is minimized. The component errors are given by h(\Delta x)2i = " B 2 8z + z 2 # 2 2oe2 f 2 h(\Delta y)2i = z 2oe2 f 2 h(\Delta z)2i = " B4 + z 2 B # 2 2oe2 f 2 The minimum values of h(\Delta y)2i and h(\Delta z)2i are zero and occur at z = 0. The minimum value of h(\Delta x)2i occurs when z = B=2 and is equal to B2oe2=2. At this value of z, h(\Delta y)2i = B2oe2=4 and h(\Delta z)2i = B2oe2=2 so that the maximum dimension of the error ellipsoid is B2oe2=2. Therefore, the minimax error occurs when z = B=2. It is clear that at this depth, the projection of the error ellipsoid onto the x-z plane is a circle. In 65 addition, it should be noted that this error occurs when the apex angle, ff, is 90 degrees. Therefore, the minimax positioning error occurs when the cameras are placed at equal distances from the target and face orthogonal directions. Again, it should be noted that this result is of primary use when the features are well defined. Matching accuracy is likely to be low in the presence of occlusions and feature distortion that occur when the cameras are viewing the scene from significantly different directions. 4.3.3 The accuracy of shading based methods Although the assumption of orthographic projection is usually made for shape from shading algorithms, it is necessary to consider the full perspective equations in order to analyze the dependency of shading errors on depth. In the case of perspective projection, Horn [36] has shown that the image irradiance equation may be written, F (x; y; z; p; q) = 0 where (p; q) = (zx; zy) is the gradient of the surface height function, z(x; y). The solution to this differential equation may be written, .x = Fp .y = Fq .z = pFp + qFq .p = \Gamma Fx \Gamma pFz .q = \Gamma Fy \Gamma qFz where differentiation is with respect to a parameter that varies along the characteristic strip. Combining the expressions for .x and .y with the expression for .z yields the following expression for the variation of the height along the characteristic curve, .z = p .x + q .y = zf (p .X + q .Y ) where the upper case coordinates are image coordinates. This is nothing more than a statement of the fact that projection of a characteristic strip into the image depends upon the perspective transformation. Let (\Delta p; \Delta q) be the error in the gradient of the 66 surface and (\Delta .X; \Delta .Y ) be the error in the characteristic curve. Then, the error in the height is given by, \Delta .z = zf (p\Delta .X + q\Delta .Y + .X \Delta p + .Y \Delta q) which is proportional to the depth, z. From the above discussion, it can be seen that the magnitude of the expected error is proportional to the depth or, equivalently, that the relative error is constant for shape from shading algorithms. This is intuitively reasonable. The fact that shading does not give absolute depth estimates means that any shading solution that is scaled uniformly is still a solution. Therefore, the absolute error magnitude is proportional to the scale and hence to the depth of the surface. 4.4 Conclusions This chapter has compared the resolution and accuracy of stereo, focus and shading methods. It was shown that the resolution of all methods decreases at an asymptotically quadratic rate in the depth, z. However, it was also shown that the resolution of stereo has a maximum for some nonzero value of the base angles and that it goes to zero as the base angles, and hence the depth, goes to zero. Neither focus nor shading methods suffer from this problem. The accuracy of all methods was shown to decrease as a function of increasing depth. However, it was shown that the accuracy of stereo and focus methods decreases with the square of depth while that of shading decreases at a linear rate. In addition, stereo accuracy is maximized at some nonzero depth and goes to zero as the target distance goes to zero. Neither focus nor shading methods suffer from this problem. Of the three methods studied, shape from shading has the best asymptotic properties. 67 5 INTEGRATION OF STEREO AND SHADING 5.1 Introduction Previous chapters have discussed the basic theory of stereo and shading methods and compared their accuracy and resolution. This chapter addresses the issue of integrating the foregoing methods for the purpose of obtaining more accurate estimates of surface shape. There are several ways in which stereo and shading information can be combined in a comprehensive approach to surface estimation. Indeed, several approaches have been examined in the course of the research reported in this thesis. Similar approaches have been proposed by Leclerc and Bobick [52] and Fua and Leclerc [29, 30]. An approach based on frequency analysis has been proposed by Frankot and Chellappa [26] and Cryer, Tsai, and Shah [17]. Their approach is based on the observation that the low frequency components of the stereo result tend to be more accurately determined than the low frequency components of the the shading result and, conversely, that the high frequency components of the shading result tend to be more accurately determined than than the corresponding components of the stereo result. Integration of stereo and shape from shading has several advantages [12, 9, 52]. The initial depth estimate provided by stereo can be used to provide an estimate of the lighting and reflectance that are required by shape from shading, thus eliminating the need for human intervention. Stereo systems can operate in highly textured regions and at the boundaries between different colored regions where shape from shading systems cannot operate. Conversely, shape from shading methods can be used in large featureless regions where stereo methods are inaccurate. Therefore, an integrated system has the potential of operating under a wider range of conditions than either stereo alone or shape from shading alone. 68 For stereo systems, errors in surface shape are locally large but are independently distributed so that global errors in surface shape are not cumulative. Conversely, shape from shading can be quite accurate in resolving small variations in surface shape if the lighting and surface properties are known. Therefore, integration presents the possibility of obtaining both global accuracy and high resolution. In order for shape from shading to be useful in an integrated system, the problem of albedo variations must be addressed. In most real scenes, including those containing features that are useful for stereo vision, the albedo is not uniform. However, existing shape from shading algorithms require that the albedo be uniform. To circumvent this problem, it is assumed that the surfaces in the scene are composed of regions of piecewise constant color and albedo and can be described by a single reflectance function Based on the above assumptions, images may be segmented into regions of uniform albedo by segmenting them into regions of uniform color. Segmentation using color is more reliable than segmentation along gray level boundaries because color and albedo boundaries generally correspond to material boundaries but gray level boundaries often occur as the result of significant variations of surface geometry, e.g., at a bend or crease in a surface. The rest of this chapter describes a method for estimating surface shape that involves the integration of the information provided by stereo with that provided by shape from shading. The combined method is designed to make use of the complimentary aspects of ordinary stereo and shape from shading to overcome the limitations of the individual methods. 5.2 Algorithmic Considerations This section describes some typical methods by which stereo and shape from shading are integrated. The first algorithm, illustrated in the form of a block diagram shown in figure 5.1, is composed of five main steps: (1) Initial estimation of the depth map using stereo. (2) Segmentation of the image into regions of uniform color. (3) Estimation of 69 Surface Shape Stereo Albedo Source Shape Source Image ImageImage ImageCamera Camera Depth Map ReflectivitySegmentation Segment Figure 5.1 Data flow diagram one. A pair of cameras produce images for the stereo module which produces an initial depth map. One image is segmented and the albedos of the regions are computed. The initial depth map, segmentation, and albedo are used in the computation of the light source direction and magnitude. The final shape is estimated from the image using all of the previously calculated results as inputs. 70 the albedo of each region. (4) Estimation of the light source direction. (5) Improved estimation of the surface shape using shape from shading. The above algorithm is designed to operate on images in which all regions have a known common reflectance function. The only difference between the various regions is the albedo or reflectivity constant. Moreover, the reflectance function is assumed to be explained by a single distant or collimated light source. In addition, it is assumed that the regions form a single continuous surface. These assumptions are relaxed in other versions of the algorithm. In chapter 6, which discusses a method for estimation of the light source distribution, the only change made to the algorithm described above is the substitution of a source distribution estimation module for the single source estimation module used above. Figure 5.2 illustrates an algorithm very similar to that described above which is obtained by the addition of a depth segmentation module and the removal of the albedo estimation module. The depth segmentation module makes possible relaxation of the assumption that there is a single continuous surface in the scene. The albedo module is removed in favor of estimation of a separate reflectance map in each region. This is the approach taken in chapter 7, which discusses direct estimation of the reflectance map. Therefore, the diagram illustrates a system in which a general reflectance map, rather than a light source direction or distribution, is estimated in each region. All of the modules used in the various algorithms are described in the following section. 5.3 Component Algorithms This section describes the component algorithms and explains their utility in an integrated system. 5.3.1 Stereo algorithm There are several points to consider in choosing a stereo algorithm to be used in an integrated system. In order to estimate the light source direction, it is desirable to have 71 Camera Segmenter Depth Module Stereo Modeller Reflectivity Camera Region Groups Segmenter Image Surface Shape Surface Shape Shading Shapefrom Regions Regions Depthmap Regions Regions Region Groups Image Image Depthmap Depthmap DepthmapImage Image Image ReflectanceMap Figure 5.2 Data flow diagram two. A pair of cameras produce images which are used by the stereo module to produce an initial depth map. The image segmentation module produces homogeneous regions that are used by the reflectively modeller and shape from shading module. The depth segmenter finds stereo errors and depth discontinuities. The reflectively modeller produces a reflectance map for each region group. The reflectance maps are used by the shape from shading module to calculate the final shape of each region. 72 at least a crude estimate of the surface orientation for a large number of surface patches covering a large number of possible orientations. Because feature matching algorithms only produce depth at isolated points, some type of interpolation must be done before the results can be used in the light source calculation. On the other hand, some of the final depth map values will be constrained by the depth values provided by the stereo algorithm. Therefore, it is desirable to have a stereo algorithm that produces accurate results. To simplify matters, an area-comparison based algorithm, described in chapter 2 is used throughout this research. In particular, the primary match criterion is the sum of absolute differences between potentially matching regions is applied to a set of prefiltered color images in which features have been highlighted by various zero-mean interest operators. Interest operators include finite difference approximations to the Laplacian of Gaussian operator and the first partial derivatives of the image evaluated at various smoothing scales. This simple algorithm can be used to obtain reasonable results on wide variety of scenes. Keeping the algorithm simple has the virtue of making modifications easier, an important issue in the design of integrated systems [44]. Although this is a fairly simplistic algorithm, it will be seen that the final results are highly tolerant to errors in the stereo estimate of depth. Once the disparity is computed, a depth map is obtained that is aligned with one of the images which is selected arbitrarily for shape from shading analysis. 5.3.2 Image segmentation algorithm Image segmentation plays an important role in analyzing complex scenes. Regions with different reflectivity properties must be treated differently by the shape from shading algorithm. Even in the simplest case considered here, before shape from shading can be used, an image must first be partitioned into regions of uniform albedo. Moreover, as seen later, image segmentation plays an important role in identifying erroneous depth estimates. 73 For reasons that were discussed earlier, it is advantageous to use color for segmentation. A complete color segmentation algorithm must account for the presence of highlights, shadows and interreflections. For simplicity, the algorithms used in this research are designed to work on Lambertian objects. Initial research made use of a segmentation algorithm based on minimal spanning trees. The use of minimal spanning trees in segmentation was previously suggested by Suk and Cho[90]. The algorithm is defined in terms of an undirected graph G = (V; E) where V is the set of vertices and E is the set of edges. The vertices correspond to pixels and the edges join pixels to their four-connected neighbors. The length of each edge in the graph is defined to be the magnitude of the vector difference between normalized color vectors that represent the vertex pixels, d = jci=jcij\Gamma cj=jcjjj. This is a close approximation to angular separation in color space which is intensity independent. This measure is sensitive to saturation changes causing some specularities to be missed. However, a purely hue based measure is also unreliable in desaturated regions. A minimal spanning tree is built using the edges defined above. Most neighboring pixels in the minimal spanning tree should be very close in color space since they almost always belong to the same colored region. However, image noise and quantization errors cause the distance to be nonzero. Conversely, large changes in color occur only at the boundaries between regions. One estimate of the image noise level is the median edge length in the tree. Tree edges that are much more than the median edge length usually cross region boundaries and are therefore discarded. After the regions have been labelled, any `abandoned' pixels or small regions are appended to the nearest large region. In later research, including that reported in chapter 7, the algorithm of Tabb and Ahuja [91] is used to segment both images and depthmaps. The algorithm divides the input array into homogeneous regions according to a specified inhomogeneity criterion. Comparisons are made between the element of interest and all other elements within a prespecified radius making the algorithm nonlocal and robust. 74 The original algorithm takes the gray level difference as its criterion function, d = jgi \Gamma gjj . The image segmentation algorithm used here is based on the color space distance measure given above. 5.3.3 Depth segmentation algorithm The depth segmenter identifies depth discontinuities and divides the depth map into regions of continuous depth variation. This information is passed to the reflectivity modeller and shape from shading program for use in determining depth map reliability and, in the case of shape from shading, to ascertain an overall depth constant for each region. It is important for a number of reasons that the initial depth estimate produced by the stereo program be segmented along depth discontinuities. The most important is that the shape from shading module will produce erroneous results if a solution is continued across a depth discontinuity. Shading does not give any information about the relative depths of surfaces on opposite sides of a discontinuity and algorithms that use shading information operate on the implicit assumption that the surface is continuous. Therefore, discontinuities must be explicitly identified at an early stage if they are to be present in the final reconstructed surface. Another reason for segmenting the depth map is to eliminate erroneous depth estimates. Stereo errors are related to image structure and therefore often form clumps of erroneous estimates that are too large to remove by median filtering or morphological techniques. In addition, such errors are difficult to predict from interest operator values or match quality comparisons. However, it is almost always the case that a single continuous region of uniform color in the image corresponds to a continuous surface in the scene. Therefore, erroneous regions can be removed by isolating disconnected surface regions within each image region. The depth segmentation algorithm is essentially identical to the image segmentation algorithm described in section 5.3.2, the principle difference being the distance measure used. The depth segmentation program takes the difference in depth values as its criterion 75 function, d = jzi \Gamma zjj. Therefore, the segmentation algorithm maximizes uniformity of depth within regions. This is a crude but useful approximation of continuity as continuity is not directly measurable. Ideally, it is possible to compare derivatives of the depth, but derivatives are highly noise sensitive and the stereo algorithm generates very noisy estimates. 5.3.4 Albedo computation algorithm In a multicolored scene, it is necessary to find the length and direction of the color vector associated with each distinctly colored region. The direction of the color vector determines the color of the region while its length gives the reflectivity or albedo of the region. A method for albedo estimation based on frequency analysis has been described by Funt, Drew, and Brockington [31]. It is similar to the method that Horn [41] has suggested for monochromatic images. Two methods are given for recovering the color vectors. The first method involves finding the minimum of a functional that represents the departure from the image irradiance equation. It is found that this method does not work well. Therefore, a second method is introduced that involves comparing the brightness of neighboring pixels taken from different regions. This method is found to work better and the two methods are compared. 5.3.4.1 Region based method For Lambertian color images, the image irradiance equation may be written I(x; y) = c(x; y)( ^n(x; y) \Delta l) where I is a vector representing the red, green, and blue components of the image brightness, c is the color vector associated with each region, ^n is the surface normal and l is the light source vector. 76 Consider minimizing the following functional with respect to the color vectors associated with each regionZ Z (I (x; y) \Gamma c(fl(x; y))( ^n(x; y) \Delta l))2dxdy Assuming that the image can be segmented into regions of constant color, the above functional may be minimized separately for each region. Let \Omega fl be the flth region, fl = 1; . . . ; N . Differentiating with respect to the flth color vector yields the following condition for a minimum in each regionZ Z \Omega fl (I \Gamma c( ^n \Delta l))( ^n \Delta l)dxdy = 0 Because the color vector, c(fl) is independent of the image coordinates in each region, the equation may be rearranged and solved for each color vector. The solution is, c(fl) = RR\Omega fl I( ^n \Delta l)dxdyRR \Omega fl ( ^n \Delta l)2dxdy An estimate of the normal to the surface can be obtained from the initial surface estimate provided by stereo. Notice that the light source vector must also be known in order to compute the color vectors. However, the color vectors must be known in order to estimate the light source vector. Thus, each estimate is dependent upon the other. It is conceivable that an iterative scheme in which the light source vector and color vectors were alternately estimated could be used to obtain to a global minimum. Unfortunately, such schemes did not converge in practice. Even when the light source vector was known exactly, the above method of obtaining the color vectors did not give accurate results. Therefore, another method was used to find the color vectors. 5.3.4.2 Boundary based method Computing the color vectors associated with distinctly colored regions may be broken down into two steps. The first step is to compute the directions of the vectors in color space. The second step is to compute the lengths of the vectors. Computing the directions is easy if the image can be segmented. Once a partition of the image is known, the 77 direction of the vector associated with each region may be taken to be the average direction of the vectors in the region. The length of the color vector associated with each image point depends upon the reflectivity of the material and the shading at that point. If it is assumed that the shading changes slowly, then the shading of neighboring points should be nearly the same. Therefore, if neighboring points lie in different regions, any difference in irradiance may be attributed to the difference in the albedo of the regions. Hence, it seems reasonable that the ratio of the albedo in one region to that in another could be found by taking the average of the ratio of the irradiances of neighboring points that lie on opposite sides of the boundary between the two regions. A `naive', direct method for finding the albedo ratios can be defined as follows. Given N regions, rk; k = 1; . . . ; N , let (Ijki; Ikji) be the ith pair of pixels drawn from regions rj and rk. Then, a simple estimate of the albedo ratios is given by fijk = aejae k = 1 Njk NjkX i=1 j Ijkijj Ikjij where fijk is the ratio of the albedo, aej, of region rj to the albedo, aek, of region rk. Although this simple estimator captures the spirit of the albedo ratio computation, it has several drawbacks in practice. First, some ratios, fijk, cannot be computed directly because the regions rj and rk are not adjacent. Second, for the fi's to be consistent, one should have fijkfikl = (aej=aek)(aek=ael) = aej =ael = fijl. Therefore, it is desirable to have an estimate that is based on all the pixel pairs simultaneously. The derivation of a more general estimator is facilitated by noting that one may set fijk = PNjki=1 jIjkij= PNjki=1 jIkjij. This estimate of the albedo ratio has the same expected value as that introduced in the previous section as may be easily shown. Let the sum of the pixel intensities along one side of a boundary segment be written Ijk = PNjki=1 jI jkij. Then the albedo ratios may be written aej=aek = fijk = Ijk=Ikj . The relations of this form may be rearranged to yield a set of linear homogeneous equations for the albedos of the form Ikj aej = Ijkaek. The resulting system of equations can be further simplified by noticing that they may be combined to yield equations of the following form 78 P j; j6=k Ikj aej = iPj; j6=k Ijkj aek. This is equivalent to a statement that the sum of the irradiance along the interior boundary of a region multiplied by its albedo is equal to the weighted sum along the exterior boundary where the weights are the albedos of the adjoining regions. Let ~Ikk = Pj; j6=k Ijk. Then the matrix F may be defined F = 0BBB BBBBB @ \Gamma ~I11 I12 I13 \Delta \Delta \Delta I1N I21 \Gamma ~I22 I23 \Delta \Delta \Delta I2N ... ... IN1 IN2 \Delta \Delta \Delta IN;N\Gamma 1 \Gamma ~INN 1CCC CCCCC A Now, the set of linear homogeneous equations may be written F ~ae = 0 where jF j = 0 and the solution may be found by one of the usual methods. In the current case, the albedo of the brightest region was set equal to one, leaving an inhomogeneous set of equations that may be subsequently solved by least squares. This method seems to work well in practice. 5.3.4.3 Comparison of region and boundary methods Both the region and boundary based methods for finding the color vectors require knowledge of the image segmentation. The region based method also depends upon knowledge of the light source vector which is not generally available. On the other hand, the boundary based method is more complicated than the region based method to implement and depends upon the assumption that neighboring points have nearly the same shading. However, the boundary based method does not require knowledge of the light source vector and was found to be highly accurate in practice. Therefore, the boundary based method of finding the color vectors is used in the current implementation. 5.3.5 Source from shading algorithm The source from shading algorithm uses the input image, initial depth map estimate, and knowledge of the surface coloration to produce an estimate of the source direction, or, more generally, the source distribution. The source from shading algorithm may be 79 any of the algorithms described in chapters 3 or 8 or the source distribution algorithm given in chapter 6. The experimental results given at the end of this chapter are based on a color version of the method given by Brooks and Horn [13] and reported in chapter 8. 5.3.6 Reflectance map algorithm The reflectance map algorithm, if present, uses the input image and initial depth map estimate to produce an estimate of the reflectance map in each image region. An algorithm for calculation of the reflectance map is given in chapter 7. In order to obtain reliable source distribution or reflectance map estimates, it is desirable to keep the regions within which an estimate is required large. In particular, if there is more than one disconnected region with the same reflectance map, it is convenient to combine them into a single larger region. This can be done by comparing the mean unit color vector of each region. After region grouping is done, the reflectance modeller associates image brightness values with corresponding estimates of the surface derivatives calculated from the reliable stereo depthmap values. Because stereo estimates tend to be noisy, a prior estimate of the reflectance data may also be included. Once the data has been collected, the reflectance modeller estimates each reflectance map using adaptive polynomial regression. 5.3.7 Shape from shading algorithm The shape from shading program generates an improved estimate of the surface shape in each image region using the albedo ratios and the source direction, source distribution, or the reflectance map along with the reliable depth map estimates provided by the stereo module. The shape from shading algorithm could be any of those reported in chapters 3, 8 and 6. The experimental results given at the end of this chapter are based on a color version of the method given by Horn [42] and similar to that reported in chapter 8. The main difference is that the smoothing term was sometimes omitted. In this case the 80 functional to be minimized isZ Z [(I(x; y) \Gamma c(x; y)f (p; q))2 + _((zx \Gamma p)2 + (zy \Gamma q)2)]dxdy The first term is designed to enforce the color image irradiance equation. The second term is the integrability penalty term and is designed to enforce p = zx and q = zy. The Euler equations for this problem are p = zx + 1_ 3X i=1( Ii \Gamma cif )cifp q = zy + 1_ 3X i=1(I i \Gamma cif )cifq and \Delta z = px + qy These equations may be converted to an iterative scheme by a method similar to that given in Horn. Whichever shape from shading algorithm is used, several different kinds of information about each image pixel and its corresponding height map entry are required. The reflectance model used at each pixel is determined by the image segmentation and region grouping processes. Sometimes, each image region is processed separately while at other times solutions are extended across region boundaries. Separate processing allows for cases in which regions belong to disjoint surfaces. Conversely, the extension of solutions across boundaries is desirable when the various regions correspond to a single surface as this approach aids in the enforcement of continuity and smoothness. The choice of whether to process regions together or separately has yet to be automated. Overall depth estimates are provided by stereo and the reliability of those estimates may be determined by comparing the depth and image segmentation results. Currently, feedback from the shape from shading module to the reflectivity modeller is under investigation. Using the optimal control approach to surface estimation, it has proven possible to accurately estimate albedo constants by comparing global features of the final shape with the expected shape given by stereo. This estimation method makes 81 possible more accurate surface estimation than methods that do not involve feedback because it makes possible use of the fact that stereo estimates are globally but not locally accurate. 5.4 Experimental Results The integrated stereo and shape from shading algorithm was implemented on a Sun 4 and applied to pairs of stereo images acquired with one of the stereo camera systems in the University of Illinois Computer Vision Laboratory. The images were acquired with a Cohu 8210 series color camera, digitized, cropped and subsampled to produce 240 \Theta 243 images in 24 bit color. A typical example of the performance is shown figure 5.3. A portion of a brown grocery bag with red lettering, shown at the upper left, was used in this experiment. To the upper right is the shaded depth map produced by stereo. The shaded image was constructed using the recovered light source vector. Although the result is within a few millimeters of the correct depth, it is clear that it does not closely resemble the true surface shape. To the lower left is the result of smoothing the depth map using a trimmed mean filter. Although the large spikes have been removed, the result does not appear to be a grocery bag. At the lower right is the result of applying shape from shading to the output of the stereo algorithm. It can be seen that most of the major surface features of the grocery bag are present in this picture. In addition, some small (one or two millimeter) surface features have been recovered. Although the picture is not perfect, this result clearly demonstrates the potential advantages of combining stereo and shape from shading. 5.5 Conclusions This chapter discussed the integration of stereo and shading information. Color images were used to facilitate the segmentation process. Emphasis was placed on the fact 82 that the combined method can be used under a wider set of conditions than either stereo alone or shape from shading alone. In addition, it was shown that the surface shape estimate produced by the combined method is more accurate than the estimate produced by either method used alone. 83 Figure 5.3 Performance of integrated approach. Upper left: Image of grocery bag. Upper right: Shaded depth map produced by the stereo module. Lower left: Smoothed depth map produced by stereo. Lower right: Final result. 84 6 ESTIMATION OF THE LIGHT SOURCE DISTRIBUTION 6.1 Introduction This chapter is concerned with estimation of the light source distribution and its use in surface shape estimation by the methods of stereo and shading. As stated previously, there are many advantages to combining stereo and shading information in an integrated approach including the applicability of such methods to a wider range of scenes than either method used alone [52, 43]. However, shape from shading algorithms are limited in their applicability by the assumption of overly simplistic models of the complex light source distributions that occur in the real world. One of the central problems of physics based vision is the estimation of the light source distribution. Several methods have been developed for recovering the direction of a single point light source [100, 13, 73], some of which have been reviewed in chapter 3. A few methods have also been developed for recovering the directions of a small number of point light sources [98]. This chapter describes a more complete representation of the light source distribution that facilitates the approximation of complex lighting conditions. The lighting model presented here makes use of multiple fixed point sources located at infinity. Methods of estimating the model parameters are developed and discussed and a method of estimating the surface shape given the source distribution is also presented. The shape estimation algorithm using multiple sources is based on a new, single source algorithm, presented in chapter 3. Complex source distributions composed of several continuously distributed and/or discrete sources commonly occur in both natural and artificial settings. Typical office lighting consists of a large number extended sources in the form of recessed ceiling lights. Many buildings admit light through several windows that act as distributed sources. 85 Outdoors, trees and other plants act as an array of windows, selectively admitting light. In both natural and artificial settings, reflected light from unobserved parts of the world act as additional sources [25]. All of these sources make the distribution of light arriving at a surface very complex. The method described in this paper is designed to work with complex lighting distributions containing multiple extended and/or discrete sources. However, because it is very difficult to solve all of the problems posed by real light source distributions, it is still necessary to make several assumptions. It is assumed that all sources are located at infinity. This implies that the direction of the light coming from a particular point source is constant throughout the scene. It is assumed that surface patches do not shadow each other. This implies that a surface patch can see every light source that is in front of it, ie., that is within ninety degrees of the surface normal. It is further assumed that there are no interreflections within the visible part of the scene. This limitation can be partially overcome by applying the method described here to individual parts of the image or by using the method of Nayar, Ikeuchi and Kanade [66]. Finally, this method works better if the reflectance function is not highly sensitive to the incident direction. It works best when the scene is composed of dull or matte surfaces, rather than highly polished metals or other materials that have a large specular spike as a component of the reflectance function. All of these assumptions put constraints on the types of scenes that this method can handle. However, there are many real scenes for which these assumptions are approximately valid. The rest of this chapter describes a method of estimating the light source distribution given an initial estimate of the surface shape and a method of recovering the surface shape from shading by multiple sources. Experimental results comparing approaches that use the single source and distributed source recovery methods are shown. 86 6.2 Determination of the Source Distribution from Shading This section contains a solution to the problem of determining the source distribution from shading. From the radiometry equations given in section 3.2 it can be seen that source radiance appears as a multiplicative constant in the equation for the surface radiance. This fact can be exploited in the solution of the light source distribution. For a surface region illuminated by a continuous light source located at infinity, the total image irradiance is E(x; y) = ae(x; y) Z \Omega F ( ^n(x; y); ^l(`; OE))Ls(^l(`; OE))d\Omega where ae is the albedo, F is the surface reflectance function written as a function of the surface normal, ^n, and a unit vector in the direction of the source, ^l, and Ls is the source radiance. The integral is taken over the sphere of possible incident directions and \Omega is the projected solid angle. The source radiance Ls may be approximated by contributions from a set of m distinct light source directions, ^l1; ^l2; . . . ; ^lm where ^li is an average value of ^l(`; OE) over a neighborhood of `i; OEi. Given this definition, an approximation to the image irradiance may be written E(x; y) ss ae(x; y) mX i=1( ^ n(x; y) \Delta ^li)F ( ^n(x; y); ^li)Ls(^li) where the dot-product term results from the projected solid angle. If ^li is known and constant, then Ls(^li) is also constant and may be replaced with ai = Ls(^li). Given this definition, the above approximation may be written, E(x; y) ss ae(x; y) mX i=1( ^ n(x; y) \Delta ^li)F ( ^n(x; y); ^li)ai Let E be measured at J image points, pj , where 1 ^ j ^ J . Then, for j = 1; . . . ; J , Ej = aej mX i=1( ^nj \Delta ^li)F ( ^nj; ^li)ai This is a set of linear equations for a1; . . . ; am. If J * m and the associated matrix is of full rank, a unique solution exists to the corresponding least squares problem. In 87 order to use this set of equations, the albedo and surface orientation must be given for at least m points. In addition, the unit source vectors, ^l1; . . . ; ^lm, must be known. Fortunately, it is not necessary to solve for the positions of the unit source vectors. In fact, the positions of the unit source vectors may be chosen by any suitable method before the computation begins. The particular choice of unit source vectors may affect the quality of the estimate of the source distribution and the quality of the reconstructed surface. However, under certain conditions, outlined below, the results are fairly insensitive to the choice of unit source vectors. The albedo and surface are estimated by other subsystems of a vision system that combines stereo and shape from shading. An initial estimate of the surface is given by stereo and the albedo is estimated by the method explained in section 5.3.4. In general, it is assumed that this information comes from other subsystems of a complete vision system. The image irradiance model may be augmented by the inclusion of a term representing the contribution of ambient light to the total image irradiance. In this case, the resulting image irradiance equation is Ej = aej (F0a0 + mX i=1( ^nj \Delta ^li)F ( ^nj; ^li))ai This form of the model often results in a better fit in practice. The accuracy of the multisource method in approximating the source distribution is limited by the number of sources used in the representation. In order for this method to produce reliable results in the presence of possibly inaccurate estimates of the surface shape, the number of light sources used in the approximation must remain relatively small. However, if the reflectance function is highly sensitive to the incident direction, as is the case for specular surfaces, the estimate will only be accurate if there is guaranteed to be a light source in the representation that is very close to each significant light source in the original distribution. Because the form of the approximating light source distribution is fixed in advance, this implies that the space of possible source directions must be densely sampled. These competing requirements limit the specularity that can 88 be accommodated. Consequently, the experiments reported in this chapter are limited to nearly diffuse reflectors. 6.3 Representation of the Source Distribution The collection of unit source vectors determines the form of the representation that is to be used in the approximation of the continuous light source distribution. The choice of unit source vectors serves the same purpose in the present case as the choice of knot points serves in the definition of the cubic spline and as the choice of partition points serves in approximating the Riemann integral. Just as it is convenient in the case of the cubic spline to establish equally spaced knot points and in the case of the Riemann integral to establish a uniform partition, in the present case it is convenient to establish uniformly distributed unit source vectors. The important thing to note is that the particular choice of unit source vectors is independent of the data and may be fixed in advance. In the algorithm for arranging the sources, the unit source vectors are treated as points on a unit sphere. Unfortunately, it is not possible in general to uniformly distribute an arbitrary number of points on a sphere or hemisphere [16]. In the present implementation, points are placed on the hemisphere of directions on the camera side of the image plane by a method that is designed to generate highly uniform patterns on the unit sphere at different resolutions, as explained further below. A more highly optimal distribution might be obtained by estimating the probability density of incident radiant energy as a function of direction for real scenes and distributing the unit source vectors accordingly. Currently, the resolution of the representation is determined by specifying the number of latitude lines or, more precisely, the number of gradations of the polar angle, `, that are to be used. Each latitude line is then partitioned uniformly to determine the final light source placement. The gradations of each latitude line are made as close as possible to the interline spacing. In addition, the origin on each latitude line is offset in order to more uniformly represent the hemisphere of possible directions. 89 Although this source placement method is somewhat ad hoc, it is fast and in practice it results in reasonable distributions. Other possible placement methods involve the minimization of an objective function designed to favor uniform source distributions [16]. 6.4 Methods of Solving for the Source Distribution This section discusses the solution of the multiple source from shading equations. As stated in the previous section, the equations Erj = aej( ~F0a0 + mX i=1( ^nj \Delta ^li)F ( ^nj ; ^li))ai are linear in the unknowns, a0; . . . ; am. In addition, for the solution to be physically meaningful, the intensity of every light source including the ambient source must be positive or zero. More precisely, the following relations must hold, 0 ^ ai; i = 0; . . . ; m. This section explores the effects of these constraints on the solution. There are two basic methods of solving for the intensities of the sources in the multiple source from shading model. The first method is to ignore the positivity constraints. In this case the sources are called virtual sources and can be either positive or negative. A negative source can be thought of as absorbing light from a scene. Clearly, negative sources are not realizable. However, the use of virtual sources has the advantage that the solution can be found by ordinary methods of linear least squares. The second basic method of solving for the source intensities is to enforce the nonnegativity constraints. In this case, the problem becomes an instance of the problem of nonnegative linear least squares [51]. The solution to the nonnegative least squares problem is straightforward and there exist algorithms in the literature for solving it [51]. Because the error surface contains no local minima, the unique global minimum is always found. This fact may be established by observing the convexity of the objective function and the convexity of the constraints. In this case the solution is constrained to lie in the positive hypercone. In section 6.7, it is shown that for the Lambertian reflectance function the virtual source method often yields a better fit to the image data than the positive source method. 90 However, this does not necessarily lead to a more accurate estimate of the surface shape. The reason for this is related to the numerical instability of the virtual source method. As the number of sources in the approximation is increased, the sources become more nearly linearly dependent which results in coefficient cancellation between neighboring positive and negative sources. The positive source method is not subject to this difficulty because positive sources do not cancel. Such effects are expected to be even more pronounced for more highly specular reflectance functions. Such hypotheses form the basis of future research. Other methods of solving the multiple source equations involve letting some, but not all, of the coefficients be negative. In particular, it is sometimes convenient to let the ambient term be unconstrained. The reason for this is that in images acquired from actual camera systems the ambient term plays a dual role. It acts to compensate real ambient light and also to adjust for a voltage gain cutoff in the digitization process. The effect of a voltage cutoff is to reduce the brightness of every pixel by a fixed amount. Allowing the ambient term to be negative allows this effect to be modelled. A problem in which some but not all of the variables in a model are constrained is an instance of the problem of least squares with inequality constraints or least squares with bounded variables [51]. In addition, optimization and quadratic programming algorithms can potentially be used to solve this problem. In the work reported in this paper, a simpler approach is used. The problem considered here is less general than that of constrained least squares and is not much more difficult than the problem of nonnegative least squares. Since only the ambient term is allowed to vary freely and because the amount of the variability is bounded by the range of brightness values in the digitized image, the problem can be solved by adding a negative constant to the brightness. This has the effect of forcing the ambient term to be positive. Later, the actual value of the ambient term is found by subtracting the same constant. 91 6.5 Shape from Shading Using Multiple Sources It is a relatively simple matter to extend the single source shape from shading algorithms given in chapter 3 to the multiple source case. The details of some algorithms are slightly different, due to altered form of the reflectance map. Since the modified method of Leclerc and Bobick was used for this research, the extension of that method is described here. Extensions to other algorithms are straightforward. In the case of m sources, the image irradiance equation becomes, Er = F0a0 + mX s=1( ^ n \Delta ^ls)F ( ^n; ^ls)as where F0a0 is the ambient light term, as is the strength of the sth light source and ^ls is the unit vector pointing in the direction of the the sth light source. To simplify the following expressions, the multisource reflectance function F M is defined by, F Mi;j = F0a0 + mX s=1 ~Fi;j;sas where ~Fi;j;s is shortened notation for ( ^nij \Delta ^ls)F ( ^nij; ^ls). Combining the new image irradiance equation with the smoothing term given previously leads to the following multisource objective function, QM = X ij (1 \Gamma fl)(E ij \Gamma F Mi;j )2 + fl(u2ij + v2ij) Computing the gradient of this new objective function yields the following expression, @QM @zi;j = \Gamma 2 n (1 \Gamma fl) 0X k=\Gamma 1 0X l=\Gamma 1( Ei+k;j+l \Gamma F Mi+k;j+l) @F Mi+k;j+l @zi;j + 2n fl 1X k=\Gamma 1 1X l=\Gamma 1 ui+k;j+l @ui+k;j+l@z i;j + v i+k;j+l @v i+k;j+l @zi;j where the derivative of the multisource reflectance function is given by @F Mi+k;j+l @zi;j = mX s=1 a s @ ~Fi+k;j+l;s @zi;j 92 The derivatives of the reflectance function and the smoothing term are the same as computed previously. In order to obtain the surface shape, the multisource objective function is minimized using a conjugate gradient algorithm as was done by Leclerc and Bobick [52]. 6.6 Integration of Shape from Stereo and Shading Integration of stereo and shading was discussed in detail in chapter 5. However, it is worth stating the exact set of modules used for the experiments reported in this chapter. The system used in this chapter is composed of five main parts (as shown in figure 5.1): (1) A stereo module that provides an initial depth estimate. (2) A segmentation module that segments one of the images into regions of uniform color. (3) An albedo module that estimates the reflectivity coefficients of the various regions. (4) A source module that uses the stereo depth estimate and the reflectivity map in the estimation of the source distribution. And (5) a multiple source, shape from shading module that uses the initial depth estimate provided by the stereo module, the reflectivity map, and the source distribution in the estimation of the final surface shape. In this chapter, the modified algorithm of Leclerc and Bobick [52] reported in chapter 3 is used to recover shape from shading. In this case, however, the shape is forced to remain close to the stereo estimate by including the departure from the stereo estimate in the objective function. More specifically, a term of the form fi(zij \Gamma ~zij)2 where ~zij is the stereo estimate and fi is a weighting factor is included. The algorithms for estimating the source distribution and shape from shading were described in sections 6.2 and 6.5. The stereo, segmentation, and albedo estimation algorithms were described in chapter 5. 6.7 Experimental Results Three types of experiments were performed to determine the performance of the source distribution estimation algorithm and the new multiple source, shape from shading algorithm. The results are summarized below. 93 6.7.1 Tests of the source estimation methods The algorithms for estimating the source distribution were tested on a large number of synthetic images and the results were compared with the results obtained from the single source estimation algorithm of Brooks and Horn [13]. The depth maps and images were constructed by a three step procedure: (1) Two basic depth map types were defined by the equations, z = A cos(jr), and z = Br cos(ssjffw=2), where A and B are amplitudes, j is the angular frequency, r = px2 + y2 is the radial distance from the center of the image, ff = arctan(y=x) is the angular displacement, and w is the image width. These map types were chosen because they contain a wide range of surface slopes and avoid depth discontinuity problems. For this set of experiments, A = 5; B = 5; j = 1=20. These values were chosen after preliminary testing to make the problem moderately difficult for the estimation algorithms. (2) An artificial light source distribution was created by randomly generating a given number, m, of light source vectors, l1; . . . ; lm. An ambient light term was sometimes also included. (3) The random light source distribution was applied to the depth map as in Horn's method [39] using a Lambertian reflectance function to generate the test images. Ten 100 \Theta 100 images of each depth map type were generated using each of five different numbers of light sources for each of two different values of the ambient term for a total of 200 test images. The numbers of light sources used were 1; 3; 9; 27 and 81 and the values of the ambient term were 0 and 20 out of 255 gray levels. The light source algorithms were tested for a number of different parameter settings, establishing a total of twelve different test conditions in addition to the "control". The baseline, or control, was established by the method of Brooks and Horn [13]. The source distribution algorithm was tested using both the virtual and positive source solution methods. Both methods were tested with and without an ambient light term as part of the model. For each of the foregoing conditions, the number of light sources in the model was varied among three values. As explained earlier, the number of sources is controlled by first choosing the number of latitude lines. Using 1, 2, and 3 latitude lines resulted in 5, 9, and 17 sources being used in the estimation process. 94 The tests were conducted as follows: (1) For each test condition, the source algorithm was applied to the test depth maps and images. (2) The resulting source distribution was used to construct a new image using the same reflectance model. (3) The root mean squared (RMS) difference between the original and reconstructed images was computed and stored. In total, 2600 tests were performed. Figures 6.1 and 6.2 summarize the results in the form of twelve graphs. Figure 6.1 shows the results for the first type of surface and figure 6.2 shows the results for the second type. The first and second columns show results on test distributions without and with an ambient term, respectively. From top to bottom, the estimation algorithms used 5, 9, and 17 sources. The average RMS error is plotted versus the number of light sources in the test distribution. Results for the single light source program and various versions of the multiple source program are shown in each case. Several empirical observations can be made: ffl The multiple source methods almost always perform better than the single source method. However, the single source method sometimes performs better for one test source. ffl Increasing the number of model sources increases the performance of the multiple source methods. ffl The inclusion of an ambient term in the model increases algorithm performance. Evidently, the ambient term gives the model more flexibility and allows more effective modelling of some effects. ffl The virtual source method performs better than the positive source method. Evidently, the allowance of negative values increases model flexibility. ffl The improvement of the multiple source methods over the single source method increases as a function of the number of light sources. Therefore, as the number of test light sources increases, the advantage of using multiple source methods increases. 95 Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Figure 6.1 Performance of source distribution algorithms on surface type 1. The first and second columns show results on test distributions without and with an ambient term, respectively. From top to bottom, the estimation algorithms use 5, 9, and 17 sources. 96 Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average RMS Error (gray levels out of 255) 0.00 10.0 20.0 30.0 1 3 9 27 81 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Figure 6.2 Performance of source distribution algorithms on surface type 2. The first and second columns show results on test distributions without and with an ambient term, respectively. From top to bottom, the estimation algorithms use 5, 9, and 17 sources. 97 ffl The single source method performed better on the second surface type than on the first and the improvement gained by using the multiple source methods was reduced. Therefore, as the difficulty of the problem increases, the benefit of using multiple source methods also increases. ffl As the number of test sources increases beyond a certain point, the performance of all methods increases. Evidently, the hardest distributions to fit are those with several distinct light sources. As the number of sources increases, each light source becomes less distinct. ffl The sample standard deviation decreases as the number of sources used to generated the test images increases. As the number of test sources increases, the source distribution converges asymptotically to a uniform distribution so that all of the samples are statistically very similar leading to lower variance. Overall, the multiple source programs performed much better than the single source program, commending their use. However, it would be convenient to have performance measures to determine when use of the single source method is desirable. 6.7.2 Tests of the shape estimation methods The algorithms for estimating the surface shape from shading by multiple sources were tested on several synthetic images and the results compared with those obtained using the new single source, shape from shading algorithm. A depth map was constructed according to the equation z = A cos(jr), with A = 3 and j = 1=20 and used to generate several 100 \Theta 100 images. Using this depth map, 3 images were generated as in the last section using 1; 8 and 64 light sources. The depth map and source distributions were selected to be of moderate difficulty for the programs. No ambient term was used. The source was first computed from the depth map and images using each of the methods outlined previously, namely the positive and virtual methods with and without an ambient term as part of the model. In each case, 9 and 17 sources were included in 98 Number of Light Sources Used to Generate Test Images Average Percent Error in Height 0.00 0.10 0.20 0.30 1 8 64 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Number of Light Sources Used to Generate Test Images Average Percent Error in Height 0.00 0.10 0.20 0.30 1 8 64 Single Source Multiple Virtual Sources Multiple Virtual Sources with Ambient Term Multiple Positive Sources Multiple Positive Sources with Ambient Term Figure 6.3 Performance of the shape from shading algorithms on surface type 1. The left and right graphs show the results of surface estimation with 9 and 17 sources, respectively. the model. The method of Brooks and Horn [13] was also used. The shape from shading program for each source type was applied to each image to arrive at a new depth map. In each case, the resulting depth map was compared with the original and the mean error percent, fflp = Pij(zij \Gamma ~zij)2= Pij z2ij was computed and stored. In total, 19 tests were performed. Figure 6.3 summarizes the results in the form of two graphs. The first graph shows the results for 9 sources and the second graph shows the results for 17 sources. The average percentage error in height is plotted versus the number of light sources in the test distribution. Results for the single source, shape from shading program and various versions of the multiple source, shape from shading program are shown in each case. Several empirical observations can be made: ffl The multiple source, shape from shading methods generally performed better than the single source method on images that were generated with many sources. ffl The single source method tended to perform as well as or better than the multiple source methods on images generated with a single source. ffl The performance of the multiple source methods increased as the number of light sources used in the estimation process increased. 99 ffl There was no consistent difference in the performance of the virtual and positive source methods. ffl The inclusion of an ambient term in the multiple source model did not consistently improve performance and in one case lead to a significant decrease in performance. Overall, the multiple source, shape from shading methods tended to perform better on scenes that were generated with a large number of light sources. This is to be expected given that the multiple source methods more accurately model the light source distribution. The causes of the other effects noted above are currently under investigation. 6.7.3 Tests of the integrated shape recovery system This section describes a test of the integrated shape recovery system that was performed on a stereo pair of images acquired in the laboratory. Tests of the single source integrated system can be found in [43]. Pairs of stereo images were acquired with one of the stereo systems in the Computer Vision Laboratory at the University of Illinois. The images were acquired with a Cohu 8210 series color camera, digitized, trimmed and subsampled to produce 200\Theta 200 images in 24 bit color. One view of a rectangular solid (a box viewed from the edge) is shown in the top, left-hand picture of figure 6.4. The surface of the solid has been covered with a crenulated, colored material (a paper towel). The material has no surface texture other than that caused by shaded undulations. The two vertical bands appearing near the edges are blue and rest of the surface is white or cream colored. The scene is illuminated by ordinary ceiling lights which are an array of diffuse rectangular illumination sources. The source distribution was modelled by 17 sources plus an ambient term. The solution was found by the positive source method. The top, right-hand picture of figure 6.4 shows the result of applying the stereo algorithm to the images and shading the resultant depth map. The corresponding depth map is shown in the upper right-hand graph of figure 6.5. Although this result is globally quite accurate, as can be seen from 100 Figure 6.4 Performance of the integrated stereo and shape from shading system on an image of a box. The picture in the upper left is the original image. To the upper right is the result of shading the depth map produced by stereo. To the lower left and right are two outputs produced by the shape from shading program as the stereo weighting parameter is reduced. figure 6.5, the surface detail is not accurate. The lower two pictures in figure 6.4 show the shaded depth map after applying the multiple source, shape estimation program to the output of the stereo program. The left picture is the result after the continuation parameter, fl, described in section 3.5.3 has been reduced in one step from its initial value of 0.1 to 0.01. The right picture is the result of then decreasing the stereo weighting parameter, fi, described in section 6.6, in one step from 0.1 to 0.01. The lower two graphs in figure 6.5 are the corresponding depth maps. It can be seen that the overall surface shape improves when the stereo weighting factor is reduced. 101 0 20 40 0 20 40 -722.5 -720 -717.5 -715 -712.5 0 20 40 0 20 40 -722.5 -720 -717.5 -715 -712.5 0 20 40 0 20 40 -7.5 -5 -2.5 0 2.5 0 20 40 0 20 40 -7.5 -5 -2.5 0 2.5 0 20 40 0 20 40 -7.5 -5 -2.5 0 2.5 0 20 40 0 20 40 -7.5 -5 -2.5 0 2.5 Figure 6.5 Performance of the integrated stereo and shape from shading system on an image of a box. The graph to the upper right is the depth map produced by stereo. To the lower left and right are two depth maps produced by the shape from shading program as the stereo weighting parameter is reduced. These results demonstrate the applicability of the multiple source estimation technique to real scenes. The results also clearly show the advantages of combining stereo and shape from shading methods in a single system. The integrated estimation method is able to recover surface shape much more effectively than either method used alone. 6.8 Conclusions The purpose of the research summarized here has been to broaden the applicability and increase the accuracy of visual shape estimation methods. It has been argued that 102 an integrated method that combines stereo and shading information can be applied to a wider range of scenes and achieve greater accuracy than either method used alone. However, it has been pointed out that shape from shading methods are limited in their applicability by the assumption of overly simplistic models of the complex light source distributions that occur in the real world. In order for the potential advantages of an integrated approach to be realized, this problem must be addressed. This chapter has introduced a method of representing and estimating more complex light source distributions using a multiple source model. Methods of estimating the model parameters have been introduced and a method of using the source distribution for shape estimation has been presented. The multiple source, shape estimation method is based on a new, single source shape estimation method. The new methods of estimating the source distribution and shape have been integrated with a stereo depth estimation method to produce a more widely applicable approach to shape estimation. The advantages of the multiple source method over the single source method have been demonstrated experimentally. In the results reported here, the multiple source method almost always produces a better approximation of the light source distribution than the single source method. This effect becomes more pronounced as the number of sources is increased, as the complexity of the scene is increased and as the complexity of the scene lighting increases. In addition, the multiple source method usually produces better approximations to the surface shape. However, the single source method sometimes performs better when the scene is illuminated by a single source. Finally, the applicability of the multiple source method to a real scene has been demonstrated. The integrated system was applied to a stereo pair of color images taken of a scene with albedo variations. The images were taken under ordinary room lighting conditions involving several large, rectangular, ceiling lights. The results show that both the overall surface shape and small surface detail can be recovered by the approach presented here. 103 7 ESTIMATION AND USE OF THE REFLECTANCE MAP 7.1 Introduction This chapter is concerned with estimation of the reflectance map and its use in surface shape estimation by a method that combines stereo and shading information. As stated in the introduction, there are many advantages to combining stereo and shading information in an integrated approach including the applicability of such methods to a wider range of scenes than either method used alone [52, 43, 44]. However, shape from shading algorithms are limited in their applicability by the assumption of idealized reflectance and lighting models involving many preset or hard to estimate parameters. Traditional approaches to shape from shading start with the assumption that the reflectance map is known and use this information to infer surface shape from the image of a shaded scene [36]. However, in real world applications the reflectance map is generally unknown. More recent approaches are based on the assumption that the surface reflectance function or BRDF is given and that the light source distribution can be estimated [52, 42, 43, 44, 73, 100]. The previous chapter describes a method for estimation of the light source distribution. In addition, a method has recently been developed for using range images to estimate the parameters of a simple surface reflectance function [47]. One hope for continuing progress appears to be work directed at identifying surface types [34, 85] and using this information to select among several common reflectance models such as those described in [67, 96, 15]. However, even if the form of the model is known, it is difficult to estimate the model parameters due to the fact that most models are complex and nonlinear. This chapter describes a completely different approach to the problem. The key to the present approach is the fact that the reflectance map contains all of the information about the light source distribution and the surface reflectance function 104 that is necessary and useful for recovering surface shape. Therefore, if the goal is to estimate surface shape, it is not necessary to estimate the surface reflectance function or light source distribution. It is sufficient to estimate the reflectance map. Thus, the method described here makes it possible to accurately estimate surface shape under a wide variety of surface reflectance and lighting conditions. Due to the complexity of real scenes it is still necessary to make some assumptions. All sources are assumed to be located far away so that the reflectance map is independent of the image coordinates. Shadows other than those caused by self shadowing are not handled. Intereflections within the visible part of the scene are assumed to be negligible. This limitation can be partially overcome by applying the method described here to individual parts of the image or by using the method of Nayar, Ikeuchi and Kanade [66]. Finally, this method works better if the reflectance function is not highly sensitive to the incident direction. These limitations constrain the types of scenes for which this method works well. However, this method is far less constrained than previous methods. The rest of this chapter describes a method for direct estimation of the reflectance map given an initial estimate of the surface shape. As in the previous chapter, the initial estimate is provided by a stereo module. The resulting reflectance map is then used to refine and improve the shape estimate. The method of adaptive polynomial modelling is presented and its application to estimation of the reflectance map is described. Two methods of estimating the surface shape given the model estimate are presented. The first shape estimation algorithm is based on a single source algorithm described in section 3.5.3. The other shape estimation algorithm is a generalization of that presented by Bischel and Pentland [8] and reported in section 3.5.4. 7.2 Adaptive Polynomial Modelling Estimation of the reflectance map may be viewed as a multivariate regression problem with R an unknown function of p and q. A model for R containing a minimum 105 number of parameters is desirable as it will be used in the computationally intensive shape from shading procedure. There are several methods that have been developed in recent years for solving such problems [28, 27, 77, 89]. This paper explores the method of adaptive polynomial regression, originally suggested by Barron [6] and later reported in [28]. Adaptive polynomial regression is defined below. 7.2.1 Types of models Consider estimating the regression function f (x) = hY jxi corresponding to the model Y = f (x) + " where h\Delta i means expected value and " is a zero mean random variable with finite variance. Among the many possible models for f , one possible model is a weighted sum of basis functions, B1; . . . ; BM with corresponding weights, `1; . . . ; `M . The goal of adaptive regression is to produce accurate models with the fewest parameters possible. Adaptive regression is an automatic stepwise procedure in which basis functions are selected to minimize an appropriate criterion function, Q. The selected functions are combined to form a succession of models, f1; . . . ; fM . In the case of additive models, the M th model is defined by fM (x; `) = MX j=1 ` jBj(x) These models are fit to the data, (xi; yi)Ni=1. The model, fM , obtaining the best fit with M terms becomes the M th estimate, ^fM . Thus, adaptive regression represents a set of methods of searching the space of possible models belonging to a particular class. A method of adaptive regression is defined in terms of a class of models and the search strategy used to select among candidate models. In the case of d-variate polynomial regression, the class of models is the set of all d-variate polynomials of finite degree. This paper briefly examines two strategies for exploring the space of polynomial models. A model building strategy is defined in terms of the set of basis functions, \Omega M , that is considered at each step of the model building process. In the first strategy, the set of basis functions is the set of d-variate terms that can be constructed by increasing the degree of a term already in the model. In the simplest case, the initial set, \Omega 0, contains 106 the constant polynomial, x01 \Delta \Delta \Delta x0d, and the set, \Omega M , of basis functions considered at the M + 1st step, is \Omega M = fxkBj (x) : k = 1; . . . ; d; j = 1; . . . ; M g \Gamma AM where AM = fBj(x) : j = 1; . . . ; M \Gamma 1g. This has the effect of increasing by one the degree of one variable of one existing term. Duplicate terms are not allowed. A generalization of the preceding strategy is to allow the degree of any term to be increased by a bounded amount. In this case, the set of basis functions considered at the M + 1st step is \Omega M = fxm 10 \Delta \Delta \Delta xmdd Bj(x) : 1 ^ m1 + \Delta \Delta \Delta + md ^ K; j = 1; . . . ; M g \Gamma AM. This greatly increases the number of terms considered at each step, but may significantly reduce the number of steps before the procedure converges to a satisfactory solution and may thereby significantly reduce the number of terms in the final model. Parsimonious models are preferable because they can be evaluated faster. Another strategy is one in which the complete polynomial model of maximum degree, M , is generated at the M th step. In this case, there is only one basis function considered at the M th step, the multinomial in which every term is of degree, M . More precisely, the M +1st set of basis functions is \Omega M = f(x1+\Delta \Delta \Delta +xd)M+1g. The size of such models grows much faster than those described by the above procedure. This may lead to problems with overfitting. However, many fewer models must be considered before reaching a final model, resulting in less computational overhead. Both types of model building strategies have been employed in the current research and give satisfactory results. The best choice depends upon a tradeoff of computation time required for model building and shape from shading. For simple the scenes, the time required to compute shape from shading dominates the total time. However, if there are many small regions in which different reflectance maps must be used, the model building time can be significant. 7.2.2 Roughness penalty Although term selection imposes some smoothing on a model, it is important, in the presence of noise and model uncertainty, to incorporate a roughness penalty into the criterion function. The adaptive polynomial algorithm minimizes the sum of the average 107 squared error ASR = 1N NX i=1( yi \Gamma f (xi; `))2 and a roughness penalty RP = ffi 2 N NX i=1 jjrx f (xi; `)jj2 With this choice of roughness penalty, ASR + RP provides an estimate of the average squared error that would be incurred if the inputs were perturbed slightly. This is a desirable property under conditions in which the initial estimates of surface slope may be inaccurate. 7.2.3 Stopping criteria In order for the model building process to be fully automatic, some criterion must be established for terminating the building procedure. An optimal termination criterion may be established by approximating the length of an asymptotically optimal informationtheoretic code that describes the the data in terms of the measurement variables [6]. The analysis yields the following minimum description length criterion, MDL = ASR + MN oe2 log(N ) where oe2 is the variance of the noise. 7.2.4 Robust estimation In order to estimate the reflectance map in the presence of noisy depth map estimates produced by stereo, it is useful to consider methods of using the stereo estimates more effectively. Since it is known that the stereo estimates are locally noisy but generally accurate in capturing the overall structure, it makes sense to look for a method of putting more emphasis on the low frequency components of the stereo result while suppressing the high frequency components. 108 If the reflectance map is written as a linear sum of basis functions, then the image irradiance equation may be written, E(x; y) = R(p; q) = mX i=1 ` iBi(p; q) Since p and q are functions of (x; y), this equation may also be written, E(x; y) = mX i=1 `i ~Bi(x; y) where ~B(x; y) = B(p(x; y); q(x; y)). Using this formulation, it is possible to consider applying a low pass filter to both sides of the equation. Let G(x; y) be a low pass filter, possibly Gaussian. Then, the following holds, G \Lambda E = G \Lambda [ mX i=1 `i ~Bi] = mX i=1 `i(G \Lambda ~Bi) The last equality follows from the interchangeability of linear operations. Thus, the original linear least squares problem may be converted to a weighted linear least squares problem. Let C be a matrix with entries Cji = (G \Lambda ~Bi)j; i = 1; . . . m; j = 1; . . . ; N where j is an index into the image array. Let a be the vector with entries aj = (G \Lambda E)j; j = 1; . . . ; N and let ` = (`1; . . . ; `m). Then the above equation may be written, C` = a and the weighted least squares problem is to find the vector ` that minimizes Q = (C` \Gamma a)2 The normal form of the solution is, as usual, ` = (CT C)\Gamma 1CT a From the above discussion, it can be seen that derivation of a robust solution is easy when linear models are used. Furthermore, the solution process can be accelerated through use of the FFT in the convolution steps. Such techniques are not readily applicable to the use of nonlinear reflectance models. 109 7.3 Shape from Shading Algorithm Two shape from shading algorithms have been used in this research. The first is a modification of the direct height from shading method of Leclerc and Bobick [52] and falls into the category of objective function minimization approaches. The second algorithm is the direct shape from shading algorithm developed by Dupuis and Oliensis [23] and simplified and extended by Bischel and Pentland [8] and is based on the theory of optimal control. Both algorithms have been found to have advantages and disadvantages in the context of a complete approach to shape recovery. 7.3.1 Objective function minimization approach The basic constraint in all approaches to shape from shading is the image irradiance equation which may be written E(x; y) = R(p(x; y); q(x; y)) where E is the image irradiance, R is the reflectance map and p = zx and q = zy are the partial derivatives of the surface height function z(x; y). In the modified version of the direct height from shading method of Leclerc and Bobick the surface height (or depth) is represented as a discrete array fzijg and the objective function to be minimized is given by Q = X ij (1 \Gamma fls \Gamma flu)(Eij \Gamma R(pij ; qij))2 + fls(zsij \Gamma zij)2 + flu(u2ij + v2ij + t2ij) where p; q; u and v are taken to be finite difference approximations to the corresponding derivatives, zx; zy; zxx and zyy. In addition, zs is the depthmap produced by the stereo module, t is a 'twist error', and fls and flu are weights that control the contribution of stereo and the amount of smoothing. Modifications to the approach of Leclerc and Bobick are explained in section 3.5.3. The gradient of the objective function is given by the following expression 110 @Q @zi;j = \Gamma 2(1 \Gamma fls \Gamma flu) Xk;l (Ek;l \Gamma Rk;l) @Rk;l @zi;j \Gamma 2fls Xk;l (z sij \Gamma zij) +2flu X k;l uk;l @uk;l@z i;j + v k;l @vk;l@z i;j + t k;l @tk;l@z i;j where Rij is an abbreviation for R(pij ; qij) and the sum is from (i \Gamma 1; j \Gamma 1) to (i; j). In this research the algorithm is further modified by substitution of the calculated reflectance map for the preset (usually Lambertian) map used previously. If the model of the reflectance map is a linear sum of basis functions, as in the present case, then the reflectance map may be written Rk;l = R(pk;l; qk;l) = MX m=1 ` mBm(pk;l; qk;l) where Bm is the mth basis function. The gradient of the reflectance map is given by @Rk;l @zi;j = MX m=1 ` m "( @B m @p )k;l @pk;l @zi;j + ( @Bm @q )k;l @qk;l @zi;j # If the basis functions, Bm are polynomial terms, then Bm = pnm;1 qnm;2 for some choice of nm;1 and nm;2 and the derivatives of the model with respect to p and q are @Bm @p = nm;1p nm;1\Gamma 1qnm;2 @Bm @q = nm;2p nm;1 qnm;2\Gamma 1 The objective function is minimized using the conjugate gradient algorithm as in previous work. 7.3.2 Optimal control approach The optimal control approach is explained in section 3.5.4 and its application to integrated estimation follows. Consider moving towards the point (x; y) from a neighboring point in the direction ss+OE. The slope oe(OE) corresponds to the directional derivative of the surface in the direction OE and is given by oe(OE) = cos(OE)p + sin(OE)q where (p; q) = (zx; zy). Initially, the gradient of the surface is unknown. Therefore, the slope in the direction OE 111 must be chosen to fulfill the brightness equation, E(x; y) = R(p; q). If the point (x; y) has brightness, E, then (p; q) = (p(ffE); q(ffE)) for some ffE where ffE parameterizes the level curve at level E of the reflectance map. As shown by Bischel and Pentland [8], the choice of ffE which maximizes oe(OE) = cos(OE)p(ffE) + sin(OE)q(ffE) leads to the correct surface shape. The slope is always a positive distance from the peak of the reflectance map, ensuring algorithm convergence. Applying the minimum downhill principle and propagating information from neighboring points towards (x; y) the update equation for the surface becomes, zt+1(x; y) = sup OE [z t(x + ds cos(OE); y + ds sin(OE)) \Gamma dsoe(OE)] at every point except those singular points that are specified in advance. In order for the surface to remain consistent, the height of a singular point is allowed to increase or remain fixed but not decrease. The height of a singular point can increase only if there is another singular point that is higher on the surface. From the update equation, it is clear that z must always be lower than at least one neighbor. Therefore, the maximum height of the surface is bounded by the height of the highest singular point. Again, height is specified relative to the maximum of the reflectance map. In order to use the shading information in an integrated system, it is necessary to modify the update equation to include stereo information. Ideally, one would like to find the singular points in the image that are highest on the surface and all of those points that are higher than the highest singular point or that are not connected to a higher point by a path that leads monotonically downhill. However, that particular approach leads to many complications related to the accuracy of stereo methods and errors in the appearance of points that are singular or nearly singular. In addition, it is inherently difficult to identify all of those points that are not connected to a higher point on the surface. In order to avoid such complications, an averaging approach is used here. The 112 modified update equation is given by zt+1(x; y) = (1 \Gamma fl) sup OE [z t(x + ds cos(OE); y + ds sin(OE)) \Gamma dsoe(OE)] + flzs(x; y) where zs is the stereo depthmap and fl is a small weight that controls the stereo contribution. The effect of this approach is to automatically select the highest singular points on the surface. The method works because the slope in the reflectance map near singular points is small and the stereo contribution dominates near these points. Conversely, where the slope in the reflectance map is large, the shading contribution dominates. This result greatly simplifies the integration process. From an examination of the algorithm given above it can be seen that if the slope is only evaluated at a relatively small number of orientations and if the image brightness values are quantized, then the algorithm can be divided into two main steps. The first step consists of calculating the maximum slope for each orientation and each brightness value. This step is completely independent of the image and depends only upon the reflectance map and knowledge of the number of image quantization levels (usually 256). The algorithm is further simplified by noticing that it is only necessary to calculate the level curves of the reflectance map once for each intensity level. Currently the level curves are computed by first evaluating the model of the reflectance map on a discrete grid. Then, for each level the the grid is searched for edges that intersect a plane at that level. Finally, the point of intersection of each grid edge with the plane is determined by linear interpolation. The level plots included in this chapter are determined in the same manner. The second step of the algorithm is to compute the surface shape. This is done by repeatedly applying the update equation given above until convergence. The depth value for each of the preset orientations used in the slope array is approximated by interpolating the four neighboring depth values. Convergence is accelerated by changing the direction in which the program 'sweeps' over the image on each pass. Another modification that has been made to the algorithm of Bischel and Pentland is to increase the number of orientations at which the slope is computed. The use of only 113 eight orientations leads to noticeable artifacts in many instances. Perhaps surprisingly, the use of only four neighbors in the interpolation process does not lead to any noticeable artifacts. Therefore, the only modification to the algorithm has been to use a larger number orientations. Experimentation has shown that sixteen to twenty-four directions are generally sufficient to eliminate most visible artifacts. 7.3.3 Coordinate systems For sake of clarity, the shape from shading algorithms given in the preceding sections have been formulated in terms of the gradient (p; q) of the surface height function z. However, the use of this particular coordinate system causes a number of computational problems. It is well known that high order polynomials are only well behaved within a bounded range. In particular, they are only well behaved within the range of the data. Other types of models such as splines are also difficult to extend to infinity. In addition, any surface orientation data collected from the stereo depth map that corresponds to a steep slope is likely to be unreliable and should be discarded. Also, computations near occluding boundaries may lead to very large slope values. Therefore, it is desirable to use a bounded coordinate system. Previously, Ikeuchi and Horn [46] have used a stereographic coordinate system. However, stereographic coordinates are complex and therefore costly to compute and are not numerically well behaved; special cases must be considered. Other coordinate systems considered by Ikeuchi and Horn have similar difficulties. Therefore we have chosen to use the components of the normal vector in this work. The x and y components of the normal vector are given by n1 = \Gamma pp1 + p2 + q2 n2 = \Gamma qp1 + p2 + q2 The third component is given by the first two and is therefore unneeded. The normal components are bounded, \Gamma 1 ^ n1; n2 ^ 1 and they are very smooth functions of p and q 114 having derivatives of all orders. Substituting the components of the normal vector for p and q in the above equations and altering the derivatives appropriately gives the desired algorithm. 7.4 Integration of Component Algorithms Integration was discussed in detail in chapter 5. However, it is worth stating the exact set of modules used for the experiments reported in this chapter. Figure 5.2 shows the data paths between the major blocks: ffl The stereo module operates on the input images and uses the known camera geometry to produce an initial estimate of the depth map that is passed to the depth segmenter, the reflectivity modeller and the shape from shading program. ffl The depth segmenter identifies depth discontinuities and divides the depth map into regions of continuous depth variation. This information is passed to the reflectivity modeller and shape from shading program for use in determining depth map reliability and, in the case of shape from shading, to ascertain an overall depth constant for each region. ffl The image segmenter operates on one of the input images and produces a set of homogeneously colored regions and an associated set of region groups. ffl The reflectivity modeller uses the input image and the reliable parts of the initial depth map estimate to produce a reflectance map for each region group. ffl The shape from shading program generates an improved estimate of the surface shape in each image region using the reflectance map for each region group and the reliable depth values provided by the stereo module. 115 7.5 Experimental Results Pairs of stereo images were acquired with one of the stereo systems in the Computer Vision Laboratory at the University of Illinois. The images were acquired with a Cohu 8210 series color camera, digitized and trimmed to remove digitizing artifacts, producing 500 \Theta 500 images in 24 bit color. The image in figure 7.1 is a gray scale rendition of a color picture of a clay face. The object was placed approximately 1.0 meter from the camera. The top right of figure 7.1 shows the result of image segmentation. In this case, segmentation consists of nothing more than separating the figure from the background. The lower left of figure 7.1 shows the stereo depth reliability. The regions that have been labelled unreliable by the algorithm are outlined. The depth values within those regions are not used in the reflectance map or shape from shading procedures. The lower right of figure 7.1 shows the level curves of the reflectance map. As in most cases, the reflectance map is very smooth, making a low order model appropriate. From figures 7.2 through 7.4 it can be seen that the integrated approach results in a significant improvement in surface shape recovery over the unaided stereo algorithm or stereo aided by filtering. The graphs in figure 7.2 show the depth map produced by stereo, that produced by filtering the stereo output and that produced by the current approach. It is clear that the present approach produces smoother surfaces containing more shape information. The top pictures in figure 7.3 and figure 7.4 show the results of stereo processing and subsequent smoothing using a trimmed mean filter. The upper pictures in figure 7.3 have been generated by shading the corresponding depth maps with the single source (1; 1; 1)=q(3). Figure 7.4 contains the corresponding level curves of the recovered surfaces. The lower pictures in figure 7.3 and figure 7.4 show the final results of processing. These results have been generated using the optimal control approach to shading which has proven more robust on images of real scenes. The lower picture in figure 7.3 has been 116 generated by shading the depth map with a single source at (1; 1; 1)=q(3). The lower graph in figure 7.4 is the corresponding set of level curves. From the first image, it can be seen that very small features of the surface such as the eye lids have been recovered. Moreover, the eyes, nose and mouth are much more prominent in the final result than in the stereo result. More problems were encountered with more complex images as described below. The image in figure 7.5 is a gray scale rendition of a color picture of of a child's toy puzzle with three-dimensional colored pieces. The object was placed approximately 1.0 meter from the camera and is slightly inclined away from the viewer. The pieces rise no more than 1.0 cm above the frame. The musical score and words "Donald Duck" on the frame are only 1.0 mm in height. Therefore, a relative error of much less than 1% must be achieved in order to accurately recover the surface shape. The top right of figure 7.5 shows the result of image segmentation. The segmentation contains some errors around specularities that are partially responsible for errors in the final reconstruction, especially around the base of the piano. The lower left of figure 7.5 shows the stereo depth reliability. The lower right of figure 7.5 shows the level curves of one reflectance map. Although the duck image appears simple, the segmentation algorithm has divided it into thirty regions requiring the computation of thirty reflectance maps. This number is larger than necessary but consistent with the complexity of the image. It should be remembered that the form of the reflectance map as well as the albedo constant may vary between regions making it a nontrivial task to use common information from several regions. The graphs in figure 7.6 show the depth map produced by stereo, that produced by filtering the stereo output and that produced by the current approach. The top pictures in figure 7.7 and figure 7.8 show the results of stereo processing and subsequent smoothing using a trimmed mean filter. The upper pictures in figure 7.7 have been generated by shading the corresponding depth maps with the single source (1; 1; 1)=q(3). Figure 7.8 contains the corresponding level curves of the recovered surfaces. 117 The lower pictures in figure 7.7 and figure 7.8 show the final results of processing. The lower pictures in figure 7.7 have been generated by shading the depth map with single sources at (1; 1; 1)=q(3) and (0; 0; 1). The lower graph in figure 7.8 is the corresponding set of level curves. From the first image, it can be seen that very small features of the surface such as the musical score have been recovered. Since those features are perpendicular to the surface, it is not surprising that they are not visible in the second image. From the level curves it is clear that some features, such as the hands were accurately recovered. Other regions show the persistence of errors resulting from stereo and segmentation problems. However, it is clear that the result is much better than that achieved using only stereo information. 7.6 Conclusions This chapter has presented a direct method of calculating the reflectance map that avoids both the complexity of estimating the parameters of nonlinear surface reflectance functions and the complexity of estimating the light source distribution. The reflectance map is modelled as a polynomial function of the components of the normal vector. It has been shown that polynomial reflectance models are easily incorporated into the standard approaches to shape from shading. The reflectivity modeller and shape from shading module have been incorporated into a complete shape analysis approach designed to provide accurate autonomous surface reconstruction. Stereo estimation, image segmentation, depth segmentation, and shape from shading using automatically generated reflectance maps are all considered to be important components of a complete approach. Results indicate that the integrated approach provides much more accurate results than those obtainable from stereo. However, there are many sources of error in a complex system, not all of which are thoroughly understood or modelled. Obtaining complete feedback and convergent error correction are still significant challenges to the approach. 118 Figure 7.1 Image of Cherub, outlines of the image segmentation and depth segmentation, and level curves of the reflectance map. 119 Figure 7.2 Depth map from stereo, filtered depth map from stereo, and final depth map produced by integrated approach. 120 Figure 7.3 Shaded depth map from stereo, shaded filtered depth map, and the final result illuinated from (1; 1; 1)=q(3) and (0; 0; 1) 121 Figure 7.4 Level curves of the stereo result, level curves of the filtered stereo result and the level curves of the final surface. 122 Figure 7.5 Image of Donald Duck, outlines of the image segmentation and depth segmentation, and level curves of a reflectance map. 123 0 20 40 0 20 40 -20020 0 20 40 0 20 40 -20020 0 20 40 0 20 40 -20020 0 20 40 0 20 40 -20020 0 20 40 0 20 40 -20020 0 20 40 0 20 40 -20020 Figure 7.6 Depth map from stereo, filtered depth map from stereo, and final depth map produced by integrated approach. 124 Figure 7.7 Shaded depth map from stereo, shaded filtered depth map, and the final result illuinated from (1; 1; 1)=q(3) and (0; 0; 1) 125 Figure 7.8 Level curves of the stereo result, level curves of the filtered stereo result and the level curves of the final surface. 126 8 THEORY OF COLOR SHADING 8.1 Introduction This chapter discusses the role of color in source estimation and three-dimensional shape estimation. A novel algorithm for shape estimation in the case of color invariant reflectance functions is presented. It is shown that several common reflectance functions exhibit a relationship between color variation and surface orientation. Several standard shape from shading algorithms are modified to make use of color information and the resulting shape estimation procedures are discussed in practical terms. In addition, a novel shape from shading algorithm is proposed for situations under which color variations strongly constrain surface orientation. In order to better understand the notation used in this chapter, it should be noted that the symbol E is generally reserved for image irradiance which is, properly speaking, a function of wavelength, E(*). The symbol I is used to denote the brightness of a color image that results from filtering the image irradiance with a set of filters q(*). The reflectance map is denoted R and is generally a function of wavelength. However, R denotes a color reflectance map which may be viewed as a vector in the color space whose explicit dependence on wavelength has been eliminated through a filtering operation. In addition, the equation E(*) = R(p; q; *) is generally called the image irradiance equation while the equation I = R(p; q) is called the color image brightness equation or simply the image brightness equation. 127 8.2 Color Reflectance Maps This section describes the ways in which common reflectance maps depend upon color. Such dependency may arise as the result of light source variation or variation in the reflectance function of the surface. Since light sources are often very homogeneous, it is the latter effect which is of more importance to computer vision. 8.2.1 Color dependency on light source variation One mechanism contributing to the variation in object color with surface orientation is the color variation in the light source distribution. The simplest case is that of two distinctly colored, infinitely distant light sources placed at different positions on the Gaussian sphere. Taking the surface reflectance function to be Lambertian and the surface to be white results in the following equation for the image brightness, I = ( ^n \Delta ^l1)c1 + ( ^n \Delta ^l2)c2 where ^li is a light source direction vector and ci is a color vector associated with the particular light source. In this simple case, the image brightness, I, is simply a weighted sum of the two color vectors where the weight varies with the orientation of the surface. If the assumption that the reflectance function is color independent is maintained while dropping the requirement that it be Lambertian and allowing a general light source distribution in the spirit of chapter 6, the image brightness can be written, I = mX i=1 ci ~R( ^n; ^l) where ~R is a color independent reflectance map. Again, the image brightness is a linear sum of the various color vectors and the method of chapter 6 can be used to recover each component color separately. More details are given in section 8.3.2. In the case of multiple distinct light sources, it is also possible to recover the surface shape more easily than for the uniform color case. Drew provides a solution for the case of a Lambertian surface and suggests a method for extending the solution to surfaces 128 with specularities that occupy a relatively small area [21]. That method is reviewed in section 8.4. More general solutions are also discussed. 8.2.2 Color variation of standard reflectance functions This section reviews several common reflectance functions, examining the manner in which the color of the reflected light varies with orientation. Many reflectance functions based on physical principles contain terms in which the dependency on wavelength is a function of surface orientation. This is true for diffuse, specular and dichromatic reflectance functions. 8.2.2.1 Diffuse reflectance A good model of diffuse reflection that has recently been proposed is the model of Wolff [96]. Here, a simplified version of that reflectance function is examined and found to exhibit a coupling between color dependency and surface orientation. The Wolff reflectance law for a colored surface with index of refraction, n, is given by E(*) = Li(*)ae(*)[1 \Gamma F (; n; *)] cos()[1 \Gamma F ( _OE; 1=n; *)] where ae(*) is the diffuse albedo and Li(*) is the radiance of the incident light. In addition, is the angle between the local surface normal and the incident direction, OE is the angle between the local surface normal and the reflectance direction and _OE is the corresponding internal transmission angle obtained by applying Snell's law. Furthermore, F (\Delta ; \Delta ; *) is the Fresnel power reflection coefficient. The first Fresnel term describes the behavior of the incident light as it enters the material. The second Fresnel term describes the behavior of the light exiting the material in the direction of the viewer. The cosine term in the middle describes the forshortening of the surface as seen from the incident direction. The diffuse albedo describes the effects of internal scattering from colorant particles. Since the diffuse albedo is approximately independent of the direction of the surface normal for large values of the single scattering albedo, it will be assumed constant in this 129 discussion. Conversely, the Fresnel coefficient functions may be dependent on both the direction of the surface normal and the wavelength of the incident light. The Fresnel coefficients are composed of two terms, one normal and the other parallel to the plane of incidence. A good reference is that of Lorrain and Corson [60]. The normal component, FN , and parallel component, FP , are given by FN (`i; `t) = 8!: n1 n2 cos(`i) \Gamma _r1 _r2 cos(`t) n1 n2 cos(`i) + _r1 _r2 cos(`t) 9=;2 FP (`i; `t) = 8!: n1 n2 cos(`t) \Gamma _r1 _r2 cos(`i) n1 n2 cos(`t) + _r1 _r2 cos(`i) 9=;2 The total power is given by, F = (1=2)(FN + FP ). In this expression for the reflected power, dependency upon the wavelength of the incident light enters primarily through the index of refraction. Healey [34] gives an expression for the complex index of refraction, n, in terms of fundamental physical quantities, n2(*) = _fflc 2 2 8?!? : 264 1 + 0@1 + *oe2sscffl! 21A1=2375 + i 2641 + 0@1 + *oe2sscffl! 21A1=23759?=?; Note that both ffl and oe may also depend upon wavelength, making the relationship of the index of refraction to wavelength quite complex. Here, ffl is the electrical permittivity, _ is the magnetic permeability, and oe is the conductivity of the material. The point of this discussion is the fact that the Wolff reflectance law given above has a different geometric dependence for each value of the wavelength of the incident light. Or, stated another way, the power spectrum of the received light is unique to the orientation of the surface patch. Therefore, if the relationship were known, it would be possible to identify the orientation of a surface patch from its power spectrum. An identical theme is repeated in the following sections on specular and dichromatic reflectance. 8.2.2.2 Specular reflectance A good model of specular reflectance is given by Cook and Torrance [15]. The CookTorrance model includes both diffuse and specular terms, but the specular term introduced by Torrance and Sparrow [92] is of primary interest here. 130 The specular part of the Cook-Torrance reflectance function can be written E(*) = Li(*)ae(*)( ^n \Delta ^l) F (*)DGss( ^n \Delta ^v)( ^n \Delta ^l) where F is the Fresnel reflection coefficient, D is the microfacet distribution function and G is a geometric attenuation factor. As usual, ^n is the unit surface normal, ^l is a unit vector in the direction of the light source, and ^v is the unit viewing vector. The Fresnel coefficient is as given in the previous section. The microfacet distribution function used here is that proposed by Beckmann and Spizzichino [7] and reported by Watt [95], D = 1m2 cos4 ff exp "\Gamma tan 2 ff m2 !# where m is the root mean square slope of the microfacets. In addition, ff is the angle between the normal to the microfacet and mean surface normal. The angle ff can be found from cos ff = ^n \Delta ^h where ^h = (^l + ^v)=jj^l + ^vjj is the bisector of the light source and viewing rays. The geometric attenuation factor, G, has been derived by Blinn [10] and is given by G = min (1; 2( ^n \Delta ^h)( ^n \Delta ^v)(^v \Delta ^h) ; 2( ^n \Delta ^h)( ^n \Delta ^l)(^v \Delta ^h) ) The second term describes attenuation due to masking of reflected light and the third term describes attenuation due to shadowing of incident light. As can be seen by examining the terms of the Cook-Torrance specular reflectance model, the geometric dependency on wavelength enters through the Fresnel coefficient as in the case of diffuse reflection. In each case, Healey [34] has shown empirically that the effect is weak for most materials. However, the reflectance functions of materials such as dieletrics are best described by a dichromatic reflectance model containing both diffuse and specular components. In this case, described in the next section, the relationship between geometry and power spectrum can be dramatic. 8.2.2.3 The dichromatic reflectance model The previous two sections have described diffuse and specular reflection. Diffuse reflection is often also denoted body reflection because it is the result of a process in 131 which light penetrates the body of the material and is retransmitted. Similarly, specular reflection is often referred to as surface or interface reflection because it is the result of light that is reflected at the interface without penetrating the material. Although some materials can be described by purely diffuse or purely specular reflection models, many materials are dichromatic, exhibiting both phenomena. A simple model introduced by Shafer [87] and studied by Klinker, Shafer, and Kanade [49] considers the reflectance function to be a sum of a diffuse term and a specular term. The diffuse and specular terms are further decomposed into geometric and spectral factors. Thus, the resultant model has the form, E(*) = L(*)[ms(i; e; g)cs(*) + mb(i; e; g)cb(*)] where ms and mb are the surface and body geometric terms, respectively, and cs and cb are the surface and body spectral terms, respectively. Furthermore, i; e; g, are the incident, emittance, and phase angles while * is the wavelength of light. It can be seen that the Shafer model embodies a simplification that appears to contradict the close coupling of spectral and geometric properties within the component terms that was demonstrated in the previous sections. For example, within the body reflectance term, geometry and spectrum are decoupled. The same is true of the surface reflectance term. However, Healey [34] has shown that such coupling is often weak, a fact justifying the above decomposition for many materials. In particular, the above model is appropriate for many dielectric materials. Healey [34] has also argued that the surface decomposition is accurate for many metals. For present purposes, the significance of the dichromatic model is that it provides a simple model in which there is a strong coupling of geometry and spectrum that appears in the interaction of the body and surface terms. For dielectrics, the surface spectral reflectance factor, cs, is nearly independent of wavelength so that the reflected light has nearly the same spectrum as the source. On the other hand, the body spectral reflectance factor, cb, is generally a strong function of wavelength. Furthermore, the surface geometric reflectance factor, ms, is generally a strongly peaked function with its 132 peak at the specular angle. Conversely, the body geometric reflectance factor, mb, is generally a relatively slowly varying function of geometry. Consequently, the body color dominates the appearance of the object for most viewing angles but the source color dominates near the specular angle. 8.3 Source Estimation from Color Shading In this section, several monochromatic source estimation algorithms are extended to color shading. 8.3.1 Estimation of the direction of a single source This section describes a method for computing the source direction from the shading of a multicolored scene. It is similar to a method given by Brooks and Horn[13] and reported in chapter 3. for uniformly colored scenes Consider the following functionalZ Z (I (x; y) \Gamma c(x; y)( ^n(x; y) \Delta l))2dxdy Differentiation with respect to the light source vector yields the following vector equation describing the condition for a minimumZ Z 3X i=1( Ii \Gamma ci ^n \Delta l)ci ^ndxdy = 0 Using the relation, ( ^n \Delta l) ^n = ( ^nT l) ^n = ^n( ^nT l) = ( ^n ^nT )l the above expression can be rearranged to solve for l. The solution is l = "Z Z ( 3X i=1 c2i ) ^n ^nT dxdy# \Gamma 1 Z Z ( 3X i=1 Iici) ^ndxdy This equation can be used to solve for the light source vector using the initial surface estimate provided by stereo. Note that use of this equation requires knowledge of the color vectors. 133 8.3.2 Determination of the source distribution from color shading This section contains a solution to the problem of determining the color source distribution from color shading. It is shown that if the surface reflectance function is independent of the wavelength of the incident and reflected light, then the spatial distribution of the incident light can be recovered. For a surface region illuminated by a continuous light source located at infinity, the total image irradiance, E, is E(*) = ae(*) Z \Omega F ( ^n; ^l)Ls(^l; *)d\Omega where ae(*) is the surface color, F is the surface reflectance function written as a function of the normal, ^n and the incident light source direction, ^l, and Ls is the source radiance incident on the surface. The integral is taken over the sphere of possible incident directions and \Omega is the projected solid angle. The source radiance Ls may be approximated by contributions from a set of m distinct light source directions, ^l1; ^l2; . . . ; ^lm Given this definition, an approximation to the image irradiance may be written E(*) ss ae(*) mX i=1( ^n(x; y) \Delta ^li)F ( ^n; ^li)Ls(^li; *) where the dot-product term results from the projected solid angle. Let q1(*); . . . ; qJ (*) be a set of sensor response functions. Then the jth component of the image brightness is given by Ij = Z \Lambda qj(*)ae(*) mX i=1( ^n \Delta ^li)F ( ^n; ^li)Ls(^li; *)d* Because the surface reflectance function is assumed to be independent of wavelength, it can be removed from the integral and the image brightness may be written Ij = mX i=1( ^n \Delta ^li)F ( ^n; ^li) ~Lj(^li) where the function ~Lj is given by ~Lj (^li) = Z \Lambda qj(*)ae(*)Ls(^li; *)d* 134 As in chapter 6, the directions of the light sources are taken to be fixed sampling directions. Therefore, it is possible to set aij = ~Lj(^li) where each aij is an unknown constant. Let Ij be measured at K image points, pk, where 1 ^ k ^ K. Then, for k = 1; . . . ; K, Ijk = mX i=1( ^nk \Delta ^li)F ( ^nk; ^li)aij This is a set of K linear equations for a1j; . . . ; amj. If K * m and the corresponding matrix is of full rank, a unique solution exists to the corresponding least squares problem. As in the monochromatic case, estimates of the surface orientation are provided by the stereo program. Solution of the equations is also as in the monochromatic case reported in chapter 6. It should be noted that in this formulation, the color of the light source distribution cannot be separated from the color of the surface. Separation of these effects is called the color constancy problem and is not addressed here. However, it is clear that more information is required to accomplish the separation. 8.4 Shape from Color Shading This section examines algorithms for obtaining shape from the shading of colored objects. The first approach covered in this section is a method of obtaining shape from local color shading information when the surface is Lambertian. Next, modifications of several standard shape from shading algorithms are presented. Finally, a new method for obtaining shape from local color shading information in the case of a general color reflectance function is presented. 8.4.1 Recovery of a Lambertian surface This section reviews the surface shape recovery approach of Drew [21]. It is based on the assumption of color variation due to lighting variation. Consider the case in which a uniformly colored Lambertian surface is illuminated by m light sources, l1; . . . ; lm, with corresponding colors, ~c1(*); . . . ; ~cm(*). Let ae(*) describe 135 the color of the surface and let q(*) be the vector of sensor response functions. Then, the color of an image point, (x; y), is given by I(x; y) = mX i=1 ci( ^n(x; y) \Delta li) where ci is the color of the light generated by a particular light source and reflected by the surface and is given by ci = Z ae(*)~ci(*)q(*)d* The above expression for the image brightness can be rewritten in matrix form as I (x; y) = CM ^n(x; y) where the following geometry and color matrices have been defined M = 0BBB BBBBB @ lT1 lT2 \Delta lm 1CCC CCCCC A and C = (c1; . . . ; cm) Here, C is 3 \Theta m and M is m \Theta 3. The geometry and color matrices may be combined by defining A = CM . Then, the image brightness equation reduces to the following linear system, I = A ^n As Drew points out, this model is only valid when every light source can be seen by every surface patch. The model breaks down when there is shadowing or self-shadowing. For the matrix A to be invertible, the geometry and color matrices must be of full rank. So, if there are three light sources, then the light source directions, l1; l2; l3, must be linearly independent. In addition, the sensory color vectors, c1; c2; c3, must also form a linearly independent set. 136 Let B be the inverse of A. If estimates of ^n were given, for example, by stereo, it would be possible to estimate B directly and the final set of normal vectors would be given by ^n = BI. However, Drew has shown that even in the complete absence of estimates of ^n it is possible to place strong constraints on the possible solutions. Since ^n is of unit length, 1 = ^n \Delta ^n = IT BT BI = IT DI The matrix D is symmetric positive definite and consists of 6 independent elements corresponding to the parameters of an ellipsoid centered at the origin. Expanding the expression for D yields the following equation for an ellipsoid, d11I21 + d22I22 + d33I23 + 2d12I1I2 + 2d13I1I3 + 2d23I2I3 = 1 This is linear equation in the unknown coefficients and a least squares solution is easily obtainable. Once D has been estimated, it is possible to put constraints on the matrix B. In fact, B can be found up to a rotation. This can be seen by writing D = BT W T W B where W is an arbitrary rotation matrix. If the estimate, ~^n = W BI is used, then each vector ^nij is given up to a rotation. Drew does not take this solution further and it would be interesting to see if integrability constraints could be used to recover a unique solution. It should be noted that real scenes are often not as cooperative as those required for this method to work. As mentioned previously, light spectra are often quite uniform. Moreover, most reflectance functions exhibit only weak coupling between color and geometry and that coupling is generally nonlinear. The next sections discuss methods of using weak color information. 137 8.4.2 Variational approach In section 3.5.2 various function minimization approaches to the surface estimation problem were introduced. Although such approaches have not been found to be as robust as the optimal control approach, they are easy to extend to situations in which additional information, such as that provided by color images, is available. This section and the next examine some of those extensions. Consider once again the variational approach of Horn [42]. The variational approach can be extended to color images by modifying the term in the objective function quantifying departure from the image irradiance equation. Thus, a color image brightness equation of the form, I (x; y) = R(p; q) where I and R are each vectors in an appropriate color space, gives rise to an objective function of the form, Z Z [(I(x; y) \Gamma R(p; q))2 + *(p2x + p2y + q2x + q2y) + _((zx \Gamma p)2 + (zy \Gamma q)2)]dxdy The first term of the criterion function penalizes departure from the image brightness equation. The second term is a smoothing term written as a penalty on the squared variation of the components of the gradient field. The third term is designed to enforce integrability by penalizing the departure of the components of the gradient field from their defined values in terms of an underlying surface. The Euler equations corresponding to the above criterion function are found to be *r2p = \Gamma 3X c=1(I c \Gamma Rc)(Rc)p \Gamma _(zx \Gamma p) *r2q = \Gamma 3X c=1(I c \Gamma Rc)(Rc)q \Gamma _(zy \Gamma q) r2z = px + qy 138 There is one Euler equation for each unknown image function. Together, they form a set of coupled second order differential equations. The principle difference between this set of update equations and the previous set is the appearance of a sum over the dimension of the color space. The color method is expected to work better than the monochromatic method when the components of the reflectance map, R, differ widely, as in the case of a Lambertian surface illuminated from distinct directions with distinctly colored light sources. The reason for this expectation is related to a difficulty with the monochromatic method. Examination of the update equations for the monochromatic method shows that if a component of the gradient of the reflectance map is small, the image irradiance term provides only a weak constraint on the value of the corresponding surface gradient. So, if Rp is small, then p is difficult to determine whereas if Rq is small, then q, is difficult to determine. In general, the gradient of the surface is difficult to determine when it lies in the direction perpendicular to the gradient of the reflectance map. In the case of a color image, however, there are multiple reflectance maps that may provide constraints in several directions simultaneously. In the case of several distinct sources with distinct spectra, the reflectance maps act to constrain the shape of the surface locally, thereby easing the updating process. If the reflectance maps are all very similar, then the method will do no worse than the monochromatic method. Thus, this is a method for making use of additional information when it is available, but it is not critically dependent on the presence of such information. Similar conclusions can be drawn about the discrete approach described in the next section. 8.4.3 Discrete approach In section 3.5.3 a discrete approach was introduced as a method of eliminating the need for separate representations of the gradient field and surface height function. This section explores the extension of that approach to color images. In the direct height from color shading method the surface height (or depth) is represented as a discrete array fzijg and the objective function to be minimized is given 139 by Q = X ij (1 \Gamma fl)( Iij \Gamma R(pij; qij))2 + fl(u2ij + v2ij) where I is the image brightness, R is the color reflectance map, and p; q; u and v are functions of the surface height variables fzijg. The variables, p and q are approximations to the derivatives zx and zy respectively. The variables u and v are approximations to the second derivatives zxx and zyy respectively. The parameter fl is used to control the amount of smoothing and is treated as a continuation parameter that is gradually reduced to zero. For simplicity, the albedo is assumed to be unity. Using the derivatives defined in section 3.5.3 the gradient of this objective function can be written, @Q @zi;j = \Gamma 2 n (1 \Gamma fl) 0X k=\Gamma 1 0X l=\Gamma 1 3X c=1( Ic;i+k;j+l \Gamma Rc;i+k;j+l) @Rc;i+k;j+l@z i;j + 2n fl 1X k=\Gamma 1 1X l=\Gamma 1 ui+k;j+l @ui+k;j+l@z i;j + v i+k;j+l @v i+k;j+l @zi;j The objective function and its gradient can again be used to obtain an estimate of the surface using the conjugate gradient algorithm. As in the case of the variational approach, the color shading method is expected to perform better than the corresponding monochromatic image method. Although it is more difficult to see in the discrete formulation, the reason is basically the same. The gradient of the surface is only weakly determined when the gradient of the reflectance map is small. With more than one reflectance map, it is more likely that the gradient of at least one will be large. 8.4.4 Local shape from color shading In some cases the surface orientation is locally determined by color. In such cases, it is useful to pursue the direct recovery of shape from color shading by forming the inverse image irradiance equation. Section 8.4.1 discussed a method applicable to scenes in which the surfaces are Lambertian and in which the color variation is due to lighting 140 variation. This section discusses a more generally applicable method which may be used when an initial surface estimate is available. The method discussed here is applicable to scenes with surface reflectance functions that are not constrained to be Lambertian and in which the color variation may or may not be the result of lighting variation. 8.4.4.1 Conditions for the existence of an inverse The image brightness equation for a color image may be written I (x; y) = R(n1(x; y); n2(x; y)) where I and R are vectors in a color space, say the RGB space, and n1 and n2 are the first two components of the surface normal. If the color space is three-dimensional, then the reflectance map, R is a mapping from a two-dimensional space into a three-dimensional space. Estimation of the surface normals would be greatly simplified if it were possible to write ~n(x; y) = G(I(x; y)) where G = R\Gamma 1 is the inverse reflectance map and ~n = (n1; n2). Thus it becomes of interest to determine the conditions under which the inverse mapping exists. The inverse function theorem [84] states, roughly, that for any continuously differentiable mapping, f , an inverse exists in the neighborhood of a if f 0(a) is invertible. In the present case it is assumed that R is continuously differentiable. In practice, R tends to be very smooth, so this is not a difficult assumption to satisfy. Let ~n0 be a point of the domain and let A = R0( ~n0). An inverse exists in a neighborhood of ~n0 if A is invertible. Strictly speaking, A is only invertible if it is a square matrix. However, the concept of pseudo-inverse is applicable in cases where the dimension of the color space is greater than two. Such a pseudo-inverse exists whenever A has a rank of at least two. If the reflectance map is linear, this will occur whenever two colors are linearly independent functions of (n1; n2). If the reflectance map is nonlinear, then the independence must be checked at each point of the domain. 141 Although it is likely that randomly chosen reflectance maps will exhibit independence and thus invertibility, nature may not be so kind. The dichromatic model of Shafer [87] suggests that the color will often occupy only a small `L'-shaped region in a two-dimensional subspace of the color space. Nevertheless, it is useful to consider methods that are applicable when additional information is present. 8.4.4.2 Surface estimation Consider estimation and use of the inverse reflectance map or surface function, S. The inverse color image brightness equation may be written ~n(x; y) = S(I(x; y)) If an initial estimate of the surface height function, z(x; y), is provided, say by stereo, then estimation of S is a regression problem with S an unknown function of I. If S is written as a weighted sum of basis functions, then estimation of S is a linear regression problem. If B1; . . . ; Bm are basis functions then S may be written S(I) = mX i=1 ` iBi(I) where `i; i = 1; . . . ; m are weights. Each component of S may also be modelled separately. In this case, the models would be written, Sj(I) = mjX i=1 `jiBji(I ) where j = 1; 2. In this case, a separate linear estimation step is required for each component of S. However, the modelling is more flexible since the components are modelled separately. Once the surface model has been estimated, the components of the surface normal can be determined at each image point by simple model evaluation. After the normals have been calculated, they must be combined to produce a surface height map. This point receives scant mention in the literature and yet is quite important. It is quite likely that the surface normal estimates will be inconsistent. That is, they will not correspond to any 142 valid surface. This results from the fact that the surface normals or their corresponding gradients overdetermine the surface. A surface has only one degree of freedom at each point while the gradient has two. Therefore, some method must be found to handle errors in the gradient field. A possible method of surface estimation is to form the least squares solution, giving the x and y components of the gradient equal weight. In this case, the objective function to be minimized can be written, D(z) = Z Z \Omega (^p \Gamma zx) 2 + (^q \Gamma zy)2dxdy where ^p and ^q are estimates of the surface gradient and z(x; y) is the unknown surface height function to be estimated. This problem is conveniently solved in the Fourier domain. Using Parseval's theorem it can be shown that if \Omega is taken to be the entire plane, then the objective function can be rewritten as D(z) = Z 1 \Gamma 1 Z 1 \Gamma 1[( ^P \Gamma i!1Z)] 2 + [( ^Q \Gamma i!2Z)]2d!1d!2 where ^P ; ^Q and Z are the Fourier transforms of ^p; ^q and z respectively. The above integral is minimized by minimizing the argument at every point of the domain. Carrying out the minimization yields the following estimate of the transformed surface height function, ^Z = \Gamma i(!1 ^P + !2 ^Q)!2 1 + !22 The final estimate of the surface height function, ^z(x; y) is found by inverting the transform. In conclusion, it can be seen that there is a fast, linear algorithm for surface recovery from color images. This algorithm is valid for any reflectance function provided that the color variation is sufficient to constrain the surface orientation at each point. 143 8.5 Conclusions This chapter has shown that color plays an important role in estimation of the source distribution and surface shape. Shape related color variation was shown to result from both lighting variation and reflectivity variation. Several common reflectance functions were shown to exhibit a coupling between surface shape and the spectrum of the reflected light. Algorithms for recovery of a single source and a colored light source distribution were presented. Several algorithms for estimation of surface shape including a novel direct estimation algorithm for general reflectance functions were also presented. 144 9 SHAPE FROM APPEARANCE 9.1 Introduction This chapter describes a method of surface shape estimation that involves automatic generation of an associative model that relates surface shape to appearance. In a very different approach, Lehky and Sejnowski [58] explored the use of an associative model on simple artificial examples. Here, the model parameters are estimated using examples provided by a stereo algorithm and the model is tested on real images. It is shown that through a scale change and the use of a smoothness requirement, the statistically estimated model can be made to be more accurate than the source of examples. Associative modelling techniques are considered to be important for a number of reasons. The shape estimation procedure described below is a generalization of physics based methods and embodies many of the advantages of such methods with few of the disadvantages. Physics based methods generally rely heavily on idealized models of the image formation process which do not capture the complexity of real scenes [25, 9, 43, 44, 45]. In addition, such models often contain hard to estimate parameters [44, 45]. However, shading information, in particular, is useful for recovering small surface detail. In comparison, methods that rely upon the coincidence or correlation of features in two or more images, such as stereo and motion based methods, cannot be used to recover small surface detail due to the resolvability problem discussed in chapter 4, and the fact that accuracy drops with the square of depth. In addition, such methods are only reliable in highly textured regions or in the presence of well defined image features. However, such methods are based on relatively weak assumptions and are therefore useful for recovering coarse or sparse depth estimates. Chapters 5, 6, 7 and 8 discuss integrated methods which combine the strengths of the above methods while avoiding many of the limitations. The research reported there 145 demonstrates the advantages in resolution, accuracy and range of applicability that can be achieved through integration. In addition, some of that research has involved generalization of reflectance and lighting models used previously. However, despite the increase in generality, such methods are still dependent upon highly restrictive idealized models of the image formation process. In order to overcome the above limitations, a general method based on statistical model estimation is proposed for obtaining surface shape from appearance. In general, both local and nonlocal information is required to estimate the shape of a surface at any given image point. However, it is conjectured that most of the information is available locally and that nonlocal information is primarily a source of simple contextual information. Contextual information is required when it is impossible to determine the cause of a visual effect locally. For example it might be impossible to locally determine whether an effect is the result of surface coloration, lighting, or surface shape. It might also be impossible to determine the sign of the surface curvature locally. Once the determination is made, however, it is generally valid for an entire region, not just at a single point. Regardless of the amount of contextual information provided, the relationship between local appearance and corresponding surface shape can be captured in the form of a probability density function. The density estimation problem encountered here is the continuous analogue of the pattern recognition problem [22, 48, 50, 55, 99] and is closely related to function learning problems encountered in robotics [70, 71, 72, 80]. Indeed, in the presence of global, contextual information, it may be possible to simplify the problem and treat the local relationship of shape to appearance as a functional relationship. This approach is explored in the following sections. 9.2 Algorithm Overview There are three major components of the local shape-from-appearance estimation procedure, (1) generation of coarse surface shape estimates for statistical modelling, (2) estimation of the associative model governing the statistical relationship of shape to 146 appearance, and (3) surface shape estimation through application of the statistical model to the desired image. Figure 9.1 illustrates these components in an approach in which stereo is used to generate the coarse shape estimates. Generation of the coarse surface shape estimates involves the use of a standard vision algorithm such as a stereo or motion algorithm. The purpose of using a stereo or motion algorithm to generate the coarse estimates is that such algorithms are based on weak assumptions of lighting, reflectance, and other image properties. Therefore, such algorithms are capable of producing coarse yet reasonable estimates under a wide range of conditions. Perhaps the most important limitation of such algorithms, other than the coarseness of the results, is the fact that they are unreliable in featureless regions. However, featureless regions are generally smooth, a fact which can be exploited in the later processing stages. Estimation of the associative model governing the relationship of shape to appearance is accomplished by associating examples of estimated surfaces with corresponding examples from images as illustrated in figure 9.2. Each example of surface shape and appearance is represented by one or more mathematical features which are designed to capture important information about the examples. The relationship between corresponding examples is represented by a statistical model and serves as a substitute for the derivation of an idealized model as is usually attempted for shape from shading methods. Shape from shading methods are generally based upon restrictive assumptions about lighting, reflectance and surface coloration that are violated by most real world scenes. By comparison, the present method is based only on the weak assumption that there is some statistical relationship between appearance and shape. More precisely, it is based on the assumption that the conditional density of shape given appearance is not uniform. If the relationship between appearance and shape is particularly simple, it may be possible to replace estimation of the probability density with estimation of a mapping function. In this case the model is referred to as an associative map. The general approach and special case of an associative map are discussed in detail in the following sections. 147 Camera Camera StereoModule ShapeModule LearningModule Image Surface Shape Image Depth map AssociativeModel Figure 9.1 Data flow diagram for the shape from appearance method. A pair of cameras provide images to a stereo module which produces coarse shape estimates. The learning module produces and associative model of the relationship of shape to appearance. The shape module uses the model to estimate the surface shape of novel objects. 148 (x,y)f \Omega z \Omega I I(x,y) g z(x,y) s(x,y) f y Figure 9.2 Associative mapping. The image, I, is represented through OE by a set of features f and the surface z is represented through by the shape function s. The learning module estimates an associative mapping g from f to s. The shape module finds the shape function, s, associated with a novel image and inverts to produce the corresponding surface height function, z. 149 Surface shape estimation is accomplished through application of the previously estimated associative model to the desired image. The features calculated at a particular image location serve as input vectors to the associative model, allowing the statistically expected shape parameters to be computed at that location. The surface description obtained in this manner may be transformed into a more recognizable form by inverting the feature calculation process. A method for accomplishing this inversion is given in the following sections. 9.3 Associative Modelling Let z : A ! !\Gamma be a surface height function and I : A ! [0; Imax] be an image brightness function defined on A ae !2. The functions z and I may be viewed as members of the ensembles Z and I respectively where Z is the set of all viewable height functions and I is the set of all images of the height functions in Z. For a single surface height function, a wide variety of possible lighting conditions and surface marking patterns make possible a wide variety of possible images. Conversely, a single image may correspond to more than one surface height function. However, the main point of interest is that some height functions are more likely than others to have produced a given image. The problem considered here is to find the surface most likely to have produced a given image. Note that the problem considered here is more complex than the typical pattern recognition problem. In the latter case, the only output is a category label. Here an entire surface height function is required. If it were true that the shape of the surface at a particular point was only dependent upon the image in a small neighborhood of that point then the problem could be significantly simplified. In that case, the shape could be determined at every surface point from a summary of the information in a neighborhood of that point in the corresponding image. Although it is not generally true that the surface shape can be determined locally, one approach to the general problem is to assume that the local estimation method can be 150 made to work if the values of certain global parameters are known. That is the approach taken here. 9.3.1 Choosing features In order to make the above formulation more precise, it is necessary to find representations of the image, the surface height function, and the relationships between them that capture information important to the surface estimation task. There are numerous possible representations of surface shape and appearance. Surface shape may be represented by the surface height Z(x; y) or by its first or second derivatives, Zx; Zy or Zxx; Zxy = Zyx; Zyy respectively. Two important criteria for choosing a surface representation are that it be simple and complete. Therefore, it is natural to seek a single feature operator such that it is possible to reconstruct the surface from z. In addition to simplicity and completeness, it is necessary to consider learnability. In the present context, a representation is learnable if it is possible to estimate it at each point from locally available image information. Surface height is difficult to estimate locally as is surface slope. In contrast, higher order attributes of surface shape such as curvature are much more apparent in an image. For these reasons, it is desirable to use the second derivatives or other high order functions of the surface shape in the density estimation process. One difficulty that accompanies the direct use of the derivatives of the surface is that real surfaces need not be differentiable. Computationally this implies a scale ambiguity problem. Derivatives must always be estimated at some scale and that scale must be made explicit to avoid scaling errors. Therefore, a reasonable scheme for generating surface features is through the use of a filter based on the second derivatives of a smoothing filter. Experimentation has shown that in addition to the criteria of simplicity, completeness, and learnability, the criterion of circular symmetry is important. A surface representation which satisfies all of these criteria is obtained by convolution of the original surface with the Laplacian of a Gaussian smoothing filter. Thus, the surface operator is defined to be 151 = r2G(oe)\Lambda where G(oe) is the two-dimensional Gaussian. The surface is represented by s(x; y; oe) = (oe)z(x; y) = r2G(oe) \Lambda z(x; y). Here, the scale, oe, is made explicit in order to emphasize its importance to the shape estimation procedure. In the next section, one method of recovering z from s(oe) is given. Just as it is useful to represent a depthmap, z, by a surface, s(oe), it is useful to represent the image I, by an image feature vector, f (oe). The image irradiance at a point reveals little about the local shape of the surface in the absence of extensive knowledge of the scene, but higher order functions of the image irradiance are statistically related to surface shape. A smoothly varying intensity indicates a smooth surface. A bright, narrow specularity indicates a corner, and so on. The most important criterion for choosing an image representation is that it be locally informative. In general, it is possible to define image feature operators, OE1(oe); . . . ; OEk(oe) yielding a set of image features, fj(oe) = OEj(oe)I; j = 1; . . . ; k. The exact choice of image feature operators is much less obvious than was the choice of surface features. The simplicity and completeness of the feature operators is much less important than their informativeness. Moreover, the use of nonlinear feature operators is possible and generally inconsequential to algorithm performance. 9.3.2 Conditional density At a point, (x; y), the conditional density of shape given appearance in the local neighborhood of (x; y) is written p\Lambda (oe)(s(x; y; oe)jf(x; y; oe)) where \Lambda (oe) is a label that depends upon the feature operators and scale factor, oe. If the image feature vector is given on A ae !2 and the surface feature vector at a particular point depends only on the image feature vector at that point then the maximum log-likelihood solution for surface shape given the information about appearance is given by z(x; y) = maxz(x;y) Z Z A log(p\Lambda (oe)(s(x; y; oe)jf(x; y; oe)))dxdy where the maximization is over all functions z : A ! !\Gamma . In general, there may be multiple solutions to the maximization problem. Intuitively, however, multiple solutions 152 exist only when there is insufficient information locally to determine the sign of the surface curvature or to determine whether a given effect is the result of surface coloration, lighting, or surface shape. The above formulation can be simplified by using the marginal probability density in which the dependency upon oe has been removed. This is a reasonable simplification given the fact that most objects that appear in the world are observed at many ranges and therefore at many scales. Moreover, since the `objects' that are of interest for a general purpose shape reconstruction algorithm are generally low level characteristics such as surface bends and curves, it appears to be highly likely that such objects will be observed at all scales. In this case the conditional density is nearly independent of scale and the marginal density has significant structure. More formally, it is assumed that, p\Lambda (oe) ss p\Lambda where \Lambda (oe) = \Lambda for some constant \Lambda . 9.3.3 Scaling to increase power Whether or not the estimation process is scale independent, a scale change can be used to amplify its power. The fact that a surface curve or bend or marking has previously been seen up close, allowing its shape to be accurately determined, means that the shape can be accurately determined later when the surface is far away. In essence, the statistical association between surface shape and appearance determined at a coarse scale is stored in the form of a conditional probability density and used later to accurately determine the surface shape at a finer scale. If the probability density is scale independent, it is not necessary to know the change in scale to reconstruct the surface. As a preliminary, it should be noted that it is only possible to increase power by scaling if the performance is greater for the surface estimation procedure than for the procedure that generates the examples. The performance mentioned here is a combination of resolution and accuracy. As an example, the resolution is higher and the expected error magnitude is smaller for shape from shading methods than for stereo, motion, or focus methods. For further details, see chapter 4. The present method is a relative of shape 153 from shading and has similar performance characteristics. In particular, the resolution and accuracy are higher than for stereo, making possible an increase in performance. Let the probability density, p\Lambda be estimated by examples given at scale oee where oee has been chosen to obtain the maximum performance from the algorithm that produces the examples. Let the final resultant surface be estimated at scale oer where oer has also been chosen optimally or suboptimally with oer * oeopt. Then, if oer ! oee the resolution and hence the performance is increased by a factor of oee=oer. Although the above formulation is very general, use of the density in the surface shape recovery process involves a complex, nonlinear optimization of a criterion function that involves the depth only indirectly. Moreover, estimation of a high dimensional density function is not trivial. In the next section, a simplified model is presented which captures important aspects of the above formulation and facilitates experimentation on real images. 9.4 Associative Mapping To simplify the foregoing formulation, consider the form of the conditional probability density. In many instances considered in computer vision, the probability density will be unimodal and may be well approximated by a normal distribution. The correspondence of a smooth surface to a smoothly varying image could be one such case. In other cases, the distribution might be bimodal and be well approximated by a sum of two normal variates. The correspondence of a long narrow specularity to a surface with a convex or concave bend might be such a case. Given the above considerations, it is convenient to assume that the density is accurately described by a small number of normals and that the peak to be used in the current estimation has already been determined by another process. This is not unreasonable in cases in which a single choice is required for an entire region--for example, when the curvature of a surface has constant sign in a given region of interest. Given 154 the above assumption, the maximization of the log-likelihood reduces to the solution of a least squares problem. Let g : \Omega I ! \Omega z be a function from the image feature space, \Omega I , into the surface feature space, \Omega z, such that s(x; y; oe) = g(f (x; y; oe)) + ffl where ffl is zero mean Gaussian white noise. If the conditional density, p\Lambda , is Gaussian white noise with mean, s(x; y; oe), then g is guaranteed to exist and is given by g(f (oe)) = hs(oe)jf (oe)i where h\Delta i denotes expectation. Thus, estimation of g is a regression problem. Note that the mapping function, g, is assumed to be independent of the the scale factor oe. If the mapping is scale dependent, then g(f (oe)) may be written g(f (oe); oe). Let (f i(oee); si(oee)); i = 1; . . . ; N , be pairs of image feature vectors and corresponding surface shape estimates generated by the stereo program. In order to obtain the least squares estimate of g a criterion function Q is defined by Q(`) = 1N NX i=1( si(oee) \Gamma g(f i(oee); `))2 where g is parameterized by ` = (`1; . . . ; `m). If g is modelled by a linear sum of basis functions, (B1; . . . ; Bm), with coefficients (`1; . . . ; `m). Then ^g may be written, ^g(f i(oee)) = mX j=1 `jBj(f i(oee)) : In this case, the regression reduces to an ordinary linear least squares problem. Figure 9.2 illustrates the relationships between I; OE(oe); f (oe); z; (oe); s(oe) and g. The feature operators, OE(oe) and (oe) transform the functions I(x; y) and z(x; y) into f (x; y; oe) and s(x; y; oe) respectively. The function g maps each point of f (x; y; oe) to a point in the surface feature space that differs from s(x; y; oe) by an amount ffl. 9.5 Surface Estimation In the preceding analysis, g was treated as a random variable with mean s(oee). For purposes of surface estimation, s(oer) is identified as a random variable with mean g. If 155 s(oer)jf (oer) has a normal distribution with mean g(f (oer)) and variance ae2 then log(p\Lambda (s(oer)jf (oer))) = 12ae2 (s(oer) \Gamma g(f (oer)))2 \Gamma ^ where ^ = 12 log(2ssae2) is a constant. Therefore, the maximum likelihood estimate of the surface is found by maximizing the criterion function D(z) = Z Z A(s(x; y; oer) \Gamma g(f (x; y; oer))) 2dxdy over all surfaces z : A ! !\Gamma . Let Z; H(oer); S(oer) and \Psi (oer) be the Fourier transforms of z; g(f (oer)); s(oer) and (oer) respectively. Then, by Parseval's theorem, D(z) = Z Z jS(!1; !2; oer) \Gamma H(!1; !2; oer)j2d!1d!2 = Z Z j\Psi (!1; !2; oer)Z(!1; !2) \Gamma H(!1; !2; oer)j2d!1d!2 The minimum integrated squared error is achieved by the function that minimizes the error at each point of the domain. That minimum is achieved by setting, ^Z = H(oer)\Psi (oe r) The solution surface, ^z, is the inverse transform of ^Z. Although ^z is the maximum likelihood estimate in the absence of noise, a better estimate in the presence of noise is found by Wiener filtering. The resulting optimal estimate is found by setting ^Z = H(oer)\Psi (oer)\Psi 2(oe r) + K2 where K2(!1; !2) = hj2(!1; !2)=Z2(!1; !2)i is the variance of the noise divided by the expected power spectrum of the surface. Under the assumption of white noise, the noise term reduces to a constant. If the surface is assumed to be fractal Brownian, the final value of K2 is given by K2 = j2(!21 + !22)2. The next section contains tests of the mapping estimation and surface recovery procedures applied to real images. 156 9.6 Experimental Results The algorithm described in section 9.2 can be thought of as operating in two major modes, the model estimation mode and the surface estimation mode. In the model estimation mode, the input images are used by the stereo module to produce surface shape estimates which serve as examples to be used in estimating the associative model. In the surface estimation mode, the model is used to estimate the shape of a previously unseen surface. The experiments explained in this section are designed to illustrate both major operational modes. 9.6.1 Model estimation This section describes tests of the model estimation procedure. Here the model is assumed to be described by an associative map as explained in section 9.4. Figure 9.3 shows images of a `ridge' surface viewed at various orientations. Each image is the left image of a stereo pair of images taken at a depth of about 10cm with a baseline of about 1cm. The corresponding depth maps produced by the stereo program are shown in figure 9.4. At this range, the stereo program does a reasonable job of reconstructing the surface. However, a closer look shows that the results are not particularly accurate. Figure 9.5 shows the level curves of the depth maps shown in figure 9.4. Although the general orientation of the surface is visible in these plots, the surface shape is hard to discern. Nevertheless, these results are sufficiently accurate to use in the model estimation phase. Once the surface estimates have been computed by the stereo program, regions from each image and corresponding surface are selected to act as input data for the model estimation procedure. The original data regions are converted to data points, (f i(oee); si(oee)); i = 1; . . . N through the actions of the feature operators, OE(oee) and (oee). For the experiments reported here, the image feature operators were defined to be local, second degree polynomial fits and the output features were the polynomial coefficients. Note that this is a linear set of features that can be computed by convolution with the 157 appropriate filters. Recall that the surface feature operator is defined as convolution with a Laplacian of a Gaussian smoothing filter. Figure 9.6 shows a plot of the surface data projected onto a two-dimensional subspace of the image feature space. The size of each dot shows its magnitude. The clear trend in the data suggests that a low order model should account for a large percentage of the variance. In this work, the mapping function, g, is represented by a low degree polynomial. Figure 9.7 shows two projections of a third degree polynomial onto a two-dimensional subspace of the image feature space. In this case, the average residual error is 37%. Although this appears to be a large error, the accuracy of the final surface estimate shown in the next section indicates that most of the error is due to noise in the stereo surface estimates and does not indicate a modelling problem. 9.6.2 Surface estimation This section describes a test of the surface estimation procedure. This test is designed to show that the system can recover the shape of a previously unseen surface that is very different from the surfaces used in the model estimation phase. The shape estimation procedure is conducted using the model estimated from the ridge surfaces of the previous section. The test image is the face shown in figure 9.8. The first step of the surface recovery procedure is calculation of the image feature vector at every image location. Figures 9.9 and 9.10 shows the feature arrays produced using the local polynomial fit method described above using a scale factor oer. Each feature can be thought of as encoding a particular type of information about the local image structure. Once the feature arrays have been computed, the mapping function g is evaluated at each point producing a surface map, s(oer), shown in figure 9.11. The final step of the surface estimation procedure is deconvolution of the surface map using the kernel, (oer), to obtain a surface height map, z, shown in figure 9.12. 158 The final result should be compared with the results produced by stereo and stereo combined with shape from shading shown in figures 7.1 through 7.3. Using stereo alone, the face appears to be an undifferentiated blob with random errant spikes. Using the combined approach involving stereo and shading, the result is much better. However, the small scale errors introduced by stereo have not been completely removed. Conversely, the current method does not depend upon stereo during the surface estimation procedure and therefore produces a smooth surface. 9.7 Conclusions The shape from appearance method is a new method for estimating surface shape based on a learned associative model. The model is generated by associating examples of local surface shape with corresponding image features. The model may be a probability density or an associative map. The associative map is easier to use but can only be used in the presence of sufficient contextual information. The experiments described in this paper involve the use of a stereo module as a source of local shape examples. It has been shown that through a scale change, the associative model can be made more accurate than the stereo algorithm. As a consequence, it is possible to recover the shape of an unknown surface more accurately than is possible with the stereo algorithm. In general, the method reported here is more accurate than stereo, motion, or focus based methods. The experiments clearly demonstrate the improvement of this method over the use of stereo alone. Shading based methods are also quite accurate, but they are based on strong and often unrealistic assumptions about reflectance, lighting, shadowing and other scene characteristics. The method described here is based on no such assumptions. The shape from appearance method is still in its infancy. It has not been tested on a wide range of scenes and there is still much theoretical development to be done. However, 159 its generality promises to make it useful under a wider range of conditions than existing methods. 160 Figure 9.3 Images of ridges at various orientations. 161 Figure 9.4 Depth maps produced by applying stereo to images of ridges. 162 Figure 9.5 Level curves corresponding to stereo depth maps of ridge images. 163 0 1 2 3 4 5 Figure 9.6 Data collected from ridge images projected on dimensions 1 and 2. 164 Figure 9.7 Two projections of the associative map onto two-dimensional subspaces. 165 Figure 9.8 Image of clay cherub figure used to test surface reconstruction. 166 Figure 9.9 Images of the components of the feature vector associated with the cherub image. 167 Figure 9.10 Level curves of the feature vector components associated with the cherub image. 168 Figure 9.11 Shaded surface map and level curves corresponding to the cherub image. The surface map is the function s(x; y; oer) = g(f (x; y; oer)) 169 Figure 9.12 The depth map, z(x; y), corresponding to cherub image. The upper left and right images are depth maps shaded from (\Gamma 1; 1; 1)=p3 and (1; \Gamma 1; 1)=p3, respectively. The lower left figure is the depth map and the lower right figure is the corresponding set of level curves. 170 REFERENCES [1] A. L. Abbott and N. Ahuja, "Surface reconstruction by dynamic integration of focus, camera vergence, and stereo," Proc. Second Intl. Conf. Comput. Vis., pp. 532-543, December, 1988. [2] A. L. Abbott, "Dynamic Integration of Depth Cues for Surface Reconstruction from Stereo Images," PhD Thesis, University of Illinois, Urbana, IL, 1990. [3] N. Ayache and B. Faverjon, "Efficient registration of stereo images by matching graph descriptions of edge segments," International Journal of Computer Vision, pp. 107-131, 1987. [4] R. Bajcsy, E. Krotkov, and M. Mintz, "Models of errors and mistakes in machine perception," Proc. DARPA Image Understanding Workshop, pp. 194-204, Feb. 1987. [5] S. T. Barnard and W. B. Thompson, "Disparity analysis of images," IEEE Trans. Patt. Anal. Mach. Intell., vol. PAMI-2, no. 4, pp. 333-340, 1980. [6] A. R. Barron and X. Xiao, "Multivariate adaptive polynomial synthesis," personal communication. [7] P. Beckmann and A. Spizzichino, "Scattering of electromagnetic waves from rough surfaces," Basingstoke: Macmillan. [8] M. Bischel and A. Pentland, "A simple algorithm for shape from shading," Proc. Comput. Vis. Patt. Recog. pp. 459-465, June 1992. [9] A. Blake, A. Zisserman and G. Knowles, "Surface descriptions from stereo and shading," Image Vision Comput., vol. 3, no. 4, pp. 183-191, 1985. [10] J. F. Blinn, "Models of light reflection for computer synthesized pictures," Comput. Graph., vol. 11, pp. 192-198, 1977. [11] S. D. Blostein and T. S. Huang, "Error analysis in stereo determination of 3-D point positions," IEEE Trans. Patt. Anal. Machine Intell., vol. PAMI-9, pp. 752-765. [12] H. Bulthoff and H. Mallot, "Interaction of different modules in depth perception," Proc. First Intl. Conf. Comput. Vis., pp. 295-305, June, 1987. [13] M. J. Brooks and B. K. P. Horn, "Shape and source from shading," Proc. Intl. Joint Conf. Artif. Intell., pp. 932-936, Los Angeles, CA, 1985. 171 [14] A. R. Bruss, "The eikonal equation: some results applicable to computer vision," J. Math. Phys., vol. 23, no. 5, pp. 890-896, May 1982. [15] R. L. Cook and K. E. Torrance, "A reflectance model for computer graphics," Comput. Graph., vol. 15, no. 3, pp. 307-316, 1981 ??? Is it 82?. [16] H. T. Croft, K. J. Falconer, R. K. Guy, Unsolved Problems In Geometry, SpringerVerlag, 1991. [17] J. E. Cryer, P. S. Tsai, and M. Shah, "Combining shape from shading and stereo using human vision model," Tech. Rep., CS-TR-92-25, Dept. Comput. Sci., Univ. Central Florida, 1992. [18] S. Das and N. Ahuja, "Multiresolution image acquisition and surface reconstruction," Proc. Third. Intl. Conf. Comput. Vision, pp. 485-488, 1990. [19] S. Das and N. Ahuja, "Integrating multiresolution image acquisition and coarseto-fine surface reconstruction from stereo," in Physics-Based Vision: Principles and Practice: Radiometry, eds., L. B. Wolff, S. A. Shafer, and G. E. Healey, pp. 361-367, 1992. [20] S. Das and N. Ahuja, "A comparative study of stereo, vergence, and focus as depth cues for active vision," Proc. Comput. Vis. Patt. Recog., pp. 194-199, June, 1993. [21] M. S. Drew, "Shape and specularity from color," Tech. Rep. CSS/LCCR TR 93-01, Centre for Systems Science, Simon Fraser University, 1993. [22] R. O. Duda and P. E Hart, Pattern classification and scene analysis. New York: John Wiley & Sons, 1973. [23] P. Dupuis and J. Oliensis, "Direct method for reconstructing shape from shading," Proc. Comput. Vis. Patt. Recog., pp. 453-458, June, 1992. [24] F. P. Ferrie and M. D. Levine, "Where and why local shading analysis works," IEEE Trans. Patt. Anal. Mach. Intell., vol. 11, no. 2, Feb. 1989. [25] D. Forsyth and A. Zisserman, "Shape from shading in the light of mutual illumination," Image Vision Comput., vol. 8, no. 1, pp 42-49, 1990. [26] R. T. Frankot and R. Chellappa, "A method for enforcing integrability in shape from shading algorithms," IEEE Trans. Patt. Analysis Mach. Intell., vol. 10, no. 4, July 1988. [27] J. H. Friedman and W. Stuetzle, "Projection pursuit regression," J. Am. Stat. Assoc., vol. 76, no. 376, pp. 817-823, 1981. [28] J. H. Friedman, "Multivariate adaptive regression splines," Annals of Statistics, vol. 19, pp. 1-141, 1991. Note: Includes discussion by A. R. Barron and X. Xiao about polynomial regression. 172 [29] P. Fua and Y. G. Leclerc, "Object-centered surface reconstruction: combining multiimage stereo and shading," Tech. Note 535, SRI International, Oct. 1993. [30] P. Fua and Y. G. Leclerc, "Using 3-dimensional meshes to combine image-based and geometry-based constraints," Tech. Note 536, SRI International, Oct. 1993. [31] B. V. Funt, M. S. Drew, and M. Brockington, "Recovering shading from color images," Proc. Second European Conf. Comput. Vis., pp. 124-132, Italy, May, 1992. [32] M. A. Gennert and A. L. Yuille, "Stereo matching by energy function minimization," Optics, Illumination, and Image Sensing for Machine Vision V, SPIE vol. 1385, pp. 268-279, 1990. [33] W. E. L. Grimson, "Computational experiments with a feature based stereo algorithm," IEEE Trans. Patt. Anal. Mach. Intell., vol. PAMI-7, no. 1, pp. 17-34, Jan. 1985. [34] G. Healey, "Using color for geometry-insensitive segmentation," J. Opt. Soc. Am. A, vol. 6, no. 6, pp. 920-937, June, 1989. [35] W. Hoff and N. Ahuja, "Extracting surfaces from stereo images: an integrated approach," Proc. First Intl. Conf. Comput. Vis., pp. 284-294, June, 1987. [36] B. K. P. Horn, "Obtaining shape from shading information," in The Psychology of Computer Vision, P. H. Winston (Ed.), McGraw-Hill, 1975. [37] B. K. P. Horn, "Understanding image intensities," Artificial Intelligence, vol. 8, pp. 201-231, 1977. [38] B. K. Horn and R. W. Sjoberg, "Calculating the reflectance map," Applied Optics, vol. 18, no. 11, pp. 1770-1779, 1 June, 1979. [39] B. K. P. Horn, "Hill shading and the reflectance map," Proc. IEEE, vol. 69, no. 1, pp. 14-47, January, 1981. [40] B. K. P. Horn and M. J. Brooks, "The variational approach to shape from shading," Comput. Vis., Graphics, Image Process., vol. 33, pp. 174-208, 1986. [41] B. K. P. Horn, Robot Vision. MIT Press: Cambridge, MA; and McGraw-Hill: New York, 1986. [42] B. K. P. Horn, "Height and gradient from shading," Intl. J. of Comput. Vis., vol. 5, no. 1, pp. 37-75, 1990. [43] D. Hougen and N. Ahuja, "Integration of stereo and shape from shading using color," Proc. Second Intl. Conf. Auto. Robotics and Comput. Vis., vol. 1, pp. cv-6.6.1-6.6.5, Singapore, September, 1992. 173 [44] D. Hougen and N. Ahuja, "Estimation of the Light Source Distribution and its Use in Shape Recovery from Stereo and Shading," in Fourth International Conference on Computer Vision, ICCV '93, pp. 148-155, May 1993. [45] D. Hougen and N. Ahuja, "Adaptive Polynomial Modelling of the Reflectance for Shape Estimation from Stereo and Shading," in Proc. IEEE Conf. Computer Vision Patt. Recog.,, pp. 991-994, June 1994. [46] K. Ikeuchi and B. K. P. Horn, "Numerical shape from shading and occluding boundaries," Artificial Intelligence, vol. 17, no. 3, pp. 141-184, 1981. [47] K. Ikeuchi and K. Sato, "Determining reflectance parameters using range and brightness images," Proc. Third Intl. Conf. Computer Vision, pp. 12-20, Dec. 1990. [48] M. Kendall and A. Stuart, The Advanced Theory of Statistics, Bucks England: Charles Griffin & Co. Ltd., 1983. [49] G. J. Klinker, "Color image analysis with an intrinsic reflection model," Proc. Second Intl. Conf. Computer Vision, pp. 292-296, 1988. [50] T. Kohonen, Self-Organization and Associative Memory. New York: SpringerVerlag, 1989. [51] C. L. Lawson and R. J. Hanson, Solving Least Squares Problems, Englewood Cliffs, New Jersey: Prentice Hall, Inc., 1974. [52] Y. G. Leclerc and A. F. Bobick, "The direct computation of height from shading," Proc. Comput. Vis. Patt. Recog., pp. 552-558, Lahaina, HA, June, 1991. Thanks to Leclerc for answering questions about boundary conditions and other details of the algorithm. [53] C. Lee and A. Rosenfeld, "Albedo estimation for scene segmentation," Patt. Recog. Letters, vol. 1, pp. 155-160, March, 1983. [54] C. H. Lee and A. Rosenfeld, "Improved methods of estimating shape from shading using the light source coordinate system," Artificial Intell., vol. 26, pp. 125-143, 1985. [55] K. F. Lee and S. Mahajan, "A pattern classification approach to evaluation function learning," Artificial Intelligence, vol. 36, pp. 1-25, 1988. [56] K. M. Lee and C. C. J. Kuo, "Robust shape reconstruction from combined shading and stereo information," Appl. Digital Image Process. XV, SPIE vol. 1771, pp. 171- 182, 1992. [57] K. M. Lee and C. C. J. Kuo, "Shape from shading with a generalized reflectance map model," Univ. South. Cal. Dept. Elec. Engr. Sys., USC-SIPI Report 235, June 1993. 174 [58] S. R. Lehky and T. J. Sejnowski, "Neural network model of visual cortex for determining surface curvature from images of shaded surfaces," Proc. R. Soc. Lond. B, vol. 240, pp. 251-278, 1990. [59] M. S. Lew, T. S. Huang, and K. W. Wong, "Learning and feature selection in stereo matching," personal communication. [60] P. Lorrain and D. Corson, Electromagnetic Fields and Waves, second edition, New York: W. H. Freeman and Company, 1970. [61] J. Malik and D. Maydan, "Recovering three-dimensional shape from a single image of curved objects," IEEE Trans. Patt. Anal. Mach. Intell., vol. 11, no. 6, June 1989. [62] D. Marr and T. Poggio, "Cooperative computation of stereo disparity," Science, vol. 194, pp. 283-287, 1976. [63] D. Marr and T. Poggio, "A computational theory of human stereo vision," Proc. R. Soc. Lond. B, vol. 204, pp. 301-328, 1979. [64] E. S. McVey and J. W. Lee, "Some accuracy and resolution aspects of computer vision distance measurements," IEEE Trans. Patt. Anal. Machine Intell., vol. PAMI4, no. 6, pp. 646-649, 1982. [65] G. Medioni and R. Nevatia, "Segment-based stereo matching," Computer Vision, Graphics, and Image Processing, vol. 31, pp. 2-18, 1983. [66] S. K. Nayar, K. Ikeuchi, and T. Kanade, "Shape from Interreflections," Proc. Intl. Conf. Comput. Vis., pp. 2-11, Osaka, Japan, December, 1990. [67] S. K. Nayar, K. Ikeuchi, and T. Kanade, "Surface reflection: physical and geometrical perspectives," IEEE Trans. Patt. Recog. Machine Intell., vol. 13, no. 5, pp. 185-212, July, 1991. [68] J. Oliensis, "Shape from shading as a partially well-constrained problem," Computer Vision, Graphics, and Image Understanding, vol. 54, no. 2, pp. 163-183, 1991. [69] J. Oliensis and P. Dupuis, "A global algorithm for shape from shading," Fourth Intl. Conf. Comput. Vision, pp. 692-701, May 1993. [70] S. Omohundro, "Efficient algorithms with neural network behavior," Rep. No. UIUCDCS-R-87-1331, Dept. Comput. Sci., Univ. Ill. Urbana, 1987. [71] S. Omohundro, "Fundamentals of geometric learning," Rep. No. UIUCDCS-R-88- 1408, Dept. Comput. Sci., Univ. Ill. Urbana, 1988. [72] S. Omohundro, "Geometric learning algorithms," Physica D, vol. 42 pp. 307-321, 1990. and in Emergent Computation, ed. Stephanie Forrest, MIT Press 1991. 175 [73] A. P. Pentland, "Finding the illuminant direction," J. Opt. Soc. Am., vol. 72, no. 4, pp. 448-455, April, 1982. [74] A. P. Pentland, "Local shading analysis," IEEE Trans. Patt. Anal. Mach. Intell., vol. PAMI-6, no. 2, pp. 170-187, March 1984. [75] A. P. Pentland, "Shape information from shading: A theory about human perception," Proc. Second Intl. Conf. Comput. Vision, pp. 404-413, Dec. 1988. [76] A. P. Pentland, "Linear shape from shading," Intl. J. Comput. Vision, vol. 4, pp. 153-162, 1990. [77] T. Poggio and F. Girosi, "A theory of networks for approximation and learning," A.I. Memo No. 1140, MIT, July 1989. [78] S. B. Pollard, J. E. W. Mayhew, and J. P. Frisby, "PMF: A stereo correspondence algorithm using a disparity gradient limit," Perception, vol. 14, pp. 449-470, 1985. [79] T. C. Pong, R. Haralick, and L. Shapiro, "Shape from shading using the facet model," Patt. Recog., vol. 22, no. 6, pp. 683-695, 1989. [80] H. J. Ritter, T. M. Martinetz and K. J. Schulten, "Topology-Conserving maps for learning visuo-motor-coordination," Neural Networks, vol. 2, pp. 159-168, 1989. [81] J.J Rodriguez and J.K. Aggarwal, "Quantization error in stereo imaging," Comput. Vis. Patt. Recog., pp. 153-158, 1988. [82] B. Ross, "A practical stereo vision system," Proc. Comput. Vision Patt. Recog., pp. 148-153, June, 1992. [83] E. Rouy and A. Tourin, "A viscosity solutions approach to shape-from-shading," SIAM J. Numer. Anal., vol. 29, no. 3, pp. 867-884, June 1992. [84] W. Rudin, Principles of mathematical analysis. New York: McGraw-Hill, 1976. [85] Y. Sato and K. Ikeuchi, "Temporal-color space analysis of reflection," Proc. Comput. Vision Patt. Recog., pp. 570-576, June 1993. [86] B. V. H. Saxberg, "An application of dynamical systems theory to shape from shading," Proc. DARPA Image Understanding Workshop, pp. 1089-1104, May 1989. [87] S. A. Shafer, "Using color to separate reflection components," COLOR research and application, vol. 10, no. 4, pp 210-218, 1985. [88] J. Shah, "A nonlinear diffusion model for discontinuous disparity and half-occlusions in stereo," Proc. Comput. Vision Patt. Recog., pp. 34-40, June 1993. [89] R. Shibata, "An optimal selection of regression variables," Biometrika, vol. 68, no. 1, pp. 45-54, 1981. 176 [90] M. Suk and T.H. Cho, "Segmentation of images using minimum spanning trees," Intl. Soc. Opt. Engr., SPIE, vol. 397, pp. 180-185, April 19-22, 1983. [91] M. Tabb and N. Ahuja, "Detection and representation of low-level image structure using a new transform," to appear in Asian Conference on Computer Vision, Osaka, Japan, 1993. [92] K. E. Torrance and E. M. Sparrow, "Theory for off-specular reflection from roughened surfaces," Optical Soc. Am., vol. 57, no. 9, pp. 1105-1114, 1967. [93] A. Verri and V. Torre, "Absolute depth estimate in stereopsis," J. Opt. Soc. Am. A, vol. 3, no. 3, pp. 297-299, 1986. [94] D. Waltz, "Understanding line drawings of scenes with shadows," in The Psychology of Computer Vision, P. H. Winston (Ed.), McGraw-Hill, 1975. [95] A. H. Watt, Fundamentals of Three-Dimensional Computer Graphics, New York, Addison-Wesley, 1989. [96] L. B. Wolff, "Diffuse Reflection," Proc. Comput. Vis. Patt. Recog., pp. 472-478, Champaign, June, 1992. [97] L. B. Wolff, "On the relative brightness of specular and diffuse reflection," Proc. Comput. Vis. Patt. Recog., pp. 369-376, 1994. [98] Y. Yang and A. Yuille, "Sources from shading," Proc. Comput. Vis. Patt. Recog., pp. 534-539, Lahaina, HA, June, 1991. [99] C. T. Zahn, "Graph-theoretical methods for detecting and describing Gestalt clusters," IEEE, Trans. Computers, vol. C-20, no. 1, Jan. 1971. [100] Q. Zheng and R. Chellappa, "Estimation of illuminant direction, albedo, and shape from shading," Proc. Comput. Vis. Patt. Recog., pp. 540-545, Lahaina, HA, June, 1991. 177 VITA Darrell Roy Hougen was born on January 31, 1964, in Story City, Iowa. He was awarded the Bachelor of Science degrees in Mathematics and Physics by Iowa State University of Science and Technology in May 1986 from which he graduated with honors and distinction. He received the Master of Science degree in Electrical and Computer Engineering in 1988 and the Doctor of Philosophy degree in Computer Science in 1994 from the University of Illinois at Urbana-Champaign. Dr. Hougen is a member of several academic honoraries including Phi Beta Kappa, Phi Kappa Phi, and Pi Mu Epsilon. He is currently a Post Doctoral Fellow at the Beckman Institute for Advanced Science and Technology and has several publications in the area of computer vision. 178