Filtering by qingyunliuliu

VIEWS: 6 PAGES: 67

									Filtering and Image Enhancements

         Dr. Ramprasad Bala
   Computer and Information Science
         UMASS Dartmouth
    CIS 585 – Image Processing and
           Machine Vision
       Morphological Operators -
         Erosion and Dilation
 In a binary image this is also known as
  Expanding and Shrinking.
 Expanding – Change a pixel from 0 to 1 if
  any of the neighbors of the pixel are 1.
 Shrinking – Change a pixel from 1 to 0 if any
  neighbor of the pixel are 0.


                                              2
          Erosion and Dilation

 An erosion followed by a dilation (refered to as
  an "Open" operation) can be used to eliminate
  point noise.
 A dilation operation followed by erosion
  (referred to as a "Close" operation) can be used
  to close up holes or gaps in the object of interest.
 While erosion and dilation can employ arbitrary
  "structuring elements", a typical structuring
  element is simply a 3x3 matrix of 1's.

                                                         3
                 Original Image
After Dilation                    After Erosion




                                                  4
5
Erosion and Dilation in Grayscale
            Images




         Original Image             6
Resulting image after applying grayscale dilation




                                                    7
Resulting image after applying grayscale erosion.




                                                    8
                Introduction

 Image processing – more accurately filtering,
  enhancement or conditioning is the process
  of extracting the signal or structure in the
  image while suppressing unwanted or
  uninteresting variations in the image.
 Operations can be based on local
  neighborhood or on the entire image.
 Correlation or Convolution.

                                              9
          What needs fixing?
Image Enhancement




                               10
             Image Enhancement

 Image enhancement operators improve
  detectability of important image details or
  objects manually or automatically.
     Noise reduction/suppression
     Smoothing
     Contrast stretching
     Edge enhancement

                                                11
Image Restoration




                    12
               Image Restoration

 Image restoration attempts to restore a
  degraded image to an ideal condition for
  further processing.
     Constrained by the understanding and modeling
      of the ideal image formation and image
      degradation process.
     If successful we can use the model to invert the
      degradation to return the ideal image.

                                                         13
           Gray-level Mapping

 Change the appearance of an image by
  transforming the pixels via a single function
  that maps an input gray-value into a new
  output value.
 This can be done to the entire image or to use
  different functions for different sub-images.
 Remapping the gray values is called
  stretching

                                               14
Example




          15
Example




          16
               Gamma correction

 Any function map can be used.
 The square root function (f(x) = x ½ ) for example
  boosts, nonlinearly, all intensities, but more so the
  lower intensities than higher ones.
 The function f(x) = x 1/γ is called Gamma
  correction. Where γ can be varying.
 Image variation will be increased in the intensity
  ranges where the slope of the function is greater
  than 1.

                                                          17
                  Point operator

 A point operator applied to an image is an
  operator in which the output pixel is determined
  only by the input pixel,
       Out[x,y] = f(In[x,y]);
  function f() may depend on some global parameter.
 A contrast stretching operator is a point operator
  that used a piecewise smooth function f(In[x,y]) of
  the input gray level to enhance important details of
  the image.
                                                     18
                  Disclaimer

 While monotonic point operators work well
  in enhancing images for human consumption
  (or graphics etc), they do change the original
  intensities considerably.
 In applications where the original intensity
  levels play a significant role (eg.
  mammography images) point operators are
  not good solutions for image enhancement.

                                               19
          Histogram Equalization

 Histogram equalization is often used to
  enhance an image.
 It accomplishes the following:
  a.   The output image uses all available gray levels
  b.   The output image has approximately the same
       number of pixels of each gray level.
 While a. makes sense, b. is ad hoc and its
  effectiveness can be judged only
  empirically.
                                                     20
Histogram Equalization




                         21
Histogram Equalization




                         22
      Mathematically Speaking…

 Condition a. implies that all gray levels will
  be represented:z = z1,z = z2…z = zn
 Condition b. implies that gray level zk is used
  q times where q = (RxC)/n, where R,C and n
  are number of rows, number of columns and
  number of intensities in the image
  respectively.

                                                23
               Implementation

 Hin[i] is the number of pixels of the input
  image having gray level zi.
 The first gray level threshold t1is found by
  advancing I in the input image histogram
  until approximately q1 pixels are accounted
  for: i.e.all input image pixels zk < t1 –1 will
  be mapped to gray level z1 in the output
  image.

                                                    24
                Assignment 4

 Implement histogram equalization.
 Your program will take as input the number
  of intensities you want represented in the
  image.
 Display the original image, its intensity
  histogram, the output image and its intensity
  histogram.
 Due October 18th 9AM. Weight 1
                                                  25
                    Noise Removal

 Salt and Pepper Noise.
      The presence of a single bright pixel in a dark region or
       vise versa is called Salt and Pepper noise.
      Typically results from classification errors resulting
       from variation in surface material or illumination.
      A (4- or 8 neighbor) mask is usually applied to eliminate
       this noise.
 CC can also be used for removal of small regions.


                                                               26
27
             Image Smoothing

 Smoothing an image by equally weighting a
  rectangular neighborhood of pixels is called
  using a box filter.
 Mean filter: use the average of it neighbors




                                                 28
Original image modified with some gaussian noise.
                                                    29
                   Gaussian Filter

 Instead of weighting the neighbors equally you could weight
  them based on their distance from the center pixel.
 When a Gaussian filter is used, pixel [x,y] is weighted
  according to




  where d = sqrt((x-xc)^2 + (y-yc)^2).

 More on this later …
                                                            30
                  Median Filter

 The Mean filter usually works if the regions
  tend to be homogenous.
 The Median Filter replaces the center pixel
  with the median of the neighboring values.
     Works well for many types of noise.
     Preserves edges, unlike the mean filter.
     Computationally expensive, due to sorting.

                                                   31
5x5 Median Filter




   7x7 Median Filter   32
Another Example




                  33
           Detecting Edges Using
            Differencing Masks
 Image points of high contrast can be detected
  by computing intensity differences in local
  image regions.
 Differencing in the 1-D signal:
     The derivative would be discretely computed by
      subtracting successive values.
     In the form a mask it will look like this
        M’ = -1 1



                                                       34
35
Difference masks can be used to obtain different results.
I only the presence of an edge is important, you can simply
compute the absolute. If direction of the edge is important
then leave the sign in there. In the former case [-1 1] would be
equivalent mask to [1 –1]. Similarly for the second derivative,
The mask [1 –2 1] would be equivalent to [-1 2 –1].

The first derivative gives you information about sharp changes.
The second derivative gives you information on zero-crossing.
                                                               36
First derivative mask




                        37
Second derivative mask




                         38
Smoothing versus differencing




                                39
        Properties of Differencing

 Coordinates of derivative masks have opposite
  signs in order to obtain a high response in signal
  regions of high contrast.
 The sum of coordinates of derivative masks is zero
  so that zero response is obtained on constant
  regions.
 First derivative masks produce high absolute values
  at points of high contrast.
 Second derivative masks produce zero-crossing at
  points of high contrasts.
                                                    40
   Properties of Smoothing Masks

 Coordinates of smoothing masks are positive
  and sum to one so that output on constant
  regions is the same as the input.
 The amount of smoothing and noise
  reduction is proportional to the mask size.
 Step edges are blurred in proportion to the
  mask size.

                                            41
          Different operators on 2D
                   signals.
 From calculus we know that the derivative of
  a 2D function is given by
         [δf/δx δf/δy] and the direction is given by tan-1 of
         these two values.
 Since an edge might cut across an edge we
  may want to use more than one point to find
  the difference.


                                                                 42
So the difference is defined as




                                  43
Intuitively




              44
Transforming this into a mask...




                               45
Applying this mask to an image




                             46
47
The Sobel Operator




                     48
Analysis




           49
    Notes on using these operators

 The Roberts mask is more efficient due to
  smaller neighborhood operation.
 All these local operators miss a lot of edges.
 Computing square roots and squares can
  become quite expensive – other variations
  include, absolute, maximum.


                                                   50
     Zero crossings of the second
             derivative
 The main disadvantage of these edge detectors is
  their dependence on the size of objects and
  sensitivity to noise.
 An edge detection technique, based on the zero
  crossings of the second derivative explores the fact
  that a step edge corresponds to an abrupt change in
  the image function.
 The first derivative of the image function should
  have an extreme at the position corresponding to
  the edge in the image, and so the second derivative
  should be zero at the same position.                51
      Gaussian Filtering and LoG

 A Gaussian function of one variable with
  spread σ is of the following form



 A Gaussian function in two variables is
  shown below:


                                             52
         Laplacian of the Gaussian

 Robust calculation of the 2nd derivative:
     smooth an image first (to reduce noise) and then
      compute second derivatives.
     the 2D Gaussian smoothing operator G(x,y)




                                                         53
                             LoG

   After returning to the original co-ordinates x, y and
    introducing a normalizing multiplicative coefficient c
    (that includes 1/ 2), we get a convolution mask of a zero
    crossing detector




       where c normalizes the sum of mask elements to zero.

                                                               54
55
56
              Some Properties

 The are under the curve of g(x) making it
  suitable for being used as a filter.
 g’(x) is g(x) multiplied by the function –x
  and one over σ2.
 g’’(x) is the difference of two even functions
  and the central lobe will be negative when x
  is approximately 0. The zero crossings occur
  when x = σ2*.

                                               57
Examples of G-masks




                      58
LoG




      59
A large LoG filter




                     60
LOG   Roberts   Prewitt   Sobel




                                  61
Neural Networks




                  62
Marr-Hildreth Theory




                       63
64
       The Canny Edge Detector

 Smoothes the intensity image and then
  produces extended contour segments by
  following high gradient magnitudes from one
  neighborhood to another.
 Details in chapter 10.




                                            65
66
 Color and Shading




                      67

								
To top