220 likes | 304 Views
got c o l o r s ?. Color Quantization Techniques Joo Hyun Song. Outline. Overview Implementation Results and Discussion Concluding Remarks. Overview. What is color quantization? “Color quantization is applied when the color information of an image is to be reduced.“ 1
E N D
got colors? Color Quantization Techniques Joo Hyun Song
Outline • Overview • Implementation • Results and Discussion • Concluding Remarks
Overview • What is color quantization? • “Color quantization is applied when the color information of an image is to be reduced.“1 • “The most common case is when a 24-bit color image is transformed into an 8-bit color image.” 1 • Used when high-depth color is not supported or necessary. 1http://www.dai.ed.ac.uk/HIPR2/quantize.htm
Overview (cont’d) • Main issues concerning color quantization • What are the criteria for colors that are retained in the resulting image?(How are the ‘important’ colors selected?) • How ‘accurate’ is the resulting image?(How well are the important features of the image preserved in the resulting image?) • How fast is the quantization process?
Implementation • Diversity Algorithm 2 • Color quantization algorithm devised by John Bradley, the creator of the popular UNIX-based imaging software xv. • The algorithm starts by picking the most populous color (the overall color) of the original image. • Then the most ‘distant’ colors from the colors in the new color table are picked until the new color table is filled. • Results in the most ‘diverse’ selection of colors surrounding the overall color. 2 http://www.trilon.com/xv/manual/xv-3.10a/diversity-algorithm.html
Implementation (cont’d) • Modified Diversity Algorithm 2 • Improvement over the original Diversity Algorithm suggested by Tom Lane of the Independent JPEG Group. • The modification aims to better balance the allocation between diverse colors and populous colors. • The alternation strategy is subjective – some strategy works better in certain images while not as good in other. • Examples in this presentation use the 10-div-pop/div rule.
Implementation (cont’d) • ImageMagickTM 3 libraries and tools • Provides readily available libraries and tools for reading, manipulating and writing most of the popular image formats. • Programming Language of choice: C++ • C++ has std::vector and std::map datatypes that made the histogram and colorMap implementation simpler. • C++ has a built-in optimized sort() function that can be used for sorting elements in std::vector datatypes. • Not Java. ;-) 3http://www.imagemagick.org/
Results • Tested Algorithms • Diversity Algorithm • Modified Diversity Algorithm • Tested Color Spaces • RGB • YUV • YIQ • XYZ • U*V*W* (not really)
Original Diversity vs. Modified Diversity Original Diversity Algorithm (RGB) Modified Diversity Algorithm (RGB)
Original Diversity vs. Modified Diversity (cont’d) Original Diversity Algorithm (RGB) Modified Diversity Algorithm (RGB)
Original Diversity vs. Modified Diversity (cont’d) Original Diversity Algorithm (RGB) Modified Diversity Algorithm (RGB)
Color Space Comparisons Original RGB YUV XYZ
Color Space Comparisons Original RGB YUV XYZ
Color Space Comparisons Original RGB YUV XYZ
Weird… U*V*W* (supposedly)
My U*V*W* Implementation double DecodeUVW(const unsigned int color, const char opt) { double X = DecodeXYZ(color, 'x'); double Y = DecodeXYZ(color, 'y'); double Z = DecodeXYZ(color, 'z'); double x = X/(X+Y+Z); double y = Y/(X+Y+Z); double u = 4*x/(-2*x+12*y+3); double v = 6*y/(-2*x+12*y+3); double W = 25*pow(100*Y, 1/3)-17; // Get reference white X = DecodeXYZ(0xFFFFFF, 'x'); Y = DecodeXYZ(0xFFFFFF, 'y'); Z = DecodeXYZ(0xFFFFFF, 'z'); x = X/(X+Y+Z); y = Y/(X+Y+Z); double u0 = 4*x/(-2*x+12*y+3); double v0 = 6*y/(-2*x+12*y+3); if(opt == 'u') { return 13*W*(u-u0); } if(opt == 'v') { return 13*W*(v-v0); } if(opt == 'w') { return W; } }
Future Interest • Investigate more advanced color spaces (such as L*u*v* or IHS). • Investigate other color metrics (e.g. Riemannian color space). • Investigate more advanced color quantization algorithms (such as the Neural Networks color quantization algorithm).
ImageMagick’s built-in quantizeColors() algorithm Performance of other programs
Gimp Performance of other programs (cont’d)
What I Have Learned • Start EARLY • Subjectivity of image quality. • Different Color Spaces. • Don’t use ImageMagick