image enhancement in the spatial domain1

Upload: kumarbsnsp

Post on 05-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    1/54

    1

    Image Enhancement in the

    Spatial Domain

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    2/54

    Principle Objective ofEnhancement

    Process an image so that the result will bemore suitable than the original image for a

    specific application.

    The suitableness is up to each application.

    A method which is quite useful for

    enhancing an image may not necessarily bethe best approach for enhancing anotherimages

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    3/54

    2 domains

    Spatial Domain : (image plane)

    Techniques are based on direct manipulation of pixelsin an image

    Frequency Domain : Techniques are based on modifying the Fourier

    transform of an image

    There are some enhancement techniques based

    on various combinations of methods from thesetwo categories.

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    4/54

    Good images

    For human visual The visual evaluation of image quality is a highly

    subjective process.

    It is hard to standardize the definition of a goodimage.

    For machine perception The evaluation task is easier.

    A good image is one which gives the best machinerecognition results.

    A certain amount of trial and error usually isrequired before a particular image enhancementapproach is selected.

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    5/54

    Spatial Domain

    Procedures that operatedirectly on pixels.

    g(x,y) = T[f(x,y)]

    where f(x,y) is the input image

    g(x,y) is the processedimage

    Tis an operator onfdefined over someneighborhood of (x,y)

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    6/54

    Point Processing

    Neighborhood = 1x1 pixel

    g depends on only the value offat (x,y)

    T= gray level (or intensity or mapping)

    transformation functions = T(r)

    Where

    r = gray level off(x,y)

    s = gray level ofg(x,y)

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    7/54

    3 basic gray-leveltransformation functions

    Linear function

    Negative and identitytransformations

    Logarithm function Log and inverse-log

    transformation

    Power-law function

    nth power and nth roottransformations

    Input gray level, r

    Negative

    Lognth root

    Identity

    nth power

    Inverse Log

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    8/54

    Identity function

    Output intensities areidentical to inputintensities.

    Is included in thegraph only forcompleteness.

    Input gray level, r

    Negative

    Lognth root

    Identity

    nth power

    Inverse Log

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    9/54

    Image Negatives

    An image with gray level in therange [0, L-1]whereL = 2n; n = 1, 2

    Negative transformation :s = L1r

    Reversing the intensity levelsof an image.

    Suitable for enhancing whiteor gray detail embedded indark regions of an image,especially when the black areadominant in size.Input gray level, r

    Negative

    Lognth root

    Identity

    nth power

    Inverse Log

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    10/54

    Example of Negative Image

    Original image Negative Image : gives abetter vision to analyzethe image

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    11/54

    Log Transformations

    s = c log (1+r)

    c is a constantand r 0

    Log curve maps a narrow

    range of low gray-levelvalues in the input imageinto a wider range ofoutput levels.

    Used to expand thevalues of dark pixels in animage while compressingthe higher-level values.

    Input gray level, r

    Negative

    Lognth root

    Identity

    nth power

    Inverse Log

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    12/54

    Example of Logarithm Image

    Result after apply the log

    transformation with c = 1,range = 0 to 6.2Fourier Spectrum withrange = 0 to 1.5 x 106

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    13/54

    Inverse LogarithmTransformations

    Do opposite to the Log Transformations

    Used to expand the values of high pixelsin an image while compressing the darker-level values.

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    14/54

    Power-Law Transformations

    s = cr c and are positive

    constants

    Power-law curves withfractional values of mapa narrow range of darkinput values into a widerrange of output values,

    with the opposite beingtrue for higher values ofinput levels.

    c = = 1 Identityfunction

    Input gray level, rPlots ofs = cr

    for various values of (c = 1 in all cases)

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    15/54

    Another example : MRI

    (a) a magnetic resonance image ofan upper thoracic human spinewith a fracture dislocation and

    spinal cord impingement The picture is predominately dark

    An expansion of gray levels aredesirable needs < 1

    (b) result after power-law

    transformation with = 0.6, c=1

    (c) transformation with = 0.4

    (best result)

    (d) transformation with = 0.3

    (under acceptable level)

    a b

    c d

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    16/54

    Effect of decreasing gamma

    When the is reduced too much, theimage begins to reduce contrast to thepoint where the image started to have very

    slight wash-out look, especially in thebackground

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    17/54

    Another example

    (a) image has a washed-outappearance, it needs acompression of gray levels needs > 1

    (b) result after power-lawtransformation with = 3.0(suitable)

    (c) transformation with = 4.0

    (suitable)(d) transformation with = 5.0

    (high contrast, the image hasareas that are too dark,some detail is lost)

    a b

    c d

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    18/54

    Piecewise-LinearTransformation Functions

    Advantage:

    The form of piecewise functions can bearbitrarily complex

    Disadvantage:

    Their specification requires considerably moreuser input

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    19/54

    Contrast Stretching

    Produce highercontrast than theoriginal by

    darkening the levelsbelow m in the originalimage

    Brightening the levels

    above m in the originalimage

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    20/54

    Thresholding

    Produce a two-level(binary) image

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    21/54

    Contrast Stretching

    increase the dynamic range of thegray levels in the image

    (b) a low-contrast image : resultfrom poor illumination, lack ofdynamic range in the imagingsensor, or even wrong setting of alens aperture of image acquisition

    (c) result of contrast stretching:(r1,s1) = (rmin,0) and (r2,s2) =

    (rmax,L-1)

    (d) result of thresholding

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    22/54

    Gray-level slicing

    Highlighting a specificrange of gray levels in animage Display a high value of all

    gray levels in the range ofinterest and a low value forall other gray levels

    (a) transformation highlightsrange [A,B] of gray level andreduces all others to a

    constant level (b) transformation highlights

    range [A,B] but preserves allother levels

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    23/54

    Bit-plane slicing

    Highlighting the contributionmade to total imageappearance by specific bits

    Suppose each pixel is

    represented by 8 bits Higher-order bits contain the

    majority of the visuallysignificant data

    Useful for analyzing therelative importance playedby each bit of the image

    Bit-plane 7(most significant)

    Bit-plane 0(least significant)

    One 8-bit byte

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    24/54

    Example

    The (binary) image for bit-plane 7 can be obtainedby processing the inputimage with a thresholding

    gray-level transformation. Map all levels between 0

    and 127 to 0

    Map all levels between 129and 255 to 255

    An 8-bit fractal image

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    25/54

    8 bit planes

    Bit-plane 7 Bit-plane 6

    Bit-plane 5

    Bit-plane 4

    Bit-plane 3

    Bit-plane 2

    Bit-plane 1

    Bit-plane 0

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    26/54

    Histogram Processing

    Histogram of a digital image with gray levels inthe range [0,L-1] is a discrete function

    h(rk

    ) = nk

    Where

    rk : the kth gray level

    nk : the number of pixels in the image having gray

    level rk h(rk) : histogram of a digital image with gray levelsrk

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    27/54

    Example

    2 3 3 2

    4 2 4 3

    3 2 3 5

    2 4 2 4

    4x4 image

    Gray scale = [0,9]histogram

    0 11

    2

    2

    3

    3

    4

    4

    5

    5

    6

    6

    7 8 9

    No. of pixels

    Gray level

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    28/54

    Normalized Histogram

    dividing each of histogram at gray levelrk by thetotal number of pixels in the image,n

    p(rk

    ) = nk

    / n For k = 0,1,,L-1

    p(rk)gives an estimate of the probability ofoccurrence of gray levelrk

    The sum of all components of a normalizedhistogram is equal to 1

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    29/54

    Histogram Processing

    Basic for numerous spatial domainprocessing techniques

    Used effectively for image enhancement

    Information inherent in histograms also isuseful in image compression andsegmentation

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    30/54

    Example

    rk

    h(rk) or p(rk)

    Dark image

    Bright image

    Components of

    histogram areconcentrated on thelow side of the grayscale.

    Components ofhistogram areconcentrated on thehigh side of the gray

    scale.

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    31/54

    Example

    Low-contrast image

    High-contrast image

    histogram is narrow

    and centered towardthe middle of thegray scale

    histogram covers broad

    range of the gray scaleand the distribution ofpixels is not too far fromuniform, with very fewvertical lines being much

    higher than the others

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    32/54

    Histogram Equalization

    As the low-contrast images histogram is narrowand centered toward the middle of the grayscale, if we distribute the histogram to a wider

    range the quality of the image will be improved. We can do it by adjusting the probability density

    function of the original histogram of the image sothat the probability spread equally

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    33/54

    Example

    before after Histogramequalization

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    34/54

    Example

    before after Histogramequalization

    The quality isnot improved

    much becausethe originalimage alreadyhas a broadengray-level scale

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    35/54

    Example

    2 3 3 2

    4 2 4 3

    3 2 3 5

    2 4 2 4

    4x4 image

    Gray scale = [0,9]histogram

    0 11

    2

    2

    3

    3

    4

    4

    5

    5

    6

    6

    7 8 9

    No. of pixels

    Gray level

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    36/54

    Gray

    Level(j)0 1 2 3 4 5 6 7 8 9

    No. ofpixels

    0 0 6 5 4 1 0 0 0 0

    0 0 6 11 15 16 16 16 16 16

    0 0

    6

    /

    16

    11

    /

    16

    15

    /

    16

    16

    /

    16

    16

    /

    16

    16

    /

    16

    16

    /

    16

    16

    /

    16

    s x 9 0 03.3

    3

    6.1

    6

    8.4

    89 9 9 9 9

    k

    j

    jn0

    k

    j

    j

    n

    ns

    0

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    37/54

    Example

    3 6 6 3

    8 3 8 6

    6 3 6 9

    3 8 3 8

    Output image

    Gray scale = [0,9]Histogram equalization

    0 11

    2

    2

    3

    3

    4

    4

    5

    5

    6

    6

    7 8 9

    No. of pixels

    Gray level

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    38/54

    Histogram Matching(Specification)

    Histogram equalization has a disadvantage

    which is that it can generate only one type ofoutput image.

    With Histogram Specification, we can specifythe shape of the histogram that we wish theoutput image to have.

    It doesnt have to be a uniform histogram

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    39/54

    Consider the continuous domainLetpr(r) denote continuous probability density

    function of gray-level of input image, rLetpz(z) denote desired (specified) continuousprobability density function of gray-level ofoutput image, z

    Let s be a random variable with the property

    r

    r dw)w(p)r(Ts0

    Where w is a dummy variable of integrationHistogram equalization

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    40/54

    Next, we define a random variable z with the property

    s = T(r) = G(z)

    We can map an input gray level r to output gray level z

    thus

    sdt)t(p)z(g

    z

    z 0

    Where t is a dummy variable of integrationHistogram equalization

    Therefore, z must satisfy the conditionz = G

    -1

    (s) = G-1

    [T(r)]

    Assume G-1 exists and satisfies the condition (a) and (b)

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    41/54

    Procedure Conclusion

    1. Obtain the transformation function T(r) bycalculating the histogram equalization of theinput image

    2. Obtain the transformation function G(z) bycalculating histogram equalization of thedesired density function

    r

    r dw)w(p)r(Ts0

    sdt)t(p)z(G

    z

    z

    0

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    42/54

    Procedure Conclusion

    3. Obtain the inversed transformationfunction G-1

    4. Obtain the output image by applying theprocessed gray-level from the inversed

    transformation function to all the pixels inthe input image

    z = G-1(s) = G-1[T(r)]

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    43/54

    Example

    Assume an image has a gray level probability densityfunction pr(r) as shown.

    0

    1

    2

    12

    Pr(r)

    elsewhere;0

    1r;022r)r(pr

    1

    0

    r

    r dw)w(p

    r

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    44/54

    Example

    We would like to apply the histogram specification withthe desired probability density function pz(z) as shown.

    0

    1

    2

    12

    Pz(z)

    z

    elsewhere;0

    1z;02z)z(pz

    1

    0

    z

    z dw)w(p

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    45/54

    Step 1:

    0 1

    1s=T(r)

    rrr

    ww

    dw)w(

    dw)w(p)r(Ts

    r

    r

    r

    r

    2

    2

    22

    2

    0

    2

    0

    0

    Obtain the transformation function T(r)

    One to onemappingfunction

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    46/54

    Step 2:

    2

    0

    2

    0

    2 zzdw)w()z(Gz

    z

    Obtain the transformation function G(z)

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    47/54

    Step 3:

    2

    22

    2

    2

    rrz

    rrz

    )r(T)z(G

    Obtain the inversed transformation function G-1

    We can guarantee that 0 z 1 when 0 r 1

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    48/54

    Discrete formulation

    12100

    L,...,,,ks)z(p)z(G

    k

    k

    i izk

    12100

    0

    L,...,,,knn

    )r(p)r(Ts

    k

    j

    j

    k

    j

    jrkk

    12101

    1

    L,...,,,ksG

    )r(TGz

    k

    kk

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    49/54

    Example

    Image of Mars moon

    Image is dominated by large, dark areas,resulting in a histogram characterized bya large concentration of pixels in pixels inthe dark end of the gray scale

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    50/54

    Image Equalization

    Result imageafter histogram

    equalizationTransformation function

    for histogram equalization Histogram of the result imageThe histogram equalization doesnt make the result image look better thanthe original image. Consider the histogram of the result image, the neteffect of this method is to map a very narrow interval of dark pixels intothe upper end of the gray scale of the output image. As a consequence, the

    output image is light and has a washed-out appearance.

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    51/54

    Histogram Equalization

    Histogram Specification

    Solve the problem

    Since the problem with thetransformation function of thehistogram equalization wascaused by a large concentrationof pixels in the original image withlevels near 0

    a reasonable approach is tomodify the histogram of thatimage so that it does not havethis property

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    52/54

    Histogram Specification

    (1) the transformationfunction G(z) obtained

    from

    (2) the inversetransformation G-1(s)

    1210

    0

    L,...,,,k

    s)z(p)z(G k

    k

    i

    izk

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    53/54

    Result image and its histogram

    Original image

    The output images histogramNotice that the outputhistograms low end hasshifted right toward thelighter region of the gray

    scale as desired.

    After appliedthe histogram

    equalization

  • 8/2/2019 Image Enhancement in the Spatial Domain1

    54/54

    Note

    Histogram specification is a trial-and-errorprocess

    There are no rules for specifying

    histograms, and one must resort toanalysis on a case-by-case basis for anygiven enhancement task.