Texture Segmentation
Texture Segmentation
Via
Gaussian Markov Random Field (GMRF) Model
And
Filter Bank Decomposition
by
Zhou Shaohua
March 15, 2001
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
Abstract
This report deals with texture segmentation under no supervision. With absence
of training patterns in unsupervised segmentation, typically, K-Means clustering
technique is invoked to make the segmentation in the feature space. Two kinds of features
are extracted from the mosaic texture in this study. GMRF model is used to capture the
statistical properties of textures, while filter bank decomposition to attain the frequency
properties.
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
Chapter 1: Introduction
Due to its widespread presence all over the world, texture is served as an
important cue in human visual system (HVS). Texture-related research topics, such as
texture analysis, classification, and segmentation, attract a significant amount of attention
in the literature. In this report, we focus on the problem of texture segmentation.
Despite of long history of research effort on texture, no exact definition of texture
can be found in the literature, because texture has multi-fold characteristics, which are
hard to be described in one single sentence. For instance, some textures have strong
structural organization, some have random natures, and some have both properties. Thus,
approaches to texture analysis, according to their emphases, can be roughly divided into
three groups: structural, statistical [1, 2, 3], and spectral [4, 5] ones. Also, there are
alternative approaches, such as normalized cut [6], available in the literature. In this
report, we study both statistical and spectral approaches. In particular, GRMF model is a
statistical approach, and filter bank decomposition is a spectral one.
Texture segmentation can be achieved under no supervision. With absence of
training patterns in unsupervised segmentation, unsupervised clustering techniques such
as K-means algorithm are common practices. However, clustering image intensities
produces nothing meaningful, especially for textural images. Therefore, feature should be
extracted before clustering. The ideal feature, which is hard to extract in practice, should
possess the capability of minimizing within-cluster distance while maximizing betweencluster one. Two features proposed in this report are (i) GMRF parameters, and (ii) postprocessed results of filter responses after filter bank decomposition.
The rest of this report is organized as follows. Chapter 2 introduces the GMRF
model and its implemental details. Chapter 3 describes the filter bank approach and
discusses the issues of filter selection and feature extraction. Experimental results are also
included in according chapters. Chapter 4 concludes the report.
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
p( f (m, n) | f (k, l), (k, l) (m, n), (k, l) } p( f (m, n) | f (k, l), (k, l) (m,n) )
where ( m , n ) is the neighborhood of pixel ( m, n) . If this PDF happens to be a Gaussian
distribution, we call this MRF as a GMRF. Fig. 2.1 illustrates the order of GMRF, which
is related to the location of neighbors.
(t , s) f (m t , n s) e(m, n)
( t , s )
where
and
e(m, n) ~ N (0, 2 ) with zero mean and variance 2 . For each pixel, we train the mean
(LSE), i.e.,
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
r (0,0)
r (0,1)
r (0,2)
r (1,0)
r (0,1)
r (0,0)
r (0,2)
r (0,1)
r (0,1)
r (1,1)
r (0,0)
r (1,2)
r (1,0) (1,1)
r (1,1)
r (1,0)
r (1,1) (1,0)
r (1,1)
r (1,2) (1,1)
r (0,0) (0,1)
r (0,1)
2 r (0,0)
(t , s)r (t , s)
( t , s )
r (t , s )
1
Nw
f (m, n) f (m t , n s)
( m , n )W
1
Nw
f (m, n)
( m , n )W
where N w is the number of pixel in the window W . Note that, due to the symmetry of
correlation function, only four s are estimated. We now form the feature space
{ , , (t , s ), (t , s ) } , and K-Means clustering algorithm is then applied to make
However, misclassifications are there due to (i) that some regions of the given
mosaic images are too non-stationary to be captured by GMRF model, or in other
word, the trained parameters have large variations, and (ii) that estimation from a
window centered at the pixel has de facto smoothing effect, which blurs the
boundary.
In addition, Fig. 2.2(b) is much more different to segment than Fig. 2.2(a) because
of the small patch of each class in the down part, which make it extremely hard to
train GMRF parameters.
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
(a)
(b)
Figure 2.2: Two mosaic images used in the experiment.
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
(a)
(b)
Figure 2.4: Segmented results using GMRF model.
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
k u2
k u2
2
2
2
GW[u ,v ] (m, n) 2 exp(
(
m
n
)){cos(
k
(
m
cos
n
sin
))
exp(
)}
u
v
v
2
2 2
/2
v
k u u / 2 , u 0,1,2; v
, v 0,1,...,7
8
2
Fig. 3.2 shows some examples of filters and their spectrums. There are 24 filters in this
wavelet family, which covers almost all high-frequency components. In addition, a
simple Gaussian averaging filter is introduced in order to cover low-frequency
components.
Filter responses themselves are features. However, as argued in [4], purely linear
mechanism such as convolution is inadequate for discrimination, and thus nonlinear
operations are needed. In this report, we introduce two nonlinear operations: (i) full-wave
rectification, and (ii) adaptive pooling. Full-wave rectification is mathematically defined
as taking the absolute operation, i.e.,
rk ( m, n) ( f hk )(m, n)
where g k (m, n) is a Gaussian averaging function with its variance proportional to the
sample variance of rk (m, n) . The idea of adaptive pooling stems from the fact: the filter
responses are non-stationary even within one class, thus need pooling before feeding to
K-Means clustering.
Fig. 3.3 shows the segmented results using Gabor filter bank decomposition. We
can observer the following:
Filter bank approach seems to produce a better segmentation than GMRF model
algorithm. The benefit may arise from the adaptive pooling to overcome the
irregularity within one texture class.
There exist boundary artifacts (as shown in Fig. 3.3), which are inherent to
filtering approaches.
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
(a)
(b)
Figure 3.3 Segmented results of Gabor Filter Bank
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
Chapter 4: Conclusion
In this report, texture segmentation is achieved in unsupervised way. GMRF
model is fitted on the mosaic images, and the model parameters are used to form a multidimensional feature space. In filter bank approach, nonlinear operations are applied to
filter responses to extract features. K-Means clustering algorithm is then invoked to
perform the segmentation. Experimental results are presented and observations are made
to demonstrate the efficiency of our approaches.
Reference
[1] B. S. Manjunath, T. Simchony, and R. Chellappa, Stochastic and Deterministic
Networks for Texture Segmentation, IEEE Acoustic, Speech, and Signal Processing,
Vol. 38, No. 5, July 1990.
[2] Fure-Ching Jeng, J. W. Woods, and S. Rastogi, Compound Gauss-Markov Random
Fields for Parallel Image Processing, Markov Random Fields Theory and Application,
Academic Press, 1993.
[3] S. Krishnamachari, and R. Chellappa, Multiresolution Gauss-Markov Random Field
Models for Texture Segmentation, IEEE Trans. Image Processing, Vol. 6, No. 2,
February 1997.
[4] J. Malik and P. Perona, Preattentive texture discrimination with early vision
mechanisms, J. Opt. Soc. Am. A, Vol. 7, No. 5, May 1990
[5] B. S. Manjunath and W. Ma, Texture features for browsing and retrieval of image
data, IEEE Trans. on Pattern Analysis and Machine Intelligence, Vol. 18, No. 8, August
1996.
[6] Jianbo Shi and J Malik, Normalized Cuts and Image Segmentation, IEEE
Transactions on Pattern Analysis and Machine Intelligence, Vol. 22, No. 8, August 2000.
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
[7] L. Wiskott, J.-M. Fellous, N. Kruger, and C. von der Malsburg, Face recognition by
elastic graph matching, IEEE Trans. Pattern Analysis and Machine Intelligence, Vol. 19,
No. 7, July 1997.
[8] Part of Matlab source is attached in the appendix.
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
if (nno>R+1)
for m=mno-R+1:mno
for n=1:nno-R-1
para(m,n,:) = para(mno-R, n, :);
end
end
end
%CORRCOEF2 Correlation coefficient for the image
% CORRCOEF2(X, DX, DY) computes the correlation coefficient
% r(dx, dy).
function r = corrcoef2(x, dx, dy)
[M,N] = size(x);
if dx >= 0 & dy >= 0
x1 = x(dx+1:M, dy+1:N);
x2 = x(1:M-dx, 1:N-dy);
elseif dx >= 0 & dy < 0
x1 = x(dx+1:M, 1:N+dy);
x2 = x(1:M-dx, -dy+1:N);
elseif dx < 0 & dy >= 0
x1 = x(1:M+dx, dy+1:N);
x2 = x(-dx+1:M, 1:N-dy);
else
x1 = x(1:M+dx, 1:N+dy);
x2 = x(-dx+1:M, -dy+1:N);
end
r = sum(sum(x1.*x2))/(M-abs(dx))/(N-abs(dy));
%function gw = gaborw(v, u, sigma, scale, sz)
% u -- controls the center freq
% v -- controls the orientaion
% sigma -- controls the standard variation
% scale -- set to 1 by default
% sz -- filter size
function gw = gaborw(v, u, sigma, scale, sz)
k_v = pi/2/power(2, v/2);
phi_u = u*pi/8;
s = sigma;
y = scale;
rows = sz(1);
cols = sz(2);
gw = zeros([rows,cols]);
for r=1:rows
for c = 1:cols
r1 = (r-1-rows/2)*y;
c1 = (c-1-cols/2)*y;
a = y*y;
a = a*(k_v*k_v)/(s*s)*exp(-k_v*k_v*(r1*r1+c1*c1)/(2.0*s*s));
a = a*(cos(k_v*(r1*cos(phi_u)-c1*sin(phi_u)))-exp(-s*s/2.0));
gw(r,c) = a;
end
end
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
% out = JETS(in) -- compute gabor jets for input image
function out = jets(in)
[M,N] = size(in);
out = zeros([M,N,24]);
fft2_in = fft2(in);
for u=0:2
for v=0:7
fprintf('jet (%d %d)\n', u, v);
k = u*8+v+1;
gw = gaborw(u,v,2*pi,1.0, [M,N]);
out(:,:,k) = abs(fftshift(real(ifft2(fft2_in.*fft2(gw)))));
end
end
x = [1:M] - M/2 -1;
y = gauss(x, 0, 2*pi);
gw = y'*y;
out(:,:,25) = abs(fftshift(real(ifft2(fft2_in.*fft2(gw)))));
% jets pooling
function out = jpool(in)
[M,N,L] = size(in);
for l=1:L
s = std2(in(:,:,l));
if s>4
K = floor(s);
x = -K:K;
y = gauss(x, 0, s);
B = y'*y;
else
B = 1;
end
out(:,:,l) = conv2(in(:,:,l), B, 'same');
end
%function cmap = kmeans(in, cno, error)
% cmap -- cluster map
% in -- input matrix
% cno -- class number
% epsilon -- convengence error
function cmap = kmeans(in, cno, epsilon)
if nargin ~= 3
error('Usage: kmeans(in, cno, epsilon)');
end
[M,N,L] = size(in);
cmap = zeros([M,N]);
for k=1:cno
a(k,:) = in(floor(rand(1)*M), floor(rand(1)*N), :);
end
for i=1:L
Unsupervised Texture Segmentation via GMRF Model and Filter Bank Decomposition
s(i) = std2(in(:,:,i));
end
prev_error = 0;
while (1)
disp(a);
curr_error = 0;
for m=1:M
for n=1:N
v(1,:) = in(m,n,:);
[id, dist] = nnb(v, a, s); %nearest neighbor
cmap(m,n)=id;
curr_error = curr_error + dist;
end
end
curr_error = curr_error/(M*N);
error = abs(curr_error - prev_error);
fprintf('curr_error = %f, prev_error = %f, error=%f\n', ...
curr_error, prev_error, error);
if error < epsilon
break;
else
prev_error = curr_error;
a(:,:)= 0.0;
b(1:cno)= 0;
for m=1:M
for n=1:N
k = cmap(m,n);
b(k)=b(k)+1;
v(1,:) = in(m,n,:);
a(k,:) = a(k,:) + v;
end
end
for k=1:cno
a(k,:)=a(k,:)/b(k);
end
end
end
% nearest neighbor
function [id,dist] = nnb(in, a, s)
dist = 1000;
[cno,x] = size(a);
for i=1:cno
d = sum(abs((in-a(i,:))./s));
if dist>d
id = i;
dist = d;
end
end