I All measurements contain random measurement errors ......Spatial Statistics Classication Spatial...

10
Spatial Statistics Classification Spatial More Spatial Statistics with Image Analysis Johan Lindstr¨ om 1 1 Mathematical Statistics Centre for Mathematical Sciences Lund University Lund October 4, 2013 Johan Lindstr¨ om - [email protected] Spatial Statistics 1/37 Spatial Statistics Classification Spatial More Outline Spatial Statistics with Image Analysis Hierarchical Models Estimation Procedures Pixel Classification K-means Bayesian Classification EM-algorithm Example Spatial Statistics Satellite Data Image Reconstruction Temperature Learn more Johan Lindstr¨ om - [email protected] Spatial Statistics 2/37 Spatial Statistics Classification Spatial More Hierarchical Estimation A Statistical Approach All measurements contain random measurement errors/variation. Most natural phenomena have natural random variation. Often the uncertainty of an estimate is, at least, as important as the estimate itself. We need to describe and model random variation and uncertainties! Johan Lindstr¨ om - [email protected] Spatial Statistics 3/37 Spatial Statistics Classification Spatial More Hierarchical Estimation Hierarchical Models We often have some prior knowledge of the reality. Given knowledge of the true reality, what can we say about images and other data? Construct a model for observations given that we know the truth. Given data, what can we say about the unknown reality? This is the inverse problem. Johan Lindstr¨ om - [email protected] Spatial Statistics 4/37

Transcript of I All measurements contain random measurement errors ......Spatial Statistics Classication Spatial...

  • Spatial Statistics Classification Spatial More

    Spatial Statistics with Image Analysis

    Johan Lindström1

    1Mathematical StatisticsCentre for Mathematical Sciences

    Lund University

    LundOctober 4, 2013

    Johan Lindström - [email protected] Spatial Statistics 1/37

    Spatial Statistics Classification Spatial More

    Outline

    Spatial Statistics with Image AnalysisHierarchical ModelsEstimation Procedures

    Pixel ClassificationK-meansBayesian ClassificationEM-algorithmExample

    Spatial StatisticsSatellite DataImage ReconstructionTemperature

    Learn more

    Johan Lindström - [email protected] Spatial Statistics 2/37

    Spatial Statistics Classification Spatial More Hierarchical Estimation

    A Statistical Approach

    ◮ All measurements contain random measurement errors/variation.◮ Most natural phenomena have natural random variation.

    ◮ Often the uncertainty of an estimate is, at least, as important as theestimate itself.

    ◮ We need to describe and model random variation and uncertainties!

    Johan Lindström - [email protected] Spatial Statistics 3/37

    Spatial Statistics Classification Spatial More Hierarchical Estimation

    Hierarchical Models

    ◮ We often have some prior knowledge of the reality.◮ Given knowledge of the true reality, what can we say about images

    and other data?

    ◮ Construct a model for observations given that we know the truth.

    ◮ Given data, what can we say about the unknown reality?This is the inverse problem.

    Johan Lindström - [email protected] Spatial Statistics 4/37

  • Spatial Statistics Classification Spatial More Hierarchical Estimation

    Bayes’ Formula

    Using a statistical formulation:◮ A prior model for reality, π(x)◮ A conditional model for data y given reality, p(y|x)◮ We want the posterior distribution, p(x|y). The distribution for x

    given y.◮ Bayes’ Formula:

    p(x|y) = p(y|x)π(x)p(y)

    =p(y|x)π(x)∑z p(y|z)π(z)

    ,

    where p(y) is the total density for data.

    Johan Lindström - [email protected] Spatial Statistics 5/37

    Spatial Statistics Classification Spatial More Hierarchical Estimation

    Estimation Procedures

    Maximum A Posteriori (MAP): Maximise the posterior distributionp(x|y) with respect to x.

    ◮ Standard optimisation methods◮ Specialised procedures, using the model structure

    Simulation: Simulate samples from the posterior distribution p(x|y).Estimate statistical properties from these samples. Thesamples can be seen as representative “possible realities”,given the available data.

    ◮ Markov chain Monte Carlo (MCMC)◮ Gibbs sampling

    Johan Lindström - [email protected] Spatial Statistics 6/37

    Spatial Statistics Classification Spatial More Hierarchical Estimation

    Some Examples

    ◮ Classification (K-means and the EM algorithm)◮ LANDSAT

    ◮ Dependence structures; Markov random fields◮ Satellite data◮ Image reconstruction◮ Reconstruction of fields — Global mean temperature

    Johan Lindström - [email protected] Spatial Statistics 7/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Object Classification

    We present object classification as an image segmentation problem, i.e.we want to classify all pixels in an image.

    ◮ We assume that there is a set, {1, . . . ,K}, of K object categories.◮ Let x̃i denote the class of each pixel, and assume that x̃i are

    independent for all pixels.

    ◮ The prior probabilities πk = p(x̃i = k) describe the relativeabundance of each class.

    ◮ For each model class there is a data distribution.◮ For each pixel we have the distribution p(yi|x̃i = k)

    Johan Lindström - [email protected] Spatial Statistics 8/37

  • Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    The K-means Algorithm

    The K-means algorithm is a simple, popular algorithm for separatingdata into different clusters.

    1. Select K data-points at random, as initial cluster centres.

    2. Assign all data points to their nearest cluster centre.

    3. Compute the mean within each cluster, and let these be the newcluster centres.

    4. Repeat from 2.

    Johan Lindström - [email protected] Spatial Statistics 9/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Drawbacks of K-means

    ◮ Handling of different πk?◮ Different variation within clusters?

    ◮ Overlapping clusters?

    If we assume that the data within each cluster is multivariate Normal,how can we improve on K-means?

    Johan Lindström - [email protected] Spatial Statistics 10/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Bayesian Classification

    ◮ Assume that πk and the parameters of p(y|x̃ = k), μk andΣk, fork = 1, . . . ,K, are known.

    ◮ Maximum A Posteriori classification chooses the object class foreach pixel that has the highest posterior probability

    p(x̃ = k|y) = p(y|x̃ = k)π(k)p(y)

    =p(y|x̃ = k)πk∑k p(y|x̃ = k)πk

    ◮ If allΣk are equal, we obtain the method Linear discriminantanalysis. Otherwise, we obtain the method Quadraticdiscriminant analysis

    Johan Lindström - [email protected] Spatial Statistics 11/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Discriminant Analysis

    0 2 4 6 8 100

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10Linear Bayesian discrimination

    π1=0.5

    π1=0.25

    π1=0.1

    0 2 4 6 8 100

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10Quadratic discrimination

    Johan Lindström - [email protected] Spatial Statistics 12/37

  • Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Improving on K-means

    1. Select K data-points at random, as initial cluster centres.

    2. Assign all data points to their nearest cluster centre.3. Compute the mean within each cluster, and let these be the new

    cluster centres.3.1 Compute the amount of pixels in each class and use that as

    estimates of πk.3.2 EstimateΣk, one for each cluster.

    4. Use the estimated parameters to perform a MAP classification.

    5. Repeat from 2 3.

    Still one major issue: We are not sure of the classifications in each step.How should the uncertainty be taken into account?

    Johan Lindström - [email protected] Spatial Statistics 13/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Using the Posterior Probabilities

    ◮ Given estimates of πk, μk andΣk, compute the posterior classprobability for each data point.

    ◮ Let pi,k = P(x̃i = k|yi).◮ Then,

    π̂k =1n

    i

    pi,k

    is the average probability for a data point to belong to class k.

    Johan Lindström - [email protected] Spatial Statistics 14/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Using the Posterior Probabilities (cont)

    We also use the probabilities pi,k as certainty weights when estimatingμk andΣk.

    μ̂k =1

    nπ̂k

    i

    pi,kxi

    Σ̂k =1

    nπ̂k

    i

    pi,k(yi − μ̂)T(yi − μ̂)

    Johan Lindström - [email protected] Spatial Statistics 15/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    The EM-algorithm for Normal Mixtures

    Given: Initial estimates π(0) andΘ(0) of π = {π1, . . . , πK} andΘ = {μ1, . . . ,μK,Σ1, . . . ,ΣK}

    ◮ Let p(t)i,k = P(xi = k|yi,π(t),Θ(t)) ∝ π(t)k p(yi|xi = k,Θ(t)).

    ◮ Let

    π(t+1)k =1n

    i

    p(t)i,k

    μ(t+1)k =1

    nπ(t+1)k

    i

    p(t)i,k yi

    Σ(t+1)k =1

    nπ(t+1)k

    i

    p(t)i,k (yi − μ(t+1))T(yi − μ(t+1))

    This algorithm can be more rigorously derived using likelihoodprinciples.

    Johan Lindström - [email protected] Spatial Statistics 16/37

  • Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    LANDSAT image of Rio de Janeiro

    Johan Lindström - [email protected] Spatial Statistics 17/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Blue, Green, Red, and Infrared

    Johan Lindström - [email protected] Spatial Statistics 18/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Why Infrared?

    False colour composite (orIR-colour) images are used to pickout healthy vegetation(chlorophyll).

    University of Wisconsin-MadisonCampus, artificial turf on thefootball field.

    T. Lillesand, R. Kiefer, J. Chipman (2004),

    Remote Sensing and Image Interpretation,

    5ed:Plate 3.

    Johan Lindström - [email protected] Spatial Statistics 19/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Principal components extracted from 7 wavelengths

    Johan Lindström - [email protected] Spatial Statistics 20/37

  • Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    1D and 2D histograms

    Johan Lindström - [email protected] Spatial Statistics 21/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Bayesian Pixel Classification

    Johan Lindström - [email protected] Spatial Statistics 22/37

    Spatial Statistics Classification Spatial More K-means Bayesian EM-algorithm Example

    Classified Image

    Johan Lindström - [email protected] Spatial Statistics 23/37

    Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Stochastic Fields

    Many problems can be approached by modelling the spatial dependencestructure between pixels (or irregular locations).

    ◮ A random field is a collection of random variables x̃(u) with acommon density function.

    ◮ The random field can be used to model the dependence betweenpixels, or other spatially varying data.

    ◮ For a random field x̃(u), the expectation functionmx̃(u) = E(x̃(u)) collects the point-wise expectations of the field.

    ◮ For the covariance (dependence) between different pixels, we writer(u,v) = C(x̃(u), x̃(v)) = E((x̃(u)− mx̃(u))(x̃(v)− mx̃(v))).

    ◮ r(u,v) is called the covariance function.

    Johan Lindström - [email protected] Spatial Statistics 24/37

  • Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    0 20 40 60

    0

    0.2

    0.4

    0.6

    0.8

    1

    nu=0.5

    0 20 40 60

    0

    0.2

    0.4

    0.6

    0.8

    1

    nu=1.0

    0 20 40 60

    0

    0.2

    0.4

    0.6

    0.8

    1

    nu=2.0

    0 20 40 60

    0

    0.2

    0.4

    0.6

    0.8

    1

    nu=4.0

    Johan Lindström - [email protected] Spatial Statistics 25/37

    Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    nu=0.5

    5 10 15 20 25 30

    5

    10

    15

    20

    25

    30

    nu=1.0

    5 10 15 20 25 30

    5

    10

    15

    20

    25

    30

    nu=2.0

    5 10 15 20 25 30

    5

    10

    15

    20

    25

    30

    nu=4.0

    5 10 15 20 25 30

    5

    10

    15

    20

    25

    30

    Johan Lindström - [email protected] Spatial Statistics 26/37

    Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Satellite Data — Vegetation

    January 1999

    July 1999

    Johan Lindström - [email protected] Spatial Statistics 27/37

    Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Satellite Data — Trend in Vegetation

    K2 Estimate

    −0.4

    −0.2

    0

    0.2

    0.4

    Independent estimates

    K2 Estimate

    −0.3

    −0.2

    −0.1

    0

    0.1

    Correlated estimates

    Johan Lindström - [email protected] Spatial Statistics 28/37

  • Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Image Reconstruction

    Spatial Interpolation

    Given observations at some locations (pixels), y(ui), i = 1 . . .nwe want to make statements about the value at unobserved location(s),x(u0).

    The typical model consists of a latent Gaussian field

    x ∈ N (μ,Σ) ,

    observed at locations ui, i = 1, . . . ,n, with additive Gaussian noise(nugget or small scale variability)

    yi = x(ui)+ εi εi ∈ N(

    0,σ2ε).

    Johan Lindström - [email protected] Spatial Statistics 29/37

    Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Image Reconstruction (cont)

    Assuming known parameters: μ,Σ, and σ2ε with

    [Σ]kl = r(uk,ul)

    the conditional expectation of the missing pixels is

    E (x | y) = μ+ΣxyΣ−1yy (y − μ)

    where

    Σxy ∼ r(uj,ui){

    j ∈ unobservedi ∈ observed

    Σyy ∼ r(ui,ui)+ σ2ε i ∈ observed

    Johan Lindström - [email protected] Spatial Statistics 30/37

    Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Image Reconstruction

    Johan Lindström - [email protected] Spatial Statistics 31/37

    Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Image Reconstruction — Corrupted Pixels

    ◮ Typically we don’t know which pixels that are bad.◮ A better model is then

    ◮ Assume an underlying image, x.◮ Assume an indicator image for bad pixels, z.◮ Given the indicator we either observe the correct pixel value from x

    or noise.

    ◮ Use Bayes’ Formula to compute the distribution for the unknownimage (and indicator) given observations and parameters.

    Johan Lindström - [email protected] Spatial Statistics 32/37

  • Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Image Reconstruction — Corrupted pixels

    image reconstruction

    bad pixels − estimatebad pixels

    Johan Lindström - [email protected] Spatial Statistics 33/37

    Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Spatial Statistics

    ◮ Why limit ourselfs to images?◮ The principal works just as well for data that is not on a grid.

    ◮ Weather stations◮ Environmental monitoring,◮ Depth measurements◮ etc.

    ◮ We can even handle data on the globe.

    Johan Lindström - [email protected] Spatial Statistics 34/37

    Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Global Temperature — Data

    January 2003 July 2003

    Johan Lindström - [email protected] Spatial Statistics 35/37

    Spatial Statistics Classification Spatial More Satellite Data Reconstruction Temperature

    Global Temperature — Reconstruction

    Global mean: 15◦C.

    Johan Lindström - [email protected] Spatial Statistics 36/37

  • Spatial Statistics Classification Spatial More

    Learn more!

    What?Spatial statistics with image analysis, FMSN20

    When?HT2-2013, October–December

    Where?Information and Matlab files will be available atwww.maths.lth.se/matstat/kurser/fmsn20masm25/

    Who?Lecturer: Jonas Wallin

    MH:323

    Johan Lindström - [email protected] Spatial Statistics 37/37