Lie Gonzalez Ch3

Embed Size (px)

Citation preview

  • 7/31/2019 Lie Gonzalez Ch3

    1/37

    CCU, Taiwan

    Wen-Nung Lie

    Chapter 3 : ImageEnhancement in the Spatial

    Domain

  • 7/31/2019 Lie Gonzalez Ch3

    2/37

    3-1CCU, Taiwan

    Wen-Nung Lie

    Backgrounds

    Spatial domain methods are procedures that operate

    directly on pixels

    Neighborhood about a point (x,y) Neighborhood = 11 point processing or contrast stretching Larger neighborhood mask processing

    )],([),( yxfTyxg =

  • 7/31/2019 Lie Gonzalez Ch3

    3/37

    3-2CCU, Taiwan

    Wen-Nung Lie

    Some basic point

    transformations

    Implemented by look-up

    tables

    Functions

    Linear (negative andidentity)

    Logarithmic (log and

    inverse log)

    Power-law (nth power and

    nth root)

    )1log( rcs +=

    )(or +== rcscrs

  • 7/31/2019 Lie Gonzalez Ch3

    4/373-3CCU, Taiwan

    Wen-Nung Lie

    Log transform

    Expand the dynamic range of low gray-levels values

    Compress the dynamic range of images with large variations in

    pixel values

    Power-law transformation

    Curves generated with have exactly the opposite effect as

    those generated with

    1>

    1

  • 7/31/2019 Lie Gonzalez Ch3

    5/373-4CCU, Taiwan

    Wen-Nung Lie

    Gamma correction

    A variety of devices used for image capture,printing, and display respond according to a powerlaw

    The process used to correct the power-lawresponse phenomena is called gamma correction

    CRT has an intensity-to-voltage response of produce images that are darker than intended preprocess the images with beforeinputting it into the monitor

    Current image standards do not contain the value

    of gamma with which an image was created

    5.2~8.1=

    4.05.21 =

  • 7/31/2019 Lie Gonzalez Ch3

    6/373-5

    CCU, Taiwan

    Wen-Nung Lie

  • 7/31/2019 Lie Gonzalez Ch3

    7/373-6

    CCU, Taiwan

    Wen-Nung Lie

    Power-law transformation for

    contrast manipulation

  • 7/31/2019 Lie Gonzalez Ch3

    8/373-7

    CCU, Taiwan

    Wen-Nung Lie

    Piecewise-linear

    transformation

    The form of piecewise functions can be arbitrarily complex

    Contrast stretching increase the dynamic range of images

    being processed

  • 7/31/2019 Lie Gonzalez Ch3

    9/37

    3-8CCU, Taiwan

    Wen-Nung Lie

    Graylevel slicing & bit-plan

    slicing

  • 7/31/2019 Lie Gonzalez Ch3

    10/37

    3-9CCU, Taiwan

    Wen-Nung Lie

    Bit-plane decomposition

    1. The MSB plane contains the majority of information

    2. The LSB plane are likely random

  • 7/31/2019 Lie Gonzalez Ch3

    11/37

    3-10CCU, Taiwan

    Wen-Nung Lie

    Histogram processing

    Histogram

    A discrete function , where is the kthgraylevel and is the number of pixels in the imagehaving graylevel

    A normalized histogram is given by

    where n is the total number of image pixels

    An image with low contrast has a narrow histogram

    A high contrast image tends to occupy the entire rangeof graylevels and be distributed uniformly

    kk nrh =)(

    kn

    kr

    kr

    nnrp kk /)( =

  • 7/31/2019 Lie Gonzalez Ch3

    12/37

    3-11CCU, Taiwan

    Wen-Nung Lie

    Histogram equalization

    Point transformation

    Single-valued

    Monotonically increasing

    Modify the image histogram, via point

    transformation r s, such that its shape isapproximately flat

    Cdf(cumulative distribution function)

    transformation

    1r0),( = rTs

  • 7/31/2019 Lie Gonzalez Ch3

    13/37

    3-12CCU, Taiwan

    Wen-Nung Lie

    Histogram equalization (cont.)

    Discrete implementation

    Each pixel with graylevel is mapped intoin the output image

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

    ==== = = Lknn

    rprTs

    k

    j

    k

    j

    jjrkk

    kr ks

    ds

    drrpsp

    dwwprTs

    rs

    r

    r

    )()(

    )()( 0

    =

    ==

    1s0,1)( =sps Uniform distribution

  • 7/31/2019 Lie Gonzalez Ch3

    14/37

    3-13CCU, Taiwan

    Wen-Nung Lie

    Histogram equalization (cont.)

    Histogram equalization is a nonlinear(non-uniform) stretching technique, itstretches the histogram as flat aspossible (approximating a linear cdffunction)

  • 7/31/2019 Lie Gonzalez Ch3

    15/37

    3-14CCU, Taiwan

    Wen-Nung Lie

    Histogram matching

    (specification)

    Transform the image such that it has anapproximately desired histogram shape

    Given and (input and desired output),

    compute

    for a value ofk, find a smallest h such that .

    Then transform kinto h (0h,k255).

    )( kr rp )( jz zp

    =

    =k

    j

    jrk rps0

    )( =

    =h

    j

    jzh zpv0

    )(

    kh sv

    Histogram specification is a trial-and-error process, thereare no rules for specifying histograms

    f

  • 7/31/2019 Lie Gonzalez Ch3

    16/37

    3-15CCU, Taiwan

    Wen-Nung Lieoriginal

    result

    Specified histogram

  • 7/31/2019 Lie Gonzalez Ch3

    17/37

    3-16CCU, Taiwan

    Wen-Nung Lie

    Local enhancement

    Global mean and variance

    Local mean and variance

    An example

    enhance dark areas while leaving the light area asunchanged as possible

    =

    =1

    0

    )(L

    i

    ii rprm

    =

    =1

    0

    2

    2 )()()(L

    i

    ii rpmrr

    = xyxy Sts tstsSrprm

    ),(

    ,, )( = xy xyxy

    Sts

    tsStsS rpmr),(

    ,2

    ,2 )(][

    =

    ),(

    ),(),(

    yxf

    yxfEyxg

    otherwise

    DkDkMkmif GSGGS xyxy 210 AND

    4.0,02.0,4.0,0.4 210 ==== kkkE 3x3 local region

  • 7/31/2019 Lie Gonzalez Ch3

    18/37

    3-17CCU, Taiwan

    Wen-Nung Lie

    original enhanced

    Also causesome artifacts

    Enhancementmask

  • 7/31/2019 Lie Gonzalez Ch3

    19/37

    3-18CCU, Taiwan

    Wen-Nung Lie

    Enhancement using

    arithmetic/logic operations

    Arithmetic/logic operations between two or more

    images

    arithmetic : subtraction, addition

    logic : AND, OR, NOT AND and OR are for masking, i.e., for selecting subimages or

    for ROI processing

  • 7/31/2019 Lie Gonzalez Ch3

    20/37

    3-19CCU, Taiwan

    Wen-Nung Lie

    Image subtraction

    Operation :

    Commercial applications

    Mask mode radiography in medical imaging

    injecting a contrast medium into the patients bloodstream andsubtracting the mask (i.e., the image without injected medium)

    from a series of incoming images

    showing how the contrast medium propagates through the

    arteries

    Change detection via image subtraction

    tracking moving objects or vehicles

    ),(),(),( yxhyxfyxg =

  • 7/31/2019 Lie Gonzalez Ch3

    21/37

    3-20CCU, Taiwan

    Wen-Nung Lie

    angiography

    Change/motion detection

    _=

    1st frame 2nd frame motion detected

  • 7/31/2019 Lie Gonzalez Ch3

    22/37

    3-21CCU, Taiwan

    Wen-Nung Lie

    Image averaging If the noise is uncorrelated and has zero average

    value, we can average Kdifferent noisy images

    and get

    The images must be registered (aligned)accurately to avoid the introduction of blurring

    Important application : astronomy, IR imaging

    high noise often occurs in low signal case orinsufficient cooling of sensors

    =

    =K

    i

    i yxgK

    yxg1

    ),(1

    ),(

    2

    ),(

    2

    ),(

    1and),()},({ yxyxg

    KyxfyxgE

    ==

    ),(),(),( yxyxfyxg +=

    ),( yxgi

  • 7/31/2019 Lie Gonzalez Ch3

    23/37

    3-22CCU, Taiwan

    Wen-Nung Lie

    original noisy

    K=8 K=16

    K=64 K=128

  • 7/31/2019 Lie Gonzalez Ch3

    24/37

    3-23CCU, Taiwan

    Wen-Nung Lie

    Spatial filtering

    Filtering in the spatial domain by convolution

    directly on the pixels

    Need a filter mask (or the impulse response) for

    operation Calculate the response at each point (x,y) (i.e., slide the

    filter mask from point to point)

    The mask is often of odd size (2a+1)(2b+1), e.g. 33 Filtering by FFT and manipulation in the

    frequency domain

  • 7/31/2019 Lie Gonzalez Ch3

    25/37

    3-24CCU, Taiwan

    Wen-Nung Lie

    = = ++=a

    as

    b

    bttysxftswyxg ),(),(),(

    Nonlinear spatial filtering :operations that can not be

    represented by sum-of-products

    Linear spatial filtering

    How to manage the boundary problem ?

  • 7/31/2019 Lie Gonzalez Ch3

    26/37

    3-25CCU, Taiwan

    Wen-Nung Lie

    Smoothing spatial filter Used for blurring and noise reduction

    Also called averaging filter or lowpass filter

    Two 33 examples The division scale factor is equal to sum of the coefficients

    (avoiding overflow) and had better be a power of 2

    weighted average

    the weight decreases as the distance to the center pixel increases

    Discrete Gaussian averaging with variance

    1/9

    1 1 1

    1 1 1

    1 1 1

    1/16

    1 2 1

    2 4 2

    1 2 1

    2

    = =

    = =

    ++=

    a

    as

    b

    bt

    a

    as

    b

    bt

    tsw

    tysxftsw

    yxg

    ),(

    ),(),(

    ),(

  • 7/31/2019 Lie Gonzalez Ch3

    27/37

    3-26CCU, Taiwan

    Wen-Nung Lie

    More larger the window, more blurring effect it has

    More flat the coefficients are, more blurring they result in

  • 7/31/2019 Lie Gonzalez Ch3

    28/37

    3-27CCU, Taiwan

    Wen-Nung Lie

    Order-statistics (Median) filter Nonlinear spatial filter whose response is based on

    ordering (ranking) the pixels contained in the window effective to eliminate impulse noise or salt-and-pepper noise,

    with considerably less blurring than linear smoothing filter

    eliminate noise less than half of the window size

    1-D or 2-D window size

    Original noisy Low-pass filter Median filter

  • 7/31/2019 Lie Gonzalez Ch3

    29/37

    3-28CCU, Taiwan

    Wen-Nung Lie

    Sharpening spatial filter To highlight fine detail in an image

    Image differentiation (1st and 2nd-order

    derivatives) enhances edges and other

    discontinuities digital 1st-order derivative of 1-D signal

    we can expect a 2nd order derivative to enhance fine

    detail much more than a 1st-order derivative

    )(2)1()1(2

    2

    xfxfxfx

    f

    ++=

    )()1( xfxfx

    f

    +=

  • 7/31/2019 Lie Gonzalez Ch3

    30/37

    3-29CCU, Taiwan

    Wen-Nung Lie

    2nd-order derivative --

    Laplacian operator Isotropic filter -- whose response is independent of the

    direction of the discontinuities in the image, or rotation-

    invariant

    The Laplacian is the simplest isotropic derivative operator

    2

    2

    2

    22

    y

    f

    x

    ff

    +

    =

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

    2

    yxfyxfyxf

    x

    f++=

    0 -1 0

    -1 4 -1

    0 -1 0

    -1 -1 -1

    -1 8 -1

    -1 -1 -1

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

    2

    yxfyxfyxfy

    f++=

    Digital Laplacian

    ),(4)]1,()1,(),1(),1([2

    yxfyxfyxfyxfyxff +++++=

    U f L l i f

  • 7/31/2019 Lie Gonzalez Ch3

    31/37

    3-30CCU, Taiwan

    Wen-Nung Lie

    Use of Laplacian for

    sharpening enhancement Sharpening enhancement -- add the Laplacian response to

    the original image

    ),(),(),( 2 yxfyxfyxg =

    Sharpening -- Enhance the highfrequency component

    )]1,()1,(

    ),1(),1([),(5

    ),(),(),( 2

    +++

    ++=

    +=

    yxfyxf

    yxfyxfyxf

    yxfyxfyxg

    0 -1 0

    -1 5 -1

    0 -1 0

    -1 -1 -1

    -1 9 -1

    -1 -1 -1

    U h ki & hi h

  • 7/31/2019 Lie Gonzalez Ch3

    32/37

    3-31CCU, Taiwan

    Wen-Nung Lie

    Unsharp masking & high-

    boost filtering Unsharp masking in publishing industry

    High-boost filtering

    ),(),(),( yxfyxfyxfs = Sharpening reduce the lowfrequency component

    ),(),(

    ),(),()1(

    1),(),(),(

    2

    yxfyxAf

    yxfyxfA

    AyxfyxAfyxf

    s

    hb

    =

    +==

    0 -1 0

    -1 A+4 -1

    0 -1 0

    -1 -1 -1

    -1 A+8 -1

    -1 -1 -1

    The sharpeningeffect decreases as

    A increases

    If we select

    ),(),(),(2

    yxfyxfyxfs =

    A li ti f hi h b t

  • 7/31/2019 Lie Gonzalez Ch3

    33/37

    3-32CCU, Taiwan

    Wen-Nung Lie

    Application of high-boost

    filtering

    Sharpen the image and simultaneouslybrighten it

    A=1 A=1.7

  • 7/31/2019 Lie Gonzalez Ch3

    34/37

    3-33CCU, Taiwan

    Wen-Nung Lie

    Use of 1st-order derivative Gradient vector

    Gradient magnitude

    Approximation

    =

    =

    y

    fx

    f

    GG

    y

    xf

    21

    21

    ])()[(

    ][)(

    22

    22

    yf

    xf

    GGmagf yx

    +=

    +== f

    yx

    GGf +

  • 7/31/2019 Lie Gonzalez Ch3

    35/37

    3-34CCU, Taiwan

    Wen-Nung Lie

    Popular gradient operators -1 0

    0 1

    0 -1

    1 0

    Roberts cross-gradient operators

    Sobel gradient operator-1 -2 -1

    0 0 0

    1 2 1

    -1 0 1

    -2 0 2

    -1 0 1

    The coefficients sum to zero, toyield zero on flat areas

    Laplacian operator Sobel operator

    C bi i ti l

  • 7/31/2019 Lie Gonzalez Ch3

    36/37

    3-35CCU, Taiwan

    Wen-Nung Lie

    Combining spatial

    enhancement methods Use Laplacian to highlight fine detail

    also produce noiser results than the gradient

    Use gradient to enhance prominent edges The gradient has a stronger response in ramps and steps areas than

    does the Laplacian

    The response of the gradient to noise is lower than Laplacian

    The response to noise can be lowered by smoothing the gradientwith an averaging filter

    Combining Laplacian and gradient operators smooth the gradient and multiply it by the Laplacian image

    (preserve details in the strong areas while reducing noise in the flatareas)

    The above result is added to the original image

    Smoothed gradient Product of Laplaciand h d di

  • 7/31/2019 Lie Gonzalez Ch3

    37/37

    3-36CCU, Taiwan

    Wen-Nung Lie

    original Laplacian

    sharpening Sobel gradient

    by 5x5 window and smoothed gradient

    final sharpening increase DRwith =0.5