prev

next

out of 25

View

213Download

1

Embed Size (px)

1

ECE/OPTI 531 Image Processing Lab for Remote Sensing Fall 2005

Spatial TransformsSpatial Transforms

Reading: Chapter 6Reading: Chapter 6

Fall 2005Spatial Transforms 2

Spatial Transforms

Introduction Convolution and Linear Filters Spatial Filtering Fourier Transforms Scale-Space Transforms Summary

2

Fall 2005Spatial Transforms 3

Introduction Spatial transforms provide a way to access

image information according to size, shape, etc. Spatial transforms operate on different scales

Local pixel neighborhood (convolution) Global image (Fourier filters) All scales (scale-space filters)

Image Model for Spatial Filtering Any digital image can be written as the sum of two

images,

The Low-Pass (LP) image contains the large areavariations, which determines the global image contrast(macro-contrast)

The High-Pass (HP) image contains the small areavariations, which determines the sharpness and localimage contrast (micro-contrast)

Fall 2005Spatial Transforms 4

LP and HP image components can be calculatedby either convolution or Fourier filters

image(x,y) - LP(x,y) = HP(x,y)

33 neighborhood

77 neighborhood

LP and HP Image Components

3

Fall 2005Spatial Transforms 5

Spatial Transforms

Introduction Convolution and Linear Filters Spatial Filtering Fourier Transforms Scale-Space Transforms Summary

Fall 2005Spatial Transforms 6

Convolution Filters

Local processing within a moving window

Result of the calculation at each location is theoutput value at the center pixel of the movingwindow

Processing within the window uses the originalpixels, not the previously-calculated values

output at: pixel 2, row2 pixel 3, row 2 pixel 2, row 3

4

Fall 2005Spatial Transforms 7

Linear Filters

Any type of calculation can be done within themoving window

If the calculation satisfies the principal ofsuperposition (Chapter 3, Section 3.3.1), then thefilter is termed linear The output of the sum of two inputs is equal to the

sum of their respective outputs Discrete form of 2-D convolution

Symbolically,

Fall 2005Spatial Transforms 8

2-D Convolution

Alternatively, we can write for a WxWy window,

which emphasizes that the convolution is a weightingof local pixels

1. flip the window in x and y2. shift the window3. multiply the window weights times the corresponding

image pixels4. add the weighted pixels and write to the output pixel5. repeat steps 2-3-4 (shift-multiply-add) until finished

2-D Convolution Procedure

5

Fall 2005Spatial Transforms 9

Cascaded Linear Filters

Sequential linear filters can be cascaded into asingle filter Because convolution operator does not depend on the

order applied (cummutative and associative) Example with two filters

where wnet is the equivalent filter, which can be pre-computed efficiently because the kernels are generallymuch smaller than the image

Fall 2005Spatial Transforms 10

1. generate column sum of weighted input pixels2. add column sums to obtain current output pixel

(leftmost output pixel in row only)3. move window one pixel along row4. subtract leftmost column sum and add new rightmost

column sum to obtain current output pixel5. repeat steps 3 and 4 until done

Box-Filter Algorithm (along rows)

Box-Filter Algorithm

Very efficient for certain configurations ofwindow weights For column-sums, the weights within each window row

must be constant (but do not have to be equal fromrow-to-row)

Computational savings varies with window size, but atleast a factor of 2

6

Fall 2005Spatial Transforms 11

Box-Filter Algorithm (cont.)

C1 C2 C3 C4C1 C2 C3

Graphical depiction of column calculation

Fall 2005Spatial Transforms 12

Border Region There is a problem with the moving

window when it runs out of pixelsnear the image border

Several possible solutions: repeat the nearest valid output

pixel reflect the input pixels outside the

border and calculate theconvolution

reduce the window size set the border pixels to zero or

mean image DN wrap the window around to the

opposite side of the image (circularconvolution, same as produced byFourier filtering)

All solutions are a trick to getaround the problem; no realsolution

border region for 3x3 window

7

Fall 2005Spatial Transforms 13

Spatial Transforms

Introduction Convolution and Linear Filters Spatial Filtering Fourier Transforms Scale-Space Transforms Summary

Fall 2005Spatial Transforms 14

Spatial Filters

Low-Pass Filters (LPF) Preserve slowly varying spatial details (signal mean)

and smooth sudden transitions (edges, noise) Simple example: 3-pixel window with equal weights

(moving average)[1/3, 1/3, 1/3]

Weights sum to one High-Pass Filters (HPF)

Remove the signal mean and preserve edges Complimentary to the LPF

[-1/3, 2/3, -1/3] = [0, 1, 0] - [1/3, 1/3, 1/3] Weights sum to zero

8

Fall 2005Spatial Transforms 15

Example: 1-D LPF and HPF

0

20

40

60

80

100

120

140

0 10 20 30 40 50 60

input

1x3 LP

DN

index

-50

0

50

100

150

0 10 20 30 40 50 60

input

1x3 HP

DN

index

0

20

40

60

80

100

120

140

0 10 20 30 40 50 60

input

1x7 LP

DN

index

-50

0

50

100

150

0 10 20 30 40 50 60

input

1x7 HP

DN

index

Fall 2005Spatial Transforms 16

2-D LPF and HPF Kernels

Weight array for pixels within the movingwindow is known as the kernel of the spatialfilter

9

Fall 2005Spatial Transforms 17

Filtered Image Histograms

LP-filtered images same mean smaller standard deviation similar histogram

HP-filtered images zero mean much smaller standard

deviation nearly symmetric

histogram0

200

400

600

800

1000

-100 -50 0 50 100 150 200

num

ber

of

pix

els

DN

0

200

400

600

800

1000

-100 -50 0 50 100 150 200

num

ber

of

pix

els

DN

0

500

1000

1500

2000

2500

3000

3500

-100 -50 0 50 100 150 200

num

ber

of

pix

els

DN

Original

LP-component HP-component

Fall 2005Spatial Transforms 18

High-Boost Filters (HBF)

Corresponds to a boosting of the high spatialfrequency components (details) of the image

Kernel consists of edges extracted with a HPFand boosted by a gain K, then added back to theoriginal DN at the center of the window

10

Fall 2005Spatial Transforms 19

Example: HBF Varying K

Fall 2005Spatial Transforms 20

Directional Filters

Emphasize (HP) or suppress(LP) spatial features in agiven direction

orientation of window

Directional enhancements in 3 directions

11

Fall 2005Spatial Transforms 21

Gradient Filters

Find image gradient (derivative) in any directionby combining the x and y gradients in a vectorcalculation

! gx

gyg

x

y

|g|

Fall 2005Spatial Transforms 22

Example: Edge Detection

original Prewitt

Roberts Sobel

Roberts DNT = 60

DNT = 90 DNT = 120

Gradient magnitude of different filters Thresholding Roberts gradient to find edges

12

Fall 2005Spatial Transforms 23

Statistical Filters

Similar to convolution with moving window, butoutput is a statistical quantity, e.g. local minimum or maximum local standard deviation local histogram mode (DN at peak)

Morphological filters Application to spatial segmentation and noise filtering Operations are composed of two basic elements similar

to minimum and maximum filters, but defined for darkobjects in binary images

dilation (minimum) erosion (maximum)

Two filters applied in series to binary image yield opening = dilation[erosion(binary image)] Eq. 69 closing = erosion[dilation(binary image)] Eq. 610

Can use non-rectangular windows to achieve templatematching (structuring element)

Fall 2005Spatial Transforms 24

Example: Morphological Filters

original local minimum local maximum

thresholdedoriginal

dilation erosion

openingclosing

13

Fall 2005Spatial Transforms 25

Median Filter

Output at each pixel is the median of the DNswithin the window insensitive to outliers suppresses impulse (single pixel or line) noise

1-D example with 5-pixel moving window input = 10, 12, 9, 11, 21, 12, 10, 10 output = .., 11, 12, 11, 11, ..

0

20

40

60

80

100

120

140

0 10 20 30 40 50 60

input

1X3 median

DN

index

Fall 2005Spatial Transforms 26

Spatial Transforms

14

Fall 2005Spatial Transforms 27

Fourier Transforms

Old theory (18th century), with wide applicationto signal analysis

Represent a function as a linear combination(superposition) of basis functions, namely sinesand cosines

Fourier Synthesis The two-component image model is a simple example

Extend to many components, i.e. in