13 views

Uploaded by Malluri Lokanath

image enhancement in spatial domain

- Chapter 3-Software (From Digital Restoration 1st-Ed)
- Image Processing Introduction and Application
- lesson 1 - full version
- tcu11_01_03
- Coding g
- Functions Domain Range
- Lung Cancer Detection on CT Images by using Image Processing
- Function.docx
- Face Detection for Video Summary Using Enhancement Based Fusion Strategy
- How-to-Learn-Calculus-of-One-Variable-v-1.pdf
- Course Outline of MBA Afternoon)
- EE345 Study Guide for Exam I
- icecs99.pdf
- Java Homework
- Limit
- Functions
- 1.5 Inverse Functions
- multivariable calculus
- Algebraic Functions
- love

You are on page 1of 117

SPATIAL DOMAIN

M Lokanath

look at image enhancement

techniques working in the spatial

domain:

Different kinds of image enhancement

Histogram processing

Point processing

Image enhancement is the process of making images

more useful

The reasons for doing this include:

Highlighting

Removing noise from images

Making images more visually appealing

There are two broad categories of image

enhancement techniques

Spatial

Direct

domain techniques

manipulation of image pixels

Frequency

domain techniques

Manipulation

an image

operate in the spatial domain

In Spatial domain

g(x,y)=T[f(x,y)]

Where f(x,y) is the input image, g(x,y) is the processed image and T is an

operator on f.

s=T(r)

Image negatives

Negative image

Log transformations

input image into a wider range of output levels. The

opposite is true of higher values of input levels

Poor illumination

Lack of dynamic range in the image sensor

Wrong setting of lens aperture during image acquisition

Contrast stretching

Assignment 1

based on the equation

f(x,y)=Asin (uox+ voy)

elements of an array are integers (i.e., .2,1,0, -1,-2...).

Write a function for this purpose,

(Use of while or for loops is not allowed. Note: Integer and

double-precision arrays with real or complex values are

numeric, while strings, cell arrays, and structure arrays are

not. Hints: Become familiar with function floor. If you

include the capability to handle complex numbers, become

familiar with functions real and imag.)

Assignment 2

Write an M-function with the following specifications:

function H = imcircle(R, M, N)

%IMCIRCLE Generates a circle inside a rectangle.

% H = IMCIRCLE(R, M, N) generates a circle of radius R centered

% on a rectangle of height M and width N. H is a binary image with

% 1s on the circle and 0s elsewhere. R must be an integer >= 1.

Your program must check the validity of R and also it should check to

make sure that the specified circle fits in the given rectangle

dimensions. Use of for or while loops is not permitted.

Hint: Review function meshgrid and become familiar with function floor.

Assignment 2

Show the negative of these images

Matlab functions

meshgird()

imadjust()

imcomplement()

nargin ,nargout, nargchk

imhist()

Assignment

first solution

Written a function for generating

256x256 synthetic image

twodsin1.m

function f = twodsin1(A, uo, vo, M, N)

imshow(f,[ ])

f=zeros(M, N);

for c =1:N

voy=vo *(c-1);

for r= 1:M

uox=uo *(r-1);

f(r,c)= A*sin(uox+voy);

end

end

Assignment

second solutions

A=[21 23 3i 4j 5+2i -12 0.45 -2.4 -4-3i ]

if ~isnumeric(A)

error('A must be a numeric array.');

end

to convert

if isa(A, 'double')

I = isfinite(A) & (imag(A) == 0) & (A ==

floor(A));

I = imag(A) == 0;

end

end

A = double(A);

I = isfinite(A) & (imag(A) == 0) & (A ==

floor(A));

else

% to double.

if isreal(A)

I = true(size(A));

else

Array 'A'

image often is desired

Similar

to thresholding

Other levels can be

suppressed or maintained

Useful for highlighting

features in an image,

Shape, to detect blockages.

Often by isolating particular bits of the pixel values

in an image we can highlight interesting aspects of

that image

Higher-order

visual information

Lower-order bits contain

subtle details

[10000000]

[01000000]

[00100000]

[00001000]

[00000100]

[00000001]

Image Histograms

Frequencies

grey levels in the image

Massively useful in image processing, especially in

segmentation, enhancement and compression

Grey Levels

A selection of images and

their histograms

Notice the relationships

between the images and

their histograms

Note that the high contrast

image has the most

evenly spaced histogram

Dark image

Bright image

Implementation of histogram

Histogram

equalization (linearization)

Histogram Equalisation

Spreading out the frequencies in an image (or

equalising the image) is a simple way to improve dark

or washed out images

sk T (rk )

The formula for histogram

equalisation is given where

k

rk:

input intensity

sk: processed intensity

k:

the intensity range

(e.g 0.0 1.0)

nj: the frequency of intensity j

MN: the sum of all frequencies

( L 1) pr (rj )

j 0

k

( L 1)

j 0

nj

MN

ASSIGNMENT 3

Question 1

For this image find

Histogram

Histogram

equalization of image

Histogram of processed image

Plot the transfer function.

Specified histogram

Question 2

Find for the given input image

Histogram

Histogram

equalization

Processed image histogram

Histogram specification

Specified image histogram

function p= twomodegauss(m1, sig1, m2, sig2, A1, A2, k)

c1=A1*(1/((2*pi)^0.5)*sig1);

k1=2*(sig1^2);

c2=A2*(1/((2*pi)^0.5)*sig2);

k2=2*(sig2^2);

z=linspace(0,1,256);

p = k + c1*exp(-((z-m1).^2)./k1) + c2*exp(-((z-m2).^2)./k2);

p=p./sum(p(:));

Take m1=0.15, sig1=0.05, m2=0.75, sig2=0.05

A1=1, A2=0.07, k=0.002

Assignment 2

first solution

function H = imcircle(R, M, N)

IMCIRCLE Generates a circle inside a rectangle.

H = IMCIRCLE(R, M, N) generates a circle of radius R centered

on a rectangle of height M and width N. H is a binary image with 1s on

the circle and 0s elsewhere. R must be an integer >= 1.

rectangle to its center.

x = 0:M - 1;

y = 0:N - 1;

X0 = floor(M/2);

Y0 = floor(N/2);

if R > M - X0 - 1 | R > N - Y0 - 1

error('Circle does not fit in rectangle.')

(R - L/2) >= A(I,J) <= (R + L/2), with L = sqrt(2). These are

the points comprising the circumference of the circle

within a tolerance of sqrt(2). This tolerance is chosen

based on the fact that the coordinates are separated

by 1 in the horizontal and vertical directions and by

sqrt(2) in the diagonal direction.

end

if (floor(R) ~= R) | (R < 1)

Imshow(H);

end

Histogram matching(specification)

the input image to reach the target Histogram

Precompute a mapped level sk from each level

sk T (rk )

k

nj

j 0

rk

Pz (z) using

Vk G ( z k ) Pz ( zi ) sk

i 0

For each pixel in original image, if the value of the pixel is rk , map

this to its corresponding level sk , then map sk into the final z k using

the precomputed values

LOGIC OPERATIONS

IMAGE SUBTACTION

IMAGE PROCESSING

IMAGE AVERAGING

SPATIAL FILTERING

Spatial filtering

Basics

of spatial filtering

Smoothing spatial filters

Smoothing

linear filters

Order statistics filters

Sharpening

spatial filters

At the edges of an image we are missing pixels

to form a neighbourhood

Origin

e

e

Image f (x, y)

There are a few approaches to dealing with missing

edge pixels:

Only works with some filters

Can add extra code and slow down processing

Truncate the image

Allow pixels wrap around the image

One of the simplest spatial filtering operations we

can perform is a smoothing operation

Simply

around a central value

Especially useful

in removing noise

1/

1/

1/

from images

9

9

9

Simple

Also useful for

1/

1/

1/

averaging

highlighting gross

9

9

9

detail

filter

1/

1/

1/

More effective smoothing filters can be generated

by allowing different pixels in the neighbourhood

different weights in the averaging function

Pixels

closer to the

central pixel are more

important

Often referred to as a

weighted averaging

1/

16

2/

16

1/

16

2/

16

4/

16

2/

16

1/

16

2/

16

1/

16

Weighted

averaging filter

By smoothing the original image we get rid of lots of

the finer detail which leaves only the gross features

for thresholding

Original Image

Smoothed Image

Thresholded Image

Widely

The response is based on ordering (ranking) the pixels

contained in the image area encompassed by the filter

and then replacing the value of the center pixel with

the value determined by the ranking result.

Median filter

Example

Original Image

With Noise

Image After

Averaging Filter

Image After

Median Filter

Sometimes a median filter works better than an

averaging filter

Previously we have looked at smoothing filters which

remove fine detail

Sharpening spatial filters seek to highlight fine detail

Remove

Highlight edges

differentiation

Sharpening

1st

filters

derivative filters

2nd derivative filters

Spatial Differentiation

Differentiation measures the rate of change of a

function

Lets consider a simple 1 dimensional example

Spatial Differentiation

st

1

Derivative

follows:

f

f ( x 1) f ( x)

x

measures the rate of change of the function

st

1

Derivative (cont)

Image Strip

8

7

6

5

4

3

2

1

0

5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7

1st Derivative

0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0

8

6

4

2

0

-2

-4

-6

-8

nd

2

Derivative

follows: 2

f

f ( x 1) f ( x 1) 2 f ( x)

2

x

after the current value

nd

2

Derivative (cont)

Image Strip

8

7

6

5

4

3

2

1

0

5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7

-1 0 0 0 0 1 0 6

10

5

0

-5

-10

-15

-12 6

0 1

2nd0

Derivative

1 -4 1 1 0 0 7 -7 0 0

The 2nd derivative is more useful for image

enhancement than the 1st derivative

Stronger

Simpler implementation

Laplacian

Isotropic

One

We will look at a digital implementation

The Laplacian

The Laplacian is defined as follows:

f f

f 2 2

x

y

st

2

is defined as follows:

f

f ( x 1, y) f ( x 1, y) 2 f ( x, y)

2

x

2

f

f ( x, y 1) f ( x, y 1) 2 f ( x, y)

2

y

2

So, the Laplacian can be given as follows:

f [ f ( x 1, y) f ( x 1, y)

f ( x, y 1) f ( x, y 1)]

4 f ( x, y )

2

0

-4

Applying the Laplacian to an image we get a new

image that highlights edges and other discontinuities

Original

Image

Laplacian

Filtered Image

Laplacian

Filtered Image

Scaled for Display

The result of a Laplacian filtering is not

an enhanced image

We have to do more work in order to

get our final image

Subtract the Laplacian result from the

original image to generate our final

sharpened enhanced image

g ( x, y) f ( x, y ) c[ f ( x, y)]

2

C=+1 for centre coefficient positive

Laplacian

Filtered Image

Scaled for Display

Original

Image

=

Laplacian

Filtered Image

Sharpened

Image

are much more obvious

The entire enhancement can be combined into a single

filtering operation

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

f ( x, y) [ f ( x 1, y) f ( x 1, y)

f ( x, y 1) f ( x, y 1)

4 f ( x, y)]

5 f ( x, y) f ( x 1, y) f ( x 1, y)

f ( x, y 1) f ( x, y 1)

2

This gives us a new filter which does the whole job for

us in one step

0

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

Gradient

methods

IF a pixel is gray, THEN make it gray

IF a pixel is bright , THEN make it brighter

Assignment 4.

problem 1. Local Histogram Equalization

The global histogram equalization technique is easily adaptable to local histogram equalization. The procedure is to

define a square or rectangular window (neighborhood) and move the center of the window from pixel to pixel. At each

location, the histogram of the points inside the window is computed and a histogram equalization transformation function

is obtained. This function is finally used to map the intensity level of the pixel centered in the neighborhood to create a

corresponding (processed) pixel in the output image. The center of the neighborhood region is then moved to an

adjacent pixel location and the procedure is repeated. Since only one new row or column of the neighborhood changes

during a pixel-to-pixel translation of the region, updating the histogram obtained in the previous location with the new

data introduced at each motion step is possible. This approach has obvious advantages over repeatedly computing the

histogram over all pixels in the neighborhood region each time the region is moved one pixel location.

Write an M-function for performing local histogram equalization. Your function should have the following specifications.

function g = localhisteq(f, m, n)

LOCALHISTEQ Local histogram equalization.

G = LOCALHISTEQ(F, M, N) performs local histogram equalization on input image F using a window of (odd) size M-by-N to

produce the processed image, G. To handle border effects, image F is extended by using the symmetric option in

function padarray. The amount of extension is determined by the dimensions of the local window. If M and N are

omitted, they default to 3. If N is omitted, it defaults to M. Both must be odd.

This function accepts input images of class uint8, uint16, or double. However, all computations are done using 8-bit

intensity values to speed-up computations. If F is of class double its values should be in the range [0 1]. The class of the

output image is the same as the class of the input.

Hint: Your code will be simplified if you use functions cumsum and tofloat. Keep in mind that only the intensity level of the

center of the neighborhood needs to be mapped at each location of the window.

Assignment 4 problem 2:

Experimenting with Larger Laplacian Masks

It is shown in class that the Laplacian mask w8 = [ 1, 1, 1; 1 8 1; 1, 1, 1]

yields a result sharper than the result with a similar mask with a 4 in the

center.

(a) Write an M-function that generates a Laplacian mask of arbitrary odd

size. Example, the mask of size 5 5 would consist of all 1s with a 24 in

the centre location.

(b) For the given image blurry_moon.tif. Compare the results obtained with

masks of size n x n for n = 3, 5, 9, 15, and 25

(c) Explain the differences in the resulting images.

Next class

- Chapter 3-Software (From Digital Restoration 1st-Ed)Uploaded bylas_nornas
- Image Processing Introduction and ApplicationUploaded byArif Khattak
- lesson 1 - full versionUploaded byapi-242612659
- tcu11_01_03Uploaded byJagathisswary Satthi
- Coding gUploaded bymanikmathi
- Functions Domain RangeUploaded byAiram Anitsirhc Cuasito Manzano
- Lung Cancer Detection on CT Images by using Image ProcessingUploaded byEditor IJTSRD
- Function.docxUploaded byaslam844
- Face Detection for Video Summary Using Enhancement Based Fusion StrategyUploaded byInternational Journal of Research in Engineering and Technology
- How-to-Learn-Calculus-of-One-Variable-v-1.pdfUploaded byLolei Garnace
- Course Outline of MBA Afternoon)Uploaded byk1_imrankhan
- EE345 Study Guide for Exam IUploaded byskyzfree
- icecs99.pdfUploaded byhaawmaaw
- Java HomeworkUploaded bysyedasadali
- LimitUploaded byaslam844
- FunctionsUploaded byPedroBrom
- 1.5 Inverse FunctionsUploaded byAranjit Daid
- multivariable calculusUploaded byHernan Lcc Herrera
- Algebraic FunctionsUploaded byTrisha Crush
- loveUploaded byFelix Michael Toothless
- art10Uploaded byJonathan Lagos
- Count Unique Values Among DuplicatesUploaded byYG
- Calculus for EngineersUploaded byAwal Syahrani
- functionsUploaded byKarina Ferrer
- Matlab Lab5Uploaded byda_masta_j
- FunctionsUploaded byVan Mai Nguyen Thi
- Module 1 - FunctionsUploaded byMohd Rizalman Mohd Ali
- sample examUploaded byChris Thomas
- Math1 Aug 2014 SecondUploaded byPranjalShankhdhar
- Exercises_functions_Uploaded byG P Lee Lee

- Surveyor SRV-1 Blackfin Camera.pptUploaded bypitapitul
- Metaphysic BookUploaded bySonika Jagadeeshkumar
- 2011 Final Cut Pro TutorialUploaded byptsedwin
- Canon gp405 service manualUploaded bynazmi
- vision board projectUploaded byapi-253866947
- 2013 Readers' ChoiceUploaded byMatthew Saint
- The Latest Open Source Software Available and the LatestUploaded byMuhd Muzzammil
- Template Guide - Zappa - JoomlaUploaded bytonygogo
- Tools of the TradeUploaded byMohamed Sherif Aggag
- Flagella Myths Mark PerakhUploaded byMark Dickson
- Mad Max. Fury Road - 7 AreasUploaded byElizabeth Tuft
- A Refuge From the Storm_2007Uploaded byjoeljosol2353
- Malcolm Muggeridge - Chronicles of Wasted Time - Chronicle I - The Green StickUploaded byVerseucht
- Authenticating Picasso.docxUploaded bycamaralrs
- Underwater SurveyUploaded byishtiaque_anwar
- Samsung syncmaster 940bw / 941bw / 920bw ManualUploaded bykelly
- Gospel of John CoptoUploaded byElohim Li
- Raman Spectroscopy.docxUploaded byDalu Chocki
- Arch Korrbl HinweiseAutoren Engl 2Uploaded byRadus Catalina
- The Last Smartphone – Project ARAUploaded bySitaGabriel
- VBGraphicDesign.pdfUploaded byAnne Bluehill
- Manual Tv Lg 50pj350Uploaded bymanolito454
- Inspiron-1120 Setup Guide en-usUploaded byZozoaa Zozo
- An excerpt from MIDNIGHT CRAVINGS by Joelle SterlingUploaded byAtria Books
- ProbatesResearchGuide_final.pdfUploaded byDorothy Londagin
- North Carolina Wing - May 2011Uploaded byCAP History Library
- The Famed Hotel BeboirUploaded byToby Statham
- Standards of Radiography of WeldUploaded bymsiddique1
- Art and Architecture in Medieval FrancesUploaded byjaviersanchezvazquez5107
- Reading Part a 2014Uploaded byKamlesh Patel