di&sp#-03-405017

Upload: phamgiap

Post on 06-Jan-2016

213 views

Category:

Documents


0 download

DESCRIPTION

XLA

TRANSCRIPT

  • 7/17/2019 DI&SP#-03-405017

    1/46

    4border code=

    Image Enhancement in the Spatial Domain

    Lec#03: Intensity Transformations

    Dr. Ch Vit Nht Anhnhat-anh.che@{hcmut.edu.vn,hotmail.com}

    Department of Telecommunications EngineeringFaculty of Electrical and Electronic Engineerings

    Ho Chi Minh City, University of Technology

    HK I, 2015 - 2016

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 1 / 91

    Outline

    1 Introduction

    2 Histogram

    3 Some Basic Intensity Transformation Functions

    4 Histogram Processing

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 2 / 91

  • 7/17/2019 DI&SP#-03-405017

    2/46

    Learning Outcomes

    After learning this chapter, you will be able to: Illustrate the effect of power-law & logarithmic histogram transforms Describe the basis of the histogram as a Probability Density

    Function (PDF)

    Distinguish between the brightness and the contrast of an image Explain the relationship between dynamic range and contrast Explain the effects of histogram stretch, histogram equalization,

    histogram matching, histogram modification & distinguish betweenthem

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 3 / 91

    "It makes all the difference whether one sees

    darkness through the light or brightness through the

    shadows

    David Lindsay (Scottish Novelist)

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 4 / 91

  • 7/17/2019 DI&SP#-03-405017

    3/46

    Outline

    1 Introduction- Motivation- Type of operations

    - Spatial domain

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 5 / 91

    IntroductionMotivation

    Which one looks better?

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 6 / 91

  • 7/17/2019 DI&SP#-03-405017

    4/46

    IntroductionMotivation

    Which one looks better?

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 7 / 91

    IntroductionMotivation

    Which one looks better?

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 8 / 91

  • 7/17/2019 DI&SP#-03-405017

    5/46

    IntroductionMotivation

    Which one looks better?

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 9 / 91

    IntroductionMotivation

    Close-by pixel values are difficult to distinguish.

    Far apart pixel values are easy to distinguish.

    Low contrast: image values concentrated near a narrow range(mostly dark, or mostly bright, or mostly medium values).

    Contrast enhancement change the image value distribution tocover a wide range.

    Contrast of an image can be revealed by itshistogram.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 10 / 91

  • 7/17/2019 DI&SP#-03-405017

    6/46

    IntroductionType of operations

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 11 / 91

    IntroductionType of operations

    Operation Characterization Generic Complexity/PixelPoint The output value at a specific co-

    ordinate is dependent only on the

    input value at thatsame coordinate

    Constant

    Local The output value at a specific co-ordinate is dependent on the input

    values in the neighborhood of that

    same coordinate.

    (2m + 1) (2n + 1)

    Global The output value at a specific coor-dinate is dependent on all the valuesin the input image.

    M N

    Image size = M N; Neighborhood size = (2m + 1) (2n + 1).

    The complexity is specified in operations per pixel.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 12 / 91

  • 7/17/2019 DI&SP#-03-405017

    7/46

    IntroductionType of operations

    Domains

    Spatial Domain Processing

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 13 / 91

    IntroductionType of operations

    Spatial domain:Image plane itself, directly process the intensityvalues of the image plane.

    Point Operation (Intensity Transformations Function) Gamma correction, window-center correction, histogram

    equalization,...

    Spatial filters (Neighborhood Operation) Correlation Convolution (Filtering): mean, Gaussian, median, etc. Image gradients,...

    Transform domain(Frequency domain, Wavelet domain) Processthe transform coefficients, not directly process the intensity valuesof the image plane.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 14 / 91

  • 7/17/2019 DI&SP#-03-405017

    8/46

    IntroductionType of operations

    Point processing Spatial processing Frequency domainprocessing

    Contrast stretching:

    Gray level transform

    Clipping

    Intensity Level slicing

    Neighborhood pro-

    cessing:

    Averaging

    Directionalsmoothing

    Median filtering

    Unsharpmasking

    Linear filtering:

    Low pass

    High-passnonlinearfiltering

    Homomorphicfiltering

    Histogram techniques:

    Equalization

    Histogram specification(matching)

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 15 / 91

    IntroductionSpatial domain

    Spatial domain refers to the aggregated of pixels composing animage.

    Spatial domain methods are procedures that operate directly onthese pixels. Spatial domain processes will be denoted by the

    expression:s= g(x0, y0) =T(r) =T{f(x0, y0)} (1.1)

    T: an operator defined over some neighborhood of (x0, y0), maybelinear or nonlinear.

    N 1(0,0)

    r

    y

    x

    x0

    M 1

    y0 N 1(0,0)

    s

    y

    x

    x0

    M 1

    y0

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 16 / 91

  • 7/17/2019 DI&SP#-03-405017

    9/46

    Histogram

    Histogram of a monochrome image with gray levels in the range[0, L 1]:

    A discrete function, h(rk) =nk, k= 0, 1, . . . , L 1. rk: the kth gray level.

    nk the number of pixels in the image having gray level rk. Normalized histogram: An estimate of the probability of

    occurrence of gray level rk p(rk) =

    nk

    M N, k= 0, 1, . . . , L 1.

    The sum of all components of a normalized histogram is equal to 1.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 17 / 91

    Example

    Sketch the histogram of the following image:

    6 6 1 2 50 2 0 5 6

    6 7 6 1 0

    2 1 0 5 4

    0 6 7 1 6

    rk 0 1 2 3 4 5 6 7

    nk 5 4 3 0 1 3 7 20 1 2 3 4 5 6 7

    01234

    5

    7

    rk

    nk

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 18 / 91

  • 7/17/2019 DI&SP#-03-405017

    10/46

    Example

    Sketch the normalized histogram of the following image:

    6 6 1 2 50 2 0 5 6

    6 7 6 1 02 1 0 5 4

    0 6 7 1 6

    rk 0 1 2 3 4 5 6 7

    p(rk) 0.2 0.16 0.12 0 0.04 0.12 0.28 0.08

    0 1 2 3 4 5 6 70

    0.040.080.120.160.2

    0.28

    rk

    p(rk)

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 19 / 91

    Histogram

    The following two images have the same histograms:

    The histogram shows the number of pixels that have each pixelvalue, but it does not record where those pixels are located in the

    image. Thus, spatial information is discarded. The histogram is unique for a particular image, but different images

    could have the same histogram.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 20 / 91

  • 7/17/2019 DI&SP#-03-405017

    11/46

    Histogram

    The information inherent in histograms also is quite useful in otherimage processing applications:

    Image compression Segmentation

    Histograms are simple to calculate in software & also lendthemselves to economic hardware implementations, thus makingthem a popular tool for real-time image processing.

    The shape of the histogram of an image does provide usefulinformation about the possibility for contrast enhancement.

    The role of histogram processing in image enhancement: Dark image

    Light image Low contrast High contrast

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 21 / 91

    Histogram

    Dark image

    0 63 127 193 2550

    2

    4

    6

    8102

    rk

    p(rk

    )

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 22 / 91

  • 7/17/2019 DI&SP#-03-405017

    12/46

    Histogram

    Light image

    0 63 127 193 2550

    2

    4

    6

    8102

    rk

    p(rk

    )

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 23 / 91

    Histogram

    Low contrast

    0 63 127 193 2550

    2

    4

    6

    8102

    rk

    p(rk

    )

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 24 / 91

  • 7/17/2019 DI&SP#-03-405017

    13/46

    Histogram

    High contrast

    0 63 127 193 2550

    2

    4

    6

    8102

    rk

    p(rk

    )

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 25 / 91

    Histogram

    Dynamic range: The range of pixel values, defined as the difference between the

    maximum (rmax) the minimum (rmin) pixel values found in theimage, ignoring any obvious outliers.

    It can be expressed either as the difference in pixel values or dB:

    Dynamic range of image= 20 log10(rmax rmin) (2.1)

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 26 / 91

  • 7/17/2019 DI&SP#-03-405017

    14/46

    Outline

    3 Some Basic Intensity Transformation Functions- Point operations- Identity- Image Negatives- Gamma Transformations- Log Transformations- Piecewise-Linear Transformations- Bit Plane Slicing

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 27 / 91

    Some Basic Intensity Transformation FunctionsPoint operations

    g depends only onthe value off at (x0, y0). T becomes a gray-level(also called an intensity or mapping) transformation function of theform:

    s= g(x0, y0) =T(r) =T{f(x0, y0)} (3.1)

    Point operations arezero memory operations.

    N 1(0,0)

    r

    y

    x

    x0

    M 1

    y0 N 1(0,0)

    s

    y

    x

    x0

    M 1

    y0

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 28 / 91

  • 7/17/2019 DI&SP#-03-405017

    15/46

    Some Basic Intensity Transformation FunctionsPoint operations

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 29 / 91

    Some Basic Intensity Transformation FunctionsIdentity

    No change on pixel values, s= T(r) =r.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 30 / 91

  • 7/17/2019 DI&SP#-03-405017

    16/46

    Some Basic Intensity Transformation FunctionsImage Negatives

    Contrast reversal: negative, s= T(r) =L 1 r.

    It produces the equivalent of a photographic negatives.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 31 / 91

    Some Basic Intensity Transformation FunctionsGamma Transformations

    Power-Law transformations: s= cr or s= cr, c, > 0.

    Values ofsuch that 0< 1 have the opposite behavior to above (darken theintensity).

    c= = 1gives the identity transformation.

    Gamma correction is an application.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 32 / 91

  • 7/17/2019 DI&SP#-03-405017

    17/46

    Some Basic Intensity Transformation FunctionsGamma Transformations

    Plots of the equation s= r for various values of. All curves werescaled to fit in the range shown.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 33 / 91

    Some Basic Intensity Transformation FunctionsGamma Transformations

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 34 / 91

  • 7/17/2019 DI&SP#-03-405017

    18/46

    Some Basic Intensity Transformation FunctionsGamma Transformations

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 35 / 91

    Some Basic Intensity Transformation FunctionsGamma Transformations

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 36 / 91

  • 7/17/2019 DI&SP#-03-405017

    19/46

    Some Basic Intensity Transformation FunctionsGamma Transformations

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 37 / 91

    Some Basic Intensity Transformation FunctionsGamma Transformations

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 38 / 91

  • 7/17/2019 DI&SP#-03-405017

    20/46

    Some Basic Intensity Transformation FunctionsLog Transformations

    Maps a narrow range of low intensity values in input to a wideroutput range.

    The opposite is true for high intensity input values.

    Compresses the dynamic range of images with large variations inpixel values. (The dynamic range of the image data may be verylarge -> Dynamic range can be compresses via the logarithmictransformation).

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 39 / 91

    Some Basic Intensity Transformation FunctionsLog Transformations

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 40 / 91

  • 7/17/2019 DI&SP#-03-405017

    21/46

    Some Basic Intensity Transformation FunctionsLog Transformations

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 41 / 91

    Some Basic Intensity Transformation FunctionsPiecewise-Linear Transformations: Contrast Stretching

    Expands the range of intensity levels in an image so that it spansthe full intensity range of the recording medium or display device.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 42 / 91

  • 7/17/2019 DI&SP#-03-405017

    22/46

    Some Basic Intensity Transformation FunctionsPiecewise-Linear Transformations: Contrast Stretching

    Low contrast images can result from poor illumination. Reduce intensity: (0, 0)(r1, s1), (r2, s2)(L 1, L 1). Increase intensity: The slope of the transformation is chosen greater

    than unity in the region of stretch.

    s= T(r) =

    s1

    r1r 0 rr1

    s2 s1r2 r1

    (r r1) + s1 r1 < rr2

    L 1 s2L 1 r2

    (r r2) + s2 r2 < rL 1

    (3.2)

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 43 / 91

    Some Basic Intensity Transformation FunctionsPiecewise-Linear Transformations: Contrast Stretching

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 44 / 91

  • 7/17/2019 DI&SP#-03-405017

    23/46

    Some Basic Intensity Transformation FunctionsPiecewise-Linear Transformations: Contrast Compressing

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 45 / 91

    Some Basic Intensity Transformation FunctionsPiecewise-Linear Transformations: Intensity-level Slicing

    Highlighting a specific range of intensities in an image.

    Two main approaches: Display in one value (e.g. white) all the values in the range of interest

    and all others in another value (e.g black all other intensities)

    binary image. Brighten or darkens the desired range of intensity levels in the imageunchanged.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 46 / 91

  • 7/17/2019 DI&SP#-03-405017

    24/46

    Some Basic Intensity Transformation FunctionsPiecewise-Linear Transformations: Intensity-level Slicing

    This transformationhighlights intensity range[A, B]and reduces all othersintensities to a lower level.

    This transformationhighlights intensity range[A, B] and preserves all othersintensities to a lower level.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 47 / 91

    Some Basic Intensity Transformation FunctionsPiecewise-Linear Transformations: Intensity-level Slicing

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 48 / 91

  • 7/17/2019 DI&SP#-03-405017

    25/46

    Some Basic Intensity Transformation FunctionsBit Plane Slicing

    Pixels are digital numbers composed of bits.

    Suppose that each pixel in an image is represented by 8 bitsb7b6b5b4b3b2b1b0. Imagine that the image is composed of eight 1-bit

    planes, ranging from bit-plane 0, the Least Significant Bit(Lowest-order bit, b0) to bit-plane 7, the Most Significant Bit(Highest-order bit, b7).

    Each bit plane is a binary image

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 49 / 91

    Some Basic Intensity Transformation FunctionsBit Plane Slicing

    Highlight the contribution made to total image appearance byspecific bits

    Higher-order bits usually contain most of the significant visualinformation.

    Lower-order bits contain subtle details.

    Useful for compression.

    We have to use bit get and bit set to extract 8 images:

    b7b6b5b4b3b2b1b0

    136 11 124 67 7

    33 17 3

    0 1 1

    0 1 1

    1 1 1

    0 0 0

    1 0 0

    0 1 0

    0 1 0

    0 1 1

    0 0 1

    0 0 0

    0 0 0

    1 0 0

    0 0 0

    0 0 1

    0 0 0

    0 0 0

    0 1 0

    0 0 0

    1 1 0

    1 0 0

    0 0 0

    1 0 0

    0 0 0

    0 0 0

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 50 / 91

  • 7/17/2019 DI&SP#-03-405017

    26/46

    Some Basic Intensity Transformation FunctionsBit Plane Slicing

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 51 / 91

    Some Basic Intensity Transformation FunctionsBit Plane Slicing

    Reconstruction is obtained by:

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 52 / 91

  • 7/17/2019 DI&SP#-03-405017

    27/46

    Outline

    4 Histogram Processing- Histogram Equalization- Histogram matching or Histogram specification- Local Histogram Processing- Using Histogram Statistics for Image Enhancement

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 53 / 91

    Histogram ProcessingHistogram Equalization

    Consider for a momentcontinuous intensity values, & let thevariable r represent the gray levels of the image to be enhanced,that is r[0, L 1], with r = 0 representingblack, & r=L 1representingwhite.

    For any r satisfying the aforementioned conditions, we focusattention on transformations of the form:

    s= T(r) 0 r L 1 (4.1)

    Let pr(r), ps(s)denote the Probability Density Function (PDF) ofrandom variables r and s.

    0 rL 1

    pr(r)

    0 sL 1

    1

    L 1

    ps(s)

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 54 / 91

  • 7/17/2019 DI&SP#-03-405017

    28/46

    Histogram ProcessingHistogram Equalization

    Transforms an image with an arbitrary histogram to one with a flathistogram.

    The transformation function T(r) satisfies the following conditions:

    T(r)is amonotonically increasing functionin the interval0 r L 1.

    0 s= T(r) L 1 for 0 r L 1.

    T(r)is continuous and differentiable.

    0 rr1 r2 L 1

    L 1

    s1

    s

    0 rL 1

    L 1

    s1

    s

    r1

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 55 / 91

    Histogram ProcessingHistogram Equalization

    0 rL 1

    L 1

    s

    0 rdr L 1

    pr(r)

    s

    ps(s)

    ds

    ps(s)ds= pr(r)drds= 1

    ps(s)pr(r)dr = (L 1)pr(r)dr

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 56 / 91

  • 7/17/2019 DI&SP#-03-405017

    29/46

    Histogram ProcessingHistogram Equalization

    Continuous case:

    s= T(r) = (L 1) r

    0

    pr(w)dw (4.2)

    w: a dummy variable of integration. pr(r)ishigh, T(r)has asteep slope, dswill bewide, causing ps(s)to

    belowto keep ps(s)ds= pr(r)dr. pr(r)islow, T(r)has ashallow slope, dswill benarrow, causing

    ps(s)to behighto keep ps(s)ds= pr(r)dr.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 57 / 91

    Example

    Suppose that the (continuous) intensity values in an image have theProbability Density Function (PDF)

    pr(r) =

    2r

    (L 1)2 for0 r L 1

    0 otherwise

    Find the transformation function for equalizing the image histogram.

    s= T(r) = (L 1)

    r0

    pr(w)dw= (L 1)

    r0

    2w

    (L 1)2dw=

    r2

    L 1

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 58 / 91

  • 7/17/2019 DI&SP#-03-405017

    30/46

    Example

    The histograms of two images are illustrated below. Sketch atransformation function for each image that will make the image has abetter contrast. Use the axis provided below to sketch yourtransformation functions.

    r20 128 255

    1

    108

    pr(r)

    0 r100 200 255

    pr(r)

    r20 128 255

    255

    s

    0 r100 200 255

    128

    s

    255

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 59 / 91

    Histogram ProcessingHistogram Equalization

    Discrete values: For k= 0, 1, . . . , L 1

    sk = T(rk) = (L 1)k

    j=0

    pr(rj) (4.3)

    = (L 1)k

    j=0

    nj

    M N=

    L 1

    M N

    kj=0

    nj (4.4)

    The histogram equalization process consists of four steps:1 Find the running sum of the histogram values.2 Normalize the values from step 1 by dividing by the total number of

    pixels.

    3 Multiply the values from step 2 by the maximum gray level value andround.

    4 Map the gray-level values to the result from step 3 using one-to-onecorrespondence.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 60 / 91

  • 7/17/2019 DI&SP#-03-405017

    31/46

    Example

    Suppose that a 3-bit image (L= 8 intensity levels) of size 64 64 pixels(M N= 4096) has the intensity distribution shown in following table.

    rk 0 1 2 3 4 5 6 7

    nk 790 1023 850 656 329 245 122 81

    1 Sketch the original histogram.

    2 Get & sketch the histogram equalization transformation function.

    3 Give the ps(sk)for each sk. Sketch the equalized histogram.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 61 / 91

    Example

    1 Sketch the original histogram.

    rk 0 1 2 3 4 5 6 7pr(rk) 0.193 0.25 0.208 0.16 0.08 0.06 0.03 0.02

    0 1 2 3 4 5 6 7 rk

    pr(rk)

    0.250.2

    0.150.1

    0.05

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 62 / 91

  • 7/17/2019 DI&SP#-03-405017

    32/46

    Example

    2 Get & sketch the histogram equalization transformation function.

    rk 0 1 2 3 4 5 6 7k

    j=0

    nj 790 1813 2663 3319 3648 3893 4015 4096

    sk = L 1

    M N

    kj=0

    nj 1.33 3.08 4.55 5.67 6.03 6.65 6.86 7

    sk 1 3 5 6 6 7 7 7

    0 r1 2 3 4 5 6 7

    s

    1.33

    3.08

    4.555.67

    7

    0 r1 2 3 4 5 6 7

    s

    1

    3

    5677

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 63 / 91

    Example

    3 Give the ps(sk)for each sk. Sketch the equalized histogram.

    sk 0 1 2 3 4 5 6 7nk 0 790 0 1023 0 850 985 448

    ps(sk) 0 0.19 0 0.25 0 0.20 0.24 0.12

    0 1 2 3 4 5 6 7 sk

    ps(sk)

    0.250.2

    0.150.1

    0.05

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 64 / 91

  • 7/17/2019 DI&SP#-03-405017

    33/46

    0 63 127 193 2550

    2

    4

    6

    8102

    rk

    p(rk

    )

    0 63 127 193 2550

    2

    4

    6

    8102

    sk

    p

    (sk

    )

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 65 / 91

    0 63 127 193 2550

    2

    4

    6

    8102

    rk

    p(rk

    )

    0 63 127 193 2550

    2

    4

    6

    8102

    sk

    p(sk

    )

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 66 / 91

  • 7/17/2019 DI&SP#-03-405017

    34/46

    0 63 127 193 2550

    2

    4

    6

    8102

    rk

    p(rk

    )

    0 63 127 193 2550

    2

    4

    6

    8102

    sk

    p(sk

    )

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 67 / 91

    0 63 127 193 2550

    2

    4

    6

    8102

    rk

    p(rk

    )

    0 63 127 193 2550

    2

    4

    6

    8102

    sk

    p(

    sk

    )

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 68 / 91

  • 7/17/2019 DI&SP#-03-405017

    35/46

    Histogram

    Transformation function for histogram equalization:

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 69 / 91

    Histogram ProcessingHistogram Equalization

    The above procedure is for grayscale images

    For color images: Apply separately the procedure to each of the three channels

    will yield in a dramatic change in the color balance NOT RECOMMENDED unless you have a good reason for doing

    that.

    Recommended method Convert the image into another color space such as the Lab color

    space OR HSL/HSV color space. Apply the histogram equalization on the Luminance channel Convert back into the RGB color space.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 70 / 91

  • 7/17/2019 DI&SP#-03-405017

    36/46

    Histogram ProcessingHistogram equalization

    Can contrast stretching achieve similar result as histogramequalization?

    If it can, why histogram equalization then? Histogram equalization (HE) results are similar to contrast stretching

    but offer the advantage of full automation, since HE automaticallydetermines a transformation function to produce a new image with auniform histogram.

    Histogram equalization method: Only generates one result: an image with approximately uniform

    histogram (without any flexibility). Enhancement may not be achieved as desired.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 71 / 91

    Histogram ProcessingHistogram matching or Histogram specification

    What if the desired histogram is not flat?

    Histogram specification:Transform an image according to aspecified gray-level histogram

    Let pr(r)and pz(z)denote the continuous probability density

    functions of the variables r and z. pz(z)is the specified probability density function or specifyparticular histogram shapes pz(z)capable of highlighting certaingray-level ranges.

    Obtain the transformation function for transformation ofr to z.

    r

    pr(r)

    z

    pz(z)

    Histogram

    Matching

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 72 / 91

  • 7/17/2019 DI&SP#-03-405017

    37/46

    Histogram ProcessingHistogram matching or Histogram specification

    Let sbe the random variable with the probability:

    s= T(r) = (L 1) r

    0

    pr(w)dw (4.5)

    Define a random variable z with the probability

    G(z) = (L 1)

    z0

    pz(t)dt= s (4.6)

    The inverse of the above transform is

    z =G1(s) =G1(T(r)) (4.7)

    r

    pr(r)

    sHistogram

    Equalization

    G(z) z

    pz(z)

    Histogram

    Equalization

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 73 / 91

    Example

    Assuming continuous intensity values, suppose that an image has theintensity PDF:

    pr(r) =

    2r

    (L 1)2 for0 r L 1

    0 otherwise

    Find the transformation function that will produce an image whoseintensity PDF is:

    pz(z) =

    3z2

    (L 1)3 for0 z L 1

    0 otherwise

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 74 / 91

  • 7/17/2019 DI&SP#-03-405017

    38/46

    Example

    1 Find the histogram equalization transformation for the input image

    s= T(r) = (L 1)

    r0

    pr(w)dw= (L 1)

    r0

    2w

    (L 1)2dw=

    r2

    L 1

    2 Find the histogram equalization transformation for the specifiedhistogram

    G(z) = (L 1)

    z0

    pz(t)dt= (L 1)

    z0

    3t2

    (L 1)3dt=

    z3

    (L 1)2 =s

    3 The transformation function

    z=

    (L 1)2s1/3

    =

    (L 1)2 r2

    L 1

    1/3

    =[

    (L 1)r2]1/3

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 75 / 91

    Histogram ProcessingHistogram matching or Histogram specification

    Discrete Cases: Obtain pr(rj) from the input image then obtain the values ofsk,

    round the value to the integer range [0, L 1]:

    sk =T(rk) = (L 1)

    kj=0

    pr(rj) =

    (L 1)

    M N

    kj=0

    nj (4.8)

    Use the specified PDF and obtain the transformation function G(zq),round the value to the integer range [0, L 1]:

    G(zq) = (L 1)

    qi=0

    pz(zi) =sk (4.9)

    Find the smallest value ofzq so that G(zq)is closest to sk:

    zq =G1(sk) (4.10)

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 76 / 91

  • 7/17/2019 DI&SP#-03-405017

    39/46

    Example

    Suppose that a 3-bit image (L = 8) of size 64 64 pixels (M N= 4096)has the intensity distribution shown in the following table (on the left).Get the histogram transformation function and make the output imagewith the specified histogram, listed in the table at the bottom.

    rk 0 1 2 3 4 5 6 7nk 790 1023 850 656 329 245 122 81

    zk 0 1 2 3 4 5 6 7pz(zk) 0 0 0 0.15 0.2 0.3 0.2 0.15

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 77 / 91

    Example

    1 Obtain the scaled histogram-equalized values:

    rk 0 1 2 3 4 5 6 7k

    j=0nj 790 1813 2663 3319 3648 3893 4015 4096

    sk =T(rk) 1.33 3.08 4.55 5.67 6.03 6.65 6.86 7

    sk 1 3 5 6 6 7 7 72 Compute all the values of the transformation function G

    zq 0 1 2 3 4 5 6 71

    j=0pz(zj) 0 0 0 0.15 0.35 0.65 0.85 1

    G(zq) 0 0 0 1.05 2.45 3.55 5.95 7

    G(zq) 0 0 0 1 2 5 6 7

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 78 / 91

  • 7/17/2019 DI&SP#-03-405017

    40/46

    Example

    3 Relate the two mapping above to build a lookup table for the overall mapping. Specifically, for each input level k, find an output levelqso that G(zq)best matches sk.

    rk 0 1 2 3 4 5 6 7

    sk 1 3 5 6 6 7 7 7G(zq) 0 0 0 1 2 5 6 7

    zq 0 1 2 3 4 5 6 7

    nq 0 0 0 790 1023 850 985 448

    pz(zq) 0 0 0 0.19 0.25 0.21 0.24 0.11

    0 1 2 3 4 5 6 7 zq

    pz(zq)

    0.150.2

    0.3

    0.20.15

    0 1 2 3 4 5 6 7 zq

    pz(zq)

    0.190.25

    0.11

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 79 / 91

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 80 / 91

  • 7/17/2019 DI&SP#-03-405017

    41/46

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 81 / 91

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 82 / 91

  • 7/17/2019 DI&SP#-03-405017

    42/46

    Histogram ProcessingHistogram matching or Histogram specification

    Issues with Histogram specification/matching: No rule for specifying an optimal histogram. Each given enhancement task needs to be analyzed on a case-by-case

    basis. Histogram specification is somehow a trial-and-error process.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 83 / 91

    Histogram ProcessingLocal Histogram Processing

    The histogram processing methods mentioned up to now are globaltransformation where:

    Function is designed according to the gray-level distribution over anentire image

    Global transformation methods may not be suitable for enhancing

    details over small areas Where number of pixels in these small areas may have negligible

    influence on designing the global transformation function

    To enhance details over small areas in an image Procedure:

    Define a neighborhood (e.g. N8) Move it from pixel to pixel. For every pixel:

    Histogram computed for the neighborhood. Transfer function computed for Histogram sHistogram specification

    or Histogram specification. Applied on Centre Pixel.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 84 / 91

  • 7/17/2019 DI&SP#-03-405017

    43/46

    Histogram ProcessingLocal Histogram Processing

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 85 / 91

    Histogram ProcessingUsing Histogram Statistics for Image Enhancement

    Global statistics: Themean (average) intensity is given by

    m=

    L1

    i=0

    ripr(ri) = 1

    M N

    M1

    x=0

    N1

    y=0

    f(x, y) (4.11)

    Thevariance of the intensities is given by

    2 =u2(r) =

    L1i=0

    (ri m)2pr(ri) =

    1

    M N

    M1x=0

    N1y=0

    [f(x, y) m]2

    (4.12) The nth moment of the intensity variable r is

    un(r) =L1

    i=0

    (ri m)npr(ri) (4.13)

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 86 / 91

  • 7/17/2019 DI&SP#-03-405017

    44/46

    Histogram ProcessingUsing Histogram Statistics for Image Enhancement

    Mean gives the average brightness of the image.

    Variance 2 and its square root the standard deviation gives thedeviation of intensities on average from the mean value (average

    contrast).

    = 14.3 = 31.6 = 49.2

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 87 / 91

    Histogram ProcessingUsing Histogram Statistics for Image Enhancement

    Local Statistics: Sxy: a neighborhood (subimage) of specific sizecentered at (x, y):

    Local average intensity:

    mSxy =

    L1

    i=0

    ripSxy(ri) (4.14)

    Local variance:

    2Sxy =L1i=0

    (ri mSxy)2pSxy(ri) (4.15)

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 88 / 91

  • 7/17/2019 DI&SP#-03-405017

    45/46

    Histogram ProcessingUsing Histogram Statistics for Image Enhancement

    The statistical parameters can

    be used in various ways. Enhance the background

    filament.

    Enhance details in dark areaswhile leaving light areaunchanged.

    Define rules to chose the

    candidate pixels that need tobe enhanced.

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 89 / 91

    Histogram ProcessingUsing Histogram Statistics for Image Enhancement

    A pixel at point (x, y)is considered if: mSxy k0mG, where k0 is a positive constant less than 1.0, and mG

    is global mean. Sxy k2G, where G is the global standard deviation and k2 is a

    positive constant. Also need to put a lower limit on standard deviation to avoid

    distorting areas which dont have details, i.e., k1G Sxy , withk1 < k2.

    A pixel that meets all above conditions is processed simply bymultiplying it by a specified constant, E, to increase or decrease thevalue of its gray level relative to the rest of the image.

    The values of pixels that do not meet the enhancement conditions

    are left unchanged.

    g(x, y) =

    { Ef(x, y) ifmSxy < k0mG and k1G < Sxy < k2Gf(x, y) otherwise

    (4.16)Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 90 / 91

  • 7/17/2019 DI&SP#-03-405017

    46/46

    Histogram ProcessingUsing Histogram Statistics for Image Enhancement

    Dr. Che Viet Nhat Anh Digital Image & Speech Processing DI&SP - 405017 91 / 91