Вы находитесь на странице: 1из 4

COLOR QUANTIZATION USING PRINCIPAL COMPONENTS FOR

INITIALIZATION OF KOHONEN SOFM


D. Mavridis and N. Papamarkos
Image Processing and Multimedia Laboratory
Department of Electrical & Computer Engineering
Democritus University of Thrace
67100 Xanthi, Greece, papamark@ee.duth.gr
ABSTRACT
A new method is proposed for initializing Kohonens selforganizing feature maps (SOFM) for use in color quantization. The
method employs the two largest principal components of the input
image so that the initial weights of a number of neurons
approaches the input image color distribution. The rest of the
neurons are initialized using the smallest principal component of
the input image. Namely, SOFM is applied to the projection of the
input image pixels onto the plane spanned by the two largest
principal components and to pixels of the original image defined
by the smallest principal component. The neuron values which
emerge initialize a final SOFM that performs the color
quantization of the original image. Experimental results show that
in most cases the proposed method is able to produce smaller
quantization errors than standard SOFM and other existing color
quantization methods.
Index Terms Color quantization, neural networks, selforganizing feature maps
1. INTRODUCTION
Color quantization is an image processing technique whose
purpose is to reduce the colors of digital images to a small limited
number in such a way that a measure of difference between the
original image and the color quantized one is minimized.
Several color quantization techniques have been proposed.
These techniques can be classified into major categories. First, it is
the class of splitting algorithms where the color space is divided
into disjoined regions by consecutively splitting up the color space
and then choosing a color to represent the region in the color
palette e.g. median-cut [10], variance-based algorithm [22], Octree
[1], Wu [24]. They are considered to be fast algorithms, however
better quality results are usually obtained by methods of the
second major class which are based on cluster analysis of the color
space. The methods of Growing Neural Gas (GNG) [8], Adaptive
Color Reduction (ACR) [18], Self-Growing and Self-Organized
neural network (SGONG) [2], Fuzzy ART [4], Fuzzy C-Means
(FCM) [3], [15] belong to this category. In these methods the
cluster representatives are continuously adapted to the color
content of the original image achieving this way a statistically
analogue color distribution and good quality results.
2. KOHONEN SELF-ORGANIZING FEATURE MAP
A well known unsupervised neural network classifier belonging to
the previous category is the Kohonen Self-Organizing Feature Map

(SOFM) [12], [13]. It consists of two separate layers of neurons,


the input and output layer. The input layer operates as a buffer for
the input vectors which are parallelly transmitted to all neurons of
the output layer. The number of neurons and the connections
between them are user defined and fixed, shaping a linear, planar
or multidimensional lattice (figure 1 - left), independent of the
input vectors dimension.
The main steps for using SOFM classifier to perform color
quantization to N colors are:
Step 1: Define the output layer structure of the N neurons forming
it. Initialize the neuron weights wi = [Wi1, Wi2, Wi3]T, 0 i <N.
Reset variable t which increases on every new input vector (a new
pixel value xk = [ rk , g k , bk ]

from the input image). Reset epochs

variable ep which increases on every m consecutive input vectors.


Initialize the neighborhood size and define a neighborhood
function nei(wi,ep). Initialize learning rate 1(ep) for the winner
neuron and learning rate 2(ep) for its neighboring neurons.
Step 2: Get a new input vector xk = [ rk , g k , bk ]

and find the

winner neuron wc using the smallest square of the Euclidean


distance in RGB color space as follows:
d(xk, wc)2 = mini((rk - Wi1)2 + (gk - Wi2)2 + (bk - Wi3)2) ,
0i<N
(1)
Step 3: The winner neuron wc and its neighboring neurons wb
defined from nei(wc,ep) are biased towards the input vector

xk = [ rk , g k , bk ] as follows:
T

wc ( t + 1) = wc ( t ) + 1 ( ep ) ( xk wc ( t ))

(2)

wb ( t + 1) = wb ( t ) + 2 ( ep ) ( xk wb ( t ))

(3)

Step 4: If m consecutive vectors are inputted, increase ep variable


by 1. In this case decrease also the values of learning rates 1(ep)
and 2(ep) and the radius of the neighbourhood domain.
Step 5: Repeat from step 2 until either the maximum difference of
the correspondent weight values of each neuron wi from epoch to
epoch is below a threshold, or a maximum number of epochs is
reached.
Step 6: Construct the quantized output image using Euclidean
distance metric on the generated color palette and the pixels of the
input image.
There exist several variants of SOFM neural network.
Methods taking into account the frequency a neuron is chosen, in
order to form equal-sized classes and to avoid underutilized classes
are proposed in [6], [5], [23]. In Adaptive Color Reduction [18],
local spatial features are extracted from the neighboring sampled
pixels and fed to a neural network consisting of a Principal

Component Analyzer (PCA) and a SOFM, extending previous


methods used on color [16] and gray images [17]. Two-stage
image segmentation is proposed in [11]. Hybrid methods are also
implemented, as in SGONG [2] where the proposed neural
network uses the GNG [8] mechanism of growing the neural lattice
and the SOFM learning adaptation algorithm.

Figure 1. A two dimensional SOFM neural network (left) and PCA


performed by a neural network implementing GHA (right)

3. PRINCIPAL COMPONENTS BASED INITIALIZATION


When the SOFM was introduced for the first time [12], it was
shown that the initials values of its models in the learning process
can be selected as random vectors. However, since SOFM is
gradient descent in nature, the quality and speed of the
convergence of the neurons are sensitive to initialization values. In
general, it is considered to be a good initialization if the initial
weights of the neurons are made to match the input image color
distribution more closely. Kohonen in [12] mentions accordingly
that the training process could be faster if the point density of the
initial models approaches that of the input data and in [14]
recommends to choose the initial models as a regular array of
vectors on the hyperplane spanned by the two largest principal
components of input data. In absence of a priori knowledge of the
input image color distribution and in order to approach it in a
broad way, it is proposed in [20] to initialize SOFM distributing
the neurons uniformly along the luminance axis of RGB cube. An
extension of this method is presented in [25] where a color group
of neurons distributed uniformly throughout the RGB cube is
added to the previous gray group.
The proposed method for color quantization to N colors
employs the two largest principal components of the input image,
so that the initial weights of a number of neurons approaches the
input image color distribution. Let k1 be the number of neurons to
initialize this way (k1 N), a SOFM with an output layer of k1
neurons is applied to the projection of the input image pixels onto
the plane spanned by the two largest principal components. The
weights of the k1 neurons, after applying the first SOFM, are the
intended initialization of k1 neurons of the final SOFM.
Furthermore, the smallest principal component of the input
image is employed to initialize the rest k2 neurons of the final
SOFM (k1 + k2 = N). A SOFM with an output layer of k2 neurons is
applied to pixels of the input image defined by the smallest
principal component. This sorting of the input image pixels is
carried out by means of thresholding the projection of the input
image pixels onto the smallest principal component. The weights
of the k2 neurons, after applying the SOFM, are the intended

initialization of the rest k2 neurons of the final SOFM. This kind of


initialization, which is based on the smallest principal component,
considers the color information of pixels with the least
contribution to the color content of the input image. Although
contrary in principle to the initialization method of the k1 neurons
of the final SOFM based on the two largest principal components,
the two methods in conjunction can usually lead to more equalsized classes and better quality convergence compared to
initializing all neurons by means of the first method.
The main steps for using the proposed method to perform
color quantization to N colors are:
Step 1: A Principal Component Analysis (PCA) method is
performed. A single-layer feedforward neural network is used
(figure 1 - right), which is trained using the Generalized Hebbian
Algorithm (GHA) [21], [9], [7]. This is an unsupervised learning
algorithm based on the Hebbian learning rule which states that if
two neurons on either side of a synapse are activated
simultaneously, the strength of that synapse is selectively
increased, otherwise it is weakened or eliminated. Let t be a
variable which increases on every new input vector (a new pixel
value xk = [rk, gk, bk]T from the input image 3-feature vectors X), w
the matrix of PCA coefficients, y = [y0, y1, y2]T the neural
networks output computed by the relation y = wX, Wi = [Wi0, Wi1,
Wi2]T, 0 i 2 the neuron weights vectors, n a small enough
learning rate parameter. The first principal component is extracted
from the first neurons weight vector as follows:
W0 (t + 1) = W0 (t ) + ny0 ( xk y0W0 (t )) ,

(4)
y0 = W0T (t ) xk , xk X
The second principal component can be extracted from the
second neurons weight vector using the vectors X orthogonal to
the first principal component:
(5)
X = X y0W0
W1 (t + 1) = W1 (t ) + ny1 ( xk y1W1 (t )) ,

y1 = W1T (t ) xk xk X
(6)
In general, all principal components can be extracted from
the correspondent neurons weight vector as follows:
i

Wi (t + 1) = Wi (t ) + nyi xk nyi y jW j (t ) ,
j =0

(7)
yi = WiT (t ) xk , xk X , 0 i 2
It should be noted that after training, w approximates with
probability one the matrix whose rows are the eigenvectors of the
covariance matrix. Application of a Principal Component Analyzer
that feeds a SOFM in [17], [18] and [19].
Step 2: Get the color projection X0,1 of the input image pixels onto
the plane spanned by the two largest principal components:
(8)
X0,1 = y0W0 + y1W1 , yi = WiT (t ) xk , 0 i 1
Get the color projection X2 of the input image pixels onto the
smallest principal component:
X 2 = y2W2 , y2 = W2T (t ) xk
(9)

Step 3: Perform thresholding to the color projection X2 of the input


image pixels onto the smallest principal component, using a SOFM
with a single neuron at the output layer.
Step 4: Choose the input image pixels p(x,y) based on the
following criterion: the correspondent pixel p2(x,y) on color
projection X2 has one of its R, G, B values greater than the
respective R, G, B value of the threshold found on step 3.
Step 5: Define values k1 and k2 (2 k2 N/2). Let be the ratio of

the number of pixels of the color projection X2, which have one of
their R, G, B values greater than a small threshold T, to the
total number of pixels (after experimentation, T value is set to T =
15). Because of the nature of PCA value will be small, let be a
coefficient on (after experimentation, = 10).

Figure 2. Depiction of the proposed initialization method

k2 = max(2, min(( / 2), / 2))


(10)
k1 = - k2
(11)
The procedure described uses as indication the color
information quantity contained in the smallest principal component
and does not always lead to optimal solution for k1 and k2 values.
Step 6: Perform color quantization on the color projection X0,1,
using a SOFM with k1 neurons at the output layer.
Step 7: Perform color quantization only on pixels of the input
image defined on step 4, using a SOFM with k2 neurons in the
output layer.
Step 8: Initialize the finals SOFM neuron weights using the k1
and k2 neuron weights from step 7 and step 8. Perform color

quantization on the input image to N colors. If the final SOFMs


neighborhood radius is fixed to 0 then the classes will not
influence each other, taking full advantage of the initialization
process.
4. EXPERIMENTAL RESULTS
In order to test the performance of the proposed initialization and
compare it to other color quantization methods, the following nine
images from Ohio State University Signal Analysis and Machine
Perception Laboratory webpage (http://sampl.eng.ohio-state.edu)
were used: frymire, girl, peppers, lena, mandrill,
home3, monarch, sails and tulips. As a measure of quality
of the quantization MSE and PSNR were employed.
The methods compared to the proposed SOFM initialization,
denoted as PCA-INIT SOFM, are: SOFM [12], [13] as described in
section 2, ACR [18], SGONG [2], GNG [8] and FCM [3]. To
define an epoch, 20 different sets of 3000 samples are collected
from the input image with a maximum of 1000 epochs. The
applied settings for the algorithms, used for the comparison, are as
follows:
SOFM: An one dimensional grid topology is used for the
output layer, 1(ep) = 2(ep) and both learning rates are linearly
decreased from 0.02 to 0.0005 reaching their minimum value after
150 epochs from the beginning of the training procedure. The
radius of the neighbourhood domain of the winner neuron is
initially equal to 67% of the total number of output neurons and it
linearly decreases to zero within 150 epochs. The training
procedure has 1000 epochs.
ACR: The SOFM settings for ACR are the same with SOFM
in the previous paragraph. For the splitting and merging
conditions: minimum number of pixels in each class is set to
greater than 100 and minimum number of samples in each node of
the tree is set to greater than 20. No other conditions for splitting
(e.g. variance based) or merging of the classes are set.
SGONG, GNG and FCM parameters are set as in [2].
PCA-INIT SOFM: After performing PCA, the parameters
used for SOFM are set as described in previous SOFM paragraph.
An exception is made to the maximum number of epochs which is
limited to 300 and the neighbourhood radius of the finals SOFM
which is fixed to 0.
As seen in Table 1, which presents error results for color
quantization to 16 colors at the first execution of the algorithm, in
most cases, the proposed method produces better results than
SOFM and other quantization methods. A comparison with SOFM
initialization based solely on the two largest principal components
(k1 = 16) is also presented. The results obtained at subsequent
executions of the algorithm, which can be better (e.g. for
frymire), preserve the general tendency shown in Table 1. The
method can be used for color quantization to a different number of
colors and achieve analogue quality error results.

5. CONCLUSIONS
A new method based on PCA is proposed for initializing SOFM
for use in color quantization. It employs the two largest principal
components, in order to achieve an initialization of a number of
neurons based on the color distribution of the input image and uses
the smallest principal component, in order to consider the color
information of pixels with little contribution to the color content of
the input image. In most cases the proposed method is able to
produce better quality results than SOFM and other top
performance quantization methods.

Frymire
Girl
Lena
Mandrill
Monarch
Peppers
Sail
Tulips
Home3

MSE
PSNR
MSE
PSNR
MSE
PSNR
MSE
PSNR
MSE
PSNR
MSE
PSNR
MSE
PSNR
MSE
PSNR
MSE
PSNR

Table 1. Comparative quantization error results after quantizing the initial images to 16 colors
PCA-INIT
PCA-INIT
SOFM
ACR
SGONG
GNG
SOFM
SOFM, k1=16
1432.572
1369.047
1427.828
1396.897
1449.214
1427.742
49.139
49.593
49.172
49.391
49.024
49.173
67.534
71.719
73.567
81.858
69.148
107.079
79.195
78.594
78.339
77.271
78.959
74.586
208.903
212.657
215.806
216.066
209.772
215.683
65.598
65.420
65.273
65.260
65.557
65.279
627.453
629.316
633.958
629.804
628.259
651.224
56.904
56.875
56.801
56.867
56.892
56.533
261.771
254.912
259.082
261.738
258.467
269.133
64.569
64.835
64.673
64,570
64.697
64.292
370.211
372.624
379.565
374.679
377.123
392.961
62.618
62.553
62.369
62.498
62.433
62.022
279.573
282.129
282.726
281.238
280.551
300.569
64.204
64.113
64.092
64.145
64.169
63.480
445.060
559.681
559.485
474.775
445.848
467.762
60.128
57.877
57.880
59.522
60.151
59.671
171.870
175.067
175.094
175.509
179.223
178.552
67.423
67.239
67.237
67.213
67.004
67.042

6. REFERENCES
[1] Ashdown, I., Octree color quantization, Radiocity - A
Programmers Perspective, Wiley, New York, 1994.
[2] Atsalakis, A. and Papamarkos, N., Color reduction and
estimation of the number of dominant colors by using a selfgrowing and self-organized neural gas, Engineering Applications
of Artificial Intelligence, 19(7), pp. 769-786, 2006.
[3] Bezdek, J.C., Pattern Recognition with Fuzzy Objective
Function Algorithms, Plenum Press, New York, 1981.
[4] Carpenter, G., Grossberg, S. and Rosen, D.B. Fuzzy ART: fast
stable learning and categorization of analog patterns by an
adaptive resonance system, Neural Networks, vol. 4, pp. 759771,
1991.
[5] Chang, C.-H., Xu, P.F., Xiao, R. and Srikanthan, T., New
adaptive color quantization method based on self-organizing
maps, IEEE Transactions on Neural Networks vol. 16, no. 1, pp.
237249, 2005.
[6] Dekker, A.H., Kohonen neural networks for optimal color
quantization, Network: Computation in Neural Systems vol. 5, pp.
351367, 1994.
[7] Diamantaras K.I. and Kung S.Y., Principal Component Neural
Networks, Wiley, New York, 1996.
[8] Fritzke, B., Growing cell structures - a self-organizing
network for unsupervised and supervised learning, Neural
Networks, vol. 7 no. 9, pp. 14411460, 1994.
[9] Haykin S., Neural Networks: A Comprehensive Foundation,
MacMillan, New York, 1994.
[10] Heckbert, P., Color image quantization for frame buffer
display, Computer & Graphics vol. 16, pp. 297307, 1982.
[11] Huang, H.Y., Chen, Y.S. and Hsu, W.H., Color image
segmentation using a self-organized map algorithm, Journal of
Electronic Imaging vol. 11, no. 2, pp. 136 -148, 2002.
[12] Kohonen, T., The self-organizing map, Proceedings of
IEEE vol. 78, no. 9, pp. 14641480, 1990.
[13] Kohonen, T., Self-Organizing Maps, Springer, Berlin, 1997.
[14] Kohonen, T., Self-organized maps of sensory events, Royal
Soc. of London Trans. Ser. A, vol. 361, (1807), 1177-1186, 2003.

FCM
1331.241
49.873
86.997
76.663
211.998
65.452
633.788
56.804
255.983
64.793
372.182
62.565
281.690
64.128
460.935
59.818
176.510
67.157

[15] Lim, Y., and Lee S., On the color image segmentation
algorithm based on the thresholding and the fuzzy C-means
techniques Pattern Recognition, vol. 23, (9), pp. 935-952, 1990.
[16] Papamarkos, N., Color reduction using local features and a
KSOFM neural network, International Journal of Imaging
Systems and Technology, vol. 10, pp. 404409, 1999.
[17] Papamarkos, N. and Atsalakis, A., Gray-level reduction
using local spatial features Computer Vision and Image
Understanding vol. 78, pp. 336350, 2000.
[18] Papamarkos, N., Atsalakis, A. and Strouthopoulos, C.,
Adaptive color reduction, IEEE Trans. on Systems, Man and
Cybernetics Part B: Cybernetics vol 32, no. 1, pp. 44-56, 2002.
[19] Papamarkos, N., Strouthopoulos, C., and Andreadis, I.,
Multithresholding of color and gray-level images through a neural
network technique, Image and Vision Computing, vol. 18, pp.
213-222, 2000.
[20] Pei, S.-C., Lo, Y.-S., Color image compression and limited
display using self-organization Kohonen map, IEEE Trans.
Circuits Syst. Video Technol. vol. 8, no. 2, pp. 191205, 1998.
[21] Sanger T.D., An Optimality Principle for Unsupervised
Learning, Advances in Neural Information Processing Systems,
Morgan Kaufmann Publishing Inc, San Francisco, CA, 1989.
[22] Wan, S.J., Prusinkiewicz, P., Wong, S.K.M., Variance based
color image quantization for frame buffer display, Color
Research and Application vol. 15, no. 1, pp. 5258, 1990.
[23] Wang C.-H., Lee, C.-N. and Hsieh, C.-H., Sample-size
adaptive self-organization map for color images quantization,
Pattern Recognition Letters Vol. 28, pp. 16161629, 2007.
[24] Wu, X., Color quantization by dynamic programming and
principal analysis, ACM Transactions on Graphics, vol. 11, no. 4,
pp. 384392, 1992.
[25] Xiao, R., Chang C.-H., Srikanthan, T., On the Initialization
and Training Methods for Kohonen Self-Organizing Feature Maps
in Color Image Quantization, Proc. Ist Int. Workshop on
Electronic Design, Test and Applications, Christchurch, New
Zealand, pp. 321-325, 2002.

Вам также может понравиться