SlideShare a Scribd company logo
1 of 43
Introduction to MATLAB and
      image processing
                 Amin Allalou
                amin@cb.uu.se

            Centre for Image Analysis
               Uppsala University

        Computer Assisted Image Analysis
                 April 4 2008
MATLAB and images
•   The help in MATLAB is very good, use it!
•   An image in MATLAB is treated as a matrix
•   Every pixel is a matrix element
•   All the operators in MATLAB defined on
    matrices can be used on images: +, -, *, /, ^, sqrt, sin, cos etc.
Images in MATLAB
•   MATLAB can import/export               •   Data types in MATLAB
    several image formats                      – Double (64-bit double-precision
    –   BMP (Microsoft Windows Bitmap)           floating point)
    –   GIF (Graphics Interchange Files)       – Single (32-bit single-precision
    –                                            floating point)
        HDF (Hierarchical Data Format)
                                               – Int32 (32-bit signed integer)
    –   JPEG (Joint Photographic Experts
        Group)                                 – Int16 (16-bit signed integer)
    –   PCX (Paintbrush)                       – Int8 (8-bit signed integer)
    –   PNG (Portable Network Graphics)        – Uint32 (32-bit unsigned integer)
    –   TIFF (Tagged Image File Format)        – Uint16 (16-bit unsigned integer)
    –   XWD (X Window Dump)                    – Uint8 (8-bit unsigned integer)
    –   MATLAB can also load raw-data or
        other types of image data
Images in MATLAB
• Binary images : {0,1}
• Intensity images : [0,1] or uint8, double etc.
• RGB images : m-by-n-by-3
• Indexed images : m-by-3 color map
• Multidimensional images m-by-n-by-p (p is the number of layers)
Image import and export
•   Read and write images in Matlab
    >> I=imread('cells.jpg');
    >> imshow(I)
    >> size(I)
    ans = 479 600 3                (RGB image)
    >> Igrey=rgb2gray(I);
    >> imshow(Igrey)
    >> imwrite(lgrey, 'cell_gray.tif', 'tiff')


Alternatives to imshow
    >>imagesc(I)
    >>imtool(I)
    >>image(I)
Images and Matrices
•   How to build a matrix (or image)?
    >> A = [ 1 2 3; 4 5 6; 7 8 9 ];
    A= 1 2 3
          4 5 6
          7 8 9
    >> B = zeros(3,3)
    B= 0 0 0
          0 0 0
          0 0 0
    >> C = ones(3,3)
    C= 1 1 1
          1 1 1
          1 1 1

    >>imshow(A) (imshow(A,[]) to get automatic pixel range)
Images and Matrices
•   Accesing image elements (row, column)          X
    >> A(2,1)
    ans = 4
•   : can be used to extract a whole column or
    row                                        Y
    >> A(:,2)
    ans =
    2
    5
    8
•    or a part of a column or row                  A=
     >> A(1:2,2)                                   22 3
    ans =                                          35 6
    2                                              7 8 9
    5
Image Arithmetic
•   Arithmetic operations such as addition, subtraction, multiplication and
    division can be applied to images in MATLAB
     – +, -, *, / performs matrix operations
    >> A+A
    ans = 2 4 6
           8 10 12                                                        A=
           14 16 18
                                                                          22 3
    >> A*A
                                                                          35 6
    ans = 30 36 42
                                                                          7 8 9
           66 81 96
          102 126 150

•   To perform an elementwise operation use . (.*, ./, .*, .^ etc)
    >> A.*A
    ans = 1 4 9
           16 25 36
           49 64 81
Logical Conditions
•   equal (==) , less than and greater than (< and >), not equal (~=) and not (~)
•   find(‘condition’) - Returns indexes of A’s elements that satisfies the
    condition.
    >> [row col]=find(A==7)
                                                           A=
    row = 3
                                                           22 3
    col = 1
                                                           35 6
    >> [row col]=find(A>7)
                                                           7 8 9
    row = 3
             3
    col = 2
             3
    >> Indx=find(A<5)
    Indx = 1
           2
           4
           7
Flow Control
•   Flow control in MATLAB
    - if, else and elseif statements
    (row=1,2,3 col=1,2,3)
    if row==col
            A(row, col)=1;
    elseif abs(row-col)==1
            A(row, col)=2;             A=
    else
                                        1   2   0
            A(row, col)=0;              2   1   2
    end                                 0   2   1
Flow Control
•   Flow control in MATLAB
    - for loops

    for row=1:3
          for col=1:3
                    if row==col
                              A(row, col)=1;
                    elseif abs(row-col)==1     A=
                              A(row, col)=2;
                    else                        1   2   0
                                                2   1   2
                              A(row, col)=0;    0   2   1
                    end
          end
    end
Flow Control
•   while, expression, statements, end   A=
                                         22 3
    Indx=1;                              35 6
                                         7 8 9
    while A(Indx)<6
          A(Indx)=0;
          Indx=Indx+1;
     end


     A=

       0   2   3
       0   5   6
       7   8   9
Working with M-Files
•   M-files can be scripts that simply execute a series of MATLAB statements,
    or they can be functions that also accept input arguments and produce
    output.
•   MATLAB functions:
     – Are useful for extending the MATLAB language for your application.
     – Can accept input arguments and return output arguments.
     – Store variables in a workspace internal to the function.
Working with M-Files
•   Create a new empty m-file

    function B=test(I)
    [row col]=size(I)
    for r=1:row
          for c=1:col
                    if r==c
                              A(r, c)=1;
                    elseif abs(r-c)==1
                              A(r, c)=2;
                    else
                              A(r, c)=0;
                    end
          end
   end
B=A;
Linear Systems
Superposition theorem




•   The superposition theorem for electrical circuits states that for a linear system the response (
    Voltage or Current) in any branch of a bilateral linear circuit having more than one independent
    source equals the algebraic sum of the responses caused by each independent source acting alone,
    while all other independent sources are replaced by their internal impedances.
Requirements for Linearity
• A system is called linear if it has two
  mathematical properties:
2.Homogeneity
3.Additivity
4.Shift invariance
(where “Shift invariance” is not a strict
  requirement for linearity, but it is a
  mandatory property for most DSP
  techniques.)
Homogeneity
Additivity
Shift invariance
Superposition: the Foundation of DSP
Decomposition & Convolution
• While many different decompositions are
  possible, two form the backbone of signal
  processing:
2.Impulse decomposition
3.Fourier decomposition.
• When impulse decomposition is used, the
  procedure can be described by a
  mathematical operation called convolution.
Definition of delta function (unit
impulse) and impulse response
Shifted & Scaled Delta function
Convolution




If the system being considered is a filter, the impulse
   response is      called the filter kernel, the
   convolution kernel, or simply, the kernel. In
   image processing, the impulse response is called
   the point spread function.
Correlation
Correlation
Correlation is a mathematical operation that is
   very similar to convolution.
Just as with convolution, correlation uses two
   signals to produce a third signal.
This third signal is called the cross-correlation of
   the two input signals.
If a signal is correlated with itself, the resulting
   signal is instead called the autocorrelation.
Correlation


The formula essentially slides the function along
  the x-axis, calculating the integral of their
  product at each position. When the functions
  match, the value of is maximized. This is because
  when peaks (positive areas) are aligned, they
  make a large contribution to the integral.
  Similarly, when troughs (negative areas) align,
  they also make a positive contribution to the
  integral because the product of two negative
  numbers is positive
Convolution In MATLAB
• Linear filtering of an image is accomplished
  through an operation called convolution.
  Convolution is a neighborhood operation in
  which each output pixel is the weighted sum
  of neighboring input pixels. The matrix of
  weights is called the convolution kernel, also
  known as the filter. A convolution kernel is a
  correlation kernel that has been rotated 180
  degrees.
Go to Matlab …..
Thanks,,,

More Related Content

What's hot

Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Randa Elanwar
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programmingDamian T. Gordon
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMohd Esa
 
Matlab Overviiew
Matlab OverviiewMatlab Overviiew
Matlab OverviiewNazim Naeem
 
Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Randa Elanwar
 
Matlab tme series benni
Matlab tme series benniMatlab tme series benni
Matlab tme series bennidvbtunisia
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsMukesh Kumar
 
A Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in MatlabA Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in MatlabaiQUANT
 
MatLab Basic Tutorial On Plotting
MatLab Basic Tutorial On PlottingMatLab Basic Tutorial On Plotting
MatLab Basic Tutorial On PlottingMOHDRAFIQ22
 
Simple Scala DSLs
Simple Scala DSLsSimple Scala DSLs
Simple Scala DSLslinxbetter
 
Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsRay Phan
 
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical ComputingNaveed Rehman
 

What's hot (20)

Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Matlab Workshop Presentation
Matlab Workshop PresentationMatlab Workshop Presentation
Matlab Workshop Presentation
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programming
 
Matlab lec1
Matlab lec1Matlab lec1
Matlab lec1
 
Matlab/R Dictionary
Matlab/R DictionaryMatlab/R Dictionary
Matlab/R Dictionary
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
Matlab Overviiew
Matlab OverviiewMatlab Overviiew
Matlab Overviiew
 
Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4
 
Matlab tme series benni
Matlab tme series benniMatlab tme series benni
Matlab tme series benni
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projects
 
A Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in MatlabA Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in Matlab
 
MatLab Basic Tutorial On Plotting
MatLab Basic Tutorial On PlottingMatLab Basic Tutorial On Plotting
MatLab Basic Tutorial On Plotting
 
Simple Scala DSLs
Simple Scala DSLsSimple Scala DSLs
Simple Scala DSLs
 
Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & Scientists
 
matlab
matlabmatlab
matlab
 
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical Computing
 
Matlab Tutorial
Matlab TutorialMatlab Tutorial
Matlab Tutorial
 
2D Plot Matlab
2D Plot Matlab2D Plot Matlab
2D Plot Matlab
 

Viewers also liked

Laboratory manual
Laboratory manualLaboratory manual
Laboratory manualAsif Rana
 
Monte Carlo Simulation Of Heston Model In Matlab(1)
Monte Carlo Simulation Of Heston Model In Matlab(1)Monte Carlo Simulation Of Heston Model In Matlab(1)
Monte Carlo Simulation Of Heston Model In Matlab(1)Amir Kheirollah
 
Matlab for diploma students(1)
Matlab for diploma students(1)Matlab for diploma students(1)
Matlab for diploma students(1)Retheesh Raj
 
Ch9 failure mechanisms
Ch9 failure mechanismsCh9 failure mechanisms
Ch9 failure mechanismsdhyun
 
BAKER DONELSON - INVISIBLE PRACTICES - PULLING THE STRINGS BEHIND-THE-SCENE P...
BAKER DONELSON - INVISIBLE PRACTICES - PULLING THE STRINGS BEHIND-THE-SCENE P...BAKER DONELSON - INVISIBLE PRACTICES - PULLING THE STRINGS BEHIND-THE-SCENE P...
BAKER DONELSON - INVISIBLE PRACTICES - PULLING THE STRINGS BEHIND-THE-SCENE P...VogelDenise
 
092712 julian assange (president obama's audacity) - haitian creole
092712   julian assange (president obama's audacity) - haitian creole092712   julian assange (president obama's audacity) - haitian creole
092712 julian assange (president obama's audacity) - haitian creoleVogelDenise
 
031808 obama speech (serbian)
031808   obama speech (serbian)031808   obama speech (serbian)
031808 obama speech (serbian)VogelDenise
 
082512 us supreme court response (serbian)
082512   us supreme court response (serbian)082512   us supreme court response (serbian)
082512 us supreme court response (serbian)VogelDenise
 
031808 obama speech (armenian)
031808   obama speech (armenian)031808   obama speech (armenian)
031808 obama speech (armenian)VogelDenise
 
092712 julian assange (president obama's audacity) - bengali
092712   julian assange (president obama's audacity) - bengali092712   julian assange (president obama's audacity) - bengali
092712 julian assange (president obama's audacity) - bengaliVogelDenise
 
Obama us wars used to train white supremacist (hebrew)
Obama   us wars used to train white supremacist (hebrew)Obama   us wars used to train white supremacist (hebrew)
Obama us wars used to train white supremacist (hebrew)VogelDenise
 
100112 obama reality check (update)-chinese traditional
100112 obama   reality check (update)-chinese traditional100112 obama   reality check (update)-chinese traditional
100112 obama reality check (update)-chinese traditionalVogelDenise
 
092812 david addington article (persian)
092812   david addington article (persian)092812   david addington article (persian)
092812 david addington article (persian)VogelDenise
 
031808 obama speech (hebrew)
031808   obama speech (hebrew)031808   obama speech (hebrew)
031808 obama speech (hebrew)VogelDenise
 
04/14/13 PUBLIC NOTICE (03/11/13 FAX TO BARACK OBAMA) - indonesian
04/14/13  PUBLIC NOTICE (03/11/13 FAX TO BARACK OBAMA) - indonesian04/14/13  PUBLIC NOTICE (03/11/13 FAX TO BARACK OBAMA) - indonesian
04/14/13 PUBLIC NOTICE (03/11/13 FAX TO BARACK OBAMA) - indonesianVogelDenise
 
021013 adecco email (serbian)
021013   adecco email (serbian)021013   adecco email (serbian)
021013 adecco email (serbian)VogelDenise
 
George zimmerman's not guilty (persian)
George zimmerman's not guilty (persian)George zimmerman's not guilty (persian)
George zimmerman's not guilty (persian)VogelDenise
 
071310 obama email (slovak)
071310   obama email (slovak)071310   obama email (slovak)
071310 obama email (slovak)VogelDenise
 
Δήμος Χερσονήσου Απολογισμός 2011-2014
Δήμος Χερσονήσου Απολογισμός 2011-2014Δήμος Χερσονήσου Απολογισμός 2011-2014
Δήμος Χερσονήσου Απολογισμός 2011-2014My Chersonissos
 

Viewers also liked (20)

Correlation
CorrelationCorrelation
Correlation
 
Laboratory manual
Laboratory manualLaboratory manual
Laboratory manual
 
Monte Carlo Simulation Of Heston Model In Matlab(1)
Monte Carlo Simulation Of Heston Model In Matlab(1)Monte Carlo Simulation Of Heston Model In Matlab(1)
Monte Carlo Simulation Of Heston Model In Matlab(1)
 
Matlab for diploma students(1)
Matlab for diploma students(1)Matlab for diploma students(1)
Matlab for diploma students(1)
 
Ch9 failure mechanisms
Ch9 failure mechanismsCh9 failure mechanisms
Ch9 failure mechanisms
 
BAKER DONELSON - INVISIBLE PRACTICES - PULLING THE STRINGS BEHIND-THE-SCENE P...
BAKER DONELSON - INVISIBLE PRACTICES - PULLING THE STRINGS BEHIND-THE-SCENE P...BAKER DONELSON - INVISIBLE PRACTICES - PULLING THE STRINGS BEHIND-THE-SCENE P...
BAKER DONELSON - INVISIBLE PRACTICES - PULLING THE STRINGS BEHIND-THE-SCENE P...
 
092712 julian assange (president obama's audacity) - haitian creole
092712   julian assange (president obama's audacity) - haitian creole092712   julian assange (president obama's audacity) - haitian creole
092712 julian assange (president obama's audacity) - haitian creole
 
031808 obama speech (serbian)
031808   obama speech (serbian)031808   obama speech (serbian)
031808 obama speech (serbian)
 
082512 us supreme court response (serbian)
082512   us supreme court response (serbian)082512   us supreme court response (serbian)
082512 us supreme court response (serbian)
 
031808 obama speech (armenian)
031808   obama speech (armenian)031808   obama speech (armenian)
031808 obama speech (armenian)
 
092712 julian assange (president obama's audacity) - bengali
092712   julian assange (president obama's audacity) - bengali092712   julian assange (president obama's audacity) - bengali
092712 julian assange (president obama's audacity) - bengali
 
Obama us wars used to train white supremacist (hebrew)
Obama   us wars used to train white supremacist (hebrew)Obama   us wars used to train white supremacist (hebrew)
Obama us wars used to train white supremacist (hebrew)
 
100112 obama reality check (update)-chinese traditional
100112 obama   reality check (update)-chinese traditional100112 obama   reality check (update)-chinese traditional
100112 obama reality check (update)-chinese traditional
 
092812 david addington article (persian)
092812   david addington article (persian)092812   david addington article (persian)
092812 david addington article (persian)
 
031808 obama speech (hebrew)
031808   obama speech (hebrew)031808   obama speech (hebrew)
031808 obama speech (hebrew)
 
04/14/13 PUBLIC NOTICE (03/11/13 FAX TO BARACK OBAMA) - indonesian
04/14/13  PUBLIC NOTICE (03/11/13 FAX TO BARACK OBAMA) - indonesian04/14/13  PUBLIC NOTICE (03/11/13 FAX TO BARACK OBAMA) - indonesian
04/14/13 PUBLIC NOTICE (03/11/13 FAX TO BARACK OBAMA) - indonesian
 
021013 adecco email (serbian)
021013   adecco email (serbian)021013   adecco email (serbian)
021013 adecco email (serbian)
 
George zimmerman's not guilty (persian)
George zimmerman's not guilty (persian)George zimmerman's not guilty (persian)
George zimmerman's not guilty (persian)
 
071310 obama email (slovak)
071310   obama email (slovak)071310   obama email (slovak)
071310 obama email (slovak)
 
Δήμος Χερσονήσου Απολογισμός 2011-2014
Δήμος Χερσονήσου Απολογισμός 2011-2014Δήμος Χερσονήσου Απολογισμός 2011-2014
Δήμος Χερσονήσου Απολογισμός 2011-2014
 

Similar to Intro matlab and convolution islam

Summer training matlab
Summer training matlab Summer training matlab
Summer training matlab Arshit Rai
 
Summer training matlab
Summer training matlab Summer training matlab
Summer training matlab Arshit Rai
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.pptkebeAman
 
Lecture1_computer vision-2023.pdf
Lecture1_computer vision-2023.pdfLecture1_computer vision-2023.pdf
Lecture1_computer vision-2023.pdfssuserff72e4
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxDevaraj Chilakala
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABFundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABAli Ghanbarzadeh
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxmydrynan
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxagnesdcarey33086
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functionsjoellivz
 
Lines and planes in space
Lines and planes in spaceLines and planes in space
Lines and planes in spaceFaizan Shabbir
 
Matlab intro
Matlab introMatlab intro
Matlab introfvijayami
 
1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptxBeheraA
 

Similar to Intro matlab and convolution islam (20)

Intro matlab
Intro matlabIntro matlab
Intro matlab
 
Summer training matlab
Summer training matlab Summer training matlab
Summer training matlab
 
MATLAB & Image Processing
MATLAB & Image ProcessingMATLAB & Image Processing
MATLAB & Image Processing
 
Summer training matlab
Summer training matlab Summer training matlab
Summer training matlab
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 
Lecture1_computer vision-2023.pdf
Lecture1_computer vision-2023.pdfLecture1_computer vision-2023.pdf
Lecture1_computer vision-2023.pdf
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABFundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLAB
 
Matlab-1.pptx
Matlab-1.pptxMatlab-1.pptx
Matlab-1.pptx
 
Intro to matlab
Intro to matlabIntro to matlab
Intro to matlab
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
Lines and planes in space
Lines and planes in spaceLines and planes in space
Lines and planes in space
 
Mat lab
Mat labMat lab
Mat lab
 
MATLABgraphPlotting.pptx
MATLABgraphPlotting.pptxMATLABgraphPlotting.pptx
MATLABgraphPlotting.pptx
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx
 
Matlab1
Matlab1Matlab1
Matlab1
 

Recently uploaded

WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseWSO2
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceIES VE
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Recently uploaded (20)

WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Intro matlab and convolution islam

  • 1. Introduction to MATLAB and image processing Amin Allalou amin@cb.uu.se Centre for Image Analysis Uppsala University Computer Assisted Image Analysis April 4 2008
  • 2. MATLAB and images • The help in MATLAB is very good, use it! • An image in MATLAB is treated as a matrix • Every pixel is a matrix element • All the operators in MATLAB defined on matrices can be used on images: +, -, *, /, ^, sqrt, sin, cos etc.
  • 3. Images in MATLAB • MATLAB can import/export • Data types in MATLAB several image formats – Double (64-bit double-precision – BMP (Microsoft Windows Bitmap) floating point) – GIF (Graphics Interchange Files) – Single (32-bit single-precision – floating point) HDF (Hierarchical Data Format) – Int32 (32-bit signed integer) – JPEG (Joint Photographic Experts Group) – Int16 (16-bit signed integer) – PCX (Paintbrush) – Int8 (8-bit signed integer) – PNG (Portable Network Graphics) – Uint32 (32-bit unsigned integer) – TIFF (Tagged Image File Format) – Uint16 (16-bit unsigned integer) – XWD (X Window Dump) – Uint8 (8-bit unsigned integer) – MATLAB can also load raw-data or other types of image data
  • 4. Images in MATLAB • Binary images : {0,1} • Intensity images : [0,1] or uint8, double etc. • RGB images : m-by-n-by-3 • Indexed images : m-by-3 color map • Multidimensional images m-by-n-by-p (p is the number of layers)
  • 5. Image import and export • Read and write images in Matlab >> I=imread('cells.jpg'); >> imshow(I) >> size(I) ans = 479 600 3 (RGB image) >> Igrey=rgb2gray(I); >> imshow(Igrey) >> imwrite(lgrey, 'cell_gray.tif', 'tiff') Alternatives to imshow >>imagesc(I) >>imtool(I) >>image(I)
  • 6. Images and Matrices • How to build a matrix (or image)? >> A = [ 1 2 3; 4 5 6; 7 8 9 ]; A= 1 2 3 4 5 6 7 8 9 >> B = zeros(3,3) B= 0 0 0 0 0 0 0 0 0 >> C = ones(3,3) C= 1 1 1 1 1 1 1 1 1 >>imshow(A) (imshow(A,[]) to get automatic pixel range)
  • 7. Images and Matrices • Accesing image elements (row, column) X >> A(2,1) ans = 4 • : can be used to extract a whole column or row Y >> A(:,2) ans = 2 5 8 • or a part of a column or row A= >> A(1:2,2) 22 3 ans = 35 6 2 7 8 9 5
  • 8. Image Arithmetic • Arithmetic operations such as addition, subtraction, multiplication and division can be applied to images in MATLAB – +, -, *, / performs matrix operations >> A+A ans = 2 4 6 8 10 12 A= 14 16 18 22 3 >> A*A 35 6 ans = 30 36 42 7 8 9 66 81 96 102 126 150 • To perform an elementwise operation use . (.*, ./, .*, .^ etc) >> A.*A ans = 1 4 9 16 25 36 49 64 81
  • 9. Logical Conditions • equal (==) , less than and greater than (< and >), not equal (~=) and not (~) • find(‘condition’) - Returns indexes of A’s elements that satisfies the condition. >> [row col]=find(A==7) A= row = 3 22 3 col = 1 35 6 >> [row col]=find(A>7) 7 8 9 row = 3 3 col = 2 3 >> Indx=find(A<5) Indx = 1 2 4 7
  • 10. Flow Control • Flow control in MATLAB - if, else and elseif statements (row=1,2,3 col=1,2,3) if row==col A(row, col)=1; elseif abs(row-col)==1 A(row, col)=2; A= else 1 2 0 A(row, col)=0; 2 1 2 end 0 2 1
  • 11. Flow Control • Flow control in MATLAB - for loops for row=1:3 for col=1:3 if row==col A(row, col)=1; elseif abs(row-col)==1 A= A(row, col)=2; else 1 2 0 2 1 2 A(row, col)=0; 0 2 1 end end end
  • 12. Flow Control • while, expression, statements, end A= 22 3 Indx=1; 35 6 7 8 9 while A(Indx)<6 A(Indx)=0; Indx=Indx+1; end A= 0 2 3 0 5 6 7 8 9
  • 13. Working with M-Files • M-files can be scripts that simply execute a series of MATLAB statements, or they can be functions that also accept input arguments and produce output. • MATLAB functions: – Are useful for extending the MATLAB language for your application. – Can accept input arguments and return output arguments. – Store variables in a workspace internal to the function.
  • 14. Working with M-Files • Create a new empty m-file function B=test(I) [row col]=size(I) for r=1:row for c=1:col if r==c A(r, c)=1; elseif abs(r-c)==1 A(r, c)=2; else A(r, c)=0; end end end B=A;
  • 15.
  • 16.
  • 17.
  • 19.
  • 20. Superposition theorem • The superposition theorem for electrical circuits states that for a linear system the response ( Voltage or Current) in any branch of a bilateral linear circuit having more than one independent source equals the algebraic sum of the responses caused by each independent source acting alone, while all other independent sources are replaced by their internal impedances.
  • 21. Requirements for Linearity • A system is called linear if it has two mathematical properties: 2.Homogeneity 3.Additivity 4.Shift invariance (where “Shift invariance” is not a strict requirement for linearity, but it is a mandatory property for most DSP techniques.)
  • 26.
  • 27.
  • 28. Decomposition & Convolution • While many different decompositions are possible, two form the backbone of signal processing: 2.Impulse decomposition 3.Fourier decomposition. • When impulse decomposition is used, the procedure can be described by a mathematical operation called convolution.
  • 29.
  • 30. Definition of delta function (unit impulse) and impulse response
  • 31. Shifted & Scaled Delta function
  • 32. Convolution If the system being considered is a filter, the impulse response is called the filter kernel, the convolution kernel, or simply, the kernel. In image processing, the impulse response is called the point spread function.
  • 34. Correlation Correlation is a mathematical operation that is very similar to convolution. Just as with convolution, correlation uses two signals to produce a third signal. This third signal is called the cross-correlation of the two input signals. If a signal is correlated with itself, the resulting signal is instead called the autocorrelation.
  • 35. Correlation The formula essentially slides the function along the x-axis, calculating the integral of their product at each position. When the functions match, the value of is maximized. This is because when peaks (positive areas) are aligned, they make a large contribution to the integral. Similarly, when troughs (negative areas) align, they also make a positive contribution to the integral because the product of two negative numbers is positive
  • 36. Convolution In MATLAB • Linear filtering of an image is accomplished through an operation called convolution. Convolution is a neighborhood operation in which each output pixel is the weighted sum of neighboring input pixels. The matrix of weights is called the convolution kernel, also known as the filter. A convolution kernel is a correlation kernel that has been rotated 180 degrees.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42. Go to Matlab …..