You are on page 1of 41

Morphological image processing

Image Restoration

SPEECH AND IMAGE PROCESSING LAB


Morphological image processing &
Image restoration

Nishil. B. S.
Nisha J. S.

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Morphological image processing

What is morphological image processing ?


A broad set of image processing operations that
process images based on shapes

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Morphological image processing

Applications of Morphological image processing


Extraction of image components
eg. Boundaries, skeletons etc.
Geometric measurements
eg. Object location, orientation ,area ,perimeter
Morphological smoothing
To compute the morphological gradient of an image
To compensate uneven background illumination
Granulometry

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Morphological image processing

Value of each pixel in the output image is based on the neighbouring


pixels in the input image
Morphological operations require an image and a structuring element
Size and shape of the neighbours depends on the structuring element

Basic morphological operations


Erosion
Dilation

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Structuring element

Matrix consisting of only 0’s and 1’s


Can have any arbitrary shape and size
Pixels with values of 1 define the neighborhood
Origin of structuring element identifies the pixel of interest

Matlab syntax
strel(shape, parameters)

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Dilation

Grows or thickens objects in a binary image


Manner and extent of thickening controlled by the structuring
element

Rule for dilation


The value of the output pixel is the maximum value of all the pixels in
the input pixel’s neighborhood

Matlab syntax
imdilate(original image, structuring element)

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of dilation of binary image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of dilation of greyscale image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Erosion

Shrinks or thins objects in a binary image


Manner and extent of shrinking controlled by the structuring element

Rule for erosion


The value of the output pixel is the minimum value of all the pixels in the
input pixel’s neighborhood

Matlab syntax
imerode(original image, structuring element)

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of erosion of binary image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Morphological Opening

Erosion followed by dilation


Smoothens object contours
Breaks thin connections between objects
Removes thin protrusions

matlab syntax
imopen(original image, structuring element)

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of opening a binary image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of opening a binary image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Morphological Closing

Dilation followed by erosion


Joins narrow breaks
Fills long thin gulfs
Fills holes smaller than the structuring element

matlab syntax
imclose(original image, structuring element)

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of closing a binary image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Hit or Miss Transformation

Used to identify specified configurations of pixels

Steps involved in Hit or Miss Transformation


1 Input image is eroded with a structuring element B1
2 Complement of input image is the eroded using a structuring
element B2
3 Logical AND operation is performed on images obtained from step 1
and 2
4 Output image consists of 1 in all locations that match the pixels in
B1

matlab syntax
bwhitmiss(original image, B1, B2)

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of Hit or Miss Transformation of a binary image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of Hit or Miss Transformation of a binary image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Skeletonization

Skeletonization
Reduce all objects in an image to lines without changing the
essential structure of the image

matlab syntax
bwmorph(original image, ‘skel’, inf)

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of Skeletonization of a binary image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Perimeter Determination

Determines the perimeter pixels of the objects in a binary image


A pixel is considered a perimeter pixel if it satisfies both of these
criteria:
The pixel is on
One (or more) of the pixels in its neighborhood is off

matlab syntax
bwperim(image)

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of Perimeterisation of a binary image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Labeling Connected Components

Method to identify objects in a binary image


Pixels in each different object are assigned a unique integer
Type of the chosen connectivity affects the number of objects found
in an image

Definition of object
Set of pixels in a binary image that form a connected group is called an
object or a connected component

matlab syntax
[L num] = bwlabel(image,connectivity)
L = label matrix
num = total number of objects

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Labeling Connected Components


Pixel Connectivity
Connectivity defines which pixels are connected to other pixels
Standard 2D connectivities are :
4-connected
8-connected
Custom connectivities can also be specified

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of Labeling of a binary image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Morpholgical Reconstruction
Repeated dilations of an image
Morphological transformation involving two images and a structuring
element
One image, the marker is the starting point of transformation
Other image, the mask constrains the transformation
Morpholgical Reconstruction Algorithm
Initialize h1 to be the marker image
Create the structuring element: B = ones(3)
Repeat:

hk+1 = (hk dilationB) ∩ mask


until hk+1 = hk .

matlab syntax
imreconstruct(marker, mask)
Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Morphological image processing
Morphological image processing
Structuring element
Image Restoration
Morhological operations

Illustration of Morpholgical Reconstruction

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Image Restoration

Image Restoration
Recovering the desired or perfect image from a degraded
version.

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Image degradation

causes of Image degradation


1 degradation due to sensor noise
2 Blur due to camera misfocus
3 Degradation due to camera motion
4 Degradation due to random atmospheric turbulence

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Degradation model

Degradation function together with an additive noise term operates on an


input image to produce degraded image

g (x, y ) = h(x, y ) ∗ f (x, y ) + η(x, y )


f(x,y) Original true image
h(x,y) Degradation function, also called PSF(Point Spread Function)
η(x, y ) Additive noise
g(x,y) Degraded image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Degradation model cont..

Figure: Degradation model

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Image blurring

A form of bandwidth reduction of the image due to imperfect image


formation process
Caused by relative motion between the camera and the original
scene, or by optical system, which is out of focus
PSF of motion blur is characterized by two parameters namely, blur
direction and blur length

matlab syntax
fspecial(’motion’, blur length, blur angle)

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Example of blurred image

Figure: Original and blurred image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Image restoration techniques

1 Inverse filtering
2 Wiener filtering
3 Lucy Richardson Algorithm
4 Blind deconvolution

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Inverse Filtering

This is a very basic restoration filter


Restoration is done using the inverse of degradation function

G (u, v )
Fb (x, y ) =
H(u, v )
This filter generally gives poor results

matlab syntax
deconvwnr(degraded image, PSF)

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Wiener Filtering

Used for restoring images in the presence of blur as well as noise


Seeks an estimate fˆ that minimises the statistical error function

e 2 = E (f − fˆ)2

Wiener filter function is given by :


" #
2
|H(u, v )|
F̂ (x, y ) = G (u, v ) 2
H(u, v ) |H(u, v )| + Sn (u, v )/Sf (u, v )

Sn = noise power spectrum


Sf = power spectrum of undegraded image

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

wiener filtering

features
This filter gives descent results
It is quite fast

matlab syntax
deconvwnr(degraded image, psf,nspr)
nspr = Noise to signal power ratio
deconwnr(degraded image,psf, nacorr, facorr)
nacorr = Noise autocorrrelation function
facorr= Undegraded image autocorrelation function

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Lucy - Richardson Algorithm

Iterative non-linear image restoration technique


Used when only the PSF is known
This algorithm maximises the liklihood function
Features
Reduce the effect of noise amplification
Accounts for nonuniform image quality
Reduces Camera read-out noise

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

matlab syntax
deconvlucy(degraded image, psf,numit, dampar, weight)
numit = Number of iterations
dampar = Threshold deviation
weight = weight to be assigned to each pixel

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

Blind deconvolution

Image restoration not based on the specific knowledge of PSF


Based on maximum liklihood estimation
Restores the image and the PSF simultaneously using an iterative
process similar to the Lucy-Richardson algorithm

matlab syntax
deconvblind(degraded image, intpsf)
intpsf = Initial PSF

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing
Image degradation
Morphological image processing
Degradation model
Image Restoration
Image restoration techniques

References

1 Rafael C. Gonzalez, Richard E. Woods & Steven L. Eddins,“Digital


image processing using matlab”, Pearson Education Inc.
2 Anil K. Jain, “Fundamentals of digital image processing”,
Prentice-Hall Inc.
3 www.prenhall.com/gonzalezwoods
4 www.mathworks.com

Nishil. B. S.Nisha J. S. SPEECH AND IMAGE PROCESSING LAB Morphological image processing

You might also like