Robotics and Computer Vision: Intensity Transformations

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

Robotics and Computer Vision

Intensity Transformations

Dr. Eva Hriekes


Email: evahriekes@gmail.com
Lecture Outline
 Why transform images?
 Spatial Processing
 Some Basic Intensity Transformation Functions
 Image Negatives

 Log Transformations

 Power-Law (Gamma) Transformations

 Piecewise-Linear Transformation Functions

 Contrast Stretching
 Intensity-level Slicing
 Bit-plane Slicing
 Histogram Processing
 Histogram Equalization

2
Why Transform images?
 Image has noise in it
 Image is low contrast
 Want to find things in an image
 Want to emphasize things in an image
 Want to remove things in an image
 Want to de-emphasize things in an image

3
Spatial Processing
 The term spatial domain refers to the image plane itself, and
image processing methods in this category are based on direct
manipulation to the image pixels.
 There are two principle categories of spatial processing:
 Intensity Transformation (Point Processing)

 Spatial Filtering (Local Processing)

 Intensity transformations operate on single pixels of an image,


principally for the purpose of contrast manipulation and image
thresholding.
 Spatial filtering deals with performing operations such as image
smoothing or sharpening, by working on a neighbourhood of
every pixel in an image.

4
General Spatial Processing
 Spatial Processing Algorithms can be reduced to the form:

𝒈 𝒙, 𝒚 = 𝑻 [𝒇 𝒙, 𝒚 ] Origin x

where f(x, y) is the


input image, g(x, y) is
the processed image
and T is some operator
(x, y)
defined over some
neighbourhood of (x, y)

y Image f (x, y)

5
Intensity Transformation
 The simplest spatial domain operations occur when the
neighbourhood is simply the pixel itself.
 Here, 𝐠 depends only on the value of 𝐟 at (𝐱, 𝐲). In this case 𝐓 is
referred to as a point processing operation (or intensity
transformation function).
 Point processing operations take the form:
𝑠 = 𝑇(𝑟)
 Where 𝐬 and 𝐫 are variables denoting, respectively, the
intensity of 𝐠 and 𝐟 at any point (𝐱, 𝐲).
 𝐓 is a transformation that maps pixel value 𝐫 into pixel value 𝐬.

6
Intensity Transformation
 There are three basic types of transformations used frequently for
image enhancement:
 Linear (identity and
negative transformations)
 Logarithmic (log and
inverse-log transformations)
 Power-law (𝑛𝑡ℎ power and
𝑛𝑡ℎ root transformations)

7
Image Negatives
 The negative of an image with intensity levels in the range [0,L-1]
can be described by:
𝑠 = 𝐿 −1− 𝑟

 This type of processing is practically suited for enhancing white or


gray detail embedded in a dark regions of an image, especially
when the black areas are dominate.

8
Log Transformations
 General form: 𝑠 = 𝑐 log(1 + 𝑟)
Where c is a constant and r ≥ 0.

 The Log transformation maps a narrow range of low intensity


values in input to a wider range of output levels. The opposite is
true for high intensity input values.

 We use transformation of this type to expand the values of dark


pixels in an image while compressing the higher level values. The
opposite is true of the inverse log transformation.

 The log function has the important characteristic that it


compresses the dynamic range of images with large variations in
pixel values.

9
Log Transformations
 A plot (image) of the Fourier Spectrum usually has a fairly large
dynamic range.

 The image can be enhanced by applying the log transformation.

10
Power-Law (Gamma) Transformations
 Basic form: 𝑠 = 𝑐𝑟 𝛾
Where c and γ are positive constants.

 There exists a family of possible


transformation curves by varying 𝛄.

 Power-law curves with fractional


values of γ map a narrow range
of dark input values to a wider
range of output values. The
opposite is true for higher values
of input levels.

11
Gamma Correction
 Many devices used for image capture, display and printing
respond according to a power law.

 The exponent in the power-law equation is referred to as gamma.

 The process of correcting for the power-law response is referred


to as gamma correction.

 Example:
 CRT devices have an intensity-to-voltage response that is a power
function (exponents typically range from 1.8-2.5)
 Gamma correction in this case could be achieved by applying the
transformation: s = r1/2.5 = r 0.4 .

12
Gamma Correction Example

13
Power-Law transformation (MRI Example)
 The Figure shows magnetic resonance image (MRI) of an upper
thoracic human spine with a fracture dislocation and spinal cord
impingement.

 Because the image is predominantly


dark, an expansion of intensity levels
is desirable.

14
Power-Law transformation (MRI Example)

s = r 0.6

1
Transformed Intensities

0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Old Intensities

15
Power-Law transformation (MRI Example)

s = r 0.4

1
0.9
Transformed Intensities

0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities

16
Power-Law transformation (MRI Example)

s = r 0.3

1
0.9
Transformed Intensities

0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities

17
Power-Law transformation (MRI Example)
 as gamma decreased from 0.6 to 0.4,
more detail became visible.
 Further decrease of gamma to 0.3
enhanced a little more detail in
the background, but began to reduce
original 𝜸=0.6
contrast to the point where the image
started to have a very slight
“washed-out” appearance, especially
in the background.
 The best enhancement in terms
of contrast and discernible detail
𝜸=0.4 𝜸=0.3
was obtained with 𝛾=0.4.
18
Power-Law transformation (Aerial Example)
 The Aerial image has washed-out appearance, so a compression of
intensity levels is desirable.

19
Power-Law transformation (Aerial Example)
 Suitable results were obtained 𝜸=3.0

with gamma values of 3.0 and


4.0, the latter having a slightly
more appealing appearance
because it has higher contrast.

 The result obtained with 𝜸=4.0 𝜸=5.0


γ=0.5 has areas that are too
dark, in which some detail is
lost.

20
Piecewise-Linear Transformation Functions
 We use user-defined transforms, defined by a set of lines “pieced”
together….piecewise linear.

 Piecewise functions can be arbitrarily complex.

 A disadvantage is that their specification requires significant user


input.

 Example functions:
 Contrast stretching

 Intensity-level slicing

 Bit-plane slicing

21
Contrast stretching
 Contrast stretching
expands the range of
intensity levels in an image
so it spans a given (full)
intensity range.

 Control points (r1 , s1 ) and


(r2 , s2 ) control the shape
of the transform T(r).

 when r1 = r2 , s1 = 0 and
s2 = L − 1, this yields
a thresholding function.

22
Intensity-level slicing
 Intensity-level slicing used to highlight a specific range of
intensities in an image that might be of interest.

 Two common approaches


 Set all pixel values within a range of

interest to one value (white) and all


others to another value (black). This
transformation Produces a binary image.
 Brighten (or darken) pixel values in

a range of interest and leave all others


unchanged.

23
Intensity-level slicing Example

24
Bit-plane slicing
 Pixels are digital values composed of bits. For example, a pixel in a
256-level gray-scale image is comprised of 8 bits.

 We can highlight the contribution made to total image appearance


by specific bits. For example, we can display an image that only
shows the contribution of a specific bit plane.

 8-bit image may be considered as being composed of eight 1-bit


planes, with plane 1 containing the lowest-order bit of all pixels in
the image and plane 8 all the highest-order bits.

 Higher-order bits usually contain most of the significant visual


information, where lower-order bits contain subtle details.

25
Bit-plane slicing

26
Bit-plane slicing Example
[00000001] [00000010]

[00000100] [00001000] [00010000]

[00100000] [01000000] [10000000]

27
Bit-plane slicing Example
 Bit-plane slicing is useful in
 Determining the number of bits necessary to quantize an image
 Image compression

 The figure shows Images reconstructed using (a) bit planes 8 and
7; (b) bit planes 8, 7 and 6; and (c) bit planes 8, 7, 6, and 5.

(a) (b) (c)

original

28
Histogram Processing
 The histogram of a digital image, f, (with intensities [0, 𝐿 − 1]) is
a discrete function: ℎ(𝑟𝑘 ) = 𝑛𝑘
Where 𝐫𝐤 is the k th intensity value and 𝐧𝐤 is the number of pixels
in 𝐟 with intensity 𝐫𝐤 .

 Normalizing the histogram is common practice:


 Divide the components by the total number of pixels in the image.
 Assuming an MxN image, this yields

𝑝(𝑟𝑘 ) = 𝑛𝑘 /𝑀𝑁 for 𝑘 = 0,1,2, … . , 𝐿 − 1


 𝐩(𝐫𝐤 ) is, basically, an estimate of the probability of occurrence of intensity
level 𝐫𝐤 in an image.
 𝜮 𝒑(𝒓𝒌 ) = 𝟏

29
Histogram Processing
 Histogram manipulation can be used for
 Image enhancements

 Image statistics

 Image compression

 Image segmentation

30
Histogram Examples
 Four basic image types and their
corresponding histograms
 Dark
 Light
 Low contrast
 High contrast

 Histograms commonly viewed


in plots as
 h(rk ) = nk versus rk
 p(rk ) = nk /MN versus rk

31
Histogram Equalization
 we want to be able to learn how to go from a non-uniform
distribution to a uniform distribution.

32
Histogram Equalization
 In order to achieve that, what we needs to find a transform that
takes basically the pixel values of the original image and
transforms them to pixel values of a different image.

33
Histogram Equalization
 Intensity levels in an image may be viewed as random variables in
the interval [0, 𝐿 − 1].

 Fundamental descriptor of a random variable is its probability


density function (PDF).

 Let pr (r) and ps (s) denote the PDFs of 𝑟 and 𝑠 respectively:

34
Histogram Equalization
 For discrete values, we deal with probabilities (histogram values),
instead of probability density functions and integrals.

 The probability of occurrence of intensity level 𝑟𝑘 in a digital


image is approximated by: p(rk ) = nk /MN for k = 0,1,2, … . , L − 1.

 the discrete form of the transformation function is:

35
Histogram Equalization Example
 Suppose we have Intensity distribution and histogram values for a
3-bit, 64x64 digital image.

36
Histogram Equalization Example
 The values of histogram equalization transformation function are
obtained using the equation:

 So:
𝑠0 = 1.33 𝑠1 = 3.08
𝑠2 = 4.55 𝑠3 = 5.67
𝑠4 = 6.23 𝑠5 = 6.65
𝑠6 = 6.86 𝑠7 = 7.00

37
Histogram Equalization Example
 At this point, the s values still have fractions because they were
generated by summing probabilities values, so we round them to
the nearest integer:

𝑠0 = 1.33 1 𝑠1 = 3.08 3
𝑠2 = 4.55 5 𝑠3 = 5.67 6
𝑠4 = 6.23 6 𝑠5 = 6.65 7
𝑠6 = 6.86 7 𝑠7 = 7.00 7

 These are the values of equalized histogram.

38
Histogram Equalization Example

Original Histogram Transformation Function Equalized Histogram

39
Contrast enhancement using Histogram Equalization

Transformation functions

40

You might also like