matlab presentation for upload

Upload: ashutosh-agarwal

Post on 05-Apr-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Matlab Presentation for Upload

    1/43

    TITLE SLIDE

    Introduction to MATLAB and its ComputationalPowers in Image Processing

    By :-

    blue ink infotech pvt. ltd.

    www.blueink.inJoin us at facebook:-

    blueink infotech

  • 8/2/2019 Matlab Presentation for Upload

    2/43

    COMPANY INTRODUCTION

    blue ink infotech pvt. ltd. has started itsjourney in early 2008. Blue Ink is an incubateecompany of Technology Business Incubator,

    KIET. Companys work domains are software

    development, web development, projectdevelopment and training, e-learning and

    content management, Embedded Systems.

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    3/43

    Outline

    Part I: Introduction and Overview (Case Study) Part II: MATLAB Desktop

    Part III: Types of Files

    Part IV: Matrix Manipulations, CommonFunctions, Plots in MATLAB

    Part V: Image Processing Commands

    Part VI: Model Demonstration

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    4/43

    What is MATLAB?

    MATLAB (MATrix LABoratory) is a high-performance language fortechnical computing. It is an interactive system whose basic dataelement is an array that does not require dimensioning. Allows tosolve many technical computing problems, examples of whichinclude:

    Matrix manipulation

    Finding the roots of polynomials Digital signal processing applications (toolbox) Plotting: x-y and polar, 3D graphics

    Particularly helpful for: Algorithm development, Modeling, simulation, and prototyping,

    Data acquisition Data analysis, exploration, and visualization, Application development, including graphical user interface building.

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    5/43

    Levels of Image Processing

    There are no clear-cut boundaries in thecontinuum from image processing at one endto computer vision at the other. However, a

    useful paradigm is to consider thee types ofcomputerized processes:

    Low level processes

    Mid level processes

    High level processes

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    6/43

    Low level processes

    A low level processes involve primitive operations, such asimage preprocessing to reduce noise, contrastenhancement, and image sharpening. A low-level process ischaracterized by the fact that both its inputs and outputstypically are images.

    Mid-level processes on images involve tasks such assegmentation (partit ioning an image into regions orobjects), description of those objects to reduce them to aform suitable for computer processing, and classification(recognition) of individual objects. A mid-level process ischaracterized by the fact that its inputs generally are

    images, but its outputs are attributes extracted from thoseimages (e.g. edges, contours, and the identity of individualobjects).

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    7/43

    High Level Processes

    High level processing involves making senseof an ensemble of recognized objects, as inimage analysis, and, at far end of continuum,

    performing the cognit ive functions normallyassociated with human vision.

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    8/43

    Applications of Image Processing

    Weather forcasting

    Machine vision measuring distance of objects

    Object detection

    Finding an odd product on the conveyor belt

    VIDEO DEMO

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    9/43

    MATLAB System

    MATLAB system consists of five main parts Development Environment

    Set of tools and facilities that help you use MATLAB functions andfiles.

    MATLAB Mathematical Function Library Collection of functions like sum, sine, cosine, and complex

    arithmetic, matrix inverse, matrix eigenvalues, and fast Fouriertransforms.

    The MATLAB Language High-level matrix/array language with control flow statements,

    functions, data structures, input/output, and object-orientedprogramming features.

    Graphics Provides extensive facilities for displaying vectors and matrices as

    graphs, as well as annotating and print ing these graphs.

    Application Program Interface (API)

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    10/43

    MATLAB DesktopWhen you start MATLAB, MATLAB desktop appears,containing tools (graphical user interfaces) for managingfiles, variables, and applications associated with MATLAB.

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    11/43

    Help in MATLAB

    >> help Shows help document for a given functionExample: help mean

    >> lookfor Searches all the help documents for a givenkeywordExample: lookfor average

    >> demo

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    12/43

    Types of Files

    .m file - command window is used to executesingle command. But if it is required toexecute/save a program, we need to generate

    a matlab programming file which is saved asxyz.m (mat file)

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    13/43

    SIMULINK Simulink software models, simulates, and analyzes

    dynamic systems. It enables you to pose a question about a

    system, model thesystem, and see what happens. With Simulink, you can easily build models from scratch, or

    modify existing models to meet your needs. Simulinksupports linear and nonlinear systems, modeled incontinuous time, sampled time, or a hybrid of the two.Systems can also be multirate having different parts that

    are sampled or updated at different rates. Thousandsof scientistsand engineersaround the world use

    Simulink to model and solve real problems in a variety ofindustries, including:

    Aerospace and Defense Automotive Communications Electronicsand Signal Processing Medical Instrumentation

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    14/43

    Variables: Scalars, Vectors andMatricesReal Scalars

    >> x = 5

    x = 5Complex Scalars>> x = 5+10j %5+10i works, as does 5+10*jx =5.0000 +10.0000iRow Vector (1 x 3)>> x = [ 1 2 3 ]x =

    1 2 3Column Vector ( 3 x 1)

    >> x = [ 1 ; 2 ; 3 ]; %; supresses output>> xx =123Matrix (3 x 3)>> x = [ 1 2 3 ; 4 5 6 ; 7 8 9 ]x =

    1 2 34 5 67 8 9

    Note: Variable Names are case sensitive

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    15/43

    Generating Vectors and the Colon Operator

    >> x = [ 0 : 0.2 : 1 ] % 0 to 1 in increments of 0.2

    x =

    0 0.20 0.40 0.60 0.80 1.00

    >> x = linspace(0, 1, 6) % 6 points from 0 to 1 on a linear scale

    x =

    0 0.20 0.40 0.60 0.80 1.00

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    16/43

    Generating Matrices>>B = [ 1 2 ; 8 9 ]

    ans =1 2

    8 9

    >>ones(2,2) % generatesan all ones2 x 2 matrixans =

    1 1

    1 1

    >>zeros(2,3) % generatesan all zero 2 x 3 matrixans =

    0 0 0

    0 0 0

    >>rand(3,3) % generatesa random3 x 3 matrixans =

    0.4447 0.9218 0.4057

    0.6154 0.7382 0.93550.7919 0.1763 0.9169

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    17/43

    Accessing Matrix Elements

    >> A= [ 1 2 3 ; 4 5 6 ; 7 8 9];

    >> x = A ( 1, 3 ) %A(,)

    x =3

    A =

    1 2 3

    4 5 6

    7 8 9

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    18/43

    Complex Number Operations

    >> x = 3+4j

    >> abs(x) %Absolute value.x = 5

    >> angle(x) %Phase angle (in radians).

    x = 0.9273

    >> conj(x) %Complex conjugate.

    x = 3-4j

    >> imag(x) %Complex imaginary part.x = 4

    >> real(x) %Complex real part.x = 3

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    19/43

    Some Useful Functions

    Some useful math functions:

    sin(x), cos(x), tan(x), atan(x), exp(x), log(x), log10(x), sqrt(x)

    >> t = [ 0 : 0.01 : 10 ];

    >> x = sin ( 2 * pi * t );

    Some useful matrix and vector functions:

    >> size (A)

    ans=

    3 3

    >> length ( t )

    ans=

    1001

    A =

    1 2 3

    4 5 6

    7 8 9

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    20/43

    What is sum(A')' ?

    A =

    1 2 3

    4 5 6

    7 8 9

    More Operators and Functions

    For vectors, SUM(X) is the sum of the elements of X. For matrices, SUM(X) is a row vector withthe sum over each column.

    >> sum ( A )ans =

    12 15 18

    >> sum ( ans ) % equivalent to sum(sum(A))

    ans =45

    >> A % equivalent to transpose(A)ans =

    1 4 72 5 83 6 9

    >> diag(A)ans =159

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    21/43

    Roots of Polynomials

    Find the roots of the polynomial: 13 x3 + 25 x2 + 3 x + 4

    >> C = [13 25 3 4];>> r = roots(C)r =

    -1.8872

    -0.0179 + 0.4034i-0.0179 - 0.4034i

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    22/43

    >> x = [ 0 : 0.001 : 2*pi ];>> y = sin ( x );>> plot (x,y) ;

    Continuous Time Plots

    0 1 2 3 4 5 6 7-1

    -0.5

    0

    0.5

    1

    The plot function has different forms, depending on the input arguments.If y is a vector, plot(y) produces a piecewise linear graph of the elements

    of y versus the index its elements. If you specify two vectors as arguments,plot(x,y) produces a graph of y versus x.

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    23/43

    Discrete Time Plots Stems Stem function is very similar to plot. It is used to plot discrete time

    sequences. For more info: help stem Example:

    >> k = [ 0 : 30 ] ;

    >> x = sin ( k / 5 ) ;

    >> stem ( k, x)

    0 5 10 15 20 25 30-1

    -0.5

    0

    0.5

    1

    0 k 5

    x[

    k

    ]

    x [ k ] = sin ( k / 5 ) for 0 k 5

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    24/43

    0 1 2 3 4 5 6 7

    -1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    sin(x)

    sin(x-.25)

    sin(x-.5)

    Multiple Data Sets in One Graph

    Mult iple x-y pair arguments create multiple graphs with a single callto plot. For example, these statements plot three related functionsof x, each curve in a separate distinguishing color.

    x = 0:pi/100:2*pi;

    y = sin(x);

    y2 = sin(x-.25);y3 = sin(x-.5);

    plot(x,y,x,y2,x,y3)

    legend('sin(x)','sin(x-.25)','sin(x-.5)')

    Thelegend command provides an easy

    way to identify the individual plots.

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    25/43

    Function

    Syntax function [out1, out2, ...] = funname(in1, in2, ...)

    Description

    function [out1, out2, ...] = funname(in1, in2, ...)defines function funname that accepts inputs in1,in2, etc. and returns outputs out1, out2, etc.

    Demo Example

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    26/43

    Precious Tip 1

    Notice that the array subscripts in Matlab start from 1and not 0 as is the case in C.

    Illustration:

    >> A = [1 2 3 4];>> A(0) % This command will result in syntax error

    The first index is 1 and not 0.

    >> A(1)ans = 1

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    27/43

    Precious Tip 2

    Tip 2: MATLAB is designed to perform vector operations. Long for-loops on theother hand are not efficient. You can see that by comparing the following two piecesof code that do the very same thing: filling an array A with 5s.

    X = 5 * ones(10^7,1);

    OR

    Y = zeros(10^7,1);for i = 1 : length(A)

    Y(i) = 5;end

    Try running the above two pieces of codes (red and blue one) in Matlab (Just copy andpaste on the command prompt). Compare the time it takes for Matlab to executethem. What do you conclude?Note: the results of two pieces of code are the same!

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    28/43

    IMAGES

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    29/43

    Pixel co-ordinate The most convenient method for expressing locations in an

    image is to use pixel coordinates. In this coordinate system,

    the image is treated as a grid of discrete elements, orderedfrom top to bottom and left to right, as illustrated by thefollowingfigure.

    Pixel coordinate system

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    30/43

    Image as Matrices

    )1,1(....)1,1()0,1(

    ....

    )1,1(....)1,1()0,1()1,0(....)1,0()0,0(

    ),(

    NMfMfMf

    NfffNfff

    yxf

    Each element of this array is called and image element, picture element, pixel or pel.A MATLAB image can be represented as a MATLAB matrix:

    ),(....)2,()1,(....

    )1,1(....)1,1()1,2(

    ),1(....)2,1()1,1(

    ),(

    NMfMfMf

    Nfff

    Nfff

    yxf

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    31/43

    Binary Image

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    32/43

    Image Processing Commands

    Reading Images

    Images are read into the MATLAB environment using function imread, whosesyntax is

    Imread(filename)

    Here, filename is a string containing the complete name of the image file

    (including anyapplicable extension). For example, the command line

    >> f = imread (flower.jpg) ;

    Readsthe JPEGimage flower into image array f. The semicolon at the end ofa command line is used by MATLAB for suppressing output. If a semicolon is

    not included, MATLABdisplays the results of the operation(s) specified in thatline. File must be located in the current directory or in the MATLAB searchpath.

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    33/43

    Displaying Images

    >> imshow (f)

    >> imshow (flower.jpg)

    This command displays the image stored in the graphics file. The file mustcontain an image that can be read by imread. The file must be in the currentdirectory or on the MATLAB path.

    >> whosf

    Name Size Bytes Class Attributes

    f 350x350x3 367500 uint8

    whos f extract basic information about the image, and display it .

    Image Processing Commands

  • 8/2/2019 Matlab Presentation for Upload

    34/43

    Writing Images

    Images are written to disk using function imwrite, which has the followingbasic syntax:

    imwrite (f, filename)

    e.g. imwrite(f, flower1.png)

    Here, the above command writes f to a png file named flower1.

    If filename contains no path information , then imwrite saves the file in thecurrent working directory. Most of the work deals with JPEG or TIFF

    images, so we focus attention here on these two formats.

    Image Processing Commands

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    35/43

    Image compression

    A more general imwrite syntax applicable only to JPEG images is

    >> imwrite (f, filename, quality, q)

    Where q is an integer between 0 and 100 (the lower the number the higher

    the degradation due to JPEG compression).

    In order to reduce storage and transmission time, it is important that theimages be compressed as much as possible while not degrading their

    visual appearance beyond a reasonable level. In this case reasonablemeans no perceptible false contouring.

    Image Processing Commands

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    36/43

    Compression

    flower.jpg (184kb) flower50.jpg ( 20 kb)imwrite(f, flower50.jpg , quality , 50)

    flower30.jpg ( 16 kb)

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    37/43

    Functions

    The function definit ion line has the form:

    Function[outputs] = name (inputs)

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    38/43

    Proposed Projects of Image Processing

    Any object shape & color detection. To judge size, shape & orientation of an object. Automatic attendance system using image processing (face

    recognition). Traffic light controller using image processing (based upon no. of

    vehicles on the road). Measure the distance of objects from camera (obstacle avoidance). Signature recognit ion. Safety alarm for a driver in drowsiness condition(based on eye

    blinking rate). Security system.

    Object Tracking

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    39/43

    Object Tracking

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    40/43

    Lane Departure System

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    41/43

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    42/43

    Car Tracking

    Prepared by : Ashutosh K. [email protected]

  • 8/2/2019 Matlab Presentation for Upload

    43/43

    For further queries you can mail me at-

    [email protected]

    Or call at- 9999645463

    Prepared by : Ashutosh K. [email protected]