Week03 Histogram

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

Gray Image and Basic

Transformations
Tạ Việt Cường
Review
Common errors in image
acquisition
u Chromatic aberration

u Sampling Errors
Review

u RGB, CMYK
u YCbCr
u HSV
u Gray color
Today

u Gray Images
u Adjacency and distance
u Operation on Histogram
Gray image
u Gray Image:
u 1-channel image
u usually, Y-component
u preserve image structure
u f(x, y)
Gray image

u Domain of f((x, y):


u 0 <= M-rows N k bits (1- Data
u 0 <= N-cols channel)
u 0<= f(x,y) < L 28 1 256 MNIST
u In practice, L = 2^k 32 1 1024
u k-bit image 32 8 8192 Cifar-10
u L: dynamic range of image 256 8 524,288 Mostly
u Number of bits: M*N*k 1024 16 ~17x10^6 Satellite
u M=N: kN^2
u Mostly issues from N
Spatial Resolution
u Spatial resolution
u No need to keep full resolution (why?)
u Subsampling an image:
Subsampling
u Interpolate row
and columns from
the original
images
u Image quality?
(a) 1024*1024, 8-bit image.
(b) 512*512 image
resampled into 1024*1024
pixels by row and column
duplication.
(c) through (f) 256*256,
128*128, 64*64, and 32*32
images resampled into
1024*1024 pixels

(a) (b) (c)


(d) (e) (f)
Isopreference
u Given an image, which N and
k are suitable?
u (a) low level of detail

u (b) medium level of detail


u (c) high level of detail

u Isopreference
Neighbors of a Pixel

u A pixel p at coordinates (x, y)


u 4-neighbors: N4 (p)
u (x+1, y), (x-1, y), (x, y+1), (x, y-1)
u 4-diagonal neighbors: ND (p)
u (x+1, y+1), (x+1, y-1), (x-1, y+1), (x-1, y-1)
u N8 (p) = N4 (p) + ND (p)

Important note: border is dangerous


Adjacency
u Adjacency
u near each other
u have similar gray level (or color)
u Let V - set of interested values
u V = {1} in binary images
u V = {0-20} in 8-bit gray images

Gray image 8-adjacent (center) mixed path


Adjacency
u Example:
u V = {1}
u S1: 4 - adj
u S2: 8 - adj
Distances
Definition:
u For pixels p, q, and z, with coordinates (x, y), (s, t),
and (v, w), respectively, D is a distance function or
metric if
+ D(p, q) >= 0 (D(p, q)=0 iff p=q),
+ D(p, q) = D(q, p), and
+ D(p, z) <= D(p, q)+D(q, z)
u Adjacency can be build on any type of distance
u Spatial distance
u Value distance
u Or both
u Apply in Image Segmentation
Distances
u Common distances:

u Moving by adjacent border


Distances
u Common distance:
u Moving by diagonal
Basic Transformations
Image Negative
u Given an image has gray level in range [0...L-1]
u s=L-1-r
u r: old value
u s: new value
u In 8-bit image:
u White pixel = 0
u Black pixel = 255
u Image negative: reverse image
u Linear relationship is "reserved"
u Others?
u Log transformations
Basic Transformations
u Need a function which define in range [0...L-1]
u By equation
u By graph
u Log transformation
s = c log(1 + r)

Result of transformation with c = 1,


non-linear transform
Basic Transformations
u Graph
u By looking at graph,
we can tell which part
of images have the
most effects
u If we want to lighten
darker area, use?
Basic Transformations
Satelite image with
c = 1 and
u Power transformations y = 3, 4,5
Piecewise-Linear
Transformation Functions
u The transformation needs to focus on some regions
u Lower contrast of some regions
u Highlight other regions
(r1, s1) and (r2, s2) control
the shape of transformation:
Which gray level is focus to
highlight contrast
More highlights

(a) function, (b) original image, (c) output image

In practice, issue?
Histogram processing

H(i) is the number of pixels with


gray level i
H(1) = 14
H(2) = 8
H(3) = 6
H(4) = 1
H(5) = 4
H(6) = 1
H(7) = 2
Histogram processing

u Simply, histogram shows the count number of each gray level.


u In maths, histogram is the probability mass function of
intensity random variable.
u Histogram applications:
u Easily to be implemented in hardware
u How contrast an image is
u Useful for applications involved with image segmentation and
compression. …
Effect of Histogram
Histogram Equalization

u Objective: the histogram is linearizing in the range [0..L-1]


u Histogram as a probability density function (PDF)
Histogram Equalization

u Firstly, consider r in [0,1], we want to find


s = T(r)

T
Histogram Equalization
u we can compute s:

u and prove s have uniform probability function in [0, 1], i.e.,


ps(s) = 1

u Use following equation:


Histogram Equalization

u In practice: s, and r in [0...L-1]


u We approximate pr and sk as follow
Histogram Equalization
u Results of
histogram
equalization
u How the contrast
and the image is
improve
Pseudocode
Exercise

Equalize histogram of following image, with L = 7

You might also like