SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
Image processing using Matlab
Author : Pooya Sagharchi Ha
Agenda
• Introduction to Matlab
• Basics & Examples
• Image processing with Matlab
• Basics & Examples
What is Matlab?
• Matlab stand for Matrix Laboratory
• Matlab is high-level language
• perform computationally intensive tasks faster
than with traditional programming languages
such as c++
• The help in Matlab is very good, use it!
• Everything is treated as a matrix
The Matlab Environment
• Matlab window components:
• Workspace
• Displays all the defined variables
• Command window
• To execute commands in the Matlab
environment
• File editor window
• Define your functions
Matlab Help
• Matlab help is an extremely powerful assistance
to learning Matlab
• Help not only contains the theoretical
background, but also shows demos for
implementation
• Matlab help can be opened by using the HELP
pull-down menu
Basics syntax
• Comment : ctrl + / OR %
• Uncomment : ctrl + t
• Semicolon : suppress printing
• Arithmetic operators:
+ addition
- subtraction
* multiplication
^ power
' transpose
 left division
/ right division
• Variable :
>> 2 * 25 + 6 * 22 + 100 / 2
ans =
232
>> a = 25; b = 22;
>> d = a * b
ans =
550
sqrt
returns the
square root of
each element of
the array X
abs
absolute value for
real numbers
cos cosine function
sin sin function
exp
exponential
function
• Who, Whos : current variables in the workspace
• Save : save workspace variables to *.mat file
• Load : load variables from *.mat file
• Clear : clear workspace variables
• Clc : clear command window
• Close : closes the current figure window
Vectors and Matrices
• How to build a matrix?
>> a = [1 5 8]
a =
1 5 8
>> a = [ 1 2 3]'
a =
1
2
3
>> a = [ 0:2:4 ; 8:1:10; 35:5:45]
a =
0 2 4
8 9 10
35 40 45
>> a = [1:3; 4:6; 7:9]
a =
1 2 3
4 5 6
7 8 9
• A particular element of a matrix can be
assigned:
>> a(3,2)
ans = 40
• Place the number 5 in the first row, second
column:
• >> a(3,2) = 29
• Operations ad functions that were defined scalars
in the previous section can also be used on
vectors and matrices, For example.
>> a = [ 1 2 3];
>> b = [ 4 5 6];
>> c = a + b
c =
5 7 9
• Special matrices:
• zeros(n,m) : n*m matrix of zeros
• ones(n,m) : n*m matrix of ones
• eye(n) : n*n identity matrix
• rand(n) : n*n random matrix
Flow Control
• Matlab has five flow control constructs:
1. if statement
2. for loop
3. while loop
4. break statement
if
• If statement condition
• The general form of the IF statement is
IF expression
statements
ELSEIF expression
statements
ELSE
statements
END
• Example:
s = input(‘Please enter a scalar value =‘);
if s > 1
error(‘Error!’);
else
disp(‘ok’);
end
for
• FOR repeats statements a specific number of
times
• The general form of a FOR statement is:
FOR variable = expression
statements
END
for i=1:10
x(i) = sin(i * pi / 10);
end;
for i=[ 1, 2, 3, 7]
x(i) = i + 1;
end;
while
• WHILE repeats statements an indefinite number
of times
• The general form of a WHILE statement is:
• WHILE expression
• statements
• END
t = 1;
while t ~= -1
t = input(' enter ..... ');
end
Scripts and Functions
• There are two kinds of M-files:
• scripts, which do not accept input arguments
or return output arguments. They operate on
data in the workspace.
• Functions, which can accept input arguments
and return output arguments. Internal
variables are local to the function.
function
function [ output_args ] = functionName( input_args )
%functionName Summary of this function goes here
% Detailed explanation goes here
end
function Z=fitness(x)
Z=sum(x.^2);
end
Visualization and Graphics
• Plot ( x, y) : plot 1D function
• figure : open a new figure
• hold on, hold off : refreshing
• title(‘figure title) : add title to figure
Image Processing
Matlab and images
• An image in Matlab is treated as a matrix
• Every pixel is a matrix element
Image import and Export
• Read and write images in Matlab:
image = imread(‘image fileName.format');
figure;
imshow(image);
imwrite(image, ‘new image filename.format');
Images and Matrices
row = 256;
col = 256;
img = zeros(row, col);
img(100:105, :) = 0.5;
img(:, 100:105) = 1;
figure;
imshow(img);
Column 1 to 256
Ro
w 1
to
25
6
o
[0, 0]
o
[256, 256]
Histograms
• Frequency of the intensity value of the image
• Quantize frequency into intervals
• Probability density function of image intensities
img = imread(‘image Filename.image format’);
imshow(img);
figure;
imhist(rgb2gray(img));
Image Filtering
• Let’s replace each pixel with a weighted average
of its neighborhood.
• The widths are called the filter kernel
• What are the weighs for the average of a 3*3
neighborhood?
111
111
111
“box filter”
Image Filtering
I = imread(‘filename.format file’);
h = fspecial(‘unsharp’);
I2 = imfilter(I,h);
imshow(I2);
Liner filter
000
010
000
Filtered
(no change)
Original
Liner filter
Shifted left by 1 pixel
Original
000
100
000
Liner filter
Bluer( with box
filter )
Original
111
111
111

Weitere ähnliche Inhalte

Was ist angesagt?

Two Days workshop on MATLAB
Two Days workshop on MATLABTwo Days workshop on MATLAB
Two Days workshop on MATLAB
Bhavesh Shah
 
Variables in matlab
Variables in matlabVariables in matlab
Variables in matlab
TUOS-Sam
 
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)
Hasitha Ediriweera
 
Matlab programming project
Matlab programming projectMatlab programming project
Matlab programming project
Assignmentpedia
 

Was ist angesagt? (20)

ADVANCED WORKSHOP IN MATLAB
ADVANCED WORKSHOP IN MATLABADVANCED WORKSHOP IN MATLAB
ADVANCED WORKSHOP IN MATLAB
 
Digital Image Processing - MATLAB Notes - Akshansh
Digital Image Processing - MATLAB Notes - AkshanshDigital Image Processing - MATLAB Notes - Akshansh
Digital Image Processing - MATLAB Notes - Akshansh
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Matlab
MatlabMatlab
Matlab
 
Summer training matlab
Summer training matlab Summer training matlab
Summer training matlab
 
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
 
Matlab and Image Processing Workshop-SKERG
Matlab and Image Processing Workshop-SKERG Matlab and Image Processing Workshop-SKERG
Matlab and Image Processing Workshop-SKERG
 
2D Plot Matlab
2D Plot Matlab2D Plot Matlab
2D Plot Matlab
 
Image Processing Using MATLAB
Image Processing Using MATLABImage Processing Using MATLAB
Image Processing Using MATLAB
 
Matlab Graphics Tutorial
Matlab Graphics TutorialMatlab Graphics Tutorial
Matlab Graphics Tutorial
 
Two Days workshop on MATLAB
Two Days workshop on MATLABTwo Days workshop on MATLAB
Two Days workshop on MATLAB
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
Basic matlab and matrix
Basic matlab and matrixBasic matlab and matrix
Basic matlab and matrix
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
Getting started with image processing using Matlab
Getting started with image processing using MatlabGetting started with image processing using Matlab
Getting started with image processing using Matlab
 
Variables in matlab
Variables in matlabVariables in matlab
Variables in matlab
 
Digital Image Processing (Lab 08)
Digital Image Processing (Lab 08)Digital Image Processing (Lab 08)
Digital Image Processing (Lab 08)
 
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)
 
Image processing using matlab
Image processing using matlab Image processing using matlab
Image processing using matlab
 
Matlab programming project
Matlab programming projectMatlab programming project
Matlab programming project
 

Andere mochten auch

Image proceesing with matlab
Image proceesing with matlabImage proceesing with matlab
Image proceesing with matlab
Ashutosh Shahi
 

Andere mochten auch (9)

Image proceesing with matlab
Image proceesing with matlabImage proceesing with matlab
Image proceesing with matlab
 
Introduction to Digital Image Processing Using MATLAB
Introduction to Digital Image Processing Using MATLABIntroduction to Digital Image Processing Using MATLAB
Introduction to Digital Image Processing Using MATLAB
 
Mex help
Mex helpMex help
Mex help
 
Image processing using matlab
Image processing using matlabImage processing using matlab
Image processing using matlab
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLAB
 
C,C++ In Matlab
C,C++ In MatlabC,C++ In Matlab
C,C++ In Matlab
 
IMAGE PROCESSING
IMAGE PROCESSINGIMAGE PROCESSING
IMAGE PROCESSING
 
Color based image processing , tracking and automation using matlab
Color based image processing , tracking and automation using matlabColor based image processing , tracking and automation using matlab
Color based image processing , tracking and automation using matlab
 
Digital image processing using matlab
Digital image processing using matlab Digital image processing using matlab
Digital image processing using matlab
 

Ähnlich wie Image processing

INTRODUCTION TO MATLAB for PG students.ppt
INTRODUCTION TO MATLAB for PG students.pptINTRODUCTION TO MATLAB for PG students.ppt
INTRODUCTION TO MATLAB for PG students.ppt
Karthik537368
 

Ähnlich wie Image processing (20)

Matlab Tutorial.ppt
Matlab Tutorial.pptMatlab Tutorial.ppt
Matlab Tutorial.ppt
 
Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshop
 
INTRODUCTION TO MATLAB for PG students.ppt
INTRODUCTION TO MATLAB for PG students.pptINTRODUCTION TO MATLAB for PG students.ppt
INTRODUCTION TO MATLAB for PG students.ppt
 
TRAINING PROGRAMME ON MATLAB ASSOCIATE EXAM (1).pptx
TRAINING PROGRAMME ON MATLAB  ASSOCIATE EXAM (1).pptxTRAINING PROGRAMME ON MATLAB  ASSOCIATE EXAM (1).pptx
TRAINING PROGRAMME ON MATLAB ASSOCIATE EXAM (1).pptx
 
MATLAB_CIS601-03.ppt
MATLAB_CIS601-03.pptMATLAB_CIS601-03.ppt
MATLAB_CIS601-03.ppt
 
Introduction to Matlab.ppt
Introduction to Matlab.pptIntroduction to Matlab.ppt
Introduction to Matlab.ppt
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Lines and planes in space
Lines and planes in spaceLines and planes in space
Lines and planes in space
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
Matlab pt1
Matlab pt1Matlab pt1
Matlab pt1
 
MatlabIntro (1).ppt
MatlabIntro (1).pptMatlabIntro (1).ppt
MatlabIntro (1).ppt
 
Mit6 094 iap10_lec05
Mit6 094 iap10_lec05Mit6 094 iap10_lec05
Mit6 094 iap10_lec05
 
From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyond
 
Matlab anilkumar
Matlab  anilkumarMatlab  anilkumar
Matlab anilkumar
 
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxMATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
 
Matlab-1.pptx
Matlab-1.pptxMatlab-1.pptx
Matlab-1.pptx
 
Mbd2
Mbd2Mbd2
Mbd2
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 

Kürzlich hochgeladen

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Kürzlich hochgeladen (20)

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 

Image processing

  • 1. Image processing using Matlab Author : Pooya Sagharchi Ha
  • 2. Agenda • Introduction to Matlab • Basics & Examples • Image processing with Matlab • Basics & Examples
  • 3. What is Matlab? • Matlab stand for Matrix Laboratory • Matlab is high-level language • perform computationally intensive tasks faster than with traditional programming languages such as c++ • The help in Matlab is very good, use it! • Everything is treated as a matrix
  • 4. The Matlab Environment • Matlab window components: • Workspace • Displays all the defined variables • Command window • To execute commands in the Matlab environment • File editor window • Define your functions
  • 5. Matlab Help • Matlab help is an extremely powerful assistance to learning Matlab • Help not only contains the theoretical background, but also shows demos for implementation • Matlab help can be opened by using the HELP pull-down menu
  • 6. Basics syntax • Comment : ctrl + / OR % • Uncomment : ctrl + t • Semicolon : suppress printing • Arithmetic operators: + addition - subtraction * multiplication ^ power ' transpose left division / right division
  • 7. • Variable : >> 2 * 25 + 6 * 22 + 100 / 2 ans = 232 >> a = 25; b = 22; >> d = a * b ans = 550 sqrt returns the square root of each element of the array X abs absolute value for real numbers cos cosine function sin sin function exp exponential function
  • 8. • Who, Whos : current variables in the workspace • Save : save workspace variables to *.mat file • Load : load variables from *.mat file • Clear : clear workspace variables • Clc : clear command window • Close : closes the current figure window
  • 9. Vectors and Matrices • How to build a matrix? >> a = [1 5 8] a = 1 5 8 >> a = [ 1 2 3]' a = 1 2 3
  • 10. >> a = [ 0:2:4 ; 8:1:10; 35:5:45] a = 0 2 4 8 9 10 35 40 45 >> a = [1:3; 4:6; 7:9] a = 1 2 3 4 5 6 7 8 9
  • 11. • A particular element of a matrix can be assigned: >> a(3,2) ans = 40 • Place the number 5 in the first row, second column: • >> a(3,2) = 29
  • 12. • Operations ad functions that were defined scalars in the previous section can also be used on vectors and matrices, For example. >> a = [ 1 2 3]; >> b = [ 4 5 6]; >> c = a + b c = 5 7 9
  • 13. • Special matrices: • zeros(n,m) : n*m matrix of zeros • ones(n,m) : n*m matrix of ones • eye(n) : n*n identity matrix • rand(n) : n*n random matrix
  • 14. Flow Control • Matlab has five flow control constructs: 1. if statement 2. for loop 3. while loop 4. break statement
  • 15. if • If statement condition • The general form of the IF statement is IF expression statements ELSEIF expression statements ELSE statements END
  • 16. • Example: s = input(‘Please enter a scalar value =‘); if s > 1 error(‘Error!’); else disp(‘ok’); end
  • 17. for • FOR repeats statements a specific number of times • The general form of a FOR statement is: FOR variable = expression statements END
  • 18. for i=1:10 x(i) = sin(i * pi / 10); end; for i=[ 1, 2, 3, 7] x(i) = i + 1; end;
  • 19. while • WHILE repeats statements an indefinite number of times • The general form of a WHILE statement is: • WHILE expression • statements • END
  • 20. t = 1; while t ~= -1 t = input(' enter ..... '); end
  • 21. Scripts and Functions • There are two kinds of M-files: • scripts, which do not accept input arguments or return output arguments. They operate on data in the workspace. • Functions, which can accept input arguments and return output arguments. Internal variables are local to the function.
  • 22. function function [ output_args ] = functionName( input_args ) %functionName Summary of this function goes here % Detailed explanation goes here end
  • 24. Visualization and Graphics • Plot ( x, y) : plot 1D function • figure : open a new figure • hold on, hold off : refreshing • title(‘figure title) : add title to figure
  • 26. Matlab and images • An image in Matlab is treated as a matrix • Every pixel is a matrix element
  • 27. Image import and Export • Read and write images in Matlab: image = imread(‘image fileName.format'); figure; imshow(image); imwrite(image, ‘new image filename.format');
  • 28. Images and Matrices row = 256; col = 256; img = zeros(row, col); img(100:105, :) = 0.5; img(:, 100:105) = 1; figure; imshow(img); Column 1 to 256 Ro w 1 to 25 6 o [0, 0] o [256, 256]
  • 29. Histograms • Frequency of the intensity value of the image • Quantize frequency into intervals • Probability density function of image intensities
  • 30. img = imread(‘image Filename.image format’); imshow(img); figure; imhist(rgb2gray(img));
  • 31. Image Filtering • Let’s replace each pixel with a weighted average of its neighborhood. • The widths are called the filter kernel • What are the weighs for the average of a 3*3 neighborhood? 111 111 111 “box filter”
  • 32. Image Filtering I = imread(‘filename.format file’); h = fspecial(‘unsharp’); I2 = imfilter(I,h); imshow(I2);
  • 34. Liner filter Shifted left by 1 pixel Original 000 100 000
  • 35. Liner filter Bluer( with box filter ) Original 111 111 111