28
Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Embed Size (px)

Citation preview

Page 1: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Digital Image Processing

Lecture 5(Enhancement)

�Bu-Ali Sina University�Computer Engineering Dep.

�Fall 2009

Page 2: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Outline� Image Enhancement in Spatial Domain

– Histogram based methods• Histogram Equalization• Histogram Specification• Local Histogram

– Spatial Filtering• Smoothing Filters• Median Filter• Sharpening• High Boost filter• Derivative filter

Page 3: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

o Histogram equalization yields an image whose pixels are (in theory) uniformlydistributed among all graylevels.o Sometimes, this may not be desirable. Instead, we may want a transformationthat yields an output image with a prespecified histogram. This technique is calledhistogram specification.o Again, we will assume, for the moment, continuous grayvalues.o Suppose, the input image has probability density . We want to find atransformation z = H(r) , such that the probability density of the new imageobtained by this transformation is , which is not necessarily uniform.o First apply the transformation

o This gives an image with a uniform probability density.o If the desired output image were available, then the following transformationwould generate an image with uniform density:

Histogram Specification

Page 4: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

oIt then follows from these two equations that G(z)=T(r) and, therefore, that z mustsatisfy the condition

o For discrete graylevels, we have :

Histogram Specification

Page 5: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

Example :Consider the previous 8-graylevel 64 x 64 image histogram:

Histogram Specification

Page 6: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

· It is desired to transform this image into a new image, using atransformation , with histogram as specifiedbelow:

Histogram Specification

Page 7: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

· The transformation T(r) was obtained earlier (reproduced below):

Histogram Specification

Page 8: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

· Next we compute the transformation G as before :Histogram Specification

Page 9: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

· Notice that G is not invertible. But we will do the best possible bysetting :

Histogram Specification

Page 10: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

· Combining the two transformation T and G-1, we get our requiredtransformation H :

Histogram Specification

Page 11: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

· Applying the transformation H to the original image yields animage with histogram as below:

Histogram Specification

Page 12: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

· Again, the actual histogram of the output image does not exactlybut only approximately matches with the specified histogram. Thisis because we are dealing with discrete histograms.

Histogram Specification

Page 13: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)

Example :Histogram Specification

Page 14: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)Histogram Specification

Page 15: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)Histogram Specification

Page 16: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)Histogram Specification

Page 17: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Histogram-based methods)Histogram Specification

Page 18: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

· Image enhancement in the spatial domain can be represented as:

The transformation T maybe linear or nonlinear. We will mainlystudy linear operators T but will see one important nonlinearoperation.

How to specify T· If the operator T is linear and shift invariant (LSI), characterized by thepoint-spread sequence (PSS) h(m, n), then (recall convolution):

Spatial Filtering

Page 19: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Spatial Filtering)

· In practice, to reduce computations, h(m, n) is of “finite extent:”

where is a small set (called neighborhood). is also called as the support of h.· In the frequency domain, this can be represented as:

where H (u,v) e and F (u,v) e are obtained after appropriate zeropadding.

· Many LSI operations can be interpreted in the frequency domain as a“filtering operation.” It has the effect of filtering frequency components (passingcertain frequency components and stopping others).

· The term filtering is generally associated with such operations.

Spatial Filtering

Page 20: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Spatial Filtering)

· Examples of some common filters (1-D case):

Spatial Filtering

Page 21: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Spatial Filtering)Spatial Filtering

Page 22: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Spatial Filtering)

· If h(m, n) is a 3 by 3 mask given by :

Spatial Filtering

Page 23: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Spatial Filtering)

�The output g(m, n) is computed by sliding the mask over each pixel of the imagef(m, n). This filtering procedure is sometimes referred to as moving averagefilter.

� Special care is required for the pixels at the border of image f(m, n). Thisdepends on the so-called boundary condition. Common choices are:

� The mask is truncated at the border (free boundary)� The image is extended by appending extra rows/columns at theboundaries. The extension is done by repeating the first/lastrow/column or by setting them to some constant (fixed boundary).�The boundaries “wrap around” (periodic boundary).

� In any case, the final output g(m, n) is restricted to the support of the originalimage f(m, n).

� The mask operation can be implemented in matlab using the filter2 command,which is based on the conv2 command.

Spatial Filtering

Page 24: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Spatial Filtering)

o Image smoothing refers to any image-to-image transformation designed to“smooth” or flatten the image by reducing the rapid pixel-to-pixel variationin grayvalues.

o Smoothing filters are used for:o Blurring: This is usually a preprocessing step for removing small(unwanted) details before extracting the relevant (large) object,bridging gaps in lines/curves,o$oise reduction: Mitigate the effect of noise by linear ornonlinear operations.

o Image smoothing by averaging (lowpass spatial filtering)

o Smoothing is accomplished by applying an averaging mask.

o An averaging mask is a mask with positive weights, which sum to 1. Itcomputes a weighted average of the pixel values in a neighborhood. Thisoperation is sometimes called neighborhood averaging.

Spatial Filtering- Smoothing Filters

Page 25: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Spatial Filtering)

· Some 3 x 3 averaging masks:Spatial Filtering- Smoothing Filters

Page 26: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Spatial Filtering)

· This operation is equivalent to lowpass filtering.Example of Image Blurring

Spatial Filtering- Smoothing Filters

Page 27: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Spatial Filtering)Spatial Filtering- Smoothing Filters

Page 28: Digital Image Processing Lecture 5 - basu.ac.ir · Digital Image Processing Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Chapter 3: Image Enhancement (Spatial Filtering)

Example of noise reduction :Spatial Filtering- Smoothing Filters