Top Banner
Filtering and Filtering and Enhancing Images Enhancing Images
36

Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Jan 03, 2016

Download

Documents

Gervase Ball
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Filtering and Enhancing Filtering and Enhancing ImagesImages

Page 2: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Major operationsMajor operations

1.1. Matching an image neighborhood Matching an image neighborhood with a pattern or maskwith a pattern or mask

2.2. Convolution (FIR filtering)Convolution (FIR filtering)

Page 3: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Why?Why?

• ImprovementImprovement

• Low level feature detectionLow level feature detection

Page 4: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

DefinitionsDefinitions

• Image enhancement = improve the Image enhancement = improve the detectability of important featuresdetectability of important features– Noise reductionNoise reduction– SmoothingSmoothing– Contrast enhancementContrast enhancement– Edge detectionEdge detection

Page 5: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Noise reduction exampleNoise reduction example

Page 6: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Contrast enhancement Contrast enhancement exampleexample

Page 7: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)
Page 8: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)
Page 9: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

DefinitionsDefinitions

• Image restoration = restore Image restoration = restore degraded imagedegraded image– Usually needs a model of degradationUsually needs a model of degradation

Page 10: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Image restoration examples Image restoration examples (deconvolution)(deconvolution)

Page 11: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

POINT OPERATIONSPOINT OPERATIONS

Page 12: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

DefinitionsDefinitions

• Point operation = output pixel is Point operation = output pixel is determined only by the input pixeldetermined only by the input pixel– Out[x,y] = f(In[x,y])Out[x,y] = f(In[x,y])

• Contrast stretching = point operator that Contrast stretching = point operator that uses a piecewise smooth function of the uses a piecewise smooth function of the input gray value to enhance important input gray value to enhance important details of the image.details of the image.

• What are some examples that we have What are some examples that we have already seen?already seen?

Page 13: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Examples of point Examples of point operations:operations:• Threshold (demo)Threshold (demo)

• Invert (demo)Invert (demo)Out[x,y] = max – In[x,y]Out[x,y] = max – In[x,y]

• RGB RGB gray conversion gray conversion

• Gamma correctionGamma correction

Page 14: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)
Page 15: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Gamma correction exampleGamma correction example

Page 16: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

NEIGHBORHOOD NEIGHBORHOOD OPERATIONSOPERATIONS

Page 17: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Image smoothingImage smoothing

• Neighborhood operations = require Neighborhood operations = require more than a single image pointmore than a single image point

• Box filter = smoothing via equally Box filter = smoothing via equally weighted rectangular neighborhood weighted rectangular neighborhood (mask)(mask)

Page 18: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Image smoothingImage smoothing

• Gaussian filterGaussian filter

Page 19: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Lowpass (smoothing) filter Lowpass (smoothing) filter exampleexample

Page 20: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Highpass filter exampleHighpass filter example

Page 21: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Image smoothingImage smoothing

• Median filter (or more generally, Median filter (or more generally, order statistic or filter)order statistic or filter)

Page 22: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Median filter exampleMedian filter example

Page 23: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

RECALL FROM A RECALL FROM A PREVIOUS DISCUSSION PREVIOUS DISCUSSION (HOLE AND OBJECT (HOLE AND OBJECT COUNTING) . . .COUNTING) . . .

Page 24: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

MasksMasks

Page 25: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

• Mask = set of pixel positions and Mask = set of pixel positions and corresponding values called weightscorresponding values called weights

• Mask origin = Mask origin = usuallyusually center center

• How?How?1.1. Calculate sum of productsCalculate sum of products

• BoundaryBoundary1.1. Replicate nearest pixel valueReplicate nearest pixel value

2.2. Use 0Use 0

2.2. Normalize or clamp (or an amplitude shift will Normalize or clamp (or an amplitude shift will occur)occur)

Applying masks to imagesApplying masks to images

Page 26: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

Applying masks to imagesApplying masks to images

• Derived from convolution:Derived from convolution:

• Discrete form is cross correlation:Discrete form is cross correlation:

• where f is the input image, h is the mask/filter kernel, and g is the output image where f is the input image, h is the mask/filter kernel, and g is the output image resultresult

ydxdyxfyyxxhyxfyxh ,,,,yx,g

x y

yxfyyxxhyxfyxh ,,,,yx,g

Page 27: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

ConvolutionConvolution

• See See http://en.wikipedia.org/wiki/Convolution for some nice animations. for some nice animations.

Page 28: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)
Page 29: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

1*40+2*40+1*80+

2*40+4*40+2*80+

1*40+2*40+1*80

=800

Page 30: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

1*40+2*80+1*80+

2*40+4*80+2*80+

1*40+2*80+1*80

=1120

Page 31: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

But what about borders?But what about borders?

• When we are missing data at the edges, When we are missing data at the edges, we typically do one of the following:we typically do one of the following:1.1. Copy to the missing value, the nearest Copy to the missing value, the nearest

neighboring value.neighboring value.

2.2. Use 0 for the missing value(s).Use 0 for the missing value(s).

(Regardless, it really doesn’t matter, but (Regardless, it really doesn’t matter, but we need to consistently do something.)we need to consistently do something.)

Page 32: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)
Page 33: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

1*40+2*40+1*40+

2*40+4*40+2*40+

1*40+2*40+1*40

=640

Method 1: copy nearest

Page 34: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

The importance of The importance of normalizing or clamping the normalizing or clamping the result.result.

• Otherwise, the values might get Otherwise, the values might get larger and larger (brighter and larger and larger (brighter and brighter) or go out of the original brighter) or go out of the original range, depending on the filter.range, depending on the filter.

Page 35: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

1+2+1+

2+4+2+

1+2+1

=16

640/16

Page 36: Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)

1 2 1

2 4 2

1 2 1