Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and...

31
Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing

Transcript of Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and...

Page 1: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Digital Image ProcessingEEE415

Lecture 3

Image Enhancement in Spatial Domain

Pixel Operations and Histogram

Processing

Page 2: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Image Enhancement

• Process an image to make the result more suitable than the

original image for a specific application

– Image enhancement is subjective (problem/application

oriented)

• Image enhancement methods

• Spatial domain: Direct manipulation of pixel in an image (on

the image plane)

• Frequency domain: Processing the image based on modifying

the Fourier transform of an image

Some techniques are based on various combinations of methods

from these two categories

Page 3: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Image Enhancement

• No general theory

• Viewer is ultimate judge

• Highly subjective process

• Easier in machine perception

Page 4: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Types of image enhancement operations - Pixel point processing

Pixel point processing is a form of image enhancement

based only on the intensity of single pixels. No consideration

what-so-ever is taken of neighbouring pixels, or the spatial

arrangement of groups of pixels, or of the position of the pixel

within the digital image.

Pixel point processing is a simple but important type of image

enhancement technique. All pixels are processed individually.

Page 5: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Pixel Point Processing

The general equation for a point process is given by:

g(x,y) = M[f(x,y)]

Where g(x,y) is the output digital image, f(x,y) is the input

digital image, and M is the mapping function.

M maps or converts input pixel brightness to an output pixel

brightness.

The mapping function can be non-linear.

Page 6: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Types of image enhancement operations: Block processing

Local operations The output value at (x,y) is dependent on the

input values in the neighborhood of (x,y)

Global operations The output value at (x,y) is dependent on all

the values in the input image

Page 7: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 7

Basic concepts

Spatial domain enhancement methods can be generalized as

g(x,y)=T[f(x,y)]

f(x,y) : input image

g(x,y): processed (output) image

T[*] : an operator on f (or a set of input images),

defined over neighborhood of (x,y)

Neighborhood about (x,y): a square or rectangular sub-

image area centered at (x,y)

Page 8: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 8

Basic Concepts

3x3 neighborhood about (x,y)

Page 9: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 9

Basic concepts

g(x,y) = T [f(x,y)]Pixel/point operation:

Neighborhood of size 1x1: g depends only on f at (x,y)

T: a gray-level/intensity transformation/mapping function

Let r = f(x,y) s = g(x,y)r and s represent gray levels of f and g at (x,y)Then s = T(r)

Local operations: g depends on the predefined number of neighbors of f

at (x,y)Implemented by using mask processing or filteringMasks (filters, windows, kernels, templates) :a small (e.g. 3×3) 2-D array, in which the values of

the coefficients determine the nature of the process

Page 10: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 10

Common pixel operations

• Image negatives

• Log

transformations

• Power-law

transformations

Page 11: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 11

Pixel Operations: Image negatives

• Reverses the gray level order

• For L gray levels the transformation function is

s =T(r) = (L-1)-r

Input image (X-ray image) Output image (negative)

Application: To enhance the visibility for images with more dark portion

Page 12: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 12

Pixel Operations: Contrast Scaling

s =T(r) = a.r (a is a constant)

Page 13: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 13

Pixel Operations: Log transformations

Function of s = c Log(1+r)

Page 14: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 14

Pixel Operations: Log transformations

Properties of log transformations

– For lower amplitudes of input image the range of gray levels

is expanded

– For higher amplitudes of input image the range of gray

levels is compressed

Application:

– This transformation is suitable for the case when the

dynamic range of a processed image far exceeds the

capability of the display device (e.g. display of the Fourier

spectrum of an image)

– Also called “dynamic-range compression / expansion”

Page 15: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 15

Pixel Operations: Log transformations

Fourier spectrum with values of range 0 to 1.5 x 106 scaled linearly

The result applying log transformation, c = 1

Page 16: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 16

Pixel Operations: Power-law Transformation

Basic form:

s = cr , where c &

are positive

Plots of equation s = crFor various values of c

Page 17: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 17

Pixel Operations: Power-law Transformation

For γ < 1: Expands values of dark pixels, compress values of

brighter pixels

For γ > 1: Compresses values of dark pixels, expand values

of brighter pixels

If γ=1 & c=1: Identity transformation (s = r)

A variety of devices (image capture, printing, display) respond

according to a power law and need to be corrected;

Gamma (γ) correction

The process used to correct the power-law response phenomena

Page 18: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 18

Pixel Operations: Power-law Transformation

• Example of gamma correction

• To linearize the CRT response a pre-distortion circuit is

needed s = cr1/

Page 19: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 19

Pixel Operations: Gamma correction

Linear wedge gray scale image

Response of CRT to Linear wedge

Gamma corrected wedge

Output of monitor

Page 20: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 20

Pixel Operations: Power-law Transformation

MRI image of fractured

human spine

Result of applying

power-law transformatio

n

c = 1,

Result of applying

power-law transformatio

n

c = 1,

Result of applying

power-law transformatio

n

c = 1,

Page 21: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 21

Pixel Operations: Power-law Transformation

Original satellite image

Result of applying

power-law transformatio

n

c = 1,

Result of applying

power-law transformatio

n

c = 1,

Result of applying

power-law transformat

ion

c = 1,

Page 22: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 22

Pixel Operations: Piecewise-linear transformation

Contrast stretching

Goal:

Increase the dynamic range of the gray levels for low contrast

images

Low-contrast images can result from

– poor illumination

– lack of dynamic range in the imaging sensor

– wrong setting of a lens aperture during image acquisition

Page 23: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 23

Pixel Operations: Piecewise-linear transformation

Contrast stretching:

Method

where a1, a2, and a3 control the result of contrast stretching

if a1 = a2 = a3 = 1 no change in gray levels

if a1 = a3 = 0 and r1 = r2, T(*) is a thresholding function,

the result is a binary image

Page 24: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

04/20/23 24

Pixel Operations: Piecewise-linear transformation

Form of Transformatio

n function

Result of contrast

stretching

Original low-contrast image

Result of thresholding

Page 25: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Pixel Operations: Non-linear contrast

stretching Non-linear contrast stretching is implemented using look-up tables, not formulas.

Page 26: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Pixel Operations: Bit-plane Slicing

1 Bit : max value = 1 = 21 – 1

1 Byte = 8 bits : max value = 255 = 28 – 1

1 Word = 2 bytes = 16 bits : max value = 65535 = 216 - 1

27 = 128 26 = 64

25 = 32

24 = 16

23 = 8 22 = 4 21 = 2 20 = 1

Bit 7 (MSB) Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 (LSB)

A bit-plane is the binary image associated with a selected bit’s contribution to overall pixel brightness. Most of the image structure is conveyed in the higher order bit planes.

Page 27: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Pixel Operations: Bit-plane Slicing

Page 28: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Pixel Operations: Bit-plane Slicing

The lower order bit

planes carry the

important but more

subtle shading and

detail of the digital

image.

Page 29: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Pixel Operations: Bit-plane Slicing

Page 30: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Pixel Operations: Bit-plane Slicing

Page 31: Digital Image Processing EEE415 Lecture 3 Image Enhancement in Spatial Domain Pixel Operations and Histogram Processing.

Quiz-211/10/2010

1. Apply contrast stretching to following 2-bit image f(x,y) according to the transformation given in equation:

g(x,y)=T{f(x,y)}=a*f(x,y)

Where g(x,y) is out image and ‘a=2’ is scaling factor. Then change the dynamic range of output image to 0-3.

3 1 2 1

2 2 0 2

1 2 1 1

1 0 1 2