Sunteți pe pagina 1din 11

Chapter 2 – Two dimensional

System

1. Discrete Fourier transform (DFT)


The DFT is the most important discrete transform, used to perform Fourier analysis
in many image processing tools. It helps to find the convert image in spatial
domain to frequency domain.
The 2D- discrete Fourier transform for a finite sequence { x(k,l)} with k є { 0,1,
…, M-1} and l є { 0,1,… N-1}, is the sequence defined for k є { 0,1,…, M-1} and l є
{ 0,1,… N-1}, by:
M −1 M −1
X (m , n)= ∑ ∑ x (k ,l)exp{−2 π j ( km
M N
ln
+ )}
k =0 l=0

2. Fast Fourier Transform


A fast Fourier transform (FFT) is an algorithm that samples a signal over a period
of time (or space) and divides it into its frequency components. The fast Fourier
transform (FFT) is a discrete Fourier transform algorithm which reduces the number
of computations needed for N points from 2N2 to 2Nlog2N. It uses Divide and Conquer
Algorithm by splitting polynomial evaluation into even and odd parts, recursively.
FFT's importance derives from the fact that in signal processing and image
processing it has made working in frequency domain equally computationally feasible
as working in temporal or spatial domain.

2.1.1Matlab Code
delta1 = 4;delta2 = 8;
block = zeros(delta2,delta2); 
block(1:delta1,1:delta1) = ones(delta1,delta1);
 
block(delta1+1:delta2, delta1+1:delta2) = ones(delta1,delta1);
 
set(gcf, 'color', [1,1,1])
subplot (131); imagesc(block); colormap('gray');
axis('image'); set(gca, 'xcolor', [0 0 0],'ycolor',[ 0 0 0 ])
 
%Spectral Content
M = 32; N = 32; blockFqs = fft2(block, M, N);
 
%Normalized spatial frequencies
mu = (0:M­1)/M; nu = (0: N­1)/N;
 
subplot (132); contour(nu,mu,abs(blockFqs),20);
axis('square');
set(gca,'xlim', [0 1], 'ylim', [0 1])
set(gca, 'xcolor', [0 0 0],'ycolor',[ 0 0 0 ])
subplot(133); imagesc(nu,mu,abs(blockFqs));
axis('square');
set(gca,'xlim', [0 1], 'ylim', [0 1])
set(gca, 'xcolor', [0 0 0],'ycolor',[ 0 0 0 ])

2.1.2Output
3. Sine and Cosine Transform
A discrete cosine transform (DCT) expresses a finite sequence of data points in
terms of a sum of cosine functions oscillating at different frequencies. DCTs are
important to various applications in signal processing, from lossy compression of
audio (e.g. MP3) and images (e.g. JPEG) where small high-frequency components can
be discarded.DCTs are equivalent to DFTs of roughly twice the length, operating on
real data with even symmetry (since the Fourier transform of a real and even
function is real and even), whereas in some variants the input and/or output data
are shifted by half a sample.
FORMULA:

Discrete sine transform (DST) is a Fourier-related transform similar to the


discrete Fourier transform (DFT), but using a purely real matrix. It is equivalent
to the imaginary parts of a DFT of roughly twice the length, operating on real data
with odd symmetry.
FORMULA:

3.1.1Matlab Code
%dst dct
grayPanda = rgb2gray(imread('panda2.jpg'));
DSTCoeff = dst(grayPanda);
DCTCoeff = dct2(grayPanda);
figure;
 
subplot(321); imshow(grayPanda); title('Orginal image');
 
subplot(323); imshow(DCTCoeff); title('DCT Coefficients ');
 
subplot(325); imshow(DSTCoeff); title('DST Coefficients');
 
subplot(322); imshow(grayPanda); colormap(gca,jet(64)); colorbar; 
title('Orginal image');
 
subplot(324); imshow(log(abs(DCTCoeff)),[]); colormap(gca,jet(64)); 
colorbar; title('DCT Coefficients ');
 
subplot(326); imshow(log(abs(DSTCoeff)),[]); colormap(gca,jet(64)); 
colorbar; title('DST Coefficients');

3.1.2Output
Chapter 3 – Image Enhancement and
restoration
4. Point Operation
The simplest spatial domain operations occur when the neighbourhood is simply the
pixel itself.In this case below T is referred to as a grey level transformation
function or a point processing operation
Point processing operations take the form
s = T ( r )
where s refers to the processed image pixel value and r refers to the original
image pixel value.
These are mapping operations done on per pixel level irrespective of their spatial
location. Mapping function may be linear or non-linear. There are two types of
point operation viz. Gray-scale mapping and Histogram modeling scheme.

4.1 Grayscale mapping


Gray-scale mapping transforms the original image pixel intensity
x = {xk,k ∈[0, K − 1]}
into the transformed image pixel intensity y = {yl, l ∈ [0, L − 1]} using y = f(x)
where f (·) is a user-defined.

4.1.1Image Negative:
Negative of an image with intensity levels in [0, L-1] obtained by:
s=(L−1)−r for all image pixels
where r is original image pixel, L is maximum pixel intensity, and s is negative
image pixel.
Matlab Code:
Image = rgb2gray(imread('panda2.jpg'));
figure; subplot(211); axis('square') imshow(Image); title('Original')
maximum = max(max(Image));
grayImage = ( maximum ­ 1 ) ­ Image;
subplot(212); axis('square'); imshow(grayImage);
title('Negative');
Output:

4.1.2Thresholding:
The simplest thresholding methods replace each pixel in an image with a black pixel
if the image intensity I i , j is less than some fixed constant T (that is, I i , j <T ),
or a white pixel if the image intensity is greater than that constant.

Matlab code:
Image = rgb2gray(imread('panda2.jpg'));
figure;
subplot(221); axis('square'); imshow(Image); title('Original');
 
Threshold = 150;
ThresholdImage = uint8( Image > Threshold ) * 255;
 
subplot(222); axis('square'); imshow(ThresholdImage); title('After 
Threshold'); 
 
subplot(223); histogram(Image); axis('square'); title('Original 
Histogram');
 
subplot(224); histogram(ThresholdImage); axis('square'); 
title('Thresholding Histogram');
Output:

4.1.3Contrast Stretching:
We can fix images that have poor contrast by applying a pretty simple contrast
specification. Contrast stretching is a simple image enhancement technique that
attempts to improve the contrast in an image by `stretching' the range of intensity
values it contains to span a desired range of values, e.g. the the full range of
pixel values that the image type concerned allows. It differs from the more
sophisticated histogram equalization in that it can only apply a linear scaling
function to the image pixel values.
This is implemented by the equations
(r−a)
s= ×(d−c)
(b−a)
where,a and b are minimum and maximum pixel value in original image.
C and d are maximum and minimum values to which the pixels need to be mapped to.
(usually [0 255])
Matlab Code:
%contrast stretching
Image = imread('panda3.jpg'); %input grayscale image.
figure;
 
subplot(221); axis('square'); imshow(Image); title('Original');
 
TransformImage = imadjust(Image,stretchlim(Image),[ ]);   
 
subplot(222); axis('square'); imshow(TransformImage); title('After 
constrast stretching'); 
 
subplot(223); histogram(Image); axis('square'); title('Original 
Histogram');
 
subplot(224); histogram(TransformImage); axis('square'); 
title('Histogram after constrast stretching'); 
 

Output:
4.1.4Bit Plane Slicing
Particular bit value of every pixel is separated to form new image. Naturally, MSB
contain Most significant information.

Matlab Code:
%Bitplane Slicing
Image = rgb2gray(imread('panda2.jpg')); %input grayscale image.
figure;
 
subplot(221); axis('square'); imshow(Image); title('Original');
 
subplot(222); axis('square'); imshow( bitget(TransformImage,1) * 2 ^ 
0); title('Bit Plane 0'); 
 
subplot(223); ; axis('square'); imshow( bitget(TransformImage,6) * 2 
^ 6); title('Bit Plane 5'); 
 
subplot(224); ; axis('square'); imshow( bitget(TransformImage,8) * 2 
^ 8); title('Bit Plane 7'); 

Output:
4.2 Histogram Modelling
4.2.1Histogram Equalization:
Histogram equalization is a method in image processing of contrast adjustment using
the image's histogram. Histogram equalization provide a sophisticated method for
modifying the dynamic range and contrast of an image by altering that image such
that its intensity histogram has a desired shape.
Unlike contrast stretching, histogram modeling operators may employ non-linear and
non-monotonic transfer functions to map between pixel intensity values in the input
and output images. Histogram equalization employs a monotonic, non-linear mapping
which re-assigns the intensity values of pixels in the input image such that the
output image contains a uniform distribution of intensities (i.e. a flat
histogram). This technique is used in image comparison processes (because it is
effective in detail enhancement) and in the correction of non-linear effects
introduced by, say, a digitizer or display system.

Matlab Code:
%Histogram Equalisation

Image = rgb2gray(imread('panda2.jpg')); %input grayscale image.
 
figure;
subplot(221); axis('square'); imshow(Image); title('Original');
 
TransformImage = histeq(Image,256);
 
subplot(222); axis('square'); imshow(TransformImage); title('After 
Histogram equalization'); 
subplot(223); histogram(Image); axis('square'); title('Original 
Histogram');
subplot(224); histogram(TransformImage); axis('square'); title('After
Histogram equalization'); 

Output:

S-ar putea să vă placă și