Different Types of Color Image Processing Using MATLAB with Source Code
Different types of Color Image Processing Using MATLAB with Source Code
Digital Image Processing Using MATLAB
Why use color in image processing?
Color is a powerful descriptor.
Object identification and extraction
Example: Face detection using skin colors
Humans can discern thousands of color shades and intensities
Human discern only two dozen shades of grays
Types of color image processing
Pseudo-color processing
Full color processing
Full color processing
Images are acquired from full-color sensor or equipment
Pseudo-color processing
In the past period, color sensors and processing hardware are not available
Colors are assigned to a range of monochrome intensities
Color fundamentals
Color models
Pseudo-color image processing
Color transformations
Smoothing and sharpening
COLOR FUNDAMENTALS
Physical phenomenon
Physical nature of color is identified
Psysio-psychological phenomenon
How human brain see and understand color?
Visible light
Chromatic light distance the electromagnetic spectrum (EM) from 400 to 700 nm
The color that human perceive in an object = the light reflected from the object
Radiance:
Total amount of energy that flow from the light source, measured in watts (W)
Luminance:
Amount of energy an observer perceives from a light source, measured in lumens far infrared light: high radiance, but 0 luminance
Brightness:
Subjective descriptor that is hard to measure, alike to the achromatic view of intensity
6~7M Cones are the sensors in the eye
3 principal sensing categories in eyes
Red light 65%, green light 33%, and blue light 2%
In 1931, CIE (International Commission on Illumination) defines specific wavelength values to the
Primary colors
B = 435.8 nm, G = 546.1 nm, R = 700 nm
However, we know that no single color may be called red, green, or blue
Secondary colors:
G+B=Cyan,
R+G=Yellow,
R+B=Magenta
Color TV
COLOR MODELS
Color model, color space, color system
Specify colors in a standard way
A coordinate system that each color is represented by a single point
RGB color model
Pixel depth:
The number of bits used to represent each pixel in RGB space
Full-color image:
24-bit RGB color image
(R, G, B) = (8 bits, 8 bits, 8 bits)
CMY model (+Black = CMYK)
CMY: secondary colors of light, or primary colors of pigments
Used to produce hardcopy output
HSI color model
Will you describe a color using its R, G, B components?
Human describe a color by its hue, saturation, and brightness
Hue : color attribute
Saturation: purity of color (white->0, primary color->1)
Brightness: achromatic notion of intensity
Fig. RGB -> HSI model
Pseudo-color image processing
Assign colors to gray values based on a specified criterion
For human visualization and understanding of gray-scale events
Intensity slicing
Gray level to color conversions
Application 1
Application 2
Application 3
Gray level to color transformation
Intensity slicing: piecewise linear transformation
General Gray level to color transformation
Color transformation
Similar to gray scale transformation
g(x,y)=T[f(x,y)]
Color transformation
RGB (CMY (K) ( HSI
Theoretically, any transformation can be performed in any color model
Practically, some operations are better suitable to specific color model
Example:
g(x,y)=k f(x,y), 0<k<1
HSI color space
Intensity: s3 = k r3
Note: transform to HSI requires complex operations
RGB color space
For each R,G,B component: si = k ri
CMY color space
For each C,M,Y component:
si = k ri +(1-k)
Color image smoothing
Neighborhood processing
MATLAB Source Code For Color Image Processing
clc;
clear all;
close all;
a=imread('peppers.png');
subplot(3,3,1);
imshow(a);
title('original image');
g=rgb2gray(a);
subplot(3,3,2);
imshow(g);
title('gray conversion');
ntsc_img=rgb2ntsc(a);
subplot(3,3,3);
imshow(ntsc_img);
title('ntsc colour space conversion');
ycbcr_img=rgb2ycbcr(a);
subplot(3,3,4);
imshow(ycbcr_img);
title('ycbcr colour space conversion');
hsv_img=rgb2hsv(a);
subplot(3,3,5);
imshow(hsv_img);
title('hsv colour space conversion');
cmy_img=imcomplement(a);
subplot(3,3,6);
imshow(cmy_img);
title('cmy colour space conversion');
rgb=im2double(a);
r=rgb(:,:,1);
g=rgb(:,:,2);
b=rgb(:,:,3);
num=.5*((r-g)+(r-b));
den=sqrt(r-g).^2+(r-g).*(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);
subplot(3,3,7);
imshow(hsi);
title('HSI');
figure(2);
subplot(2,3,1);
imshow(r);
title('red component');
subplot(2,3,2);
imshow(g);
title('green component');
subplot(2,3,3);
imshow(b);
title('blue component');
subplot(2,3,4);
imshow(H);
title('hue component');
subplot(2,3,5);
imshow(S);
title('saturation component');
subplot(2,3,6);
imshow(I);
title('brightness component');
OUTPUT
MATLAB PROGRAM USING INDIVIDUAL FIGURE
clc;
clear all;
close all;
a=imread('peppers.png');
figure(1);
imshow(a);
title('original image');
g=rgb2gray(a);
figure(2);
imshow(g);
title('gray conversion');
ntsc_img=rgb2ntsc(a);
figure(3);
imshow(ntsc_img);
title('ntsc colour space conversion');
ycbcr_img=rgb2ycbcr(a);
figure(4);
imshow(ycbcr_img);
title('ycbcr colour space conversion');
hsv_img=rgb2hsv(a);
figure(5);
imshow(hsv_img);
title('hsv colour space conversion');
cmy_img=imcomplement(a);
figure(6);
imshow(cmy_img);
title('cmy colour space conversion');
rgb=im2double(a);
r=rgb(:,:,1);
g=rgb(:,:,2);
b=rgb(:,:,3);
num=.5*((r-g)+(r-b));
den=sqrt(r-g).^2+(r-g).*(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(7);
imshow(hsi);
title('HSI');
figure(8);
subplot(2,3,1);
imshow(r);
title('red component');
figure(9);
imshow(g);
title('green component');
figure(10);
imshow(b);
title('blue component');
figure(11);
imshow(H);
title('hue component');
figure(12);
imshow(S);
title('saturation component');
figure(13);
imshow(I);
title('brightness component');
OUTPUT
Comments
Post a Comment