
Images and Colour SSC1. V. Sorge 2009 67 Images and colour Colour - colours - colour spaces - colour models Raster data - image representations - single and multi-band (multi-channel) Images - colour lookup tables - operations on images SSC1. V. Sorge 2009 68 SSC1. V. Sorge 2009 Colour images Colour images have two components: Colour images have two components: raster data - an array of pixels; colour model - a description of how pixels are mapped to colours. A pixel is defined in terms of its components in a A pixel is defined in terms of its components in a particular colour space particular colour space SSC1. V. Sorge 2009 69 SSC1. V. Sorge 2009 Java image representation: BufferedImage Java image representation: BufferedImage Raster ColorModel SampleModel ColorSpace DataBuffer SSC1. V. Sorge 2009 70 SSC1. V. Sorge 2009 Colour spectrum visible light Ultraviolet Infrared 400 nm 700 nm SSC1. V. Sorge 2009 71 Colour spaces A colour space represents a system for A colour space represents a system for measuring colours measuring colours Most colours can be represented using three Most colours can be represented using three colour components colour components They are called the primary colours (or the They are called the primaries) primaries) SSC1. V. Sorge 2009 72 SSC1. V. Sorge 2009 Colour spaces There are many colour spaces. There are many colour spaces. The choice of a particular space depends on the The choice of a particular space depends on the context in which we want to describe colours. context in which we want to describe colours. The four most common colour spaces are: The four most common colour spaces are: RGB: additive colour space HSV: artistic colour space CMY: subtractive colour space XYZ: based on human colour perception Others include: YIQ, YUV, YdbDr, YcbCr, xvYCC Others include: YIQ, YUV, YdbDr, YcbCr, xvYCC SSC1. V. Sorge 2009 73 SSC1. V. Sorge 2009 RGB Primaries: Red - Green - Blue Primaries: Red - Green - Blue Similar to colours detected by colour receptors in Similar to colours detected by colour receptors in the eye the eye Also used in TV technology Also used in TV technology Blue Cyan M agent a W hit e Black Green Red Yellow SSC1. V. Sorge 2009 74 SSC1. V. Sorge 2009 RGB SSC1. V. Sorge 2009 75 SSC1. V. Sorge 2009 RGB an additive system SSC1. V. Sorge 2009 76 SSC1. V. Sorge 2009 HSV Primaries: Hue - Saturation - Value Primaries: Hue - Saturation - Value Colour space related to subjective description of Colour space related to subjective description of colours colours Green Yellow Cyan White Red Blu e M agenta Black SSC1. V. Sorge 2009 77 SSC1. V. Sorge 2009 HSV SSC1. V. Sorge 2009 78 SSC1. V. Sorge 2009 CMY Primaries: Cyan - Magenta Yellow Primaries: Used in printing technology Used in printing technology Mixing is subtractive Mixing is subtractive SSC1. V. Sorge 2009 79 SSC1. V. Sorge 2009 CMY subtractive system SSC1. V. Sorge 2009 80 CIE XYZ Primaries: X, Y, Z Primaries: X, Y, Z Based on colour perception by humans Based on colour perception by humans Device independent Device independent The most common representation of the CIE XYZ The most common representation of the CIE XYZ space is the CIE chromacity diagram space is the CIE chromacity diagram SSC1. V. Sorge 2009 81 SSC1. V. Sorge 2009 CIE XYZ Chromacity diagram CIE XYZ Chromacity diagram SSC1. V. Sorge 2009 82 SSC1. V. Sorge 2009 Monochrome images Images represented by a single primary - a value Images represented by a single primary - a value Show only shades of grey Show only shades of grey Binary images use only two shades of grey: black Binary images use only two shades of grey: black and white. and white. SSC1. V. Sorge 2009 83 SSC1. V. Sorge 2009 Vector notation for colours [ Primary1 Primary2 Primary 3 ] [ Primary1 Primary2 Primary 3 ] [ R G B ] yellow = [ 1 1 0 ] [ R G B ] orange = [ 1 0.5 0 ] pink = [ 1 0.7 0.7] [ H S V ] pink = [ 0 0.3 1 ] [ H S V ] [ C M Y ] red = [ 0 1 1 ] [ C M Y ] SSC1. V. Sorge 2009 84 SSC1. V. Sorge 2009 Colour space conversion Colours can be converted from one space to Colours can be converted from one space to another another Conversion from RGB to CMY: Conversion from RGB to CMY: [ C M Y ] = [ 1 1 1 ] - [ R G B ] [ C M Y ] = [ 1 1 1 ] - [ R G B ] Example: Convert green from RGB to CMY Example: Convert green from RGB to CMY [ C M Y ] = [ 1 1 1 ] - [ 0 1 0 ] = [ 1 0 1 ] [ C M Y ] = [ 1 1 1 ] - [ 0 1 0 ] = [ 1 0 1 ] SSC1. V. Sorge 2009 85 SSC1. V. Sorge 2009 Conversion from RGB to XYZ Each of the R, G and B primaries is a weighted Each of the R, G and B primaries is a weighted sum of X, Y and Z primaries sum of X, Y and Z primaries Weights expressed in matrix notation, e.g. Weights expressed in matrix notation, e.g. 0.41 0.21 0.02 0.36 0.71 0.12 0.18 0.07 0.95 SSC1. V. Sorge 2009 86 SSC1. V. Sorge 2009 Conversion from RGB to XYZ Conversion implemented as a matrix Conversion implemented as a matrix multiplication multiplication 0.584 0.311 0.047 [ X Y Z ] = [ R G B ] · 0.188 0.614 0.103 0.179 0.075 0.939 SSC1. V. Sorge 2009 87 SSC1. V. Sorge 2009 Colour Spaces in Java Colour Spaces and Colours are implemented in the Colour Spaces and Colours are implemented in the java.awt.color.* package java.awt.color.* Abstract class ColorSpaces provides as constants Abstract class a number of standard colour spaces: CS_CIEXYZ, CS_sRGB some specific colour space types: TYPE_HSV, TYPE_RGB, TYPE_CMY, TYPE_XYZ some generic colour space types wrt. different number of components One can obtain an instance of a colour space One can obtain an instance of a colour space using the getInstance(int colorspace) method. using the For example: For example: ColorSpace.getInstance(ColorSpace.CS_sRGB); ColorSpace.getInstance(ColorSpace.CS_sRGB); returns a standard RGB colour space. returns a standard RGB colour space. SSC1. V. Sorge 2009 88 SSC1. V. Sorge 2009 Colour Space Conversion in Java Colour Space Conversion in Java It is often necessary to convert between colour It is often necessary to convert between colour spaces of different images. The ColorSpace class spaces of different images. The provides some simple methods to do this: provides some simple methods to do this: toRGB(float[ ] colorvalue) : Transform colour value from the space to standard RGB fromRGB(float[ ] rgbvalue) : Transform colour value from RGB to the this space toCIEXYZ(float[ ] colorvalue) : Transform colour value from the space to CIEXYZ fromCIEXYZ(float[ ] colorvalue) : Transform colour value from CIEXYZ to this space Conversion between two colour spaces therefore Conversion between two colour spaces therefore is done via intermediate conversion is done via intermediate conversion SSC1. V. Sorge 2009 89 SSC1. V. Sorge 2009 Colours in Java Colours (e.g., for the Paint component) can be Colours (e.g., for the Paint component) can be defined wrt. any colour space with constructor: defined wrt. any colour space with constructor: Color(ColorSpace cspace, float[] components, float alpha) More easily the can be defined via RGB values More easily the can be defined via RGB values Color(float r, float g, float b) Java also provides some default colours in the Java also provides some default colours in the RGB model: RGB model: Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW, Color.BLACK, Color.WHITE, Color.CYAN, etc. SSC1. V. Sorge 2009 90 SSC1. V. Sorge 2009 Raster data Colour Colour - colours - colour spaces - colour models Raster data Raster data - image representations - single and multi-band (multi-channel) Images Images - colour lookup tables - operations on images SSC1. V. Sorge 2009 91 SSC1. V. Sorge 2009 Raster data - pixel structure Raster data - an image Raster data - an image Pixels arranged as a rectangular array Pixels arranged as a rectangular array The structure of a pixel depends on The structure of a pixel depends on the colour space: how colours are computed the colour model: how colours are represented SSC1. V. Sorge 2009 92 SSC1. V. Sorge 2009 Raster data - pixel structure Raster array Pixel structure SSC1. V. Sorge 2009 93 SSC1. V. Sorge 2009 Raster data - pixel structure Binary images Binary images pixel represented by a single bit Monochrome images Monochrome images pixel represented by a single byte (a one-dimensional vector) Colour images Colour images usually represented by a 3-dimensional vector examples [ R G B], [H S V] or [C M Y] SSC1. V. Sorge 2009 94 SSC1. V. Sorge 2009 Representations: Java terminology Representations: Java terminology Normal representation Normal representation the amount of each primary defined by a number in the range [0,1] Example: pink (RGB): [1.0 0.5 0.5] Logical representation Logical representation Pixel representation as a vector Physical representation Physical representation depicted by the Colour Model SSC1. V. Sorge 2009 95 SSC1. V. Sorge 2009 Colour channel Colour channel - a component of a colour vector Colour channel RGB: red channel, green channel and blue RGB: red channel, green channel and blue channel channel A pixel vector can have more than three channels A pixel vector can have more than three channels Examples Examples alpha channel (often used to describe transparency of a pixel) z channel (in 3D graphics, the depth of the pixel, used in hidden surface removal) SSC1. V. Sorge 2009 96 SSC1. V. Sorge 2009 Colour models A colour model describes how pixels are A colour model describes how pixels are mapped into colours.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages59 Page
-
File Size-