Image Analysis of Multi-Spectral and Polarimetric SAR Imagery with Open Source Tools (Part 3)

Mort Canty (mort.canty@gmail.com)

ZFL Bonn, April 2016

4. Multispectral change detection

To quote a well-known, if now rather dated, review article on change detection (Singh 1989,

The basic premise in using remote sensing data for change detection is that changes in land cover must result in changes in radiance values ... [which] must be large with respect to radiance changes from other factors.

When comparing multispectral images of a given scene taken at different times, it is therefore desirable to correct the pixel intensities as much as possible for uninteresting differences such as those due to solar illumination, atmospheric conditions or sensor calibration. In the case of SAR imagery, solar illumination of course plays no role, but the other considerations are similarly important. If comparison is on a pixel-by-pixel basis, then the images must also be co-registered to high accuracy in order to avoid spurious signals resulting from misaligned pixels.

Algebraic methods

A simple way to detect changes in two corrected and coregistered multispectral images, represented by $N$-dimensional random vectors $X$ and $Y$, is to subtract them from each other component by component and then examine the $N$ difference images

$$ Z_i = X_i-Y_i,\quad i=1\dots N. $$

Small intensity differences indicate no change, large positive or negative values indicate change, and decision thresholds can be set to define significance. The thresholds are usually expressed in terms of standard deviations from the mean difference value, which is taken to correspond to no change. If the images are uncorrelated, the variances of the difference images are simply

$$ {\rm var}(Z_i) = {\rm var}(X_i) + {\rm var}(Y_i),\quad i=1\dots N, $$

or about twice as noisy as the individual image bands.

For SAR imagery, the situation is fundamentally different. The variance of the difference of two uncorrelated $m$-look intensity images is

$$ {\rm var}(X-Y) = {\langle X\rangle^2 + \langle Y\rangle^2 \over m}. $$

Simple thresholding of the difference image will yield larger errors for a given change in a bright area (large mean intensity) than in a darker area (small mean intensity). Image ratios are a much better choice for detection of changes in multi-look SAR intensity images as we will see later.

Multivariate Alteration Detection (MAD)

We make a linear combination of the intensities for all $N$ bands in the first image thus creating a scalar image characterized by the random variable

$$ U =a^\top X. $$

The vector of coefficients $a$ is as yet unspecified.

We do the same for the second image,forming the linear combination $$ V=b^\top Y, $$

and then look at the scalar difference image $U-V$.

We will choose $a$ and $b$ so as to make the images $U$ and $V$ as similar as possible. To do this , we maximize the correlation $\rho$ between the random variables $U$ and $V$:

$$ \rho = {{\rm cov}(U,V)\over \sqrt{{\rm var}(U)}\sqrt{{\rm var}(V)}}.\quad (1) $$

Arbitrary multiples of $U$ and $V$ would clearly have the same correlation, so a constraint must be chosen. A convenient one is

$$ {\rm var}(U)={\rm var}V)=1. \quad (2) $$

Note that, under this constraint, the variance of the difference image is

$$ {\rm var}(U-V)= {\rm var}(U)+{\rm var}(V)-2{\rm cov}(U,V) = 2(1-\rho).\quad (3) $$

The statistical procedure which makes $U$ and $V$ as similar as possible is called canonical correlation analysis.

The bitemporal, multispectral image may be represented by the combined random vector $ \pmatrix{X\cr Y}. $ This random vector has a $2N\times 2N$ covariance matrix which can be written in block form:

$$ \Sigma=\pmatrix{\Sigma_{XX}&\Sigma_{XY}\cr\Sigma_{XY}^\top&\Sigma_{YY}}. $$

The variances and covariances in Equations (1) and (2) are then

$$ {\rm var}(U) = a^\top \Sigma_{XX}a,\quad {\rm var}(V)=b^\top \Sigma_{YY}b,\quad {\rm cov}(U,V) = a^\top\Sigma_{XY} b. $$

We introduce the Lagrange multipliers ${\nu/2}$ and $\mu/2$ for each of the two constraints, then the problem becomes one of maximizing the unconstrained Lagrange function

$$ L = a^\top \Sigma_{XY} b-{\nu\over 2}( a^\top \Sigma_{XX} a-1)-{\mu\over 2}(b^\top \Sigma_{YY}\ b-1). $$

Setting derivatives with respect to $a$ and $b$ equal to zero gives

$$ {\partial L\over \partial a}=\Sigma_{XY} b-\nu\Sigma_{XX} a = 0 $$$$ {\partial L\over \partial b}=\Sigma_{XY}^\top a-\mu\Sigma_{YY} b = 0. $$

Multiplying the first of the above equations from the left with the vector $ a^\top$, the second with $ b^\top$, and using the constraints leads immediately to

$$ \nu = \mu = a^\top\Sigma_{XY} b = \rho. $$

Therefore we can write

$$ \Sigma_{XY} b - \rho\Sigma_{XX} a = 0 $$$$ \Sigma_{XY}^\top a - \rho\Sigma_{YY} b = 0. $$

Next, multiply the first Equations above by $\rho$ and the second from the left by $\Sigma_{YY}^{-1}$. This gives

$$ \rho\Sigma_{XY} b = \rho^2\Sigma_{XX} a $$

and

$$ \Sigma_{YY}^{-1}\Sigma_{XY}^\top a = \rho b. $$

Combining these two Equations, we obtain the following equation for the transformation coefficient $a$,

$$ \Sigma_{XY}\Sigma_{YY}^{-1}\Sigma_{XY}^\top a = \rho^2\Sigma_{XX} a $$

Similarly we get for $b$,

$$ \Sigma_{XY}^\top\Sigma_{XX}^{-1}\Sigma_{XY} b = \rho^2\Sigma_{YY} b. $$

which can be solved for $a$ and $b$.

Solution of the eigenvalue problems generates new multispectral images

$$ U=(U_1\dots U_N)^\top $$

and

$$ V=(V_1\dots V_N)^\top, $$

the components of which are called the canonical variates (CVs). The CVs are ordered by similarity (correlation) rather than, as in the original images, by wavelength.

The canonical correlations

$$ \rho_i={\rm corr}(U_i,V_i),\quad i=1\dots N, $$

are the square roots of the eigenvalues of the coupled eigenvalue problem:

$$ \rho_i = \sqrt{\lambda_i}. $$

The pair $(U_1,V_1)$ is maximally correlated, the pair $(U_2,V_2)$ is maximally correlated subject to being orthogonal to (uncorrelated with) both $U_1$ and $V_1$, and so on.

Taking paired differences (in reverse order) generates a sequence of transformed difference images

$$ M_i = U_{N-i+1}-V_{N-i+1},\quad i=1\dots N, $$

referred to as the multivariate alteration detection (MAD) variates.

From Equation (3),

$$ {\rm var}(M_i) = \sigma_{M_i}^2 = 2(1-\rho_{N-i+1}) = 2(1-\sqrt{\lambda_{N-i+1}}).\quad (4) $$

MAD

In [1]:
run /home/imad -h
Usage:
-----------------------------------------------------
python /home/imad.py [-h] [-n] [-i max iterations] [-p bandPositions] 
[-d spatialDimensions] filename1 filename2
-----------------------------------------------------
bandPositions and spatialDimensions are lists, 
e.g., -p [1,2,3] -d [0,0,400,400]
-n stops any graphics output
-----------------------------------------------------
The output MAD variate file is has the same format
as filename1 and is named

      path/MAD(filebasename1-filebasename2).ext1
      
where filename1 = path/filebasename1.ext1
      filename2 = path/filebasename2.ext2

For ENVI files, ext1 or ext2 is the empty string.       
-----------------------------------------------------
In [2]:
%matplotlib inline
In [3]:
cd /home/imagery
/home/imagery
In [4]:
ls -l
total 49656
-rw-rw-r-- 1 root root  6000000 Jul 28  2006 20010525
-rw-rw-r-- 1 root root      870 Jul 28  2006 20010525.hdr
-rw-r--r-- 1 root root 24000000 Apr 20 08:34 20010525_pca
-rw-r--r-- 1 root root      738 Apr 20 08:34 20010525_pca.hdr
-rw-r--r-- 1 root root  1000000 Apr 20 08:38 20010525_pca_em
-rw-r--r-- 1 root root      951 Apr 20 08:38 20010525_pca_em.hdr
-rw-rw-r-- 1 root root  6000000 Jul 28  2006 20010626
-rw-rw-r-- 1 root root      856 Jul 28  2006 20010626.hdr
-rw-rw-r-- 1 root root  6000000 Jul 28  2006 20010829
-rw-rw-r-- 1 root root      867 Jul 28  2006 20010829.hdr
drwx------ 5 root root     4096 Apr 12 09:57 RS2_OK5491_PK71074_DK68879_FQ21_20100426_172459_HH_VV_HV_VH_SLC/
drwxr-xr-x 3 root root     4096 Apr 20 08:17 RS2_OK5491_PK71074_DK68879_FQ21_20100426_172459_HH_VV_HV_VH_SLC_MapReady/
-rw-r--r-- 1 root root   364496 Apr 20 08:41 RS2_OK5491_PK71074_DK68879_FQ21_20100426_172459_HH_VV_HV_VH_SLC_MapReady.meta
drwx------ 4 root root     4096 Dec 15 11:21 RS2_OK5491_PK71074_DK68879_FQ21_20100520_172458_HH_VV_HV_VH_SLC/
drwxr-xr-x 3 root root     4096 Apr 20 08:22 RS2_OK5491_PK71074_DK68879_FQ21_20100520_172458_HH_VV_HV_VH_SLC_MapReady/
-rw-r--r-- 1 root root   364496 Apr 20 08:22 RS2_OK5491_PK71074_DK68879_FQ21_20100520_172458_HH_VV_HV_VH_SLC_MapReady.meta
drwx------ 5 root root     4096 Feb 13 09:24 RS2_OK5491_PK71074_DK68879_FQ21_20100707_172459_HH_VV_HV_VH_SLC/
drwxr-xr-x 3 root root     4096 Apr 20 08:25 RS2_OK5491_PK71074_DK68879_FQ21_20100707_172459_HH_VV_HV_VH_SLC_MapReady/
-rw-r--r-- 1 root root   364496 Apr 20 08:25 RS2_OK5491_PK71074_DK68879_FQ21_20100707_172459_HH_VV_HV_VH_SLC_MapReady.meta
-rw-rw-r-- 1 root root  3773416 Apr 20 08:38 ZFL-Course-Part1.ipynb
-rw-rw-r-- 1 root root  2859265 Apr 20 08:45 ZFL-Course-Part2.ipynb
-rw-rw-r-- 1 root root    19354 Apr 18 08:14 ZFL-Course-Part3.ipynb
-rw-rw-r-- 1 root root    30757 Apr 20 08:31 ZFL-Course-Part4.ipynb
drwxr-xr-x 2 root root     4096 Apr 18 08:15 figures/
-rw-rw-r-- 1 root root     4058 Apr  1 08:56 pca.ipynb

The "ordinary MAD transformation", i.e., just one iteration:

In [5]:
run /home/imad -i 1 /home/imagery/20010626 /home/imagery/20010829
------------IRMAD -------------
Wed Apr 20 08:46:32 2016
time1: /home/imagery/20010626
time2: /home/imagery/20010829
rho: [ 0.22766648  0.3737326   0.55342704  0.69641036  0.74200118  0.84767079]
result written to: /home/imagery/MAD(20010626-20010829)
elapsed time: 2.72670388222
In [6]:
run /home/dispms -p [4,5,6] -e 3 -f /home/imagery/MAD(20010626-20010829)

Iterated MAD

Imagine two images of the same scene, acquired at different times under similar conditions, but for which no ground reflectance changes have occurred whatsoever.

Then the only differences between them will be due to random effects like instrument noise and atmospheric fluctuation. In such a case we would expect that the histogram of any difference component that we generate will be very nearly Gaussian.

In particular, the MAD variates, being uncorrelated, should follow a multivariate, zero mean normal distribution with diagonal covariance matrix.

Change observations would deviate more or less strongly from such a distribution. We might therefore expect an improvement in the sensitivity of the MAD transformation if we can establish an increasingly better background of no change against which to detect change.

This can again be done in an iteration scheme in which, when calculating the means and covariance matrices for the next iteration of the MAD transformation, observations are weighted by the probability of no change determined on the preceding iteration.

Let the random variable $Z$ represent the sum of the squares of the standardized MAD variates,

$$ Z = \sum_{i=1}^N\left({M_i\over \sigma_{M_i}}\right)^2, $$

where $\sigma_{M_i}$ is given by Equation (4). Then, since the no-change observations are expected to be normally distributed and uncorrelated, the random variable $Z$ corresponding to such observations should be chi-square distributed with $N$ degrees of freedom. For each iteration, the observations can thus be given weights determined by the chi-square distribution, namely

$$ {\rm Pr}(\hbox{no change}) = 1-P_{\chi^2;N}(z). $$

Here ${\rm Pr}(\hbox{no change})$ is the probability that a sample $z$ drawn from the chi-square distribution could be that large or larger.

Iteration of the MAD transformation continues until there is no significant change in the canonical correlations $\rho_i$, $i=1\dots N$.

In [7]:
run /home/imad  /home/imagery/20010626 /home/imagery/20010829
------------IRMAD -------------
Wed Apr 20 08:46:49 2016
time1: /home/imagery/20010626
time2: /home/imagery/20010829
rho: [ 0.66817403  0.74675512  0.85250628  0.93893862  0.97844374  0.98936266]
result written to: /home/imagery/MAD(20010626-20010829)
elapsed time: 76.3112399578
In [8]:
run /home/dispms -e 3 -p [6,5,4] -E 3 -P [7,7,7] \
-f /home/imagery/MAD(20010626-20010829) \
-F /home/imagery/MAD(20010626-20010829)

Clustering changes

The image shown on the left is an RGB composite of the three MAD components corresponding to the three most similar canonical variates. The light blue-green (featureless) regions correspond to built-up areas and to forest canopy, neither of which have changed significantly between acquisitions. The significant changes, indicated by the various brightly colored areas, are quite heterogeneous and not easy to interpret, but from their form they are clearly associated with cultivated fields. The main crops in this area are sugar beets, corn and cereal grain. The former two are still maturing in August, whereas the grain fields have been harvested. So we might postulate two main classes of change: maturing crops and harvested crops. Allowing for a no-change class and a "catch-all" class for other kinds of change, we can try to classify the MAD image with the Gaussian mixture clustering algorithm by assuming four classes in all.

In [9]:
run /home/em -p [4,5,6] -K 4 /home/imagery/MAD(20010626-20010829)
--------------------------
     EM clustering
--------------------------
infile:   /home/imagery/MAD(20010626-20010829)
clusters: 4
T0:       0.500000
beta:     0.500000
running EM on 62500 pixel vectors
em iteration 0: dU: 0.819126 loglike: -97916.848095
em iteration 10: dU: 0.959416 loglike: -43063.511927
em iteration 20: dU: 0.854458 loglike: -32256.100982
em iteration 30: dU: 0.676945 loglike: -27984.111075
em iteration 40: dU: 0.413237 loglike: -26485.981799
em iteration 50: dU: 0.251223 loglike: -24843.116915
em iteration 60: dU: 0.098786 loglike: -23166.836140
em iteration 70: dU: 0.042118 loglike: -22527.372595
em iteration 80: dU: 0.028571 loglike: -22372.248611
em iteration 90: dU: 0.015401 loglike: -22290.556435
em iteration 100: dU: 0.009767 loglike: -22226.120687
em iteration 110: dU: 0.005855 loglike: -22172.401532
em iteration 120: dU: 0.003577 loglike: -22128.100842
em iteration 130: dU: 0.002346 loglike: -22092.071056
em iteration 140: dU: 0.001630 loglike: -22063.020305
em iteration 150: dU: 0.001163 loglike: -22039.700637
running EM on 250000 pixel vectors
em iteration 0: dU: 0.998587 loglike: -229159.663483
em iteration 10: dU: 0.025050 loglike: -76149.940871
em iteration 20: dU: 0.001553 loglike: -76081.817129
running EM on 1000000 pixel vectors
em iteration 0: dU: 0.999997 loglike: -669668.721581
em iteration 10: dU: 0.006901 loglike: -283566.006652
Cluster mean vectors
[[ 0.11820707 -0.0217766  -0.03211875]
 [ 1.16907752 -2.53559852 -3.22051503]
 [-0.17740774  0.83676821  1.85438232]
 [ 1.95855867 -0.8656198  -1.63516713]]
Cluster covariance matrices
cluster: 0
[[ 0.75547375 -0.11652035 -0.1850149 ]
 [-0.11652035  0.40481931  0.27007315]
 [-0.1850149   0.27007315  0.47019488]]
cluster: 1
[[ 1.39167059 -0.23985562  0.07388096]
 [-0.23985562  1.4737583   1.20615965]
 [ 0.07388096  1.20615965  1.55963436]]
cluster: 2
[[ 0.75391143  0.2875518   0.05428651]
 [ 0.2875518   1.27309186  0.99914964]
 [ 0.05428651  0.99914964  1.35615663]]
cluster: 3
[[ 5.26058277 -0.77788763 -0.80042824]
 [-0.77788763  4.40303008  3.29901953]
 [-0.80042824  3.29901953  4.18631136]]
classified image written to: /home/imagery/MAD(20010626-20010829)_em
elapsed time: 89.3565859795
--done------------------------
In [10]:
run /home/dispms -e 1 -c [1,2,3,4] -f /home/imagery/MAD(20010626-20010829)_em

Harvested crops

In [19]:
run /home/dispms -e 3 -p [4,4,4] -d [0,0,400,400] -f /home/imagery/20010829  \
-C [2] -E 1 -D [0,0,400,400] -F /home/imagery/MAD(20010626-20010829)_em

Automatic radiometric normalizaton

Ground reflectance determination from satellite imagery requires, among other things, an atmospheric correction algorithm and the associated atmospheric properties at the time of image acquisition. For many historical satellite scenes such data are not available and even for planned acquisitions they may be difficult to obtain. A relative normalization based on the radiometric information intrinsic to the images themselves is an alternative whenever absolute surface reflectances are not required.

In performing relative radiometric normalization, one usually makes the assumption that the relationship between the at-sensor radiances recorded at two different times from regions of constant reflectance can be approximated by linear functions. The critical aspect is the determination of suitable time-invariant features upon which to base the normalization.

Scatterplot matching

With reference to the above Figure, one can derive the following linear transformation, which relates a point $(x,y)$ in the target scatterplot to its transform $(\tilde x,\tilde y)$ in the reference scatterplot:

$$ \tilde x = X_R + (x - X_T){L_R\over L_T}{a_T\over a_R} $$$$ \tilde y = Y_R - (Y_T - y){L_R \over L_T}. $$

IR-MAD Normalization

We can use the chi-square image in the IR-MAD transformation to identify invariant pixels. These can be used for radiometric normalization of the two images because canonical correlation anaysis is invariant under linear transformations.

In [20]:
run /home/radcal -h
Usage: 
--------------------------------------------------------
python /home/radcal.py  [-p "bandPositions"] [-d "spatialDimensions"] 
[-t no-change prob threshold] imadFile [fullSceneFile]' 
--------------------------------------------------------
bandPositions and spatialDimensions are quoted lists, 
e.g., -p [4,5,6] -d [0,0,400,400]
-n stops graphics output

SpatialDimensions MUST match those of imadFile
spectral dimension of fullSceneFile, if present,
MUST match those of target and reference images
--------------------------------------------------------
imadFile is of form path/MAD(filename1-filename2).ext and
the output file is named 

            path/filename2_norm.ext.

That is, it is assumed that filename1 is reference and
filename2 is target and the output retains the format
of the imadFile. A similar convention is used to
name the normalized full scene, if present:

         fullSceneFile_norm.ext

Note that, for ENVI format, ext is the empty string.
-------------------------------------------------------
In [21]:
run /home/radcal /home/imagery/MAD(20010626-20010829)
Wed Apr 20 08:52:32 2016
reference: /home/imagery/20010626
target   : /home/imagery/20010829
no-change probability threshold: 0.95
no-change pixels: 1768
band: 1  slope: 1.141594  intercept: -0.497890  correlation: 0.970123
band: 2  slope: 1.179262  intercept: -1.879516  correlation: 0.980589
band: 3  slope: 1.256239  intercept: -7.962851  correlation: 0.986799
band: 4  slope: 1.422099  intercept: -5.731570  correlation: 0.973013
band: 5  slope: 1.253927  intercept: -3.739825  correlation: 0.988897
band: 6  slope: 1.323260  intercept: -8.025598  correlation: 0.994375
result written to: /home/imagery/20010829_norm
elapsed time: 0.911489009857

We compare the August image before and after normalization on absolute scale 0-255 with the July image:

In [22]:
run /home/dispms -e 1 -p [4,5,6] -f /home/imagery/20010829 \
-E 1 -P [4,5,6] -F /home/imagery/20010829_norm
In [23]:
run /home/dispms -e 1 -p [4,5,6] -f /home/imagery/20010626 \
-E 1 -P [4,5,6] -F /home/imagery/20010829_norm
In [ ]: