Dynamic Thresholding for Image Analysis

Similar documents
Nonparametric Density Estimation

An Introduction to PDF Estimation and Clustering

Machine Learning Lecture 3

Machine Learning Lecture 3

Machine Learning Lecture 3

Clustering. CS294 Practical Machine Learning Junming Yin 10/09/06

Machine Learning and Data Mining. Clustering (1): Basics. Kalev Kask

Machine Learning (BSMC-GA 4439) Wenke Liu

Recap: Gaussian (or Normal) Distribution. Recap: Minimizing the Expected Loss. Topics of This Lecture. Recap: Maximum Likelihood Approach

Kernel Density Estimation

Chapter 6 Continued: Partitioning Methods

Machine Learning (BSMC-GA 4439) Wenke Liu

Statistical Matching using Fractional Imputation

Supervised vs. Unsupervised Learning

Part I. Hierarchical clustering. Hierarchical Clustering. Hierarchical clustering. Produces a set of nested clusters organized as a

Multivariate Analysis

Image Segmentation. Shengnan Wang

Data Mining Chapter 9: Descriptive Modeling Fall 2011 Ming Li Department of Computer Science and Technology Nanjing University

Model Assessment and Selection. Reference: The Elements of Statistical Learning, by T. Hastie, R. Tibshirani, J. Friedman, Springer

Nonparametric Methods

Expectation Maximization (EM) and Gaussian Mixture Models

Classification. Vladimir Curic. Centre for Image Analysis Swedish University of Agricultural Sciences Uppsala University

An Efficient Model Selection for Gaussian Mixture Model in a Bayesian Framework

Clustering Lecture 5: Mixture Model

Summer School in Statistics for Astronomers & Physicists June 15-17, Cluster Analysis

SYDE Winter 2011 Introduction to Pattern Recognition. Clustering

Machine Learning A W 1sst KU. b) [1 P] Give an example for a probability distributions P (A, B, C) that disproves

Clustering in R d. Clustering. Widely-used clustering methods. The k-means optimization problem CSE 250B

Today. Lecture 4: Last time. The EM algorithm. We examine clustering in a little more detail; we went over it a somewhat quickly last time

ADAPTIVE METROPOLIS-HASTINGS SAMPLING, OR MONTE CARLO KERNEL ESTIMATION

Mixture Models and the EM Algorithm

9.1. K-means Clustering

Level-set MCMC Curve Sampling and Geometric Conditional Simulation

Nonparametric Estimation of Distribution Function using Bezier Curve

Machine Learning for OR & FE

Note Set 4: Finite Mixture Models and the EM Algorithm

Cluster Analysis. Jia Li Department of Statistics Penn State University. Summer School in Statistics for Astronomers IV June 9-14, 2008

Generative and discriminative classification techniques

Introduction to Nonparametric/Semiparametric Econometric Analysis: Implementation

Computer Experiments. Designs

Unsupervised Learning

Colorado School of Mines. Computer Vision. Professor William Hoff Dept of Electrical Engineering &Computer Science.

Robert Collins CSE598G. Robert Collins CSE598G

Smoothing Dissimilarities for Cluster Analysis: Binary Data and Functional Data

On the Parameter Estimation of the Generalized Exponential Distribution Under Progressive Type-I Interval Censoring Scheme

Lecture 25: Review I

Machine Learning. B. Unsupervised Learning B.1 Cluster Analysis. Lars Schmidt-Thieme

Motivation. Technical Background

Lecture 27: Review. Reading: All chapters in ISLR. STATS 202: Data mining and analysis. December 6, 2017

University of Florida CISE department Gator Engineering. Clustering Part 5

DATA MINING LECTURE 7. Hierarchical Clustering, DBSCAN The EM Algorithm

Operators-Based on Second Derivative double derivative Laplacian operator Laplacian Operator Laplacian Of Gaussian (LOG) Operator LOG

5. Feature Extraction from Images

Notes and Announcements

Efficient Image Compression of Medical Images Using the Wavelet Transform and Fuzzy c-means Clustering on Regions of Interest.

On Kernel Density Estimation with Univariate Application. SILOKO, Israel Uzuazor

Discussion on Bayesian Model Selection and Parameter Estimation in Extragalactic Astronomy by Martin Weinberg

Overview Citation. ML Introduction. Overview Schedule. ML Intro Dataset. Introduction to Semi-Supervised Learning Review 10/4/2010

Color Image Segmentation

Clustering and The Expectation-Maximization Algorithm

Hierarchical Mixture Models for Nested Data Structures

Comparison between Various Edge Detection Methods on Satellite Image

CS787: Assignment 3, Robust and Mixture Models for Optic Flow Due: 3:30pm, Mon. Mar. 12, 2007.

Clustering. Mihaela van der Schaar. January 27, Department of Engineering Science University of Oxford

Cluster Analysis and Visualization. Workshop on Statistics and Machine Learning 2004/2/6

Behavioral Data Mining. Lecture 18 Clustering

Introduction to Machine Learning CMU-10701

Clustering Relational Data using the Infinite Relational Model

Solution Sketches Midterm Exam COSC 6342 Machine Learning March 20, 2013

K-Means and Gaussian Mixture Models

MultiDimensional Signal Processing Master Degree in Ingegneria delle Telecomunicazioni A.A

Digital Image Processing Laboratory: Markov Random Fields and MAP Image Segmentation

Assessing the Quality of the Natural Cubic Spline Approximation

INDEPENDENT COMPONENT ANALYSIS WITH QUANTIZING DENSITY ESTIMATORS. Peter Meinicke, Helge Ritter. Neuroinformatics Group University Bielefeld Germany

10-701/15-781, Fall 2006, Final

Fitting D.A. Forsyth, CS 543

Expectation-Maximization Algorithm and Image Segmentation

Clustering. CE-717: Machine Learning Sharif University of Technology Spring Soleymani

Section 4 Matching Estimator

Machine Learning. Unsupervised Learning. Manfred Huber

Nonparametric Regression

Multivariate Standard Normal Transformation

Estimation of Bilateral Connections in a Network: Copula vs. Maximum Entropy

CS Introduction to Data Mining Instructor: Abdullah Mueen

Clustering Color/Intensity. Group together pixels of similar color/intensity.

SEMI-BLIND IMAGE RESTORATION USING A LOCAL NEURAL APPROACH

Mixture models and clustering

Markov Random Fields and Gibbs Sampling for Image Denoising

Unsupervised learning in Vision

PATTERN CLASSIFICATION AND SCENE ANALYSIS

Homework. Gaussian, Bishop 2.3 Non-parametric, Bishop 2.5 Linear regression Pod-cast lecture on-line. Next lectures:

Monte Carlo Methods and Statistical Computing: My Personal E

DATA CLASSIFICATORY TECHNIQUES

Segmentation (continued)

K-means and Hierarchical Clustering

Object Segmentation. Jacob D. Furst DePaul CTI

Lecture 11: E-M and MeanShift. CAP 5415 Fall 2007

Clustering. Discover groups such that samples within a group are more similar to each other than samples across groups.

Segmentation of Distinct Homogeneous Color Regions in Images

Generalized Fuzzy Clustering Model with Fuzzy C-Means

Transcription:

Dynamic Thresholding for Image Analysis Statistical Consulting Report for Edward Chan Clean Energy Research Center University of British Columbia by Libo Lu Department of Statistics University of British Columbia December 14, 2009

1 Background and Data Description Edge detection, an important technique in image processing and computer vision, aims at identifying points in a digital image at which the image color (grey level) changes sharply. These points are called features, and the rest points are called textures. One major method for edge detection, the search-based method, uses the gradient magnitude as a measure of edge strength for each pixel and applies thresholds to decide whether edges are present or not at an image point. In this project, a large number of gray-scale images were collected from experiments. To automate post-processing, an edge detection and thresholding algorithm was written that extracts features from each image. Two thresholds are used to classify the pixels with different gradient magnitude. The texture threshold (usually a small value) is the upper bound of the gradient magnitudes of the pixels that would be ignored, and the feature threshold, which is greater than the texture threshold, is the lower bound of the gradient magnitudes of the pixels that should be extracted and recorded. The pixels whose gradient magnitudes fall in the interval between these two thresholds would be treated by a more sophisticated method. Each image contains 256 256 pixels, whose gradient magnitude is a continuous variable ranging from 0 to 1. Two fixed threshold values were adopted for all images based on past experience and you would like to assign different threshold values for each distinct image dynamically. However, the criteria for optimal threshold values have not been decided. Therefore, at this stage, how to describe the distribution of the gradient magnitude is of interest as a basis for further study. 2 Statistical Questions Q1. How to estimate the gradient magnitude distribution of a digital image? Q2. How to define an appropriate linear combination of parametric distributions to represent the gradient magnitude distribution? 3 Suggestions We first address the above two statistical questions, then briefly introduce some other options for edge detection. 1

3.1 Q1: Density Estimation The gradient magnitude distribution could vary from one image to another. Therefore, we introduce two nonparametric (distribution-free) density estimation methods for statistical question Q1. Silverman [5] gives an overview of this topic. For each image, as you suggested, suppose you are willing to consider the gradient magnitudes of the pixels X 1, X 2,..., X n as independent, identically distributed observations 1 from a continuous random variable X with probability density function f. The random variable X ranges from 0 to 1, and f is to be estimated. Histogram The oldest and most widely used density estimator is the histogram. As an example, let m be an integer and define bins as: B 1 = [ 0, 1 ) [ 1, B 2 = m m, 2 ) [ ] m 1,..., B m = m m, 1. Define the binwidth h = 1/m and let Y j be the number of observations in B j. The histogram estimator is defined by ˆf(x; h) = (nh) 1 m j=1 Y j I(x B j ). (1) The underlying idea of the histogram estimator is that for x B j and small h, E( ˆf(x; h)) = E(Y j) nh = n B j f(u)du f(x)h = f(x). nh h Thus, f(x) can be estimated by ˆf(x; h) when h is small. The binwidth h is a critical parameter for the histogram estimator. A smaller binwidth leads to a relatively jagged histogram, while a larger binwidth results in a smoother histogram. Therefore, the binwidth h is usually called a smoothing parameter since it controls the degree of smoothing being applied to the data, which is also important for other types of nonparametric density estimators. For exploratory data analysis, the histogram is a very useful tool for density estimation. However, the histogram estimator has three disadvantages: For the same data, histograms with different bin edges can be quite different, such as Figure 1, which contains five shifted histograms and the frequency polygon of their average for the Old Faithful geyser duration data 2. 1 The independence assumption may not be appropriate for your project, because the gradient magnitudes at the different pixels are likely to be spatially correlated. 2 Refer to Page 127 of [6]. 2

Histograms are not smooth. It is difficult to use the histogram to represent multivariate data. So we need to consider other options. Figure 1: Five shifted histogram with binwith 0.5 and the frequency polygon. 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.0 0.1 0.2 0.3 0.4 0.5 0.6 1 2 3 4 5 6 duration 1 2 3 4 5 6 duration 1 2 3 4 5 6 duration 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.0 0.1 0.2 0.3 0.4 0.5 0.6 averaged 0.0 0.1 0.2 0.3 0.4 0.5 0.6 1 2 3 4 5 6 duration 1 2 3 4 5 6 duration 0 1 2 3 4 5 6 duration Kernel Density Estimation A function K is called a kernel if it satisfies K(x) = 1. The formula for the kernel density estimator is: ˆf(x; h) = (nh) 1 n i=1 K( x X i ). (2) h where the smoothing parameter or bandwidth h is a positive real number. Usually K is chosen to be a unimodel probability density function that is symmetric about zero, for example, the standard normal density. This ensures that ˆf(x; h) is also a density function. Figure 2 is a sample plot comparing histogram and kernel density estimates of a sample of gradient magnitudes and details on an enlarged (vertical) scale. To study the discrepancy of the kernel density estimator ˆf from the true density f at a single 3

Figure 2: Histogram and kernel smoothing of a sample of gradient magnitudes. Histogram and Kernel Smoothing of Gradient Magnitude Histogram and Kernel Smoothing of Gradient Magnitude Frequency 0 50 100 150 200 250 300 Frequency 0 2 4 6 8 10 0.00 0.05 0.10 0.15 binwidth = 0.01; bandwidth = 0.001, kernel = gaussian 0.00 0.05 0.10 0.15 binwidth = 0.01; bandwidth = 0.001, kernel = gaussian point x, a natural measure is the mean squared error (MSE), defined as follows: MSE( ˆf(x; h)) = E{ ˆf(x; h) f(x)} 2 = {E ˆf(x; h) f(x)} 2 + var{ ˆf(x; h)}, where {E ˆf(x; h) f(x)} 2 is the squared bias and var{ ˆf(x; h)} is the variance of the estimated density at x. To study the global discrepancy of the kernel density estimator ˆf from the true density f, a widely used measure is the mean integrated squared error (MISE), defined as follows: MISE( ˆf( ; h)) = E { ˆf(x; h) f(x)} 2 dx = {E ˆf(x; h) f(x)} 2 dx + var{ ˆf(x; h)}dx, where {E ˆf(x; h) f(x)} 2 dx is the integrated squared bias and var{ ˆf(x; h)}dx is the integrated variance. Notice that, in both discrepancy measures, there is a trade-off between the bias and variance of the density estimator ˆf( ; h). You may control the trade-off by adjusting the bandwidth h. In general, smaller h results in smaller bias and larger variance, while larger h introduces larger bias but results in smaller variance. Therefore, choosing an appropriate bandwidth h is a critical issue in density estimation. 4

There are several approaches to select the bandwidth h. Some simple approaches 3 adopt computable formulae to find a bandwidth that is reasonable for the majority of situations. More delicate approaches 4 search for the optimal bandwidth under certain criteria, for example, minimizing the MISE. However, the latter approaches usually require extensive computation, which is also a nonignorable problem. For your project, since most images exhibit similar patterns, you may try the former approaches for simpler computation. In MATLAB, the ksdensity command implements kernel density estimation without dynamic bandwidth selection. A free MATLAB software package that incorporates a simple and fast bandwidth selection method is available from the MATLAB Central File Exchange 5. 3.2 Q2: Finite Mixture Modeling The use of finite mixtures of distributions is a powerful statistical modeling tool for density estimation. Many complicated density functions can be represented as linear combinations of diverse simple density functions, such as normal density 6. For example, the bimodal density in Figure 3 could be approximated by a linear combination of two normal densities as follows: 4 5 N(0.01, ( 1 200 )2 ) + 1 5 N(0.07, ( 1 30 )2 ) Figure 3: An example of a bimodal density. Bimodal Density Density 0 10 20 30 40 0.00 0.05 0.10 0.15 3 Refer to section 3.4.1 and 3.4.2 of [5]. 4 Refer to section 3.4.3 and 3.4.4 of [5]. 5 http://www.mathworks.com/matlabcentral/fileexchange/14034-kernel-density-estimator 6 Refer to section 1.5.2 of [3] for interesting examples. 5

Suppose f is the density to be estimated, and suppose the density of X can be written as: g f(x) = π j f j (x), (3) j=1 where the f j ( ) s could be any density functions and the weights satisfy 0 π j 1, j = 1,, g, and g j=1 π j = 1. Based on the properties of f j ( ) and π j, formula (3) defines a density, which is called a g-component finite mixture density. There are two major differences between formulae (2) and (3): Formula (2) is the summation of n-components, while formula (3) is the summation of g- components and g could be a small number, such as 2 or 3. Formula (2) is based on a single kernel K, while the f j ( ) of formula (3) could be diverse. If f j ( ) are specified parametric density functions f j ( ; θ j ), then the density f( ) is represented as a linear combination of parametric distributions f(x) = g j=1 π jf j (x; θ j ) and the parameters θ j and coefficients π j need to be estimated. Therefore, we need to accomplish three tasks: Choose appropriate f j ( ; θ j ), j = 1,, g. Estimate θ j and π j, j = 1,, g. Choose appropriate g. For the first task, the normal density is perhaps the most popular choice for finite mixture modeling 7. However, strictly speaking, the normal density may not be suitable to your project because the gradient magnitude is always non-negative and is never greater than 1, while any normal density has non-zero probability of having outcomes falling outside of the interval [0, 1]. Thus you might want to consider some continuous density functions that can only take values within [0, 1], such as the uniform distribution and the Beta distribution. For example, Figure 4 are the histogram of a sample of gradient magnitudes and the distribution of the finite mixture f(x) = π 1 f 1 (x; θ 1, θ 2 ) + π 2 f 2 (x; θ 3, θ 4 ), where π 1 = 7/8, π 2 = 1/8, f 1 is a Beta distribution with parameters θ 1 = 1, θ 2 = 500, denoted as Beta(1, 500), and f 2 is a uniform distribution with parameters θ 3 = 0.01, θ 4 = 0.15, denoted as U(0.01, 0.15). Having chosen the f j ( ; θ j ) s, the log likelihood function of the observations is: 7 Refer to Section 1.5, 1.6 of [3]. 6

Figure 4: Finite mixture modeling of gradient magnitude. Histogram of Gradient Magnitude Finite Mixture Modeling of Gradient Magnitude Frequency 0 50 100 150 200 250 Density 0 50 100 150 200 250 0.00 0.05 0.10 0.15 binwidth = 0.005 0.00 0.05 0.10 0.15 Gradient Magnitude log L(Θ) = = n log f(x i ; Θ) i=1 n g log{ π j f j (x i ; θ j )}. (4) i=1 j=1 Then for the second task, you could estimate θ j and π j by maximizing likelihood 8 ; that is, maximizing log L(Θ) over the parameter space of θ j and π j. The solution for this maximization, θ j and π j say, are the maximum likelihood estimates (MLE). Maximizing the likelihood function for a g-component finite mixture density is not a trivial task. We usually need to implement iterative algorithms, such as the expectation-maximization (EM) algorithm 9 to find the optimal solution. You might also consider Markov Chain Monte Carlo (MCMC) methods 10, a Bayesian approach, to estimate the parameters. For the third task, Akaike s information criterion 11 (AIC) could be adopted for choosing g, the number of components. For any given g, the parameter estimates ˆΘ g and the maximized log likelihood, log L( ˆΘ g ), can be calculated. AIC then selects the value g that maximizes 2 log L( ˆΘ g ) + 2d g, (5) where d g is the total number of parameters. Based on the above discussions, you may obtain the 8 Refer to Chapter 2 of [3]. 9 Refer to Section 2.8 of [3]. 10 Refer to Chapter 4 of [3]. 11 Refer to Chapter 6 of [3]. 7

following parametric estimation of f: f(x; Θ) = g j=1 π j f j (x; θ j ). (6) Finite mixture modeling can be implemented in MATLAB using the package bayesf Version 2.0 12, which is based on the MCMC method. However, the Beta distribution is not available in that package yet. My suggestion is to try this approach with the distributions already available in the package. This should suffice to give you quite a good representation of the density f. In practice, you might incorporate the approaches suggested for Q1 and Q2 together. For instance, the Q1 approach could be used to guide choices (of f j especially) in the approach for Q2. 3.3 Comments The two methods introduced in the previous two subsections provide precise density estimation at the expense of considerable computational cost. The difficulty of kernel density estimation is the selection of the optimal bandwidth, while the difficulty of finite mixture modeling is the parameter estimation and the selection of the number of components. However, the more fundamental problem is that the density estimation may not necessarily help very much with the selection of texture and feature threshold values. At least this is not clear to me. In fact, edge detection has long been a topic of research. Gonzalez and Woods [1] give an overall introduction to digital image processing; their Chapter 10 focuses on edge detection. Several threshold value selection methods are discussed and compared, including a simple finite mixture modeling example. From a statistical learning viewpoint, the goal of edge detection is to distinguish the feature pixels from the texture pixels. However, given any digital image, the pixels are unlabeled in general, and we need to assign all the pixels into feature and texture subsets so that the pixels in the same subset are similar in some sense. This procedure is called cluster analysis, the subsets being the clusters. Now we introduce two nonparametric cluster analysis methods which are based on the distances between the gradient magnitudes at different pixels. In these frameworks, you may take the spatial information of the pixel locations into consideration without assuming independence 13. Suppose X i = (x i1, x i2, x i3 ) T denotes the ith pixel, where x i1 is the gradient magnitude and (x i2, x i3 ) is the pixel coordinate. 12 Refer to [4] for details. 13 The gradient magnitude of the pixels are assumed to be independent in section 3.1 and 3.2. 8

Agglomerative hierarchical Clustering Agglomerative hierarchical clustering 14 starts with n clusters, each containing one pixel X i. At each step, the method merges the two most similar (nearest) clusters, so that all pixels are combined into one single cluster (k clusters) after n 1 (n k) steps. The distance between two clusters is based on the distance between two pixels 15. For example, one type of distance between pixels X i and X j is the Euclidean distance: ( 3 ) 1/2 d ij = (x ik x jk ) 2. (7) k=1 If each of two clusters contains just one pixel, the distance between the two pixels d ij is the distance between the two clusters. If either of the clusters contain multiple pixels, the distance between the two clusters also depends on the method of linkage 16 of clusters. For example, single linkage defines the distance between clusters to be the minimum of the pairwise distances between pixels in the two clusters. One point to notice for calculating the distance between pixels is the measurement scale of the coordinate. If the range of the coordinate is from 1 to 256, then the difference between two pixels positions, determined by their coordinates, may influence the distance much more than the difference between their gradient magnitudes, because the range of gradient magnitude is just from 0 to 1. To give more weight to gradient magnitude, the range of the coordinate should be small, for example, from 0 to 0.5. In agglomerative hierarchical clustering, the pixels cannot be reallocated after having been grouped in an early stage, even though the clustering might not seem appropriate later. Consequently, the final result could be partially incorrect, and you may want to repeat the clustering procedure using different types of distances and linkages. If the clustering results obtained from different distances and linkages are roughly consistent, then you may distinguish the feature pixels from the texture pixels according to the agglomerative hierarchical clustering result. Otherwise, the agglomerative hierarchical clustering might not be suitable for this scenario. In MATLAB, you can perform agglomerative clustering using the linkage command in the statistics toolbox. But the computation of agglomerative hierarchical clustering is not a trivial task, particularly when n is large, for example, n = 256 256 for each of your images. 14 Refer to Chapter 12 of [2]. 15 Refer to Section 12.2 of [2] for several definitions and comparison of distance between pixels. 16 Refer to Section 12.3 of [2] for several definitions and comparison of linkage of clusters. 9

K-means Clustering K-means clustering 17 is an iterative algorithm for finding clusters and their centers. Unlike agglomerative hierarchical clustering, the number of clusters K should be chosen before implementing the method. Given any K pixels as initial cluster centers, the algorithm iterates the following two steps until convergence. All pixels are allocated to the nearest cluster center, based on some distance measure, such as (7); Calculate the means of the new clusters and regard them as the new centers. There are two challenges in using K-means clustering: The algorithm is sensitive to initial values. The choice of K is critical to the success of K-means clustering. For your project, there might exist several large texture areas and small feature areas. By observing the image, you may guess how many clusters there might be (the choice of K) and select the initial values for the algorithms. In MATLAB, you can perform K-means clustering using the kmeans command in the statistics toolbox. There are many other clustering methods. In my opinion, however, the primary issues are to decide whether the definitions of feature and texture are to be based on gradient magnitude and spatial information or just on gradient magnitude, and to settle on appropriate definitions of the threshold values. Well-defined objectives are invaluable in selecting suitable statistical analysis tools. 4 Conclusions In this report, we suggest two nonparametric methods for the first statistical question and one parametric method for the second statistical question. Then, regarding the scientific problem itself, we briefly discuss why it could be considered as a clustering problem and introduce two nonparametric clustering methods. Finally, we point out that having clear objectives maybe a key to this project. 17 Refer to Chapter 12 of [2]. 10

References [1] Rafael C. Gonzalez and Richard E. Woods. Digital Image Processing. Prentice-Hall, Inc., New Jersy, 2nd edition, 2002. [2] Richard A. Johnson and Dean W. Wichern. Applied Multivariate Statistical Analysis. Pearson Prentice Hall, New Jersey, 5th edition, 2001. [3] Geoffery McLachlan and David Peel. Finite Mixture Models. John Wiley & Sons, Inc., New York, 2000. [4] Sylvia F. Schnatter. Finite Mixture and Markov Switching Models. Springer Series in Statistics. Springer, Berlin, 2008. [5] Bernard W. Silverman. Density Estimation for Statistics and Data Analysis. Chapman and Hall, London, 1986. [6] W. N. Venables and B. D. Ripley. Modern Applied Statistics with S. Springer, New York, 4th edition, 2002. 11