Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength...

28
Image enhancement in Image enhancement in the spatial domain the spatial domain

Transcript of Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength...

Page 1: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Image enhancement in Image enhancement in the spatial domainthe spatial domain

Page 2: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Human vision for dummiesHuman vision for dummiesAnatomy and physiologyAnatomy and physiology

WavelengthWavelength sensitivity

Page 3: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Human vision for dummies (2)Human vision for dummies (2)Visual perception of the imageVisual perception of the image

Contrast (local change in brightness)Contrast (local change in brightness)

eye has eye has logarithmiclogarithmic perception perception

of brightnessof brightness Acuity (details)Acuity (details)

best resolution: 500 lux, 40 cmbest resolution: 500 lux, 40 cm

=> 0.16 mm=> 0.16 mm Object borderObject border

Borders are important and Borders are important and also context-dependentalso context-dependent

ColorColor

The human eye is more The human eye is more sensitive sensitive to color than brightnessto color than brightness

Page 4: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Optical illusionsOptical illusions

http://www.optillusions.com/

Page 5: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Image enhancementImage enhancement

We want to create an image which is ”better” in some sense. We want to create an image which is ”better” in some sense.

► Transformation is Transformation is pointwisepointwise► Helps visual interpretation (brightening, sharpening…)Helps visual interpretation (brightening, sharpening…)

=> SUBJECTIVE=> SUBJECTIVE► Pre-processing for a subsequent image analysis algorithmPre-processing for a subsequent image analysis algorithm

=> PERF = PERF of IA TASK=> PERF = PERF of IA TASK► Make the image more ”specific” Make the image more ”specific”

=> APPLICATION DEPENDENT=> APPLICATION DEPENDENT

f(x,y) g(x,y)

Original image New image

T

Page 6: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Image (pre-) ProcessingImage (pre-) Processing

Image processing can be performed in the Image processing can be performed in the ► Spatial domain Spatial domain ► Frequency domain that is after Fourier transformFrequency domain that is after Fourier transform

(next two lectures)(next two lectures)

We have three types of transforms in the spatial We have three types of transforms in the spatial domain :domain :

► Pixel brightness transforms, point processing Pixel brightness transforms, point processing (depend only on the pixel value itself)(depend only on the pixel value itself)

► Spatial filters, local transforms or local processingSpatial filters, local transforms or local processing(depend on a small neighborhood around the pixel)(depend on a small neighborhood around the pixel)

► Geometric transformsGeometric transforms

Page 7: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Pixel brightness transformsPixel brightness transforms► Each pixel in the output image depends directly on Each pixel in the output image depends directly on

the corresponding pixel in the input image the corresponding pixel in the input image One-to-one transform: pointwiseOne-to-one transform: pointwise

► Common transformsCommon transforms inverseinverse contrast stretchingcontrast stretching logarithmic logarithmic exponentialexponential

► With more than one input image:With more than one input image: sums, mean imagessums, mean images statistical operations (variance, t-test…)statistical operations (variance, t-test…)

► Pixel brightness transforms are easy to generalize Pixel brightness transforms are easy to generalize to 3D to 3D

Page 8: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Grey scale histogramGrey scale histogram► A grey scale histogram shows how many pixels there A grey scale histogram shows how many pixels there

are of each grey level (intensity level). are of each grey level (intensity level).

Page 9: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.
Page 10: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

original image

inverse transform

logarithmic transform

(neutral transform)

Page 11: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

How is the histogram changed?How is the histogram changed?► Explains the termsExplains the terms

- compression- compression

- expansion- expansion

you find sometimes you find sometimes in the textbooks.in the textbooks.

Page 12: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Example : the inverse transformExample : the inverse transform

Page 13: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

brightness(addition/subtraction)

contrast= histogram stretching

original image

Page 14: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Paint Shop Pro examplePaint Shop Pro example► What do the function do?What do the function do?► How to use them to get the best results? And why it is How to use them to get the best results? And why it is

best.best.

► Implementation: Look Up Table (LUT)Implementation: Look Up Table (LUT)

Note: MATLAB V6.0 with IP Toolbox 3.0, also has these toolsNote: MATLAB V6.0 with IP Toolbox 3.0, also has these tools

Page 15: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Histogram equalizationHistogram equalization► Contrast / Brightness adjustments sometimes Contrast / Brightness adjustments sometimes

need to be automatizedneed to be automatized► What can be “optimal” contrast for an image?What can be “optimal” contrast for an image?

=> FLAT histogram=> FLAT histogram

► It can also be useful to do histogram It can also be useful to do histogram normalizationnormalization

i.e.: to get a given shape for the histogram (see GW i.e.: to get a given shape for the histogram (see GW 3.3.2)3.3.2)

Page 16: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

rk nk pr(rk) sk output0/7=0 24979 0.38 0.38 31/7=0.14 21636 0.33 0.71 52/7=0.29 10865 0.17 0.88 63/7=0.43 3122 0.05 0.93 64/7=0.57 1411 0.02 0.95 75/7=0.71 656 0.01 0.96 76/7=0.86 2583 0.04 1.00 77/7=1 284 0.00 1.00 7

Histogram Equalization, Histogram Equalization, exampleexample

quantization interval [0 7], image size 256x256

Page 17: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

original image

histogram equalizationtransformation by probability density function - see black board notes

Page 18: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.
Page 19: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Adaptative / localized Adaptative / localized histogram equalizationhistogram equalization

Page 20: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Relations between pixelsRelations between pixelsA picture element (pixel) has 4 or 8 neighbors in 2D A picture element (pixel) has 4 or 8 neighbors in 2D

depending on neighbor definition:depending on neighbor definition:

► 4-neihgborhood - each neighbor must share an edge 4-neihgborhood - each neighbor must share an edge with the pixelwith the pixel

► 8- neighborhood - each neighbor must share an edge or 8- neighborhood - each neighbor must share an edge or a corner with the pixela corner with the pixel

4- neighborhood 4- neighborhood 8- neighborhood 8- neighborhood

Page 21: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Spatial filteringSpatial filteringIn spatial filtering, the pixel in the output image is given a value In spatial filtering, the pixel in the output image is given a value

calculated from a local neighborhood in the input image. calculated from a local neighborhood in the input image.

The local neighborhood is described by a mask, or spatial filter The local neighborhood is described by a mask, or spatial filter (typical sizes 3x3, 5x5, 7x7… pixels)(typical sizes 3x3, 5x5, 7x7… pixels)

Filtering is performed by letting the mask move over the image. Filtering is performed by letting the mask move over the image. The center pixel in the output image is given a value that The center pixel in the output image is given a value that depends on the input image and the weights of the mask. depends on the input image and the weights of the mask.

Several types of spatial filters: Several types of spatial filters: ► Linear filtersLinear filters► Fractile filtersFractile filters► Adaptative filters (steerable)Adaptative filters (steerable)

1

1

1

1

1

1

1

1

1

Page 22: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

ConvolutioConvolutionn

Page 23: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Filtering: implementationFiltering: implementation► Generic codeGeneric code

for P(x,y) in image

for F(u,v) in filter

Q(x,y) += F(u,v) P(x-u,y-v)end

end

► Managing the borderManaging the border Outside pixel value set to zeroOutside pixel value set to zero Mirroring of the border pixel valuesMirroring of the border pixel values Changing filter size along the border (BEST, but slower)Changing filter size along the border (BEST, but slower)

(-1,-1) (0,-1) (1,-1)

(-1,0) (0,0) (1,0)

(-1,1) (0,1) (1,1)

Page 24: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Spatial filteringSpatial filtering

original image mean filter =”smoothing”

Laplace filter Laplace + original image = ”sharpening”

Page 25: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Spatial filtersSpatial filters

Linear filters:Smoothing filters

mean filtersGauss filters

Edge enhancing filterSobel operatorPrewitt operatorLaplace operator

Fractile filters**Median, Min, Max

**have no correspondence in frequency domain

For details, see next lecture…

Page 26: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Mean filteringMean filtering

original image mean 3x3 mean 5x5 mean 11x11

Page 27: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

Edge enhancing filtersEdge enhancing filters

► The Sobel operator: The Sobel operator:

detection of horizontal edges detection of horizontal edges

-1-1 -2-2 -1-1

00 00 00

11 22 11

Page 28: Image enhancement in the spatial domain. Human vision for dummies Anatomy and physiology Wavelength Wavelength sensitivity.

► The Laplace operator: detection of The Laplace operator: detection of

edges independent of directionedges independent of direction

Edge enhancing filters00 -1-1 00

-1-1 44 -1-1

00 -1-1 00