ECE 472/572 - Digital Image Processing Lecture 3 - Image Enhancement Point Processing 08/30/11 Roadmap Introduction Image format (vector vs. bitmap) IP vs. CV vs. CG HLIP vs. LLIP Image acquisition

Perception Structure of human eye rods vs. cones (Scotopic vision vs. photopic vision) Fovea and blind spot Flexible lens (near-sighted vs. far-sighted) Brightness adaptation and Discrimination

Weber ratio Dynamic range Image resolution Image enhancement Enhancement vs. restoration Spatial domain methods Point-based methods

Negative Log transformation Power-law Contrast stretching Gray-level slicing Bit plane slicing Histogram equalization Averaging Mask-based (neighborhoodbased) methods - spatial filter Frequency domain methods

Sampling vs. quantization 2 Questions Point-based vs. Mask-based (or neighbor-based) Spatial domain vs. Frequency domain Log transformation vs. Power-law Gamma correction Dynamic range compression Contrast stretching vs. Histogram equalization Histogram Uniform histogram HE derivation (572)

Gray-level vs. Bit-plane slicing MSB Whats the philosophy behind Image averaging? Derivation (572) 3 Intuitively 4 From system point of view f(x,y) f(x,y)

T[f(x,y)] Point processing T[N{f(x,y)}] Mask processing or Spatial filter g(x,y) g(x,y) 5 Different approaches Spatial domain

Point-based processing Mask-based processing (neighbor-based processing) (spatial filters) Frequency domain Frequency domain filters 6 Point processing Simple gray level transformations

Image negatives Log transformations Power-law transformations Contrast stretching Gray-level slicing Bit-plane slicing Histogram processing Histogram equalization Histogram matching (specification) Arithmetic/logic operations Image averaging 7

Some transformations s = T(r) = L 1 r s =T (r )=clog(1 + r ) s = cr s =T (r )=mr + b 255 s =T (r )= 0 if A r B otherwise 8

Image negatives s = T(r) = L 1 r 9 Log transformation (Dynamic range compression) s =T (r )=clog(1 + r ) 10 Power-Law transformation s = cr 11

Gamma correction 12 Contrast stretching s =T (r )=mr + b 13 Gray-level slicing Highlighting an intensity range

255 s =T (r )= 0 if A r B otherwise 14 Bit-plane 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

15 16 Point processing Simple gray level transformations Image negatives Log transformations Power-law transformations

Contrast stretching Gray-level slicing Bit-plane slicing Histogram processing Histogram equalization Histogram matching (specification) Arithmetic/logic operations Image averaging 17 Histogram Gray-level histogram is a function showing, for each gray level, the number

of pixels in the image that have that gray level. nk =hist[k] = 1 ( ) f x, y =k Normalized histogram (probability): pk =nk / N 18 Histogram - Examples

19 Usage of histogram Find threshold Reveal the intensity distribution 20 Example 21 Question What does the histogram of a low-contrast

image look like? How about high-contrast? 22 Histogram equalization Why and when do we want to use HE? 23 HE Example 2 24 HE Derivation (572) s =T ( r) r =T - 1 (s)

pr (r ) ps (s)= ds dr T(r) is single-valued and monotonically increasing within range of r T(r) has the same range as r [0, 1] k sk =T (rk )= j =0 nj n

k = pr (rj ) j =0 r s =T (r )=pr (w)dw 0 pr (r ) pr (r ) ps (s)= = =1 ds pr (r )

25 dr Histogram equalization Transformation function r s =T (r )= pr (w)dw 0 0 r 1 pr(w) is the probability density function (pdf) The transformation function is the cumulative distribution function (CDF)

To make the pdf of the transformed image uniform, i.e. to make the histogram of the transformed image uniform 26 HE Discrete case k sk =T (rk )= j =0 r 0 1 2

3 hist(r) 10 70 15 5 nj n k = pr (rj ) j =0

r s s hist(s) 0 1 2 3 10 80 95

100 10 80 95 10 70 15 5 100 27 28

HE - Discussion Can contrast stretching achieve similar result as histogram equalization? If it can, why histogram equalization then? Why isnt the transformed histogram uniform? 29 30 Problems with HE ??? Solutions

??? 31 *Histogram specification Step1: Equalize the levels of the original image Step2: Specify the desired pdf and obtain the transformation function Step3: Apply the inverse transformation function to the levels obtained in step 1 32 HS - Example

r 0 1 2 3 Specified histogram hist(r) 10 70 15 5 r

s 0 1 2 3 10 80 95 100 G(z) z

hist(z) z 10 15 30 60 10 20 50 15 10 10

15 30 30 80 60 95 r z 0 1 2 3 10 30 60

65 33 Comparison (HE vs. HM/HS) 34 Local enhancement 35 Point processing Simple gray level transformations

Image negatives Log transformations Power-law transformations Contrast stretching Gray-level slicing Bit-plane slicing Histogram processing Histogram equalization Histogram matching (specification)

Arithmetic/logic operations Image averaging 36 Image averaging original image f(x, y) noisy image g(x, y) + noise (x, y) g(x, y)= f (x, y)+ (x, y) M-1

M-1 M-1 i =0 i =0 g (x, y)= f (x, y)+ (x, y) i i =0 g(x, y)= f (x, y)+ (x, y) 37

Image average (cont) If the noise is uncorrelated and has zero expectation, then E{g(x, y)} = f (x, y) 1 2 s g(x, y) = s (x, y) M 2 38 Image averaging How to generate Gaussian noise? (572) //This function creates a gaussian random number between -3 and 3 double gaussrand() {

static double V1, V2, S; static int phase = 0; double X; if (phase == 0) { do { double U1 = (double)rand() / RAND_MAX; double U2 = (double)rand() / RAND_MAX; V1 = 2 * U1 - 1; V2 = 2 * U2 - 1; S = V1 * V1 + V2 * V2; } while(S >= 1 || S == 0); X = V1 * sqrt(-2 * log(S) / S); } else X = V2 * sqrt(-2 * log(S) / S); phase = 1 - phase;

return X; } 39 Summary - Point processing Simple gray level transformations Image negatives Log transformations

Power-law transformations Contrast stretching Gray-level slicing Bit-plane slicing Histogram processing Histogram equalization Derivation (572 only) Histogram matching (specification) (572 only) Arithmetic/logic operations Image averaging Generation of Gaussian noise (572 only) 40