22
1 got colors? Color Quantization Techniques Joo Hyun Song

1 got colors? Color Quantization Techniques Joo Hyun Song

Embed Size (px)

Citation preview

Page 1: 1 got colors? Color Quantization Techniques Joo Hyun Song

1

got colors?

Color Quantization Techniques

Joo Hyun Song

Page 2: 1 got colors? Color Quantization Techniques Joo Hyun Song

2

Outline

• Overview

• Implementation

• Results and Discussion

• Concluding Remarks

Page 3: 1 got colors? Color Quantization Techniques Joo Hyun Song

3

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.

1 http://www.dai.ed.ac.uk/HIPR2/quantize.htm

Page 4: 1 got colors? Color Quantization Techniques Joo Hyun Song

4

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?

Page 5: 1 got colors? Color Quantization Techniques Joo Hyun Song

5

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

Page 6: 1 got colors? Color Quantization Techniques Joo Hyun Song

6

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.

Page 7: 1 got colors? Color Quantization Techniques Joo Hyun Song

7

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. ;-)

3 http://www.imagemagick.org/

Page 8: 1 got colors? Color Quantization Techniques Joo Hyun Song

8

Test Images

Page 9: 1 got colors? Color Quantization Techniques Joo Hyun Song

9

Results

• Tested Algorithms– Diversity Algorithm– Modified Diversity Algorithm

• Tested Color Spaces– RGB– YUV– YIQ– XYZ– U*V*W* (not really)

Page 10: 1 got colors? Color Quantization Techniques Joo Hyun Song

10

Original Diversity vs. Modified Diversity

Original Diversity Algorithm (RGB) Modified Diversity Algorithm (RGB)

Page 11: 1 got colors? Color Quantization Techniques Joo Hyun Song

11

Original Diversity vs. Modified Diversity (cont’d)

Original Diversity Algorithm (RGB) Modified Diversity Algorithm (RGB)

Page 12: 1 got colors? Color Quantization Techniques Joo Hyun Song

12

Original Diversity vs. Modified Diversity (cont’d)

Original Diversity Algorithm (RGB) Modified Diversity Algorithm (RGB)

Page 13: 1 got colors? Color Quantization Techniques Joo Hyun Song

13

Color Space ComparisonsOriginal RGB

YUV XYZ

Page 14: 1 got colors? Color Quantization Techniques Joo Hyun Song

14

Color Space ComparisonsOriginal RGB

YUV XYZ

Page 15: 1 got colors? Color Quantization Techniques Joo Hyun Song

15

Color Space ComparisonsOriginal RGB

YUV XYZ

Page 16: 1 got colors? Color Quantization Techniques Joo Hyun Song

16

Weird…U*V*W* (supposedly)

Page 17: 1 got colors? Color Quantization Techniques Joo Hyun Song

17

My U*V*W* Implementationdouble 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; }}

Page 18: 1 got colors? Color Quantization Techniques Joo Hyun Song

18

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).

Page 19: 1 got colors? Color Quantization Techniques Joo Hyun Song

19

Performance of other programs• ImageMagick’s built-in quantizeColors() algorithm

Page 20: 1 got colors? Color Quantization Techniques Joo Hyun Song

20

Performance of other programs (cont’d)

• Gimp

Page 21: 1 got colors? Color Quantization Techniques Joo Hyun Song

21

What I Have Learned

1. Start EARLY

2. Subjectivity of image quality.

3. Different Color Spaces.

4. Don’t use ImageMagick

Page 22: 1 got colors? Color Quantization Techniques Joo Hyun Song

22

Any Questions?