introductory digital image processing using matlab, iit roorkee

22
Welcome, students! Let’s learn something cool!

Upload: vinayak-sahai

Post on 05-Dec-2014

2.900 views

Category:

Technology


1 download

DESCRIPTION

Introduction to Digital Image Processing using Matlab, IIT Roorkee. Organized by Electronics Section, Hobbies Club. Reference: Gonzalez and Woods

TRANSCRIPT

Page 1: Introductory Digital Image Processing using Matlab, IIT Roorkee

Welcome, students!

Let’s learn something cool!

Page 2: Introductory Digital Image Processing using Matlab, IIT Roorkee

Is this cool?

Meet Pranav MistryFather of Sixth Sense Technology

PhD, MIT Media LabsM.Des, IIT BombayBE, Computer Science, Nirma Institute of Technology

Page 3: Introductory Digital Image Processing using Matlab, IIT Roorkee

Why Digital Image Processing?

Machine Learning

Gesture Control

Computer VisionFace

Recognition

Page 4: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 4

So, Let’s start: Lecture Overview

Lecture 1: Monday, 28 Oct, 2013Duration : 90 Mins

Topics:

1. Basic Introduction and Matlab

2. Image Handling

3. Operations on Images

4. Sample Exercises

Lecture 2: Tuesday, 29 Oct, 2013Duration : 90 Mins

Topics:

5. Noise Filtering and Segmentation

6. Colour Image Analysis

7. Gesture Recognition- Case Study

8. Textbook and beyond

10/25/2013

Page 5: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 5

1.Basic Introduction and Matlab

Digital Image: The digital image is essentially a fixed number of rows and columns of pixels. Pixels are the smallest individual element in an image, holding quantized values that represent the brightness of a given color at any specific point.

-Monochrome/Grayscale Image has 1 value per pixel, while Colour Image has 3 values per pixel. (R, G, B)

monochrome image= f( x, y)-where x and y are spatial coordinates-f gives amplitude of intensity

10/25/2013

-Colour image= 3 R,G,B monochrome images

Page 6: Introductory Digital Image Processing using Matlab, IIT Roorkee

where, Pixel Location: p = (r , c)Pixel Intensity Value: I(p) = I(r , c)

Notation to represent a pixel : [ p, I(p)]

Note: Origin in case of Matlab Image Processing Toolbox is not p=(0,0) but p=(1,1)

Page 7: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 710/25/2013

The MATrix LABoratory

MATLAB is a dynamically typed language-Means that you do not have to declare any variables-All you need to do is initialize them and they are created

MATLAB treats all variables as matrices-Scalar – 1 x 1 matrix. Vector – 1 x N or N x 1 matrix-Why? Makes calculations a lot faster

These MATRICES can be manipulated in two ways:-Matrix Manipulation (usual matrix operations)-Array Manipulation (using dot (.) operator as prefix)-Vector Manipulation

Cleve Moler Stanford University1970

Page 8: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 810/25/2013

Basics of MATrix LABoratory

What is the best way to learn Matlab?- Using the ‘Help’ file (sufficient for 90%

operations)- Practicing along with it.

Common Errors:1. Select ‘Image Processing Toolbox’ before starting to use various image functions.(only available with 2008b or newer) 2. Always make sure whether current folder is same as desired.3. Forgetting to use help command

Page 9: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 9

2. Image Handling

Matlab Functions function[output]=name(inputs)

- Create and save new ‘.m’ file in the current directorySome inbuilt functions (in Image Pro. Toolbox) to remember:

- help, clc, type- Imread(‘filename.ext’)- imwrite(g,‘filename.ext’,’compression’,’parameter’,’resolution’,

[colores,rowres],‘quality’)- mat2gray(f,[fmin,fmax])- imshow(f(:,:,x))- figure -for holding on to an image and displaying other (used

as prefix with,)- whos -for displaying size of all images currently being used

in workspace

If a statement doesn’t fit a line, we use ‘…’ , to indicate it continues in next line

Question: How to find intensity of a given pixel?

Page 10: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 1010/25/2013

Image Handling (Continued)

-Accessing subset of an image: For monochromatic images: im2 = im(row1:row2,col1:col2);For colour images: im2 = im(row1:row2,col1:col2,:);

-Resizing an image: out = imresize(im, scale, ‘method’); or out = imresize(im, [r c], ‘method’);

-Rotating an image: out = imrotate(im, angle_in_deg,

‘method’);

Methods to fill lacking data:1.’nearest’= as neighborhood2.’bilinear’=linear interpolation3.’bicubic’=cubic int. (*best)

Page 11: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 1110/25/2013

3. Operation on Images : Transformations

G( x, y) = T [f ( x, y)]where, G= Processed Image

T= Operatorf=input image

-Brightness/Intensity Transformation: im2=c*im; im2=im+c;

If c > 1, c>0 increasing brightnessIf c < 1, c<0 decreasing brightness

-Contrast Transformation: out = imadjust(im, [], [], gamma);

Contrast represents how the intensity changes from min to max value.

Page 12: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 1210/25/2013

Operations on Images: Spatial Filtering

1. First we need to create an N x N matrix called a mask, kernel, filter (or neighborhood).2. The numbers inside the mask will help us control the kind of operation we’re doing.3. Different numbers allow us to blur, sharpen, find edges, etc.4. We need to master convolution first, and the rest is easy!

a.k.a. neighborhood processing

Maska b cd e fg h i G=[

]H=[ ]

z y xw v ut s r out = a*z + b*y + c*x + d*w + e*v + f*u + g*t + h*s + i*r,

Page 13: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 13

Application:

Before

After

10/25/2013

What do we observe?

Page 14: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 14

Application: Blurring

10/25/2013

Blurring:- Reduces noise (high frequency)- Reduces edges (high

frequency)- Is essentially a low pass filter

(eliminates high f)

- Can be done through averaging filter

- For colour images, we can blur each layer independentlymask = fspecial(‘average’, N);

out = imfilter(im, mask,’conv’);

More theMask size, More blur inResult

Page 15: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 1510/25/2013

Application: Edge Detection

What is an edge? – ‘A place of change’.

f’( x, y)= f( x-1, y) – f( x+1,y)This is a Horizontal filter. (puts more weight on central

pixel)

How do we do this in MATLAB?1) Create our Prewitt or Sobel Horizontal Masks: mask = fspecial(‘prewitt’); or mask = fspecial(‘sobel’);2) Convolve with each mask separately dX = imfilter(im, mask); dY = imfilter(im, mask2);3)Find the overall magnitude mag = sqrt(double(dX).^(2) + double(dY).^(2));

EXERCISE: Use following masks in fspecial function and find out what they do- Gaussian, Laplacian, Laplacian of Gaussian (LoG)

Alternate way: Canny Edge Detector

(most powerful edge detector)

[ g, t]= edge (f, ‘canny’, T , sigma)

Page 16: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 16

4. Noise Filtering

▪ In reality, pixel corruption takes place during process of acquisition or transmission. There is a need to remove(okay, ‘try to’) this noise.

▪ As an exercise, let’s add up artificial noise in an image using function:

n = imnoise ( im, ‘salt & pepper’, density);

10/25/2013

Gaussian

PoissonSalt & Pepper

Use blurring filter against ‘Gaussian’ noise. Use median filter against ‘salt & pepper noise’.

out = medfilt2( n , [M N]);

Page 17: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 17

Segmentation

▪ This division is done mainly on the basis of :

10/25/2013

division of an image into segments or parts (region of interests)

(a) grey level (b) texture (c) motion

(d) depth

(e) colour

Can you think of ways in which this will prove useful?

Page 18: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 18

Segmentation Techniques

10/25/2013

One way is already covered. Can you name that? Thresholding : Simplest Segmentation Technique Pixels are grouped into “Object” and “Background”– Input: Gray scale image– Output: Binary image

Implementing in Matlab: output = im2bw(Image, k)

where, K=T/largest pixel size

Other Methods:1. Region Growing: A method that clubs similar property pixels. (Satellites)2. Watershed Transform: grayscale intensity is interpreted as distance. (topographical use)

Page 19: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 19

Colour Image Analysis

10/25/2013

Trichromacy theory :All colors found in nature can naturally be decomposed into Red, Green and Blue.

Other models: CMY, NTSC, YCbCr, HSI, CMYK, HSV

RGB Cube

Page 20: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 20

Colour Image Analysis

▪ Basic Conversions:

10/25/2013

What is an indexed image?An image having two components:1. Data Matrix2. Colour Map (a.k.a. ‘palette’)What is its use?1.To make display process fast2.To reduce size of image

Loss of information due to size of palette

Page 21: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 2110/25/2013

Gesture Recognition- Case Study

Page 22: Introductory Digital Image Processing using Matlab, IIT Roorkee

Introduction To Digital Image Processing 2210/25/2013

Low Level• Noise Reduction• Contrast

EnhancementMid Level• Segmentation• Recognition

High Level• Making Sense

Textbooks and beyond:

DIP using Matlab

Gonzalez,Woods,EddinsRs 500/-