You are on page 1of 36

Advanced Image Processing

Lecture 02

Dr. Md. Ali Hossain


Instructor

■ Name: Dr. Md. Ali Hossain


Email: Ali.Hossain@ruet.ac.bd, ali.ruet@gmail.com
Skype: md.ali.hossain
Subject

Image Enhancement
Image is NOT Perfect Sometimes

▪ Need some treatment/enhancement.


Image Enhancement for Visually
Impaired Case
Image Enhancement for Visually
Impaired Case Contd..
Image Enhancement
❑ Spatial domain techniques
■ Point operations
■ Histogram equalization and matching
■ Applications of histogram-based enhancement
❑ Frequency domain techniques
■ Unsharp masking
■ Homomorphic filtering*
Recall:
■ There is no boundary of imagination in the virtual world
■ In addition to geometric transformation techniques, we can
also photometrically transform images
❑ Ad-hoc tools: point operations

❑ Systematic tools: histogram-based methods

❑ Applications: increase the contrast of iris images to


facilitate recognition, enhance microarray images to
facilitate segmentation.
Point Operations Overview
Point operations are zero-memory operations where
a given gray level x∈[0,L] is mapped to another
gray level y∈[0,L] according to a transformation

y zero-memory: For every input


image pixel, transformation
L function gives corresponding
output image pixel, no memory
location is required to store
intermediate results

L x

L=255: for grayscale images


Lazy Man Operation

y
L

x
L
No influence on visual quality at all
Digital Negative
L

x
0 L
Digital Negative
L

x
0 L
Contrast Stretching

▪ The contrast of an image is a measure of its dynamic


range, or the "spread" of its histogram

▪ The dynamic range of an image is defined to be the entire


range of intensity values contained within an image (i.e.,
maximum pixel value - minimum pixel value.)

▪ Improve the contrast in an image by `stretching' the


range of intensity values to span a desired range of values
▪ Most implementations accept a graylevel image as input
and produce another graylevel image as output
Contrast Stretching

▪ The minimum pixel value in X-ray image is 81, and the


maximum pixel value is 127.
▪ We will "stretch" the histogram by applying a linear scaling
function that maps pixel values of 81 to 0 and 127 to 255,
similarly scales pixel intensities that lie within the range
[82-126] accordingly.
Contrast Stretching: Algorithm
Contrast Stretching: Algorithm

▪ The output image looks far better to the human eye.


▪ Limitation:
• If the original image is of rather low-contrast and does not contain much
information (i.e. most of the pixels fall into a rather small subset of the
full dynamic range.
Failing of Contrast stretching

▪ Contrast stretching fails if images with pixel intensities 0 and


255 are present in the image.
▪ Since it ruins the original stretching formula

Pout=[(Pin-a)/(b-a)]*255

a=min(I)
B=max(I)
Pin=f(x, y)
Pout=g(x, y)
Contrast Stretching: More General Formula

yb
ya
0 a b L x
Clipping

a b x
0 L
Range Compression

x
0 L

c=100
Summary of Point Operation

■ we have discussed different forms of mapping function f(x)


for different enhancement results
❑ MATLAB function >imadjust

■ The question: How to select an appropriate f(x) for an


arbitrary image?
■ One systematic solution is based on the histogram
information of an image
❑ Histogram equalization and specification
Histogram based Enhancement
Histogram of an image represents the relative frequency
of occurrence of various gray levels in the image

MATLAB function >imhist(x)


Why Histogram?

It is a baby in the cradle!

Histogram information reveals that image is under-exposed


Another Example

Over-exposed image
How to Adjust the Image?

■ Histogram equalization
❑ Basic idea: find a map f(x) such that the histogram
of the modified (equalized) image is flat (uniform).
❑ Key motivation: cumulative probability function
(cdf) of a random variable approximates a uniform
distribution

Suppose h(t) is the histogram (pdf)


Histogram Equalization
▪ Histogram is a graphic representation of the frequency counts of all
pixel intensities.

Intensity Count
0 1
1 7
2 4
3 2
4 1
5 1

▪ Total pixels: 16
▪ Max value: 5
Intensity Count
Histogram Equalization 0 1

▪ Steps: 1 7
2 4
• Compute the histogram of the image
• Calculate the normalized sum of histogram 3 2
• Transform the input image to an output image 4 1
5 1

Intensi Cumulati Cumulative New value


ty ve sum normalized
sum
0 1 (1/16)*5=0.31 1
1 8 (8/16)*5=2.5 3
2 12 (12/16)*5=3.7 4
3 14 (14/16)*5=4.3 5
4 15 (15/16)*5=4.6 5
▪ Total pixels: 16
▪ Max value: 5 5 16 (16/16)*5=5.0 5
Histogram Equalization
MATLAB Implementation
function y=hist_eq(x)

[M,N]=size(x);
Calculate the histogram
for i=1:256 of the input image
h(i)=sum(sum(x= =i-1));
End

y=x;s=sum(h);
for i=1:256
I=find(x= =i-1); Perform histogram
equalization
y(I)=sum(h(1:i))/s*255;
end
Image Example

before after
Histogram Comparison

before equalization after equalization


Adaptive Histogram Equalization

Please read about adaptive histogram equalization

32
Application (I): Digital Photography
Application (II): Iris Recognition

before after

34
Application (III): Microarray Techniques

before after

35
Assignment-1

■ Enhance the following image using appropriate


transformation

36

You might also like