Color Image Processing Color simplifies object identification and extraction from a scene. Humans can identify thousands of color shades and intensity.

Slides:



Advertisements
Similar presentations
ECE 472/572 - Digital Image Processing Lecture 10 - Color Image Processing 10/25/11.
Advertisements

Color Image Processing
Light Light is fundamental for color vision Unless there is a source of light, there is nothing to see! What do we see? We do not see objects, but the.
Aalborg University Copenhagen
School of Computing Science Simon Fraser University
SWE 423: Multimedia Systems Chapter 4: Graphics and Images (2)
© 2002 by Yu Hen Hu 1 ECE533 Digital Image Processing Color Imaging.
Images and colour Colour - colours - colour spaces - colour models Raster data - image representations - single and multi-band (multi-channel) images -
Lecture 4: The spectrum, color theory and absorption and photogrammetry Thursday, 14 January Ch 2.3 (color film)
CSC 461: Lecture 2 1 CSC461 Lecture 2: Image Formation Objectives Fundamental imaging notions Fundamental imaging notions Physical basis for image formation.
1 Perception. 2 “The consciousness or awareness of objects or other data through the medium of the senses.”
Color Models AM Radio FM Radio + TV Microwave Infrared Ultraviolet Visible.
Color Image Processing Jen-Chang Liu, Spring 2006.
COLOR MODELS Ramya Sarma Anusha Holla
Course Website: Digital Image Processing Colour Image Processing.
Digital Image Processing Colour Image Processing.
Computer Graphics & Image Processing Chapter # Color Image Processing
1 Color Processing Introduction Color models Color image processing.
Image Processing Lecture 2 - Gaurav Gupta - Shobhit Niranjan.
Digital Image Processing, 2nd ed. © 2002 R. C. Gonzalez & R. E. Woods Chapter 6 Color Image Processing Chapter 6 Color Image.
Color Image Processing A spectrum of possibilities…
Chapter 3: Colorimetry How to measure or specify color? Color dictionary?
1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng.
Digital Image Processing
Color. Contents Light and color The visible light spectrum Primary and secondary colors Color spaces –RGB, CMY, YIQ, HLS, CIE –CIE XYZ, CIE xyY and CIE.
6. COLOR IMAGE PROCESSING
University of Kurdistan Digital Image Processing (DIP) Lecturer: Kaveh Mollazade, Ph.D. Department of Biosystems Engineering, Faculty of Agriculture,
Chap 4 Color image processing. Chapter 6 Color Image Processing Chapter 6 Color Image Processing Two major areas: full color and pseudo color 6.1 Color.
September 17, 2013Computer Vision Lecture 5: Image Filtering 1ColorRGB HSI.
CSC361/ Digital Media Burg/Wong
CS6825: Color 2 Light and Color Light is electromagnetic radiation Light is electromagnetic radiation Visible light: nm. range Visible light:
Digital Image Processing Week VIII Thurdsak LEAUHATONG Color Image Processing.
Graphics Lecture 4: Slide 1 Interactive Computer Graphics Lecture 4: Colour.
A color model is a specification of a 3D color co-ordinate system and a visible subset in the co-ordinate System within all colors in a particular color.
Ch 6 Color Image processing CS446 Instructor: Nada ALZaben.
CS654: Digital Image Analysis Lecture 30: Color Model Conversion.
DIGITAL IMAGE. Basic Image Concepts An image is a spatial representation of an object An image can be thought of as a function with resulting values of.
Digital Image Processing In The Name Of God Digital Image Processing Lecture6: Color Image Processing M. Ghelich Oghli By: M. Ghelich Oghli
CS654: Digital Image Analysis Lecture 29: Color Image Processing.
Three-Receptor Model Designing a system that can individually display thousands of colors is very difficult Instead, colors can be reproduced by mixing.
Introduction to Computer Graphics
Presented By : Dr. J. Shanbezadeh
Lecture 15 Figures from Gonzalez and Woods, Digital Image Processing, Second Edition, 2002.
Pseudo / Color Image Processing Fasih ur Rehman. Color Image Processing Two major areas of Color Image Processing –Pseudo Color Image Processing Assigning.
Computer Graphics: Achromatic and Coloured Light.
1 of 32 Computer Graphics Color. 2 of 32 Basics Of Color elements of color:
Digital Image Processing Lecture 12: Color Image Processing Naveed Ejaz.
Digital Image Processing
Color Models Light property Color models.
School of Electronics & Information Engineering
Half Toning Dithering RGB CMYK Models
IMAGE PROCESSING COLOR IMAGE PROCESSING
Color Image Processing
Digital Image Processing
Color Image Processing
Digital Image Processing (DIP)
Color Image Processing
Chapter 6: Color Image Processing
Color Image Processing
Colour Theory Fundamentals
Color Representation Although we can differentiate a hundred different grey-levels, we can easily differentiate thousands of colors.
Computer Vision Lecture 4: Color
Color Image Processing
Digital Image Processing
Digital Image Processing
Digital Image Processing
Color Image Processing
Digital Image Processing Lecture 26: Color Processing
Color Model By : Mustafa Salam.
Color Models l Ultraviolet Infrared 10 Microwave 10
Presentation transcript:

Color Image Processing Color simplifies object identification and extraction from a scene. Humans can identify thousands of color shades and intensity compared to about only 25 shades of gray. In full color image processing, we acquire image using full-color sensor such a color TV camera or color scanner. In the case of pseudo color processing, we assign a color to a particular monochrome intensity or range of intensities.

Nature of Light and Color According to Newton, when a beam of sunlight passes through a glass prism, it splits up into a continuous spectrum of colors varying from violet to red. (VIBGYOR). The color perceived in an object are determined by the nature of the light reflected from the object. If the light is achromatic (without color), its only attribute is its intensity or amount. A chromatic light spans the electromagnetic spectrum from 400 to 700 nm. 3 quantities are used to describe a light source. They are: 1) Radiance – total amount of energy that flows from the light source and is measured in watts (W). 2) Luminance – measures the amount of energy an observer perceives from a light source and is measured in lumens (lm). 3) Brightness – a subjective descriptor and is impossible to measure.

Color Perception Cones in our eye are responsible for color vision. We have about 6 to 7 million cones in human eye 65% of cones are sensitive to red light, 33% are sensitive to green light and about 2% are sensitive to blue light. Due to this, the colors are seen as combinations of the primary colors red (R), green (G) and blue (B). The wavelength of blue is nm, green is 546.1nm and red is 700nm. When mixed in proper proportions, these colors can produce all visible colors.

Primary Colors Primary colors can be added to produce the secondary colors of light – magenta (red plus blue), cyan (green plus blue) and yellow (red plus green). Mixing these 3 primitives or a secondary with its opposite primary color, in right proportion gives white light.

Characteristics of a color The characteristics used to distinguish one color from another are brightness, hue and saturation. Brightness embodies the chromatic notion of intensity. Hue is related with dominant wavelength in a mixture of light waves. Hue represents dominant color perceived by an observer. Saturation refers to the relative purity or amount of white light mixed with a hue. The degree of saturation is inversely proportional to the amount of white light added.

Chromaticity Hue and saturation together are called chromaticity. The amounts of red, green and blue needed to form a color are called the tristimulus values and are denoted as X, Y and Z respectively. A color is then specified by its trichromatic coefficients as: X YZ x = ,y = z = X + Y + Z X + Y + Z X + Y + Z Here x + y + z = 1. Another way of specifying colors is to use the CIE chromaticity diagram where each color is expressed as a function of x (red) and y (green). We know, the value of z (blue) is obtained as: z = 1 – ( x + y).

Color Models Color models are used to specify colors in some standard. A color model uses a coordinate system and each color is represented by a single point. Hardware oriented models (monitors, video cameras) use RGB model. CMY (cyan, magenta, yellow) and CMYK (cyan, magenta, yellow, black) model are used for color printing. HIS (hue, intensity, saturation) model closely resembles human color interpretation. HIS decouples the color and ray-scale information in an image.

RGB Color Model Here each color appears in its primary spectral components of red, green and blue. It is based on Cartesian coordinate system. We can imagine a cube in which RGB values are at 3 corners; Cyan, magenta and yellow are at 3 other corners; Black is at the origin and white is at the corner farthest from the origin. Here gray scale extends from black to while along the line joining these 2 points. Different colors in this model are points on or inside the cube and are defined by vectors extending from the origin. Here all color values are normalized so that the cube is the unit cube.

Cube with RGB values are at 3 corners

clear all; close all; clc; vx = 10; vy = 10; vz = 4; vertices_matrix = [0 0 0; 0 0 1;0 1 0;0 1 1; 1 0 0;1 0 1;1 1 0;1 1 1]; faces_matrix = [ ; ; ; ; ; ]; colors = vertices_matrix; patch('Vertices', vertices_matrix,'Faces',faces_matrix, 'FaceVertexCData', colors,'FaceColor', 'interp','EdgeAlpha',0) axis off view([vx, vy, vz]) axis square

RGB Color Model All R, G and B values are assumed to be in the range [0,1]. The number of bits used to represent each pixel in RGB space is called the pixel depth. The term full-color image is used to denote a 24 bit RGB color image. It has 16,772,216 different colors. A color image can be acquired by using 3 filters, sensitive to red, green and blue respectively. A subset of colors can be reproduced faithfully, independent of viewer hardware capabilities. These are called safe RGB colors or all- systems-safe colors

RGB Color Model In internet applications we use safe Web Colors or safe browser colors. Generally 256 colors are used here. Of these 40 colors are processed differently by various operating systems. The remaining 216 colors which are common to most systems are defined as safe colors. Each of the 216 safe colors is formed from three RGB values, but each value can only be 0, 51, 102, 153, 204 or 255. The RGB triplets of these values give us 6 3 = 216 possible values. All values are here divisible by 3. The 2 digit hexadecimal representations of these values are: Hex CCFF Decimal

The CMY and CMYK Color Models Cyan, Maganta and Yellow are secondary colors or light. Color printers and copiers use this model. They perform an RGB to CMY conversion internally as follows: C=1-R M=1-G Y=1-B Here all values are normalized to the range [0,1]. The light reflected from a surface coated with pure cyan does not contain red. Pure magenta does not reflect green and pure yellow does not reflect blue. Combining these colors for printing produces a muddy-looking black. To produce true black, a fourth color, black is added, giving us CMYK color model. This leads to 4 color-printing.

HIS Color Model This model decouples the intensity component from the color-carrying information (hue and saturation) in a color image. We can do the conversion from RGB to HSI using the following formulae: H = 0if B ≤ G =360 – θif B > G (1/2)*[(R - G) + (R – B)] θ= cos [(R – G)2 + (R – B)(G – B)]1/2 3 S = [ min (R,G,B)] ( R + G + B) And I= (1/3)*( R + G + B).

Converting colors from HSI to RGB Here we are given the HIS values, we try to find the RGB values. We begin my multiplying H by 360 0, which returns the hue to its original range of [ 0 0, ]. RG sector ([ 00 ≤ H < ): When H is in this sector, the RGB components are given as: B = I ( 1- S) S cos H R = I *[ ] Cos(600 – H) G = 1 – ( R + B)

Converting colors from HSI to RGB GB sector ([ ≤ H < ): If the value of H is in this sector, we first subtract from it: H = H R = I ( 1 – S) S cos H G = I *[ ] Cos(600 – H) B = 1 – ( R + G).

Converting colors from HSI to RGB BR sector ([ ≤ H < ): Here we subtract from it: H = H G = I ( 1 – S) S cos H B = I *[ ] Cos(600 – H) R = 1 – ( G + B)

clear all;close all; clc; f = imread('onion.png'); f = im2double(f); figure,imshow(f),title('Image') figure,imshow(f(:,:,1)),title('Red'); figure,imshow(f(:,:,2)),title('Green'); figure,imshow(f(:,:,3)),title('Blue'); f1 = 1-f; figure,imshow(f1(:,:,1)),title('Cyan'); figure,imshow(f1(:,:,2)),title('Magenta'); figure,imshow(f1(:,:,3)),title('Yellow'); h = rgb2hsi(f); figure,imshow(h(:,:,1)),title('Hue'); figure,imshow(h(:,:,2)),title('Saturation'); figure,imshow(h(:,:,3)),title('Intensity');

Histogram Equalization Using HSI image

clear all; close all; clc; f = imread('Baboon24.png'); f = imresize(f,[256,256]); f1 = f(:,:,1); f2 = f(:,:,2); f3 = f(:,:,3); h = rgb2hsi(f); H = h(:,:,1); S = h(:,:,2); I = h(:,:,3); I1 = histeq(I); res = cat(3,H,S,I1); res1 = hsi2rgb(res); figure,imshow(f),title('Original Image'); figure,imshow(res1),title('Histogram Equalized');

Pseudocolor Image Processing This is also called as false color. Here we assign colors to gray values based on a specified criterion. Intensity Slicing If an image is interpreted as a 3-D function, the method can be viewed as one of placing planes parallel to the coordinate plane of the image; Each plane then “slices” the function in the area of intersection. Let us slice the image function into 2 levels and assign different color to each side of the plane. The pixels whose gray level is above the plane will be coded with one color and any pixel below the plane will be coded with the other. Levels that lie on the plane are arbitrarily assigned to one of the two colors.

Intensity Slicing Let [0, L-1] represent the gray scale, let level l 0 represent black and level l L-1 represent white. Suppose that Plane s perpendicular to the intensity axis are defined at levels l 1, l 2, … l P. Then assuming that 0 < P < L-1, the P planes partition the gray scale into P + 1 intervals, V 1, V 2, … V P+1. Gray-level to color assignments are made according to the relation: f ( x, y ) = c k if f(x,y) ξ V k. Here c k is the color associated with the k th intensity interval V k defined by the partitioning planes at l = k -1 and l = k. In general, gray scale is divided into intervals and a different color is assigned to each region, without regard for the meaning of the gray levels in the image.

clear all; close all; clc; f = imread('PIA02948.tif'); figure,imshow(f); %f = rgb2gray(f1); [m,n]=size(f); R(:,:,1)=zeros([m,n]); R(:,:,2)=zeros([m,n]); R(:,:,3)=zeros([m,n]); for i=1:m for j=1:n b = f(i,j); if b >= 200 R(i,j,3) = 200; elseif b >= 180 && b < 200 R(i,j,3) = 150; R(i,j,2) = 20; elseif b >= 160 && b < 180 R(i,j,3) = 50; R(i,j,2) = 10; R(i,j,3) = 150; elseif b >= 150 && b < 160 R(i,j,3) = 150; R(i,j,2) = 70; R(i,j,1) = 10; elseif b >= 120 && b < 150 R(i,j,3) = 10; R(i,j,2) = 70; R(i,j,1) = 150; elseif b >= 120 && b < 150 R(i,j,3) = 150; R(i,j,2) = 70; R(i,j,1) = 10; elseif b >= 100 && b < 120 R(i,j,3) = 50; R(i,j,2) = 200; R(i,j,1) = 150; elseif b >= 80 && b < 100 R(i,j,3) = 70; R(i,j,2) = 200; R(i,j,1) = 200; else R(i,j,3) = 70; R(i,j,2) = 200; R(i,j,1) = 20; end figure,imshow(uint8(R));

Gray level to color transformations Here we perform three independent transformations on the gray level of any input pixel. The three results are then fed separately into the red, green and blue channels. The image is modulated by the nature of the transformation functions. These functions act on gray levels of an image, not on its position.

Basics of full-color image processing There are 2 approaches here. In the first type, we process each component image individually and then form a composite processed color image from the individually processed components. In second type, we work with color pixels directly.

Color Transformations These techniques deal with processing the components of a color image within the context of a single color model, as opposed to the conversion of those components between models. Here we model color transformations using the relation: g(x,y) = T[f(x,y)] where f(x,y) is a color input image, g(x,y) is the transformed color output image and T is an operator on f over a spatial neighborhood of (x,y). Here pixel values are triplets or quartets from the color space chosen to represent the images

Color Transformations The transformations are of the form: s i = T i (r 1,r 2,…,r n ), i = 1,2, …, n Here r i and s i are the variables denoting the color components of f(x,y) and g(x,y) at any point (x,y), n is the number of color components and T i are the set of transformation or color mapping functions that operate. Here the n transformations T i combine to implement the single transformation function T. For RGB color space, n =3 and r i values are red, green and blue components of an image.

Color Transformations If we want to modify the intensity of the image, in the HSI color space only the intensity component r 3 needs to be modified. But in the RGB color space, all 3 components need to be transformed. The HSI transformation involves fewest number of operations, but the computations need to convert an RGB or CMY(K) image to the HSI space often offsets the advantages. But the output is the same.

Color Conversion

% RGB to CMYand YIQ conversion % Read a RGB Color image and convert it into CMY and YIQ formats f=imread('onion.png'); f = im2double(f); r=f(:,:,1); g=f(:,:,2); b=f(:,:,3); c = 1-r; m = 1-g; y = 1-b; CMY = cat(3,c,m,y); figure,imshow(f); figure,imshow(CMY); Y = 0.3*r+0.59*g+0.11*b; I = 0.6*r-0.28*g-0.32*b; Q = 0.21*r-0.52*g+0.31*b; YIQ =cat(3,Y,I,Q); figure,imshow(YIQ);

Color Slicing Highlighting a specific range of colors in an image is useful for separating objects from their surroundings. A simple approach is to “slice” a color image to map the colors outside some range of interest to a nonprominent neutral color. f the colors of interest are enclosed by a cube (or hypercube for n > 3) of width W and centered at a prototypical color with components (a 1,a 2, …, a n ), the transformation is: s i = 0.5if | r j – a j | > (W/2) for any 1 ≤ j ≤ n =r i otherwise for any i = 1,2, …, n These transformations highlight the colors around the prototype by forcing all other colors to the midpoint of the reference color space.

Color Slicing If a sphere is used to specify the colors of interest, then we have: s i = 0.5if Σ ( r j – a j ) 2 > (R 0 2 ) for 1 ≤ j ≤ n = r i otherwise for any i = 1,2, …, n Here R 0 is the radius of the enclosing sphere and a 1,a 2, …, an are the components of its center.

Histogram processing Color images are composed of multiple components. It is unwise to histogram equalize the components of a color image independently. This results in erroneous color. A logical approach is to spread the color intensities uniformly, leaving the colors themselves (hues) unchanged. The intensity equalization process did not alter the values of hue and saturation of the image, it did impact the overall color perception.

Color Image smoothing Gray-scale image smoothing can be viewed as a spatial filtering operation in which the coefficients of the filtering mask are all 1’s. As the mask is slid across the image to be smoothed, each pixel is replaced by the average of ht pixels in the neighborhood defined by the mask. For a color image, we must deal with component vectors of the color image.

Color Image smoothing The average of the RGB component vectors in this neighborhood is: c’(x,y) = (1/K)* Σ c(x,y) Also, c’(x,y) = (1/K)* Σ R(x,y) (1/K)* Σ G(x,y) (1/K)* Σ B(x,y) Thus smoothing by neighborhood averaging can be obtained by per-color- plane basis.

Color Image sharpening The Laplacian of a vector is defined as a vector whose components are equal to the Laplacian of the individual scalar components of the input vector. In the RGB color system, the Laplacian vector is given as: Λ2 R(x,y) Λ2 [c(x,y)] = Λ2 G(x,y) Λ2 B(x,y) Thus we can compute the Laplacian of a full- color image by computing the Laplacian of each component image separately.

Color segmentation Segmentation is the process of partitioning an image into regions. Saturation is used as a masking image in order to isolate further regions of interest in the hue image. The intensity image is less frequently used for segmentation of color images because it carries no color information.

Segmentation in RGB Vector space HSI space is intuitive for many aspects of image processing. But for segmentation, RGB color vectors give better results. Let us say, we want to segment objects of a specified color range in an RGB image. Given a set of sample color points of interest, we obtain the estimate of the “average” color that we want to segment. Let us denote this average color by a vector a RGB vector a. The aim of segmentation is to classify each RGB pixel in a given image as having a color in the specified range or not.

Segmentation in RGB Vector space We use Euclidean distance for comparison. Let z denotes an arbitrary point in the RGB space. We say that z is similar to a if the distance between them is less than a specified threshold D 0. The Euclidean distance between z and a is given by: D(z,a) = || z – a || = [ ( z – a ) T ( z – a ) ] 1/2 = [ (z R – a R ) 2 + (z G – a G ) 2 +(z B – a B ) 2 ] 1/2 Here the subscripts R, G and B denote the RGB components of vectors a and z. The locus of point such that D(z,a) ≤ D 0 is a solid sphere of radius D 0. Points contained within or on the surface of the sphere satisfy the specified color criterion; points outside do not. Coding these two sets of points with black and white gives a binary segmented image.

Segmentation in RGB Vector space The generalization of the distance measure is of the form: D(z,a) = [ ( z – a ) T C -1 ( z – a ) ] 1/2 Here C is the covariance matrix of the sample representative of the color we wish to segment. The locus of the points such that D(z,a) ≤ D 0 describes a solid 3-D elliptical body. Its principal axes are oriented in the direction of maximum data spread. When C = I, the 3 X 3 identity matrix, the above two equations become identical.

Segmentation in RGB Vector space As distances are positive and monotonic, we work with the distance squared, and avoid root computations. But implementing the above equation, is also computationally expensive. We can use a box centered on a and its dimensions along each of the color axes can be chosen proportional to the standard deviation of the samples along each of the axis. Standard deviations are done only once using sample color data. Given an arbitrary color point, we segment it by finding whether or not it is on the surface or inside the box. This computation is simpler than finding distance.

Color Edge Detection The edge detection by gradient operators is not defined for vector quantities. Computing the gradient on individual images and then using the results to form a color will lead to erroneous results. Because gradient discussed so far is applicable to a scalar function f(x,y); It is not applicable to vector functions. We can extend the concept of a gradient to vector functions.

Color Edge Detection Let r, g and b be unit vectors along the R, G and B axis of RGB color space and define the vectors ∂R ∂G ∂B u = --- r g b ∂x ∂x ∂x ∂R ∂G ∂B v = --- r g b ∂y ∂y ∂y

Color Edge Detection Let the quantities g xx, g yy, and g xy, are defined in terms of the dot product of these vectors as: g xx = u.u = u T u = |∂R/∂x | 2 + |∂G/∂x | 2 +|∂B/∂x | 2 g yy = v.v = v T v = |∂R/∂y | 2 + |∂G/∂y | 2 +|∂B/∂y | 2 g xy = u.v = u T v = (∂R/∂x)(∂R/∂y)+(∂G/∂x)(∂G/∂y) +(∂B/∂x)(∂B/∂y)

Color Edge Detection Now the direction of maximum rate of change of c(x,y) is given by the angle θ = (1/2) * tan -1 ( 2g xy / (g xx - g yy )) The value of the rate of change at (x,y) in the direction of θ is given by F(θ)={0.5*[(g xx + g yy )+(g xx -g yy )cos 2θ+2g xy sin 2θ]} 1/2 Since F(θ) = F(θ + Π), F needs to be calculated only for values of θ in the half-open interval [ 0, Π). The partial derivatives required here can be computed using the Sobel operator.

Color Edge

clear all; close all; clc; f = imread('Peppers2.png'); f = imresize(f,[256,256]); f1 = padarray(f,[1 1]); w = [ ;0 0 0;1 2 1]; w1 = [-1 0 1;-2 0 2;-1 0 1]; r = f1(:,:,1); g = f1(:,:,2); b = f1(:,:,3); figure,imshow(f),title('Original Image'); r1 = imfilter(r,w); r1 = abs(r1); r2 = imfilter(r,w1); r2 = abs(r2); r3 = imadd(r1,r2); g1 = imfilter(g,w); g1 = abs(g1); g2 = imfilter(g,w1); g2 = abs(g2); g3 = imadd(g1,g2); b1 = imfilter(b,w); b1 = abs(b1); b2 = imfilter(b,w1); b2 = abs(b2); b3 = imadd(b1,b2); res = imadd(r3,imadd(g3,b3)); figure,imshow(res),title('Sobel Edge');

RGB 2HSI

f=imread('onion.png'); f = im2double(f); r=f(:,:,1); g=f(:,:,2); b=f(:,:,3); num=0.5*((r - g) + (r - b)); den = sqrt((r - g).^2 + (r - b).* (g - b)); theta = acos(num./(den +eps)); H = theta; H(b > g) = 2*pi - H(b > g); H = H/(2 * pi); num = min(min(r, g), b); den = r + g + b; den(den == 0) = eps; S = 1 - (3.* num./den); H(S == 0) = 0; I = ( r + g + b)/3; hsi = cat(3,H,S,I); figure,imshow(f),title('RGB Image'); figure,imshow(hsi),title('HSI Image');

HIS2RGB

function rgb = his2rgb(hsi) %hsi=im2double(hsi); H1 = hsi(:,:,1)*2*pi; S1 = hsi(:,:,2); I1 = hsi(:,:,3); R = zeros(size(hsi, 1),size(hsi, 2)); G = zeros(size(hsi, 1),size(hsi, 2)); B = zeros(size(hsi, 1),size(hsi, 2)); idx = find((0 <= H1) & (H1 < (2*pi)/3)); B(idx) = I1(idx).* (1 - S1(idx)); R(idx) = I1(idx).* (1+ ((S1(idx).* cos(H1(idx)))./ cos((pi/3) - H1(idx)))); G(idx) = 3*I1(idx) - (R(idx) + B(idx)); idx = find((2*pi/3 <= H1) & (H1 <= (4*pi)/3)); R(idx) = I1(idx).* (1-S1(idx)); G(idx) = I1(idx).* (1+(S1(idx).* cos(H1(idx) - 2*pi/3)./cos(pi-H1(idx)))); B(idx) = 3*I1(idx) - (R(idx) + G(idx)); idx = find((4*pi/3 <= H1) & (H1 <= 2*pi)); G(idx) = I1(idx).*(1-S1(idx)); B(idx) = I1(idx).*(1+(S1(idx).*cos(H1(idx) - 4*pi/3)./cos(5*pi/3-H1(idx)))); R(idx) = 3*I1(idx) - (G(idx) + B(idx)); rgb(:,:,1)=R; rgb(:,:,2)=G; rgb(:,:,3)=B; % rgb1=im2uint8(rgb); % rgb = cat(3,R,G,B);

Noise in color images Generally the noise content of a color image has same characteristics in each color channel. But color channels can affect differently the noise. When only one RGB channel is affected by noise, conversion to HSI spreads the noise to all HSI component images. Because the computation of the HSI components makes use of all RGB components.