![Page 1: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/1.jpg)
Intensity Transformations (Chapter 3)
CS474/674 – Prof. Bebis
![Page 2: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/2.jpg)
Spatial Domain Methods
f(x,y)
g(x,y)
g(x,y)
f(x,y)
Point Processing
Area/Mask Processing
![Page 3: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/3.jpg)
Point Processing Transformations
• Convert a given pixel value to a new pixel value based on some predefined function.
![Page 4: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/4.jpg)
Identity Transformation
![Page 5: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/5.jpg)
Negative Image
• O(r,c) = 255-I(r,c)
![Page 6: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/6.jpg)
Contrast Stretching or Compression
• Stretch gray-level ranges where
we desire more information
(slope > 1).
• Compress gray-level ranges that
are of little interest
(0 < slope < 1).
![Page 7: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/7.jpg)
Thresholding
• Special case of contrast compression
![Page 8: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/8.jpg)
Intensity Level Slicing
• Highlight specific ranges of gray-levels only.
Same as doublethresholding!
![Page 9: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/9.jpg)
Bit-level Slicing
• Highlighting the contribution made by a specific bit.• For pgm images, each pixel is represented by 8 bits.• Each bit-plane is a binary image
![Page 10: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/10.jpg)
![Page 11: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/11.jpg)
Logarithmic transformation
• Enhance details in the darker regions of an image at the expense of detail in brighter regions.
compress
stretch
![Page 12: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/12.jpg)
Exponential transformation
• Reverse effect of that obtained using logarithmic mapping.
compress
stretch
![Page 13: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/13.jpg)
Histogram Equalization
• A fully automatic gray-level stretching technique.
• Need to talk about image histograms first ...
![Page 14: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/14.jpg)
Image Histograms
• An image histogram is a plot of the gray-level frequencies (i.e., the number of pixels in the image that have that gray level).
![Page 15: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/15.jpg)
Image Histograms (cont’d)
• Divide frequencies by total number of pixels to represent as probabilities.
![Page 16: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/16.jpg)
Image Histograms (cont’d)
![Page 17: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/17.jpg)
Properties of Image Histograms
• Histograms clustered at the low end correspond to dark images.• Histograms clustered at the high end correspond to bright
images.
![Page 18: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/18.jpg)
Properties of Image Histograms (cont’d)
• Histograms with small spread correspond to low contrast images (i.e., mostly dark, mostly bright, or mostly gray).
• Histograms with wide spread correspond to high contrast images.
![Page 19: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/19.jpg)
Properties of Image Histograms (cont’d)Low contrast High contrast
![Page 20: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/20.jpg)
Histogram Equalization
• The main idea is to redistribute the gray-level values uniformly.
![Page 21: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/21.jpg)
Histogram Equalization (cont’d)
• In practice, the equalized histogram might not be completely flat.
![Page 22: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/22.jpg)
Probability - Definitions
• Random experiment: an experiment whose result is not certain in advance (e.g., throwing a die)
• Outcome: the result of a random experiment
• Sample space: the set of all possible outcomes (e.g., {1,2,3,4,5,6})
• Event: a subset of the sample space (e.g., obtain an odd number in the experiment of throwing a die = {1,3,5})
![Page 23: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/23.jpg)
Random Variables - Review
• A function that assigns a real number to random experiment outcomes (i.e., helps to reduce space of possible outcomes)
X(j)
X: # of heads
![Page 24: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/24.jpg)
Random Variables - Example
• Consider the experiment of throwing a pair of dice• Define the r.v. X=“sum of dice”• X=x corresponds to the event
![Page 25: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/25.jpg)
Probability density function
• The probability density function (pdf) is a real-valued function fX(x) describing the density of probability at each point in the sample space.
• In the discrete case, this is just a histogram!
Gaussian
![Page 26: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/26.jpg)
Probability distribution function
• The integral of fX(x) defines the probability distribution function FX(x) (i.e., cumulative probability)
• In the discrete case, simply take the sum:
fX(x) FX(x)
GaussianfX(a)da
non-decreasing
![Page 27: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/27.jpg)
Probability distribution function (cont’d)
![Page 29: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/29.jpg)
Random Variable Transformations
• Suppose Y=T(X)– e.g., Y=X+1
• If we know fX(x), can we find fY(y)?
• Yes - it can be shown that:
![Page 30: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/30.jpg)
Transformations of r.v. - Example
μ=0, σ=1
μ=1, σ=1
0
![Page 31: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/31.jpg)
Special transformation!
1 1( ) ( )
1( ) [ ( ) ] [ ( ) ] 1
( )Y X Xx T y x T yX
dXf y f x f x
dY f x
Proof:
![Page 32: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/32.jpg)
Histogram Equalization (cont’d)
The intensity levels can be viewed as a random variable in [0,1]
pr(r) ps(s)
![Page 33: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/33.jpg)
Histogram Equalization (cont’d)
For PGM images:L=256 (graylevels)k=0,1,2, …, L-1 (possible graylevels)rk=k/(L-1) (normalized graylevel in [0, 1])
![Page 34: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/34.jpg)
Histogram Equalization (cont’d)
then, de-normalize: sk x (L-1)
![Page 35: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/35.jpg)
Histogram Equalization Example
3 bit 64 x 64 image
input histogram equalized histogram
![Page 36: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/36.jpg)
Histogram Equalization Examples
equalized images and histogramsoriginal images and histograms
![Page 37: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/37.jpg)
Histogram Specification (Matching)
• Histogram equalization yields a uniform pdf only.• What if we want to obtain a histogram other than uniform?
fR(r)
fR(a)da fZ(a)da
fZ(z)
onlydesiredhistogramis known
so, Q(r)=G-1(T(r))
![Page 38: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/38.jpg)
Histogram Specification (cont’d)
• fS(s) and fV(v) are uniform• G(z) can be computed by specifying fZ(z) but I2 and I’2 are
unknown!• z=G-1(v) requires that v is a r.v. with uniform pdf• IDEA: use z=G-1(s) instead of z=G-1(v)
– s is a r.v. with uniform pdf• The desired transformation is
z=G-1(T(r))
fR(a)da fz(a)da
![Page 39: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/39.jpg)
Histogram Specification (cont’d)
• Comments– We do not need to apply T( ) and G-1( ) separately!– Combine them: Q=G-1T, thus, z=Q(r)– Histogram specification assumes that we know G-1 (not
always easy to find).– G( ) must be in [0,1] and must be non-decreasing.
z=G-1(T(r))=Q(r)
![Page 40: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/40.jpg)
Histogram Specification Example
3 bit 64 x 64 image
specified histogram
actual histogram
input histogram
![Page 41: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/41.jpg)
Histogram Specification (cont’d)
• Histogram specification might yield superior results than histogram equalization.
results of histogram equalization
![Page 42: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/42.jpg)
Histogram Specification (cont’d)results of histogram specification
G(z)
G-1(z)
![Page 43: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/43.jpg)
Local Histogram Processing
• Histogram equalization/specification are global methods.– The intensity transformation is computed using pixels from
the entire image.
• Global transformations are not appropriate for enhancing little details in an image.– The number of pixels in these areas might be very small,
contributing very little to the computation of the transformation.
![Page 44: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/44.jpg)
Local Histogram Processing
Idea: Define a transformation function based on the intensity
distribution in a neighborhood of every pixel in the image!
![Page 45: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/45.jpg)
Local Histogram Processing (cont’d)
1. Define a neighborhood and move its center from pixel to pixel.
2. At each location, the histogram of the points in the neighborhood is computed. Obtain histogram equalization or histogram specification transformation.
3. Map the intensity of the pixel centered in the neighborhood.
4. Move to the next location and repeat the procedure.
![Page 46: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/46.jpg)
Local Histogram Processing: Example
local histogramequalization3 x 3 neighborhood
global histogramequalization
![Page 47: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/47.jpg)
Histogram Statistics
1
0
( ) ( ) ( )L
nn i i
i
r r m p r
1
0
( )L
i ii
m r p r
1 1
0 0
1( , )
M N
x y
f x yMN
12 2
20
( ) ( ) ( )L
i ii
r r m p r
1 1
2
0 0
1( , )
M N
x y
f x y mMN
n-th momentaround mean
Variance(2nd moment)
Mean(average intensity)
![Page 48: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/48.jpg)
Example: Comparison of Standard Deviation Values
31.6 14.3 49.2
σ is useful for estimating image contrast!
![Page 49: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/49.jpg)
Local Histogram Statistics
1
0
Local average intensity
( )
denotes a neighborhood
xy xy
L
s i s ii
xy
m r p r
s
12 2
0
Local variance
( ) ( )xy xy xy
L
s i s s ii
r m p r
![Page 50: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/50.jpg)
Using Histogram Statistics for Image Enhancement
• Useful when parts of the image might contain hidden features.
Task: enhance darkareas without changingbright areas.
Idea: Find dark, low contrastareas using local statistics.
![Page 51: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/51.jpg)
Using Histogram Statistics for Image Enhancement: Example
0 1 2
0 1 2
( , ), if and ( , )
( , ), otherwise
: global mean; : global standard deviation
0.4; 0.02; 0.4; 4
xy xys G G s G
G G
E f x y m k m k kg x y
f x y
m
k k k E
![Page 52: Intensity Transformations (Chapter 3) CS474/674 – Prof. Bebis](https://reader035.vdocument.in/reader035/viewer/2022081508/56649cf35503460f949c10f0/html5/thumbnails/52.jpg)
Question
• Intensity operations can yield pixel values outside of the range [0 – 255].
• You should convert values back to the range [0 – 255] to ensure that the image is displayed properly.
• How would you find the following mapping?
[fmin – fmax] [ 0 – 255]