SlideShare une entreprise Scribd logo
1  sur  53
Digital Image Processing (DIP)
The Fundamentals - A MATLAB assisted non-mathematical approach




                                    By Abhishek Sharma (EEE 2k7)
Materials
   Some taken from slides by a NIT Surathkal friend : Varun
    Nagaraja. He worked in the same lab at IISc Bangalore. Joined as
    a PhD student in University of Maryland – College Park, a week
    back.

   Some material taken from online works of Sabih D. Khan, a
    French-Pakistani researcher.

   Some prepared by me! 
Objective


 To take a quasi non-mathematical , MATLAB assisted
  approach to DIP.
 I cut out the equations because…
1) I don’t want to scare you even before we start the climb
2) I am pathetic at elucidating maths concepts
3) I don’t have a lot of time.
4) You don’t need maths to start working in DIP.

   If I am able to make you fall in love with DIP, I hope like
    real world love, you will be able to accept it with its’
    shortcomings – maths!
SixthSense
     by Pranav Mistry, MIT Media
     Labs
   'SixthSense' is a wearable gestural interface that
    augments the physical world around us with digital
    information and lets us use natural hand gestures to
    interact with that information.

Image Processing - a definition



   Image Processing generally involves extraction of useful
    information from an image.
   This useful information may be the dimensions of an
    engineering component, size of diagnosed tumor, or
    even a 3D view of an unborn baby.
Intro to DIP with MATLAB

 Images can be conveniently represented as matrices in
  Matlab.
 One can open an image as a matrix using imread
  command.
 The matrix may simply be m x n form or it may be 3
  dimensional array or it may be an indexed
  matrix, depending upon image type.
 The image processing may be done simply by matrix
  calculation or matrix manipulation.
 Image may be displayed with imshow command.
 Changes to image may then be saved with imwrite
  command.
Image types

 Images may be of three types i.e. black & white, grey
  scale and colored.
 In Matlab, however, there are four types of images.
 Black & White images are called binary images,
  containing 1 for white and 0 for black.
 Grey scale images are called intensity images,
  containing numbers in the range of 0 to 255 or 0 to 1.
 Colored images may be represented as RGB Image or
  Indexed Image.
Image types

   In RGB Images there exist three indexed images.
   First image contains all the red portion of the
    image, second green and third contains the blue portion.
   So for a 640 x 480 sized image the matrix will be 640 x
    480 x 3.
   An alternate method of colored image representation is
    Indexed Image.
   It actually exist of two matrices namely image matrix
    and map matrix.
   Each color in the image is given an index number and in
    image matrix each color is represented as an index
    number.
   Map matrix contains the database of which index
    number belongs to which color.
MATLAB – image conversions

   RGB Image to Intensity Image        (rgb2gray)
   RGB Image to Indexed Image          (rgb2ind)
   RGB Image to Binary Image           (im2bw)
   Indexed Image to RGB Image          (ind2rgb)
   Indexed Image to Intensity Image    (ind2gray)
   Indexed Image to Binary Image       (im2bw)
   Intensity Image to Indexed Image    (gray2ind)
   Intensity Image to Binary Image     (im2bw)
   Intensity Image to RGB Image (gray2ind, ind2rgb)
Image Histograms

   There are a number of ways to get statistical information about
    data in the image.
   Image histogram is one such way.
   An image histogram is a chart that shows the distribution of
    intensities in an image.
   Each color level is represented as a point on x-axis and on y-
    axis is the number instances a color level repeats in the image.
   Histogram may be view with imhist command.
   Sometimes all the important information in an image lies only
    in a small region of colors, hence it usually is difficult to extract
    information out of that image.
   To balance the brightness level, we carry out an image
    processing operation termed histogram equalization. Use
    MATLAB histeq command
Some histogram experiments

   Read Bill Clinton’s image in your folder into MATLAB.
Simple character recognition
     code
   Detect only particular
    characters and numbers in an
    image.
   Characters are in white and of
    a fixed size.
   Background is black in color.
   The image is in binary format.

   We will explore various DIP
    concepts while we do this….
    Let’s start 
Let’s start with reading the image
Let’s have some fun… I know my
     sense of humor sucks!
   Now read the image ‘same color.jpg’ and display it on a window.
   Once the image is displayed in the window, select Tools –Data
    Cursor or select the shortcut on the toolbar.
   Click on point A as shown, on the image. It displays three values
    (RGB) since it is a color image. You can try reading pixel values for
    the previous image. It will be either 0/1 since it is binary image.
   Hold Alt and Click on point B. This creates something called as a
    new datatip.




Now for some fun
 What are the RGB values at the two points?
Morphological Operations

   These are image processing operations done on
    binary images based on certain morphologies or
    shapes.
   The value of each pixel in the output is based on the
    corresponding input pixel and its neighbors.
   By choosing appropriately shaped neighbors one can
    construct an operation that is sensitive to a certain
    shape in the input image.
Some basic morphological
operations
Skeletonize

   It creates skeleton of an object, by removing pixels on
    the boundaries but does not allow objects to break
    apart.
   It is an extremely important operation in image
    processing as it removes complexities from an image
    without loosing details.
Erosion and Dilation

 These are the most fundamental of binary
  morphological operations.
 In dilation if any pixel in the input pixel’s neighborhood
  is on, the output pixel is on otherwise off.
 In actual dilation grows the area of the object. Small
  holes in the object are removed.
 In erosion if every pixel in the input pixel’s
  neighborhood is on the output pixel is on otherwise off
 This in actual works as shrinking the object’s area, thus
  small isolated regions disappear.
Dilation….




Dilation does not necessarily mean dilation of the holes also. The
holes get contracted as shown above.
Also try image erosion. Use MATLAB’s help.
Dilation…

   adds pixels to the boundaries of objects in an image.
   number of pixels added from the objects in an image
    depends on the size and shape of the structuring
    element
   function strel(…)can be used to generate the SEs.
Structuring Elements
                   In mathematical morphology,
                   structuring element is a shape, used
                   to probe or interact with a given
                   image, with the purpose of drawing
                   conclusions on how this shape fits or
                   misses the shapes in the image.



                   Check out help on strel for various
                   combinations
Continuing with the algo…


   When the dilated image of the character is
   subtracted from the original we get something
   like…
   Next we create such images for all the
   characters that we want to recognize.
   (For all those individual character images in
   the folder)
Hit or miss?
   Function, bwhitmiss is employed to check if a particular
    character is present in the given image.
   bwhitmiss(BW1,SE1,SE2)performs the hit‐miss operation
    defined by the structuring elements SE1 and SE2. The
    hit‐miss operation preserves pixels whose neighborhoods
    match the shape of SE1 and don't match the shape of SE2.
   If the matrix returned by bwhitmiss contains nonzero
    elements, then the character is found in the image.




       Also note the use of functions isempty and nonzeros
       You can now use charrec.m to recognize few characters
       in a crude way.
Functions…again!
Finally! Let’s detect them….
Image Segmentation

   The goal of image segmentation is to cluster pixels
    into salient image regions, i.e., regions corresponding
    to individual surfaces, objects, or natural parts of
    objects.
   A segmentation could be used for object recognition,
    image compression, image editing, or image database
    look-up.
Image Segmentation
Image Segmentation - Global
  Thresholding
Disadvantage is when there are multiple colors for objects and
backgrounds.
Otsu’s Method

   Based on a very simple idea: Find the threshold that
    minimizes the weighted within-class variance.
   This turns out to be the same as maximizing the
    between-class variance.
   Operates directly on the gray level histogram [e.g.
    256 numbers, P(i)], so it’s fast (once the histogram is
    computed).
The weighted within-class variance is:

    (t)  q1 (t) (t)  q2 (t) (t)
      2
      w
                                2
                                1
                                                             2
                                                             2


Where the class probabilities are estimated as:
                t                                      I

   q1 (t)   P(i)                    q2 (t)       P(i)
                                                  i  t 1
               i 1


And the class means are given by:


                                                   I
                t
                iP(i)                                iP(i)
  1 (t)                          2 (t)  
           i 1 q1 (t)                       i t 1 q2 (t )
Binarization - NiBlack Algo
Connected Components
The code….
This was again a very crude way, since we are depending
only on value of area which might not remain constant if
camera changes position.
Most of the times the standard features available with
regionprops() is not sufficient. We will have to write our
own code to extract features.
Also we used hard thresholds for are as to classify CCs.
Again most of the times, this is not followed. Classifiers
using Pattern Recognition techniques are employed.
Why edges?
         Reduce dimensionality of data

         Preserve content information

         Useful in applications such as:
          ◦ object detection
          ◦ structure from motion
          ◦ tracking
Why not edges?
      But, sometimes not that useful, why?

      Difficulties:
          1. Modeling assumptions
          2. Parameters
          3. Multiple sources of information
             (brightness, color, texture, …)
          4. Real world conditions


      Is edge detection even well defined?
Road detection
Canny edge detection

         1. smooth


                     2. gradient



                                   3. thresh, suppress, link




Canny is optimal w.r.t.
some model.
Canny edge detection

       1. smooth


                   2. gradient



                                 3. thresh, suppress, link




And yet…
Canny difficulties
1. Modeling assumptions
   Step edges, junctions, etc.


2. Parameters
   Scales, threshold, etc.


3. Multiple sources of information
   Only handles brightness


4. Real world conditions
   Gaussian iid noise? Texture…
Edge Detection

   Edge detection extract edges of objects from an image.
   There are a number of algorithms for this, but these
    may be classified as derivative based or gradient based.
   In derivative based edge detection the algorithm takes
    first or second derivative on each pixel in the image.
   In case of first derivative at the edge of the image there
    is a rapid change of intensity.
   While in case of second derivative there is a zero pixel
    value, termed zero crossing.
   In gradient based edge detection a gradient of
    consecutive pixels is taken in x and y direction.
   Taking derivative on each and every pixel of the image
    consumes a lot of computer resources and hence is not
    practical.
   So usually an operation called kernel operation is
    carried out.
   A kernel is a small matrix sliding over the image matrix
    containing coefficients which are multiplied to
    corresponding image matrix elements and their sum is
    put at the target pixel.
Sobel’s Method
Prewitt’s Method
Best one is – Canny’s Method

 Uses both the derivative and the gradient to perform
  edge detection
 The maths is a bit complex
 Can through the PDF in your folder later.
 Pass ‘canny’ as a parameter to the edge function to
  perform canny.

Contenu connexe

Tendances

Paper id 25201447
Paper id 25201447Paper id 25201447
Paper id 25201447
IJRAT
 
Final Thesis Presentation Licenseplaterecognitionincomplexscenes
Final Thesis Presentation LicenseplaterecognitionincomplexscenesFinal Thesis Presentation Licenseplaterecognitionincomplexscenes
Final Thesis Presentation Licenseplaterecognitionincomplexscenes
dswazalwar
 

Tendances (20)

License Plate recognition
License Plate recognitionLicense Plate recognition
License Plate recognition
 
License plate recognition.
License plate recognition.License plate recognition.
License plate recognition.
 
Ay36304310
Ay36304310Ay36304310
Ay36304310
 
Automatic vehicle license plate detection using VEDA
Automatic vehicle license plate detection using VEDAAutomatic vehicle license plate detection using VEDA
Automatic vehicle license plate detection using VEDA
 
Character recognition from number plate written in assamese language
Character recognition from number plate written in assamese languageCharacter recognition from number plate written in assamese language
Character recognition from number plate written in assamese language
 
License Plate Recognition
License Plate RecognitionLicense Plate Recognition
License Plate Recognition
 
Automatic License Plate Recognition [ALPR]-A Review Paper
Automatic License Plate Recognition [ALPR]-A Review PaperAutomatic License Plate Recognition [ALPR]-A Review Paper
Automatic License Plate Recognition [ALPR]-A Review Paper
 
Fpga human detection
Fpga human detectionFpga human detection
Fpga human detection
 
Paper id 25201447
Paper id 25201447Paper id 25201447
Paper id 25201447
 
Number plate recognition system using matlab.
Number plate recognition system using matlab.Number plate recognition system using matlab.
Number plate recognition system using matlab.
 
Optical Character Recognition
Optical Character RecognitionOptical Character Recognition
Optical Character Recognition
 
An Efficient Model to Identify A Vehicle by Recognizing the Alphanumeric Char...
An Efficient Model to Identify A Vehicle by Recognizing the Alphanumeric Char...An Efficient Model to Identify A Vehicle by Recognizing the Alphanumeric Char...
An Efficient Model to Identify A Vehicle by Recognizing the Alphanumeric Char...
 
A design of license plate recognition system using convolutional neural network
A design of license plate recognition system using convolutional neural networkA design of license plate recognition system using convolutional neural network
A design of license plate recognition system using convolutional neural network
 
Bangla Optical Digits Recognition using Edge Detection Method
Bangla Optical Digits Recognition using Edge Detection MethodBangla Optical Digits Recognition using Edge Detection Method
Bangla Optical Digits Recognition using Edge Detection Method
 
License Plate Recognition
License Plate RecognitionLicense Plate Recognition
License Plate Recognition
 
IRJET - Automatic Licence Plate Detection and Recognition
IRJET -  	  Automatic Licence Plate Detection and RecognitionIRJET -  	  Automatic Licence Plate Detection and Recognition
IRJET - Automatic Licence Plate Detection and Recognition
 
journal nakk
journal nakkjournal nakk
journal nakk
 
Number plate recognition using matlab
Number plate recognition using matlabNumber plate recognition using matlab
Number plate recognition using matlab
 
Automatic number plate recognition using matlab
Automatic number plate recognition using matlabAutomatic number plate recognition using matlab
Automatic number plate recognition using matlab
 
Final Thesis Presentation Licenseplaterecognitionincomplexscenes
Final Thesis Presentation LicenseplaterecognitionincomplexscenesFinal Thesis Presentation Licenseplaterecognitionincomplexscenes
Final Thesis Presentation Licenseplaterecognitionincomplexscenes
 

En vedette

various methods for image segmentation
various methods for image segmentationvarious methods for image segmentation
various methods for image segmentation
Raveesh Methi
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
Deepak Kumar
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domain
Ashish Kumar
 
Image proceesing with matlab
Image proceesing with matlabImage proceesing with matlab
Image proceesing with matlab
Ashutosh Shahi
 

En vedette (20)

05 histogram processing DIP
05 histogram processing DIP05 histogram processing DIP
05 histogram processing DIP
 
Digital Image Processing Fundamental
Digital Image Processing FundamentalDigital Image Processing Fundamental
Digital Image Processing Fundamental
 
Im seg04
Im seg04Im seg04
Im seg04
 
Breast Lesion Segmentation in Ultrasound Images
Breast Lesion Segmentation in Ultrasound ImagesBreast Lesion Segmentation in Ultrasound Images
Breast Lesion Segmentation in Ultrasound Images
 
COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...
COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...
COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...
 
Research methodology
Research methodologyResearch methodology
Research methodology
 
various methods for image segmentation
various methods for image segmentationvarious methods for image segmentation
various methods for image segmentation
 
Bit plane slicing
Bit plane slicingBit plane slicing
Bit plane slicing
 
Smoothing Filters in Spatial Domain
Smoothing Filters in Spatial DomainSmoothing Filters in Spatial Domain
Smoothing Filters in Spatial Domain
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
 
Unit3 dip
Unit3 dipUnit3 dip
Unit3 dip
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Segmentation
SegmentationSegmentation
Segmentation
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domain
 
BRAIN TUMOR MRI IMAGE SEGMENTATION AND DETECTION IN IMAGE PROCESSING
BRAIN TUMOR MRI IMAGE SEGMENTATION AND DETECTION IN IMAGE PROCESSINGBRAIN TUMOR MRI IMAGE SEGMENTATION AND DETECTION IN IMAGE PROCESSING
BRAIN TUMOR MRI IMAGE SEGMENTATION AND DETECTION IN IMAGE PROCESSING
 
basic research mcqs
basic research mcqsbasic research mcqs
basic research mcqs
 
Digital image processing using matlab
Digital image processing using matlab Digital image processing using matlab
Digital image processing using matlab
 
Image proceesing with matlab
Image proceesing with matlabImage proceesing with matlab
Image proceesing with matlab
 
SOLAR INVERTER
SOLAR INVERTER SOLAR INVERTER
SOLAR INVERTER
 
IMAGE SEGMENTATION.
IMAGE SEGMENTATION.IMAGE SEGMENTATION.
IMAGE SEGMENTATION.
 

Similaire à Dip day1&2

ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)
Hasitha Ediriweera
 
Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptx
AvinashJain66
 
Matlab intro
Matlab introMatlab intro
Matlab intro
fvijayami
 
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
SamridhGarg
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLAB
vkn13
 

Similaire à Dip day1&2 (20)

Dip digital image 3
Dip digital image 3Dip digital image 3
Dip digital image 3
 
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)
 
Programming in matlab lesson5
Programming in matlab lesson5Programming in matlab lesson5
Programming in matlab lesson5
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
 
Performance Anaysis for Imaging System
Performance Anaysis for Imaging SystemPerformance Anaysis for Imaging System
Performance Anaysis for Imaging System
 
mini prjt
mini prjtmini prjt
mini prjt
 
Data Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image ProcessingData Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image Processing
 
Report
ReportReport
Report
 
Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptx
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
Matlab dip
Matlab dipMatlab dip
Matlab dip
 
Image processing using matlab
Image processing using matlabImage processing using matlab
Image processing using matlab
 
computervision1.pdf it is about computer vision
computervision1.pdf it is about computer visioncomputervision1.pdf it is about computer vision
computervision1.pdf it is about computer vision
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 
BMVA summer school MATLAB programming tutorial
BMVA summer school MATLAB programming tutorialBMVA summer school MATLAB programming tutorial
BMVA summer school MATLAB programming tutorial
 
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
 
ImSeg04.ppt
ImSeg04.pptImSeg04.ppt
ImSeg04.ppt
 
ImSeg04 (2).ppt
ImSeg04 (2).pptImSeg04 (2).ppt
ImSeg04 (2).ppt
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLAB
 
Log polar coordinates
Log polar coordinatesLog polar coordinates
Log polar coordinates
 

Dernier

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Dernier (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Dip day1&2

  • 1. Digital Image Processing (DIP) The Fundamentals - A MATLAB assisted non-mathematical approach By Abhishek Sharma (EEE 2k7)
  • 2. Materials  Some taken from slides by a NIT Surathkal friend : Varun Nagaraja. He worked in the same lab at IISc Bangalore. Joined as a PhD student in University of Maryland – College Park, a week back.  Some material taken from online works of Sabih D. Khan, a French-Pakistani researcher.  Some prepared by me! 
  • 3. Objective  To take a quasi non-mathematical , MATLAB assisted approach to DIP.  I cut out the equations because… 1) I don’t want to scare you even before we start the climb 2) I am pathetic at elucidating maths concepts 3) I don’t have a lot of time. 4) You don’t need maths to start working in DIP.  If I am able to make you fall in love with DIP, I hope like real world love, you will be able to accept it with its’ shortcomings – maths!
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. SixthSense by Pranav Mistry, MIT Media Labs  'SixthSense' is a wearable gestural interface that augments the physical world around us with digital information and lets us use natural hand gestures to interact with that information. 
  • 9.
  • 10. Image Processing - a definition  Image Processing generally involves extraction of useful information from an image.  This useful information may be the dimensions of an engineering component, size of diagnosed tumor, or even a 3D view of an unborn baby.
  • 11. Intro to DIP with MATLAB  Images can be conveniently represented as matrices in Matlab.  One can open an image as a matrix using imread command.  The matrix may simply be m x n form or it may be 3 dimensional array or it may be an indexed matrix, depending upon image type.  The image processing may be done simply by matrix calculation or matrix manipulation.  Image may be displayed with imshow command.  Changes to image may then be saved with imwrite command.
  • 12. Image types  Images may be of three types i.e. black & white, grey scale and colored.  In Matlab, however, there are four types of images.  Black & White images are called binary images, containing 1 for white and 0 for black.  Grey scale images are called intensity images, containing numbers in the range of 0 to 255 or 0 to 1.  Colored images may be represented as RGB Image or Indexed Image.
  • 13. Image types  In RGB Images there exist three indexed images.  First image contains all the red portion of the image, second green and third contains the blue portion.  So for a 640 x 480 sized image the matrix will be 640 x 480 x 3.  An alternate method of colored image representation is Indexed Image.  It actually exist of two matrices namely image matrix and map matrix.  Each color in the image is given an index number and in image matrix each color is represented as an index number.  Map matrix contains the database of which index number belongs to which color.
  • 14. MATLAB – image conversions  RGB Image to Intensity Image (rgb2gray)  RGB Image to Indexed Image (rgb2ind)  RGB Image to Binary Image (im2bw)  Indexed Image to RGB Image (ind2rgb)  Indexed Image to Intensity Image (ind2gray)  Indexed Image to Binary Image (im2bw)  Intensity Image to Indexed Image (gray2ind)  Intensity Image to Binary Image (im2bw)  Intensity Image to RGB Image (gray2ind, ind2rgb)
  • 15. Image Histograms  There are a number of ways to get statistical information about data in the image.  Image histogram is one such way.  An image histogram is a chart that shows the distribution of intensities in an image.  Each color level is represented as a point on x-axis and on y- axis is the number instances a color level repeats in the image.  Histogram may be view with imhist command.  Sometimes all the important information in an image lies only in a small region of colors, hence it usually is difficult to extract information out of that image.  To balance the brightness level, we carry out an image processing operation termed histogram equalization. Use MATLAB histeq command
  • 16. Some histogram experiments  Read Bill Clinton’s image in your folder into MATLAB.
  • 17. Simple character recognition code  Detect only particular characters and numbers in an image.  Characters are in white and of a fixed size.  Background is black in color.  The image is in binary format.  We will explore various DIP concepts while we do this…. Let’s start 
  • 18. Let’s start with reading the image
  • 19. Let’s have some fun… I know my sense of humor sucks!  Now read the image ‘same color.jpg’ and display it on a window.  Once the image is displayed in the window, select Tools –Data Cursor or select the shortcut on the toolbar.  Click on point A as shown, on the image. It displays three values (RGB) since it is a color image. You can try reading pixel values for the previous image. It will be either 0/1 since it is binary image.  Hold Alt and Click on point B. This creates something called as a new datatip. Now for some fun  What are the RGB values at the two points?
  • 20. Morphological Operations  These are image processing operations done on binary images based on certain morphologies or shapes.  The value of each pixel in the output is based on the corresponding input pixel and its neighbors.  By choosing appropriately shaped neighbors one can construct an operation that is sensitive to a certain shape in the input image.
  • 22. Skeletonize  It creates skeleton of an object, by removing pixels on the boundaries but does not allow objects to break apart.  It is an extremely important operation in image processing as it removes complexities from an image without loosing details.
  • 23. Erosion and Dilation  These are the most fundamental of binary morphological operations.  In dilation if any pixel in the input pixel’s neighborhood is on, the output pixel is on otherwise off.  In actual dilation grows the area of the object. Small holes in the object are removed.  In erosion if every pixel in the input pixel’s neighborhood is on the output pixel is on otherwise off  This in actual works as shrinking the object’s area, thus small isolated regions disappear.
  • 24. Dilation…. Dilation does not necessarily mean dilation of the holes also. The holes get contracted as shown above. Also try image erosion. Use MATLAB’s help.
  • 25. Dilation…  adds pixels to the boundaries of objects in an image.  number of pixels added from the objects in an image depends on the size and shape of the structuring element  function strel(…)can be used to generate the SEs.
  • 26. Structuring Elements In mathematical morphology, structuring element is a shape, used to probe or interact with a given image, with the purpose of drawing conclusions on how this shape fits or misses the shapes in the image. Check out help on strel for various combinations
  • 27. Continuing with the algo… When the dilated image of the character is subtracted from the original we get something like… Next we create such images for all the characters that we want to recognize. (For all those individual character images in the folder)
  • 28. Hit or miss?  Function, bwhitmiss is employed to check if a particular character is present in the given image.  bwhitmiss(BW1,SE1,SE2)performs the hit‐miss operation defined by the structuring elements SE1 and SE2. The hit‐miss operation preserves pixels whose neighborhoods match the shape of SE1 and don't match the shape of SE2.  If the matrix returned by bwhitmiss contains nonzero elements, then the character is found in the image. Also note the use of functions isempty and nonzeros You can now use charrec.m to recognize few characters in a crude way.
  • 31. Image Segmentation  The goal of image segmentation is to cluster pixels into salient image regions, i.e., regions corresponding to individual surfaces, objects, or natural parts of objects.  A segmentation could be used for object recognition, image compression, image editing, or image database look-up.
  • 32.
  • 34. Image Segmentation - Global Thresholding Disadvantage is when there are multiple colors for objects and backgrounds.
  • 35. Otsu’s Method  Based on a very simple idea: Find the threshold that minimizes the weighted within-class variance.  This turns out to be the same as maximizing the between-class variance.  Operates directly on the gray level histogram [e.g. 256 numbers, P(i)], so it’s fast (once the histogram is computed).
  • 36. The weighted within-class variance is:  (t)  q1 (t) (t)  q2 (t) (t) 2 w 2 1 2 2 Where the class probabilities are estimated as: t I q1 (t)   P(i) q2 (t)   P(i) i  t 1 i 1 And the class means are given by: I t iP(i) iP(i) 1 (t)   2 (t)   i 1 q1 (t) i t 1 q2 (t )
  • 38.
  • 41. This was again a very crude way, since we are depending only on value of area which might not remain constant if camera changes position. Most of the times the standard features available with regionprops() is not sufficient. We will have to write our own code to extract features. Also we used hard thresholds for are as to classify CCs. Again most of the times, this is not followed. Classifiers using Pattern Recognition techniques are employed.
  • 42. Why edges?  Reduce dimensionality of data  Preserve content information  Useful in applications such as: ◦ object detection ◦ structure from motion ◦ tracking
  • 43. Why not edges? But, sometimes not that useful, why? Difficulties: 1. Modeling assumptions 2. Parameters 3. Multiple sources of information (brightness, color, texture, …) 4. Real world conditions Is edge detection even well defined?
  • 45. Canny edge detection 1. smooth 2. gradient 3. thresh, suppress, link Canny is optimal w.r.t. some model.
  • 46. Canny edge detection 1. smooth 2. gradient 3. thresh, suppress, link And yet…
  • 47. Canny difficulties 1. Modeling assumptions Step edges, junctions, etc. 2. Parameters Scales, threshold, etc. 3. Multiple sources of information Only handles brightness 4. Real world conditions Gaussian iid noise? Texture…
  • 48. Edge Detection  Edge detection extract edges of objects from an image.  There are a number of algorithms for this, but these may be classified as derivative based or gradient based.  In derivative based edge detection the algorithm takes first or second derivative on each pixel in the image.  In case of first derivative at the edge of the image there is a rapid change of intensity.  While in case of second derivative there is a zero pixel value, termed zero crossing.  In gradient based edge detection a gradient of consecutive pixels is taken in x and y direction.
  • 49.
  • 50. Taking derivative on each and every pixel of the image consumes a lot of computer resources and hence is not practical.  So usually an operation called kernel operation is carried out.  A kernel is a small matrix sliding over the image matrix containing coefficients which are multiplied to corresponding image matrix elements and their sum is put at the target pixel.
  • 53. Best one is – Canny’s Method  Uses both the derivative and the gradient to perform edge detection  The maths is a bit complex  Can through the PDF in your folder later.  Pass ‘canny’ as a parameter to the edge function to perform canny.