Grey_Level_mapping

Download Report

Transcript Grey_Level_mapping

Grey Level Enhancement
Contrast stretching
Linear mapping
Non-linear mapping
Efficient implementation of mapping algorithms
Design of classes to support gray level mapping
Image Histogram
•Brightness histogram provides the frequency of the
brightness value in the image.
Contrast stretching
The notion contrast refers to the amplitude of gray-level
differences within an image.
The range of gray
level is a simple
measure of how
dispersed a data
distribution is.
Range =
gmax(x,y) – gmin(x,y)
Contrast enhancement
Contrast enhancement - In some digital images, the
features of interest occupy only a relatively narrow range
of the gray scale. One might use a point operation to
expand the contrast of the features of interest so that they
occupy a larger portion of the displayed gray-level range.
This is called contrast enhancement or contrast
stretching.
Contrast stretching
151
150
150
149
148
148
151
151
150
149
147
148
151
151
150
149
148
148
152
151
151
150
150
150
152
152
151
151
151
150
204 204 204 255 255
153 204 204 204 255
153 153 153 204 204
102 102 102 153 204
51 0
51
153 204
51 51
51
153 153
This range of six values is much smaller than the 256 digital values
possible. In order to see the differences in the image the contrast
range needs to be changed so that the lowest gray value is dark, and
the highest gray value is light. If the image from Fig 1(A) was
displayed scaling 0 to 255 as black to white the result would look like
Figure 1 (B)
Contrast stretching
151
150
150
149
148
148
151
151
150
149
147
148
151
151
150
149
148
148
152
151
151
150
150
150
152
152
151
151
151
150
204 204 204 255 255
153 204 204 204 255
153 153 153 204 204
102 102 102 153 204
51 0
51
153 204
51 51
51
153 153
A simple equation shows the procedure for scaling the digital
values is the image:
[(gray value – MIN gray value )/(MAX gray value – MIN gray
value)]* 255
[(147-147)/(152-147)]*255 = 0 or [(152-147)/152-147)]*255=255
The scaling of the gray level values in an image to make hidden
information visible is called contrast stretching. The idea behind
contrast stretching is to increase the dynamic range of the gray
levels in the image
Grey scale manipulation
The process of taking the original data numbers and changing them to
new values is called mapping. A mathematical description of the
mapping is called a mapping function.
The simplest case is thresholding where the intensity profile is
replaced by a step function, active at a chosen threshold value.
In this case any pixel with a grey level below the threshold in
the input image gets mapped to 0 in the output image. Other
pixels are mapped to 255.
Gray level mapping - Conclusions
- used to adjust brightness and/or contrast of an
image
- point processes - operations at a pixel depend
only on that pixel
Linear mapping
We can adjust the overall brightness of a greyscale image simply by
adding a constant bias, b to pixel values:
g(x,y) =f(x,y) + b
(1)
If b> 0, overall brightness is increased: if b<0, it is decreased.
The operation merely shifts the gray level values of all pixels up or
down. The effect of this is to make the entire image appear darker or
lighter when displayed.
Similarly, we can adjust contrast in a greyscale image through
multiplication of pixel values by a constant gain, :
g(x,y) =f(x,y)
(2)
If  > 1, contrast is increased , whereas if  < 1 it is reduced. If 
is negative, dark areas become light, light areas become dark.
Linear mapping
We can combine two equations ( 1) and (2) to give a general
expression for brightness and contrast modification. In this case, the
gray scale transformation function takes the form
g(x,y) = T[f(x,y)] = f(x,y) + b
(3)
Often, we do not want to specify a gain and a bias, but would rather
map a particular range of gray levels [f1,f2], onto a new range
[g1,g2]The formula for mapping is :
 g 2  g1 
 f ( x, y)  f1 
g ( x, y)  g1  
 f 2  f1 
It is easy to show that Equation (4) is a linear mapping of pixel
gray level too.
(4)
Linear mapping - Example
Figure :The raw image (A, on the
left), and the contrast stretched image
(B, on the right)
The detail in Figure (A) is contained
almost between the gray levels 40 and
110. If we scale the image from 40 to
110 into 0 to 255 the entire grey level
range will be used. The actual
information in the image does not
change, however we will be able to
see the image more clearly. The
scaled, or contrast stretched image is
shown in Figure (B).
Linear mapping - Example
The diagram in Figure 4 A) shows how the original data numbers
were stretched out so that the lowest value (~40) was set to 0 (black)
and the highest value (~110) was set to 255 (white). The original
values are represented by the lower axis, and the new mapped values
by the upright axis. Figure 4( B) shows a diagram of the mapping
function used to contrast stretch Figure ( A) into Figure 3 (B).
There are two special cases of linear
mapping that are worthy of note.
In the first, we increase the gain factor until two adjacent gray level f1
and f2, are mapped onto the extremes of the 8-bit range (0-255).
Consequently, gray levels up to and including f1 are mapped onto 0,
whereas gray levels greater than f1 are mapped onto 255. We can say that
f1 acts as a threshold. This limiting case produces a two-level (binary )
image The mapping operation is then termed thresholding
The second special case of linear mapping is where , the gain
factor applied to grey levels is negative. If  is negative, dark
areas become light, light areas become dark (image negatives).
Image Negatives
In general the locations of point ( f1(x,y),
g1(x,y)) and (f2(x,y) and g2(x,y) ) control the
shape of the transformation function
f1
f2
a - Negative transformation
b - contrast enhancement (between f1 and f2)
c - Brightness thresholding
f
Linear mapping
1.
If f1(x,y) =g1(x,y) and f2(x,y) = g2(x,y) – the transformation is
linear that produces no changes in gray level.
2.
If f1(x,y)=f2(x,y) , q1(x,y) =0 and g2(x,y) = 255 – the
transformation becomes a thresholding function that creates a
binary image.
3.
Intermediate values of ( f1,g1) and (f2,g2) produce various
degrees of spread in the gray levels of the output image, thus
effecting its contrast.
( see Digital Image Processing a practical introduction using Java,
GreyMap Tool)
Linear mapping -Conclusions
•Linear mapping
g(x,y) = a*f(x,y) + b
- a is called the gain - adjusts contrast
- b is called the bias - adjusts brightness overall
- may want to map input range [f1, f2] onto output range [g1, g2]
- gain a = (g2-g1)/(f2-f1)
- bias b = g1 - a*f1
- need to clamp g(x,y) to valid range for image type
- thresholding - gain is so large that all pixels are mapped to either
black or white
- negation - gain is negative, resulting in the negative of the image
- piecewise linear mappings
Non -linear mapping
Non-linear mapping functions have a useful property. Sometimes the
dynamic range of a processed image far exceeds the capability of the
display device, in which case only the brightest parts of the image are
visible on the display screen. An effective way to compress the
dynamic range of pixel values is to perform the logarithmic intensity
mapping (transformation) function.
g ( x, y)  c log( 1  f ( x, y) )
where c is a scaling constant, and the logarithm function performs
the desired compressing of dynamic range.
The gain, applied to input grey levels – as measured by the slope
of a tangent to the function – can vary. Thus the way is which
contrast is modified depends on input grey level.
Non -linear mapping
For example we can use logarithmic mapping function
and two ranges of input grey level, f1 and f2, of equal
width , are shown. Range f1 , which occurs at low gray
level, is mapped onto a wider range, g1: thus, contrast
is increased. However, at the high end of the scale, g2
< f2 – so contrast is reduced here.
Non -linear mapping
In general, logarithmic mapping is useful if we wish to enhance detail
in the darker regions of the image, at the expense of detail in the
brighter regions.
Exponential mapping of gray level
If we apply exponential mapping of gray level, the effect is the reverse
of that obtained with logarithmic mapping; contrast in the brighter
parts of an image is increased at the expense of contrast in the
darker parts. In this case g1 < f1 and g2 >f2.
We also can use square root function as a
non-linear transformation of gray level
g ( x, y)  c f ( x, y)
Non -linear mapping - Conclusions
•Non-linear mapping
- function must be single-valued
-allows you to stretch contrast in part of the range, reduce
contrast in other parts
- i.e. the gain varies depending on the input value
- logarithmic mapping increases contrast in the darker areas
of the image
-exponential mapping increases contrast in the brighter areas
of the image
Grey-Level Transformation Table
Grey-Level
Transformation Table
for performing linear
grey level stretching of
the three bands of the
image. Red line: XS3
band; Green line: XS2
band; Blue line: XS1
band.
Multispectral SPOT image after enhancement by a
simple linear greylevel stretching.