Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Image Enhancement Lesson6 20thFeb2024

The document discusses piecewise-linear transformation functions, highlighting their advantages and disadvantages, and detailing three specific functions: contrast stretching, gray-level slicing, and bit-plane slicing. It explains how these transformations enhance image quality and discusses histogram normalization and equalization techniques to improve image contrast. Additionally, it covers arithmetic and logic operations for image analysis, including image averaging and subtraction methods for noise reduction and background removal.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Image Enhancement Lesson6 20thFeb2024

The document discusses piecewise-linear transformation functions, highlighting their advantages and disadvantages, and detailing three specific functions: contrast stretching, gray-level slicing, and bit-plane slicing. It explains how these transformations enhance image quality and discusses histogram normalization and equalization techniques to improve image contrast. Additionally, it covers arithmetic and logic operations for image analysis, including image averaging and subtraction methods for noise reduction and background removal.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Piecewise-Linear Transformation Functions

Piecewise- linear functions have the principal advantage that


piecewise functions can be arbitrarily complex.
The disadvantage of piecewise functions is that their
specification requires considerably more user input.
There are three function of Piecewise-Linear transformation:
1. Contrast Stretching
2. Gray-level slicing
3. Bit-plane slicing

1
Piecewise-Linear Transformation

Contrast Stretching
Goal:
– Increase the dynamic range of the gray levels for low
contrast images

Low-contrast images can result from


–poor illumination
–lack of dynamic range in the imaging sensor
–wrong setting of a lens aperture during image acquisition

2
Contrast Stretching Example

3
Piecewise-Linear Transformation: Gray-level slicing

• Highlights a specific range of gray


levels in an image
– Display a high value of all gray
levels in the range of interest and a
low value for all other gray levels

• (a) transformation highlights range


[A,B] of gray level and reduces all
others to a constant level
• (b) transformation highlights range
[A,B] but preserves all other levels

4
Piecewise-Linear Transformation: Bit Plane slicing

• Pixels are digital values composed of


bits
One 8-bit byte Bit-plane 8 • For example, a pixel in a 256-level
(most significant)
gray-scale image is comprised of 8
bits (bit plane 1 -> 0-31, ……)
• We can highlight the contribution
made to total image appearance by
specific bits
Bit-plane 1 • Bit plane slicing is useful for
(least significant)
analyzing the relative importance
played by each bit of the image
5
Piecewise-Linear Transformation: Bit Plane slicing

6
• we can display an image that only shows the
contribution of a specific bit plane

Bit-plane slicing is useful in:


– Determining the number of bits necessary to quantize an image
– Image compression

3/18/2025 7
8 bit planes

Bit-plane 8 Bit-plane 7
Bit- Bit- Bit-
plane 6 plane 5 plane 4
Bit- Bit- Bit-
plane 3 plane 2 plane 1

8
Histograms
A histogram is a graphical representation of the brightness
values that comprise an image i.e. their brightness values (x-
axis) against their frequencies (y-axis)
Histogram of an image with gray levels in the range (0, L-1):
A discrete function ℎ(𝑟𝑘 ) = 𝑛𝑘
Where:
𝑟𝑘 is the kth intensity value, and
𝑛𝑘 is the number of pixels in f with intensity 𝑟𝑘

9
Need for histogram normalization: equalization

Normalizing the histogram is common practice:


– It increases the contrast in an image by spreading out the
frequencies in the histogram to be approximately uniformly
distributed
- It is a nonlinear stretch that redistributes pixel values so
that there is approximately the same number of pixels with
each value within the available dynamic range.
- The result approximates a flat histogram.
- Therefore, contrast is increased at the peaks and lessened at
the tails.

3/18/2025 10
Histogram Examples

11
Normalizing the histogram
– Divide the components by the total number of pixels in the image
– Assuming an M x N image, this yields
𝑛𝑘 𝑛𝑘
𝑠𝑘 = ෍ 𝑝 𝑟𝑘 = ෍ 𝑜𝑟 𝑓𝑜𝑟 𝑘 = 0, 1, 2, … . , 𝐿 − 1
𝑛 𝑀×𝑁
– rk: input intensity
– sk: processed intensity
– k: the intensity range (e.g. 0.0 – 1.0)
– nk: the frequency of intensity k
– n: the sum of all frequencies
– 𝑝(𝑟𝑘 ) is, basically, an estimate of the probability of occurrence of intensity level
𝑟𝑘 in an image 𝛴 𝑝 𝑟𝑘 = 1

By manipulating the range of digital values in an image, graphically


represented by its histogram, we can apply various enhancements to the
data.
Consequently, Histograms are the basis for the numerous
spatial domain processing techniques
3/18/2025 12
Histogram Equalization

•Spreading out the frequencies in an image (or equalising the


image) is a simple way to improve dark or washed out images
•The formula for histogram
equalisation is given as:
– rk: input intensity sk  T (rk )
k
– sk: processed intensity
– k: the intensity range
  pr ( r j )
j 1
(e.g. 0.0 – 1.0)
– nj: the frequency of intensity j k nj
– n: the sum of all frequencies 
j 1 n
13
3/18/2025 14
Example Histogram

15
Histogram Equalization
•Idea: To find a non-linear transformation S= T(r) to be applied
to each pixel of the input image f(x,y), such that a uniform
distribution of gray levels in the entire range results for the
output image g(x,y).

•Assuming ideal, continuous case, with normalised histograms


 That 0 ≤ r ≤ 1 and 0 ≤ s ≤ 1
 T(r) is single valued i.e., there exists 𝑟 = 𝑇 −1 (𝑟)
 T(r) is monotonically increasing

16
Histogram Equalization
A function T(r) is monotonically
increasing
if T(𝑟1 ) < T(𝑟2 ) for 𝑟1 < 𝑟2 ,
and
monotonically decreasing
if T(𝑟1 ) > T(𝑟2 ) for 𝑟1 < 𝑟2 ,

Example of a transformation function which is both single valued and


monotonically increasing
17
Histogram Equalization
The discrete approximation of the transformation function for a histogram
equalization is:
𝑘

𝑠𝑘 = 𝑇 𝑟𝑘 = ෍ 𝑝𝑟 𝑟𝑗 𝑓𝑜𝑟 0 ≤ 𝑘 ≤ 𝐿 − 1
𝑗=0
Where:
𝑛𝑗
𝑝𝑟 𝑟𝑗 = , 𝑗 = 0, … … . . 𝐿 − 1 𝑎𝑛𝑑 𝑛 = σ𝐿−1
𝑗=𝑜 𝑛𝑗 ,
𝑛
𝑛𝑗 : number of pixels with gray level 𝑟𝑗
n : total number of pixels

NB: For digital images, gray level pdf cannot be exactly uniform after
histogram equalization. 18
Histogram Equalization: Example

19
Histogram Equalization: Example

No. of pixels
6
2 3 3 2 5

4 2 4 3 4

3
3 2 3 5
2
2 4 2 4
1
Gray level
4x4 image = 16 pixels, 3 bit image
0 1 2 3 4 5 6 7 8 9
Gray scale = [0,7]
histogram
20
Histogram Equalization: Example
Gray
0 1 2 3 4 5 6 7 8 9
Level(j)
No. of
0 0 6 5 4 1 0 0 0 0
pixels
k

n
j 0
j 0 0 6 11 15 16 16 16 16 16

k nj 6 11 15 16 16 16 16 16
s 0 0 / / / / / / / /
j 0 n
16 16 16 16 16 16 16 16
2.6 4.8 6.6
sx7 0 0 7 7 7 7 7
3 5 7
21
Histogram Equalization: Example

No. of pixels
6
3 5 5 3 5
7 3 7 5 4

5 3 5 7 3

2
3 7 3 7
1

Output image
0 1 2 3 4 5 6 7
Gray scale = [0,7] Gray level
Histogram equalization22
Histogram Equalization:
Assignment

a)

b) Get another image 8 * 8 size and perform image histogram matching,


The image provided in (a) to be the reference
NB: For both cases clearly show your workings though the cumulative
graphs (plotted on excel or R) and generate the new histograms
c) Assuming a new sensor 9 bit, perform contrast stretching on the image
resulting in (b) above after the histogram matching
23
Histogram Equalization: Example

24
Histogram Equalization: Example

Initial Image Image After Equalization

Notice that the minimum value (52) is now 0 and the maximum value (154) is now 255.

25
Histogram matching
• Histogram matching is a process where a time series, image, or higher
dimension scalar data is modified such that its histogram matches that of another
(reference) dataset.
• A common application of this is to match the images from two sensors with
slightly different responses, or from a sensor whose response changes over time.
The algorithm is as follows.
-The cumulative histogram is computed for each dataset

26
For any particular value (xi) in the data to be adjusted has a cumulative histogram value given by G(xi).
This in turn is the cumulative distribution value in the reference dataset, namely H(xj).
The input data value xi is replaced by xj.

3/18/2025 27
Uses of Histogram processing
• Image enhancements – applications of contrast stretching
• Image statistics
• Image compression
• Image segmentation
• Simple to calculate in software
• Economic hardware implementations
• – Popular tool in real-time image processing
• A plot of this function for all values of k provides a global description
of the appearance of the image (gives useful information for contrast
enhancement)

3/18/2025 28
Contrast Stretching through Histogram

If rmax and rmin are the maximum and minimum gray level of the input image, and
L is the total gray levels of output image, the transformation function for contrast
stretching will be:
𝐿
𝑠 = 𝑇 𝑟 = 𝑟 − 𝑟𝑚𝑖𝑛
𝑟𝑚𝑎𝑥 − 𝑟𝑚𝑖𝑛

29
Arithmetic and Logic Operators
• Arithmetic and logic operations are often applied as
preprocessing steps in image analysis in order to
combine images in various ways.
• Addition, subtraction, division and multiplication
comprise the arithmetic operation, while AND, OR,
and NOT make up the logic operations.
• These operations performed on two images, except
the NOT logic operation which require only one
image, and are done on a pixel by pixel basis

3/18/2025 30
Mathematical/Logical Operations on Images
 Addition
–Averaging images for noise removal
 Subtraction
–Removal of background from images
–Image enhancement
–Image matching
–Moving/displaced object tracking
 Multiplication
–Superimposing of texture on an image
–Convolution and correlation of images
 AND and OR operations
–To remove the unnecessary area of an image through
mask operations

3/18/2025 31
Image Averaging for Noise Reduction
 A noisy image can be represented by:

𝑔 𝑥, 𝑦 = 𝑓 𝑥, 𝑦 + 𝜂 𝑥, 𝑦

Where 𝜂 𝑥, 𝑦 denotes the noise in the image

 Since the noise is random and the content f(x,y) is fixed, the
noise can be removed by taking more noisy images of the
same object and averaging them out
𝐾
1
𝑔ҧ 𝑥, 𝑦 = ෍ 𝑔𝑖 (𝑥, 𝑦)
𝐾
𝑖=1

3/18/2025 32
Image Averaging for Noise Reduction

3/18/2025 33
Image Averaging for Noise Reduction

3/18/2025 34
Image Subtraction

• Takes two images as input and produce a third


image whose pixel values are those of the first
image minus the corresponding pixel values from
the second image
• Variants
– It is also often possible to just use a single image as
input and subtract a constant value from all the pixels
– Just output the absolute difference between pixel
values, rather than the straightforward signed output.

3/18/2025 35
Image Subtraction

• The subtraction of two images is performed in a


single pass

• If the operator computes absolute differences between


the two input images then:

• If it is simply desired to subtract a constant value C


from a single image then:

3/18/2025 36
Image Subtraction

• If the operator calculates absolute differences, then it is


impossible for the output pixel values to be outside the
range
• In rest of the two cases the pixel value may become
negative
• This is one good reason for using absolute differences.

• How to solve problem of negative pixels?

3/18/2025 37
Image Subtraction
• How to solve problem of negative pixels?
• Assuming we have an 8 bit Grayscale image (Value Range= 0 to
255)
• The result of image subtraction may come in the range of -255 to
+255
• One scheme can be to add 255 to every pixel and then divide by
2
• Method is easy and fast
• Limitations
– Truncation errors can cause loss of accuracy
– Full range of display may not be utilized

3/18/2025 38
Image Subtraction

• How to solve problem of Negative Pixels?


• Another scheme can be
– first, find the minimum gray value of the subtracted image
– second, find the maximum gray value of the subtracted image
– set the minimum value to be zero and the maximum to be 255
– while the rest are adjusted according to the interval
[0, 255], by timing each value with 255/max

3/18/2025 39
Examples of Image Subtraction

3/18/2025 40
Examples of Image Subtraction

3/18/2025 41
Example: Background Removal Using Image Subtraction

3/18/2025 42
Example: Background Removal Using Image Subtraction

3/18/2025 43
Image Subtraction
• Condition: images must be geometrically registered
– Obtain the difference in the two images
– Scale the resulting product by adding a constant (say 127 for an 8 bit gray level
image) to the output values will result in a suitable 'difference' image
– areas with little or no change (A) between the original images, will have
resultant brightness values around 127, while those areas where significant
change has occurred (B) will have values higher or lower than 127 - brighter or
darker depending on the 'direction' of change in reflectance between the two
images.
Image Multiplication
• Like other image arithmetic operators, multiplication comes in
two main forms.
– The first form takes two input images and produces an output
image in which the pixel values are just those of the first image,
multiplied by the values of the corresponding values in the
second image.
The multiplication of two images is performed in the obvious way in a single
pass using the formula:

– The second form takes a single input image and produces output in which
each pixel value is multiplied by a specified constant. This latter form is
probably the more widely used and is generally called scaling.

Scaling by a constant is performed using:

3/18/2025 45
Image Multiplication
Guidelines for Use

• There are many specialist uses for scaling.


• If a scaling factor greater than one, scaling will
brighten an image.
• Given a factor less than one, it will darken the
image.
• Scaling generally produces a much more natural
brightening/darkening effect than simply adding
an offset to the pixels, since it preserves the
relative contrast of the image better.

3/18/2025 46
Image Multiplication

(a) (b) (c)

For instance,
o Image (a) shows a picture of model robot that was taken under low
lighting conditions.
o Image (b) shows a the scaled image of (a) by a factor of 3 – it is
much clearer
o NB: When using pixel multiplication, make sure that the calculated pixel
values don't exceed the maximum possible value.
o Image (c) obtained by scaling image (a) by a factor of 5 using a 8-
bit representation
o

o All the pixels which, in the original image, have a value greater than
51 exceed the maximum value and are (in this implementation)
wrapped around from 255 back to 0.

3/18/2025 47
Examples of Image Multiplication

3/18/2025 48
Examples of Image Multiplication
• Multiplication also provides a good way of "shading" artwork.
You can use it to introduce a sense of diffuse lighting into your
paintings or 3D Colour Graphics objects.

Notice in the example below how the warm and cool grays not only
darken the final 3D rendering, but also influence its color
temperature

3/18/2025 49
Examples of Image Multiplication

• Multiplication provides a good way to color line drawings.

• Here you can really see the "black times anything is black, white
times anything is that thing unchanged" rule in action.

3/18/2025 50
An Example of Image Multiplication

Weeks 1 & 2 51
Band Ratios
• It is a method which works by enhancing minor differences
between materials so as to define the slope of spectral curve
between two bands.
• Image ratioing serves to highlight subtle variations in the
spectral responses of various surface covers.
• By ratioing the data from two different spectral bands, the
resultant image enhances variations in the slopes of the
spectral reflectance curves between the two different spectral
ranges that may otherwise be masked by the pixel brightness
variations in each of the bands.
Uses of Band ratio
• 1) reduce environmental conditions such as:
topographic slope and aspect, shadows, or seasonal
changes, sunlight illumination angle and intensity.
–These conditions can cause differences in brightness
values from identical surface materials, hence
hamper the ability of an interpreter or classification
algorithm to identify correctly surface materials or
land use in a remotely sensed image
Band ratios are relative values instead of absolute brightness
values; hence variations in scene illumination as a result of
topographic effects are reduced.
Thus, although the absolute reflectances for forest covered
slopes may vary depending on their orientation relative to the
sun's illumination, the ratio of their reflectances between the two
bands should always be very similar
• 2) Band ratios provide unique information not available
in any single band that is useful for discriminating
between features e.g. soils and vegetation
• E.g. healthy vegetation reflects strongly in the NIR
portion of the spectrum while absorbing strongly in the
visible red. Other surface types, such as soil and water,
show near equal reflectance in both the NIR and red
portions.
• Thus, a ratio image of Landsat NIR divided by Red
band would result in ratios much greater than 1.0 for
vegetation, and ratios around 1.0 for soil and water.
–Thus the discrimination of vegetation from other
surface cover types is significantly enhanced.
• Areas of unhealthy or stressed vegetation, would
show low NIR reflectance, as the ratios would be
lower than for healthy green vegetation.
• 3) Monitoring vegetation conditions using spectral indices
developed involving sums and differences between spectral
bands for various sensors e.g. Normalized Difference
Vegetation Index (NDVI)
𝑵𝑰𝑹 + 𝑹𝒆𝒅
𝑵𝑫𝑽𝑰 =
𝑵𝑰𝑹 − 𝑹𝒆𝒅
• spectral indices are formed by transforming spectral data
using ratios between bands to reduce the data into
meaningful information
• Explore spectral indices and their uses; e.g.
–Normalized Difference Water Index (NDWI), is
highly related to water bodies
–Normalized Burnt Ratio (NBR) - Burnt areas
–normalized difference built-up index (NDBI)- Built
environment, e.t.c.
Applications of arithmetic operations in image
transformation

• involving Arithmetic Operations


s(x,y) = f(x,y) + g(x,y)  noise reduction
d(x,y) = f(x,y) – g(x,y)  enhance image, static
background removal
p(x,y) = f(x,y) × g(x,y)  corrects gray-level shading
v(x,y) = f(x,y) ÷ g(x,y)  Band ratios

You might also like