You are on page 1of 3

INTRODUCTION TO IMAGE PROCESSING

1. INTRODUCTION
An image may be defined as a two-dimensional function, f(x,y), where x and y are spatial (plane)
coordinates, and the amplitude of f at any pair of coordinates (x,y) is called the intensity or gray
level of the image at that point. When x, y, and the intensity values of f are all finite, discrete
quantities, we call the image a digital image. The field of digital image processing refers to
processing digital images by means of a digital computer.

2. BASICS OF INTENSITY TRANSFORMATION


Intensity transformations are among the simplest of all image processing techniques. The values
of pixels, before and after processing, will be denoted by r and s, respectively. These values are
related by an expression of the form s=T(r), where T is a transformation that maps a pixel value r
into a pixel value s. The graph below shows three basic types of functions used frequently for
image enhancement: linear (negative and identity transformations), logarithmic (log and inverselog transformations), and power law (nth power and nth root transformations).

The expressions for the three basic transformation functions are given below
Image Negatives:
s = (L 1) r
Log Transformations:
s = clog(1 + r)
Power-Law Transformations:
s = c(r ^ )

Digital Signal Processing


College of Engineering
PAF Karachi Institute of Economics and Technology

3. CODES AND RESULTS


clc;clear all;close all;
I=double((imread('lena_gray_256.gif')));
figure;
subplot(221); imshow(uint8(I));title('Original');
I=I/255;
[rows,cols]=size(I);
MAX = max(max(I));
c = 2; GAMMA = 0.5;
X = (MAX - I)*255; % NEGATIVE TRANSFORMATION
subplot(222); imshow(uint8(X));title('Negative');
X = (c * log(I+1))*255; % LOG TRANSFORMATION
subplot(223); imshow(uint8(X));title('Log-Transformed @ c=2');
X = c*(I.^GAMMA)*255; % GAMMA TRANSFORMATION
subplot(224); imshow(uint8(X));title('Gamma-Transformed @ Gamma=0.5');

Original

Negative

Log-Transformed @ c=2

Gamma-Transformed @ Gamma=0.5

Digital Signal Processing


College of Engineering
PAF Karachi Institute of Economics and Technology

4. BASICS OF SPATIAL FILTERING


A spatial filter consists of (1) a neighborhood, (typically a rectangle), and (2) a predefined
operation that is performed on the image pixels encompassed by the neighborhood. Filtering
creates a new pixel with coordinates equal to the coordinates of the center of processed (filtered)
image is generated as the center of the filter visits each pixel in input image. If the operation
performed on the image pixels is linear, then the filter is called a linear spatial filter. Otherwise
the filter is nonlinear.
% FILTERING EXAMPLE
clc;clear all;close all;
I=double((imread('lena_gray_256.gif')));
figure;
subplot(221);imshow(uint8(I));title('ORIGINAL');
INoisy=imnoise(I/255,'gaussian',0,0.05); % Adding Noise to the original Image
subplot(222);imshow(uint8(INoisy*255));title('Noisy');
h=ones(3); % Filter Size 3 x 3
h=h/9; % Generating the Filter
IProcessed=(conv2(INoisy,h,'same')); % Applying the Filter
subplot(223);imshow(uint8(IProcessed*255));title('PROCESSED with 3 x 3 Filter');
h=ones(5); % Filter Size 5 x 5
h=h/25; % Generating the Filter
IProcessed=(conv2(INoisy,h,'same')); % Applying the Filter
subplot(224);imshow(uint8(IProcessed*255));title('PROCESSED with 5 x 5 Filter');

ORIGINAL

Noisy

PROCESSED with 3 x 3 Filter

PROCESSED with 5 x 5 Filter

Digital Signal Processing


College of Engineering
PAF Karachi Institute of Economics and Technology

You might also like