lecture 03 - chap2 point processes revised.ppt [?? ??]fit.mta.edu.vn/files/danhsach/chap2_point...

Post on 04-Oct-2020

2 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CHAPTER 2CHAPTER 2

Digital Image Processing 1

POINT PROCESSESPOINT PROCESSES

Slides courtesy of Prof. Soo-Jin Lee, Paichai Univ.

Digital Image Processing

Digital Image ProcessingSlides from CS232, Stanford.

Digital Image ProcessingSlides from CS232, Stanford.

Digital Image Processing 5Slides from CS232, Stanford.

IntroductionIntroductionIntroductionIntroduction

� Point Processes vs. Area Processes

� Point processes: operate on a pixel based solely on that pixel’s value.

� Area processes: use the input pixel as well as the pixels around it to generate a new pixel.

Point processes are easily implemented as “look-up tables”.

Digital Image Processing 6

� Point processes are easily implemented as “look-up tables”.

Arithmetic OperationsArithmetic OperationsArithmetic OperationsArithmetic Operations

� Adding, subtracting, dividing, and multiplying pixels by a constant value.

Digital Image Processing 7original image

addition (+40) subtraction (-40)

multiplication (x1.2) division (/1.2)

Arithmetic OperationsArithmetic OperationsArithmetic OperationsArithmetic Operations

� Problems

� Can create negative values and values greater than the maximum possible values.

� Clamping

� Set negative values to 0.

� Set values greater than 255 to 255.

Digital Image Processing 8

� Set values greater than 255 to 255.

Arithmetic OperationsArithmetic OperationsArithmetic OperationsArithmetic Operations

� Image Subtraction and Change Detection

� medical imaging application : display blood-flow paths

� automated inspection of printed circuits

� security monitoring

Digital Image Processing 9

Arithmetic OperationsArithmetic OperationsArithmetic OperationsArithmetic Operations

Digital Image Processing 10

add operation

subtract operation

Original image

XOR OperationsXOR OperationsXOR OperationsXOR Operations

� XOR (Exclusive OR): X’Y+XY’

X Y X’Y+XY’

0 0 0

0 1 1

1 0 1

The XOR function can be used to find all pixels ofa certain value. Every pixel that is the specifiedvalue will be set to black. All other pixels will be

Digital Image Processing 11

1 1 0

original image XOR 48 XOR 128 XOR 255

value will be set to black. All other pixels will benon-black.

XOR OperationsXOR OperationsXOR OperationsXOR Operations

� The XOR function is frequently used on graphics system to generate a cursor for the mouse.

� By XORing the cursor mask with the existing pixels, the colors are changed but you can still see the shape of the image below the cursor.

� The beauty of the XOR function when superimposing is

Digital Image Processing 12

� The beauty of the XOR function when superimposing is that you need not know the value of the background to create a high contrast.

LookLook--Up TablesUp TablesLookLook--Up TablesUp Tables

7 7 5 4 2

7 6 4 3 0

7 6 4 3 1

0

0

1

• Use the current pixel value as the array index.• New value is the array element pointed by this index.

5 5 3 2 10

1

2

Digital Image Processing 13

7 6 4 3 1

6 6 4 2 0

5 5 3 1 0

1

1

2

3

4

5

2

3

4

5

6

7

Operation of a 3-bit look-up table

HistogramsHistogramsHistogramsHistograms

� A bar graph of pixel intensities.

� The pixel intensities are plotted along the x-axis and the number of occurrences (frequency) for each intensity represents the y-axis.

5

6

Digital Image Processing 14

4 4 3 3

4 4 3 3

4 1 2 3

0 1 2 3image

1

2

3

4

1 2 3 4 5 6

Pixel intensity

Fre

quency

0

HistogramsHistogramsHistogramsHistograms

Digital Image Processing 15

original imageAddition (+40) Subtraction (-40)

HistogramsHistogramsHistogramsHistograms

Digital Image Processing 16

original imagemultiplication (x1.2) division (/1.2)

HistogramsHistogramsHistogramsHistograms

Digital Image Processing 17

HistogramsHistogramsHistogramsHistograms

� RGB Color vs. Gray Images

Digital Image Processing 18

HistogramsHistogramsHistogramsHistograms

� Compression, Expansion, and Shift

(1)

Digital Image Processing 19

(a) (b)

(c) (d)

(2)

(3)

(4)

Histogram EqualizationHistogram EqualizationHistogram EqualizationHistogram Equalization

� Goal: To obtain a uniform histogram.

� Histogram equalization will NOT “flatten” a histogram.

� It redistributes intensity distributions.

� “Spreading” is a better term than “flattening” to describe histogram equalization.

Digital Image Processing 20

� Three Steps for Histogram Equalization

� Compute histogram

� Calculate normalized sum of histogram

� Transform input to output image

Digital Image Processing

Digital Image Processing

Histogram EqualizationHistogram EqualizationHistogram EqualizationHistogram Equalization

original histogram normalized sum of histogram resulting uniform histogram

Digital Image Processing 23

Histogram Equalization (Spreading)Histogram Equalization (Spreading)Histogram Equalization (Spreading)Histogram Equalization (Spreading)

Digital Image Processing 24

Histogram Equalization (HE)Histogram Equalization (HE)Histogram Equalization (HE)Histogram Equalization (HE)

� Effects of HE

� HE stretches contrast (expand the range of gray levels) for gray levels near histogram maxima.

� Compresses contrast in areas with gray levels near histogram minima.

� Contrast is expanded for the most of the image pixels.

Digital Image Processing 25

� Contrast is expanded for the most of the image pixels.

� HE usually improves detectability of many image features.

� Similar effect of enhancement could be achieved by manual contrast stretching approach, but the advantage of HE is fully automatic.

Histogram EqualizationHistogram EqualizationHistogram EqualizationHistogram Equalization

Digital Image Processing 26

Histogram EqualizationHistogram EqualizationHistogram EqualizationHistogram Equalization

nrow=512; ncol=512; npixels = nrow*ncol;maxlevel = 255;void hist_equalize(int im[][], nrow, ncol) {

int hist[maxlevel+1], sum[maxlevel+1];// initialize : hist[]=0;

for (int k=0; k<=maxlevel; k++) hist[k]=0;// calc histogram

for (int i =0; i<nrow;i++) for (int j=0; j<ncol; j++)

hist[ im[i][j] ]++;

Digital Image Processing 27

hist[ im[i][j] ]++;// calc sum

sum[0] = hist[0];for (int k=1; k<=maxlevel; k++) sum[k]=sum[k-1]+hist[k];

// calc normalized sum : for (k=0; k<=maxlevel; k++)

sum[k] = (int) ((float) (sum[k]*maxlevel) / (float)npixels + 0.5);// transform : sum[]을 LUT로 이용

for (int i =0; i<nrow;i++) for (int j=0; j<ncol; j++)

im[i][j] = sum[ im[i][j] ];}

Color Histogram EqualizationColor Histogram EqualizationColor Histogram EqualizationColor Histogram Equalization

Digital Image Processing 28Original Image Equalized Image

Digital Image Processing

Digital Image Processing

STOP HERE 2014/01/21

Digital Image Processing 31

Digital Image Processing 32

Histogram SpecificationHistogram SpecificationHistogram SpecificationHistogram Specification

� Make a histogram you wish to have.

� Step 1: Histogram equalize the original image

� Step 2: Perform an inverse histogram equalization on the equalized image

Digital Image Processing 33

Histogram SpecificationHistogram SpecificationHistogram SpecificationHistogram Specification

0 0.0 0

1 0.0 0

2 0.0 5

3 0.0 5

4 0.0 6

5 2.6 6

Normalizedsum

Inversevalue

3

4

5

6

7

desi

red f

requency

3

4

5

6

7

norm

aliz

ed s

um

Histogram Equalized Input Pixel

Digital Image Processing 34

5 2.6 6

6 4.8 7

7 7.0 71 2 3 4 5 6 7

1

2

3

Pixel intensity

desi

red f

requency

1 2 3 4 5 6 7

1

2

3

Pixel intensity

norm

aliz

ed s

um

Desired Histogram Normalized Sum ofDesired Histogram

the index closest to 2

(2에가장가까운 index)

67 25

6 5 5

57 2.187

6 5 5

2.6

2.6

4.825 2.187 12

4.812 7.2.187 6.99 09

× =+ +

× =+ +

+ =

+ = ≈

Histogram SpecificationHistogram SpecificationHistogram SpecificationHistogram Specification

Digital Image Processing 35Original Desired Transformed Results

ContrastContrastContrastContrast

� Separation of signal (image) features from background

� Contrast describes relative brightness of a feature

( )1 11

2

: 2 2S b

C CS b

−= ⇒ −

+K

: 1S b

C C−

= ⇒ − ∞K

( )12

S b+

Digital Image Processing 36

3 3 : 0S b

C CS

−= ⇒ ∞K

2 2 : 1S b

C Cb

−= ⇒ − ∞K

Background, b Signal, S

0

S b−

30%

36%

36%

42%

C1 =0.18 C1 =0.15

Contrast ValuesContrast ValuesContrast ValuesContrast Values

Digital Image Processing 37

30% 36%

42%

48%

48%

54%

C1 =0.13 C1 =0.12

Contrast StretchingContrast StretchingContrast StretchingContrast Stretching

� Contrast stretching is applied to an image to stretch a histogram to fill the full dynamic range of the image.

� It works best with images that have a Gaussian or near-Gaussian distribution.

Digital Image Processing 38Low and high contrast histograms

Contrast StretchingContrast StretchingContrast StretchingContrast Stretching

� Basic Contrast Stretch

� Expands the image histogram to cover all ranges (0~255) of pixels.

255

new

pix

el

( )1 1y y a x x− = −

Digital Image Processing 39� Works best on images that have all pixels concentrated in one

part of the histogram, the middle.

oldpixel

low high0

( )1 1y y a x x− = −

( )2 5 5

n e w p ix e l o ld p ix e l lo wh ig h lo w

= −−

Contrast StretchingContrast StretchingContrast StretchingContrast Stretching

� End-In-Search

� A certain percentage of the pixels must be saturated to full white or full black.

0 for x low≤

255

y

Digital Image Processing 40� Works well for images that have pixels of all possible intensities

but have a pixel concentration in one part of the histogram.

( )255 for low x high

255 for high x

x lowy

high low

−= × ≤ ≤

− ≤

low high0

x

255

Intensity TransformationsIntensity TransformationsIntensity TransformationsIntensity Transformations

� Convert an old pixel into a new pixel based on some predefined function.

� Easily implemented with simple look-up tables.(ex: image negative)

255

255

Digital Image Processing 41

old pixel0

new

pix

el

255 old pixel0

new

pix

el

255

Intensity TransformationsIntensity TransformationsIntensity TransformationsIntensity Transformations

� Gamma CorrectionOften used in image processing to compensate for nonlinear responses in imaging sensors, displays and film.

1 /Y X

γ=

XGamma

Correction

255

255

255

Digital Image Processing 42

old pixel0

new

pix

el

255 old pixel0

new

pix

el

255 old pixel0

new

pix

el

255

Intensity TransformationsIntensity TransformationsIntensity TransformationsIntensity Transformations

Digital Image Processing 43Fig. 2.16 (a) Gamma correction transformation with γ=0.45;(b) gamma corrected image; (c) gamma correction transformation with γ=2.2; (d) gamma corrected image.

Intensity TransformationsIntensity TransformationsIntensity TransformationsIntensity Transformations

� Contrast Stretch/Compression Transformations

old pixel0

255

new

pix

el

255 old pixel0

255

new

pix

el

255 old pixel0

255

new

pix

el

255

Digital Image Processing 44

old pixel0 255 old pixel0 255 old pixel0 255

contrast stretchedoriginal contrast compressed

Intensity TransformationsIntensity TransformationsIntensity TransformationsIntensity Transformations

Digital Image Processing 45Fig. 2.17 (a) Contrast stretch transformation; (b) contrast stretched image; (c) Contrast compression transformation; (d) contrast compressed image.

Intensity TransformationsIntensity TransformationsIntensity TransformationsIntensity Transformations

� Posterize TransformationReduces the number of gray levels in an image

Digital Image Processing 46Fig. 2.18 (a) 8-Level posterize transformation;(b) posterized image; (c) threshold transformation;(d) threshold image; (e) bounded threshold;(f) bounded threshold image.

Intensity TransformationsIntensity TransformationsIntensity TransformationsIntensity Transformations

� Bit-Clipping

� Sets a certain number of the most significant bits of a pixel to 0.

� Effect of breaking up an image into several subregions with the same intensity cycles.

Setting 1 MSB to zero Setting 2 MSB’s to zero

Digital Image Processing 47

000 000 0

001 001 1

010 010 2

011 011 3

100 000 0

101 001 1

110 010 2

111 011 3

Fig. 2.19 (a) 2-bit bit-clipping transformation;(b) resulting image.

63

Fig. 2.20 Bit clipped imagecontrast stretched.

Intensity TransformationsIntensity TransformationsIntensity TransformationsIntensity Transformations

� Iso-Intensity Transformation

� Sets particular input intensity values to black or white.

� Can be used to create contours on an image at specific intervals.

Digital Image Processing 48Fig. 2.21 (a) Iso-intensity contouring transformation; (b) contoured image.

Intensity TransformationsIntensity TransformationsIntensity TransformationsIntensity Transformations

� Range-Highlighting Transformation

Fig. 2.22 (a) Range-highlighting transformation; (b) resulting image.

Digital Image Processing 49

� Solarize Transformation

transformation; (b) resulting image.

Fig. 2.23 (a) Solarize transformation using a threshold of 150; (b) solarized image.

Intensity TransformationsIntensity TransformationsIntensity TransformationsIntensity Transformations

� Parabola Transformations

Digital Image Processing 50Fig. 2.24 (a) First parabola transformation; (b) transformed image; (c) second parabola transformation; (d) second transformed image.

top related