Sie sind auf Seite 1von 5

Annual Conference on New Trends in Information & Communications Technology Applications-(NTICT'2017)

7 - 9 March 2017

An Efficient Color Quantization Using Color


Histogram

Sarmad Omar Abter Assist. Prof. Dr. Nada A.Z. Abdullah


Dept. of Computer Science\ College of Science Dept. of Computer Science\ College of Science
University of Baghdad University of Baghdad
Baghdad, Iraq Baghdad, Iraq
Sarmadomar88@scbaghdad.edu.iq nadaazah@scbaghdad.edu.iq

Abstract—The color reduction or color quantization is palette for the quantized image without considering any
needed for many reasons such as, to compress the high-
resolution images which take a lot of the disk space and to specific image contents, while "image dependent"
easily view the images on the screens that do not support a methods generate palettes for the quantized image based
large number of color ranges (low-resolution Screens).
Color quantization generates a new image, which has less on the color distribution within the original image. The
number of colors, but the difference between the
Quantized Image and the original image is small. In this image independent method is fast but produces usually
work, a quantization algorithm is proposed that based on poor quantization results because it does not consider
the color histogram for true color images. Also, the images
can be quantized to a different number of colors. The the contents of the image. To maintain the quality of
algorithm is applied to many images of (CorelDB) dataset,
the results show that the algorithm is high speed due to the image representation, most of the current works on
low computational cost and, the quality of quantized "color quantization" fall on "image dependent" methods.
images is very good.
Index Terms— color reduction, histogram analysis, [2]
Image quantization
For the image, dependent methods, there are two
I. INTRODUCTION
different strategies to construct "color palette": "pre-
A true-color image consists of a pixel matrix
clustering" and "post-clustering". The "pre-clustering"
that each pixel consists of triple color component (red,
green, blue), each one of the triple components of the strategy partitions the original image colors into
pixel represents the brightness of the color that is multiple subspaces based on the statistics of color
represented. Each component of the pixel value is of distribution. The "post-clustering" strategy begins color
range [0...255] then each color component has a 224 quantization with an initial palette and improves it
variation of colors. Since the computer screen is not iteratively. From the above," the challenge to color
capable of displaying many colors at the same time, the image quantization is to balance the quantization quality
reduction of the images colors become one of the
and computational complexity". [3]
interesting subjects to be studied on the color image
display, transmission of the images through networks, In general, there are three main types for "color
compression the size of the image. The color quantization"; the first type is the "vector quantization".
quantization means gathering the similar colors in a It can be applied to quantize each pixel's color in three-
group and then replacing these colors in the group with dimensional vector consisting of the three-color
one of the group colors. Any color quantization components as (red, green and blue).
algorithm consists of two main steps, the first step is the The second type is the color clustering method for
build or forming the "color palette" of the image, the finding the "color palette" of the image. The typical
second step is the operation of building the mapping method of the clustering type is the "Neural Network"
table which is used to generate the quantized image [1]. for "Optimal Color Quantization"[4].
There are two kinds of color palette creating methods: The third type of "color quantization" is the type in which the
color space is divided into smaller sub-areas and then the best
"image independent" methods and "image dependent" color will be chosen in each sub-area to construct the "color
methods. "Image independent" method generates a palette" of the image [5].

978-1-5386-2962-8/17/$31.00 ©2017 IEEE 13


Annual Conference on New Trends in Information & Communications Technology Applications-(NTICT'2017)
7 - 9 March 2017
II. RELATED WORK pixels of the next region is calculated as in the following
A lot of algorithms are proposed to construct a color equations:
map with a specific number of colors that are selected at newNP=NP-NPR ……..…..………..(2)
the beginning of the algorithm. One of the earliest newNR=NR-1 ………………….(3)
methods to reduce the "color palette" is the population newNPR=newNP/newNR..………...(4)
method, which is developed by Boyle and Lippmann in
Where
1978, another quantization method which implemented
later is the "median-cut algorithm" which groups the NPR= number of pixels in previous region
colors of the image into sets by dividing each group at NP =number of pixels of the image
the median point of the set [1]. Another famous method newNP =number of pixels of unprocessed colors
is the "octree quantization algorithm" [6]. Other NR =number of regions
quantization techniques are based on the analysis of newNR =number of remaining regions
histogram [4, 7, 8], soft computing [9-10]. Methods that newNPR= number of pixels in next region
produce images with high-quality quantization construct
From each region one color is selected which has
the set of representative colors according to the color
distribution of the original image, where the chosen maximum occurrence in the region, the output after
quantization regions are selected according to a given processing all regions is a vector of the maximum
criterion. These methods are " image dependent" [9-15]. occurrence colors in the image. This vector is used to
because that each true-color image generally has a large complete the quantization by preparing a mapping table.
number of colors, which makes the quantization method Each color in the original image is substituted by
is too complex and hard to implement, most of the nearest color in the maximum occurrence colors.
"color quantization" methods has a preprocessing step to
The Euclidian Distance(ED) is used to compute the
minimize the data that will be processed by the
quantization algorithm [9, 16]. similarity between two colors. The following is the ED
equation:
III. THE PROPOSED COLOR QUANTIZATION ALGORITHM
The proposed algorithm in this work depends
on the image histogram, since the histogram can show … (5)
the colors that are occurred most frequently, and these
colors can be used to perform quantization. The method Algorithm (1): Histogram Calculation
which is used in the implementation is divided into two
Input: colored image with the colored objects // BMP image file
stages of processing the first step is to calculate the
color palette of the original image using color histogram Output: histogram table// table of colors occurrence in the image
as demonstrated in the algorithm (1), the histogram
Begin
calculation takes the value of (R, G, B) in the image and Step1: Load the image from the file
compute its occurrence in the image. Imageload(imagepath)
Step2: scan all the pixels of the images and store the colors of the
The second stage of the quantization process is to take pixel in the Table
the color histogram of the original image that is For all rows from 0 to width of the image do
calculated in the first stage, and divided the histogram For all columns from 0 to height of the image do
Get the pixel color in the row and column location
into a number of regions based on the number of colors If pixelcolor is in the Table then
needed in the quantized image; the division is decided Add 1 to the value of that color
Else
by the following equation: Add the color to the Table and set it to 1
End For
End For
NPR=NP/NR ……….(1) End
Where
NPR= number of pixels in region
Algorithm (2): Proposed Color Quantization
NP =number of pixels of the image
NR =number of regions Objectives: Reduce the Colors in the Image
Then the colors on the regions are spread by sum the
Input: bmp //color image
occurrence value of each color until the pixel count of the
region is occupied, at the end of each region the number of Region_no //number of colors we want to minimize the
original number of colors of the image to it.

14
Annual Conference on New Trends in Information & Communications Technology Applications-(NTICT'2017)
7 - 9 March 2017
Output: Quantized image. classes in the dataset and as shown in the figures that
the images have good quality after applying the
Begin quantization and keeps most of it is details after the
Step1: Calculate the Histogram for the colors of the image using quantization is applied.
algorithm (1).
Step2: Find the number of pixels in each region.
Set Sum_allmnumber of pixels of the image.
Set no_of_pixelsmSum_all / Region_no // determine the number
of pixels in each region
Set ci m 0 // Histogram Color Index.
Set sum1= Sum_all
Step3: Determine the colors in each region and find the max color of
each region.
For I from 0 to Region_no do
Begin
Set counter m 0 // number of colors in each region.
Set sum m0 // sum of pixels of the colors in each region.
Set max_color mcolor[ci]// set the maximum color of
the region
Set max_pixel mpixel[ci] // set the maximum pixel of
the maximum color
While sum <no_of_pixels do // sum the number of pixels
of each color in the histogram until the number of pixels of
the region is reached
Figure 1: The Results after Applied the algorithm on Image
Begin
Sum msum + Pixel_no from Class 'Car'
If max_pixel <pixel[ci] do
Set max_color m color[ci]
Set max_pixelm pixel[ci]
Ci+1 // increment the color index.
Counter +1 // increment the counter of colors in the
region.
End
Set sum1 msum1 – sum// subtract the sum of pixels of the
first region from the sum of all pixels in the image.
Set no_of_pixelsmsum1/ (Region_no-1) // determine the number of
pixels in each region.
Max_array[i] m max_color // add the maximum color in
each region to array.
No_colors[i] m counter // add the number of colors in each
region into No_colors array.
End
Step4: Find the distance of each color in the histogram and the
colors of the Max_array to find the nearest max color to it using
equation (1)

Step5: create the mapping table by adding the color and the nearest Figure 2: The Results After Applied the algorithm on Image
max color corresponding to it to the table
from Class 'Bus'
Step6: set the colors of the image according to the mapping table.
End;

IV. EXPERIMENTAL RESULTS AND D ISCUSSION


Proposed quantization algorithm was applied to a large
number of images with a different color number, taken
from the available database for color images
(CorelDB)a free image dataset that contains 10,800
images in 80 different Classes (e.g. car, castle, bus,
aviation and etc.). Color images are of size 120*80
(24bits).
We applied the algorithm to reduce the colors of the
original image from 9600 colors into (256,128,64,32,16)
colors respectively as illustrated in the figures (1), (2),
and (3) that show the results of the algorithm after
applying it on sample images from three random image

15
Annual Conference on New Trends in Information & Communications Technology Applications-(NTICT'2017)
7 - 9 March 2017
Figure 3: The Results after Applied the algorithm on Image introduced a loss color reduction algorithm which
from Class 'Flower' reduces the number of colors in any image (with any
number of colors) while maintaining the quality of the
To evaluate the performances of proposed algorithm the mean quantized image. The algorithm is based on the analysis
square quantized error was chosen which is defined by the of the color histogram. The histogram is divided into a
following equation: number of regions according to the colors in the new
MSE image. The colors with the most pixels in each region
are used to be the base colors to the new palette. Other
colors are assigned to the nearest color of the new
Where
palette. The results show that the algorithm is simple,
N represents the height of the image
speed and produce high-quality images.
M represents the width of the image
As future work the use of another color spaces such as HSV
( ) represents the pixel of the original image
which may increase the performance of the proposed method.
( ) represents the pixel of the quantized image Moreover, the use of other distance metrics may lead to better
Table (1), (2), and (3) show the mean square error between the results.
original image and the quantized image for the three images
(car, bus, flower) respectively, with a different number of VI. REFERENCES
quantized colors.
[1] Wei-dong, C. and Wei, D., 2008, December. "An
The Execution time needed to apply the quantization process
improved median-cut algorithm of color image quantization".
for each image is also calculated in seconds, the Execution
In Computer Science and Software Engineering, 2008
time shows that the processing time is so short so that the
International Conference on (Vol. 2, pp. 943-946). IEEE.
algorithm is very sped in processing images.
[2] Brun, L. and Trémeau, A., 2002. "Digital Color Imaging
Table (1): The MSE of Car image with different colors number Handbook", ser. Electrical and Applied Signal Processing.
[3] Yue, X.D., Miao, D.Q., Cao, L.B., Wu, Q. and
Number of Colors Difference Chen, Y.F., 2014. "An efficient color quantization based
256 10.53 on generic roughness measure". Pattern Recognition,
128 15.60 47(4), pp.1777-1789.
64 20.26 [4] Dekker, A.H., 1994. "Kohonen neural networks for
32 28.87 optimal color quantization". Network: Computation in Neural
16 56.15 Systems, 5(3), pp.351-367.
Average execution Time for Car Image = 0.6333 second
[5] Gervautz, M. and Purgathofer, W., 1988. "A simple
method for color quantization: Octree quantization". In New
Table (2): The MSE of Bus image with different colors number trends in computer graphics (pp. 219-231). Springer Berlin
Heidelberg.
Number of Colors Difference
[6] Gervautz, M. and Purgathofer, W., 1990, August. "A
256 11.23
simple method for color quantization: octree quantization". In
128 19.27 Graphics gems (pp. 287-293). Academic Press Professional,
64 24.78 Inc..
32 36.81 [7] Tremeau, A. and Thomas, J.B., 2007, September. "A
16 77.62 gamut preserving color image quantization". In Image
Average execution Time for Bus Image = 0.6780 second Analysis and Processing Workshops, 2007. ICIAPW 2007.
14th International Conference on (pp. 221-226). IEEE.
Table (3): The MSE of Flower Image with different colors number [8] Pujol, A. and Chen, L., 2007, December. "Color
Number of Colors Difference quantization for image processing using self-information". In
256 7.60 Information, Communications & Signal Processing, 2007 6th
128 10.18 International Conference on (pp. 1-5). IEEE.
64 15.12 [9] Kim, N. and Kehtarnavaz, N., 2005. "DWT-based scene-
32 21.67 adaptive color quantization". Real-Time Imaging, 11(5),
16 32.36 pp.443-453.
[10] Payne, A.M., Bhaskar, H. and Mihaylova, L., 2008.
Average execution Time for Flower Image= 0.6872 second "Multi-resolution learning vector quantisation based automatic
colour clustering". In Information Fusion, 2008 11th
V. CONCLUSION AND FUTURE WORK International Conference on (pp. 1-6). IEEE.
Color quantization is an important processing [11] Braquelaire, J.P. and Brun, L., 1997. "Comparison and
in many different image applications. We have optimization of methods of color image quantization". IEEE
transactions on image processing, 6(7), pp.1048-1052.

16
Annual Conference on New Trends in Information & Communications Technology Applications-(NTICT'2017)
7 - 9 March 2017
[12] Chen, T.W., Chen, Y.L. and Chien, S.Y., 2008, October.
"Fast image segmentation based on K-Means clustering with
histograms in HSV color space". In Multimedia Signal
Processing, 2008 IEEE 10th Workshop on (pp. 322-325).
IEEE.
[14] Özdemir, D. and Akarun, L., 2002. "A fuzzy algorithm
for color quantization of images". Pattern Recognition, 35(8),
pp.1785-1791.
[15] Atsalakis, A. and Papamarkos, N., 2006." Color reduction
and estimation of the number of dominant colors" by using a
self-growing and self-organized neural gas. Engineering
Applications of Artificial Intelligence, 19(7), pp.769-786.
[16] Bing, Z., Junyi, S. and Qinke, P., 2004. "An adjustable
algorithm for color quantization". Pattern Recognition Letters,
25(16), pp.1787-1797.

17

Das könnte Ihnen auch gefallen