Introduction To Digital Image Processing Using MATLAB

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 35

Introduction to Digital Image

Processing Using MATLAB


By :- Pratik Gohel

Overview
What is image processing?
Applications
What is an image?
Introduction to image processing

techniques
Basic MATLAB commands for image
processing

What is Image Processing?

Photo
stitching

Color boost

Image processing is the collective name for


techniques used to extract information from digital
images or to manipulate them to render variations
of the input image.

Vehicle detection
and tracking

Popular technologies which make use of the


camera as a sensor

The Wii Remote uses


an IR camera to
sense its location
relative to the Wii
Sensor Bar.

The Kinect uses image


processing techniques on depth
images to detect and track
locations of multiple persons in

Applications
Medicine
Defense
Meteorology
Environmental science
Manufacture
Surveillance
Crime investigation

Applications: Medicine

CT
(computed

Tomography)

PET
(Positron Emission
Tomography

PET/CT
Arrows indicating
metastatic lesions

Applications: Meteorology

Applications: Environmental
Science

Applications: Manufacture

Applications: Crime
Investigation

Fingerprint enhancement

Pixels
Pixel

A pixel (abbr. for picture element) is the smallest

unit of an image.
Therefore, a 640x480 image is a matrix of 640
columns and 480 rows, each element of this
matrix is called an image pixel.

MATLAB Image Coordinates


MATLAB stores images as matrices.
In MATLAB, image pixels are referenced using
(row, col) values.
Origin of the coordinate system (1,1) is the top

left corner of the image


(1,
1)

img

Thus, img(4,3) refers


to the pixel at the
4th row and 3rd
column.

Sampling & Quantization

Sampling & Quantization

RGB and Grayscale


In RGB format, each Pixel has 3 color components: Red,

Green, and Blue.


Other color representations, e.g. HSV, YUV, CMYK, are
also used. Transformations from RGB to these color
spaces and back are defined in MATLAB.
If only intensity (bright/dark) variations are considered,
the resultant image is called a grayscale image. Each
pixel has only 1 component: intensity

Basic Image Processing techniques


Background Subtraction
Intensity Thresholding
Morphological Operations
Color-based Processing
Shape-based Processing

A combination of the above methods is usually used


in basic image processing applications. There is no
perfect solution, so keep discussing (and trying)
what suits your project best.

Spatial & Gray level resolution


Zooming & Shrinking of Digital Images
Sampling decides the spatial resolution of

an image.
Spatial resolution is the smallest discernible
detail in an image.
M x N is the resolution of an image.
What is the effect of changing the
resolution of an image on its appearance?
Smallest discernible change in gray level.
It depends on hardware.

Zooming

Shrinking

1.
2.

Its done with two processes


Create new pixel locations
Assign gray levels to these new locations

Enhancement
To make greater (in value , desirability, or

attractiveness)
Image enhancement is to make the visual
interpretation of the image easier and to
make the image more suitable to the
subsequent image analysis.

Original Image

After
Enhancement

Image processing operation


Point Processing
Obtain Negative image
Obtain Flip image
Threshold operation (Thresholding)
image arithmetic operations
Addition
Subtraction
Multiplication
image logical operations

Filtering Process
Filter mask is moved from point to point in

an image.
At each point (x,y), the response of filter is
calculated using predefined relationship

Spatial Filters
Smoothing Spatial Filters
Smoothing Linear Filters
Average Filter
Weighted Average Filter
Order-Statistics Filters
Median Filter
Minimum Filter
Maximum Filter

Sharpening Spatial Filters


First derivative
Second Derivative

Box filter and Weighted Average


Filter

Sharpening Image

Image Classes
Class for an image is data type used to

store & represent an image.


All MATLAB data types are designed to
function as classes in object-oriented
programming.

MATLAB Basic Functions for Image


processing
A = imread(filename, fmt) ,
It reads a grayscale or color image from the file specified

by the string filename


A=imread('cameraman.tif');
imwrite(A,filename,fmt)
It writes the image to filename, inferring the format to
use from the filename's extension
IM2 = imcomplement(IM)
B = imrotate(A,angle)
F = imresize(A,[r,c]);
G = im2bw(A);
H=rgb2gray(RGB);

If we read given color image using imread() function, we

get 3-D matrix. To separate out R,G and B planes, we


can read each plane separately as follows:
myImage=imread(RGBBar.bmp);
RED=myImage(:,:,1);
GREEN=myImage(:,:,2);
BLUE=myImage(:,:,3);
If we have three R,G and B planes separately and if we
want to create color image from it, we can use
concatenate function:
Example:
newImage=cat(3,RED,BLUE,GREEN)

[rows,cols] = size(imagedata);
[namefile,pathname]=uigetfile({'*.bmp;*.tif;*.jpg;*.gif','I

MAGE Files (*.bmp,*.tif,*.jpg,*.gif)'},'Choose GrayScale


Image');
img=imread(strcat(pathname,namefile));
if(size(img,3)==3)
img=rgb2gray(img);

end
B = zeros(m,n) Create array of all zeros
xorimage= xor(myimageA,myimageB);
| OR operation
& and operation

B = imnoise(A,'salt & pepper', 0.02); Add the Solt &

Pepper noise in image.


K = medfilt2(B);
L = wiener2(B,[5 5]);
Define spatial filter masks
L1=[1 1 1;1 1 1;1 1 1];
filt_image= conv2(double(myimage),double(L1))
Perform 2- D convolution
filtimg = imfilter(myimage,gaussmask);

You might also like