Digital Signal Processing Reference
In-Depth Information
Program 14.3 lists the sample MATLAB codes for pseudo-color generation for a grayscale image.
Program 14.3. Program examples for pseudo-color generation.
close all; clear all;clc
disp( ' Convert the grayscale image to the pseudo-color image ' );
[X, map] ¼ imread( ' clipim2 ' , ' gif ' ); % Read 8-bit index image, provided by the
% instructor
Y ¼ ind2gray(X,map); % 8-bit color image to the grayscale conversion
% Apply pseudo-color functions using sinusoids
C_r ¼ 304; % Cycle change for the red channel
P_r ¼ 0; % Phase change for the red channel
C_b ¼ 804; % Cycle change for the blue channel
P_b ¼ 60; % Phase change for the blue channel
C_g ¼ 304; % Cycle change for the green channel
P_g ¼ 60; % Phase change for the green channel
r ¼ abs(sin(2*pi*[-P_r:255-P_r]/C_r));
g ¼ abs(sin(2*pi*[-P_b:255-P_b]/C_b));
b ¼ abs(sin(2*pi*[-P_g:255-P_g]/C_g));
figure, subplot(3,1,1);plot(r, ' r ' );grid;ylabel( ' R value ' )
subplot(3,1,2);plot(g, ' g ' );grid;ylabel( ' G value ' );
subplot(3,1,3);plot(b, ' b ' );grid;ylabel( ' B value ' );
figure, imshow(Y);
map
¼
[r;g;b;]
;
% Construct the color map
'
figure, imshow(Y,map);
% Display the pseudo-color image
14.6 IMAGE SPECTRA
In one-dimensional signal processing such as for speech and audio, we need to examine the frequency
contents, check filtering effects, and perform feature extraction. Image processing is similar. However,
we need apply a two-dimensional discrete Fourier transform (2D-DFT) instead of a one-dimensional
(1D) DFT. The spectrum including the magnitude and phase is also in two dimensions. The equations
of the 2D-DFT are given by
M 1
N 1
X u; v ¼
0 p m; n W u M W v N
(14.16)
0
where W M ¼ e j
2 p
M and W N ¼ e j
2 p
N
m and n ¼ pixel locations
u and v ¼ frequency indices
Taking the absolute value of the 2D-DFT coefficients Xðu; vÞ and dividing the absolute value by
ðM NÞ , we get the magnitude spectrum as
A u; v ¼
1
ðN MÞ jXðu; vÞj
(14.17)
Instead of going through the details of the 2D-DFT, we focus on application results via
examples.
 
Search WWH ::




Custom Search