image enhancement in spatial domain

© All Rights Reserved

13 views

image enhancement in spatial domain

© All Rights Reserved

- College Algebra Problem Set
- Control Exercise Unit 2
- TEST+1+REVIEW+GUIDE
- 2009-03-05 Function Transformation Introduction
- 1 Analog Signals
- Gg 2411291135
- ije
- Image Enhancement
- Functions 02
- Lessons Learned and Recommendations
- Salt and Pepper Noise Removal Using Median Filtering
- bang 1 685-688.pdf
- ttd2014020363s.pdf
- MATA33_Final_2010W.pdf
- high speed networks Questions
- R05421704-DIGITALIMAGEPROCESSING
- Algebra Plus Ch00 En
- assignment.pdf
- Limits Continuity and Differentia
- Chapter 2 - Section 2-1 - Hw

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

- College Algebra Problem SetUploaded byMark
- Control Exercise Unit 2Uploaded bymohdismailjusoh
- TEST+1+REVIEW+GUIDEUploaded byPraneet Ramakrishnan
- 2009-03-05 Function Transformation IntroductionUploaded bysamjshah
- 1 Analog SignalsUploaded byDewa Yudha
- ijeUploaded byammayi9845_930467904
- Image EnhancementUploaded byGaurav Bhardwaj
- Functions 02Uploaded byjanakisanggara
- Gg 2411291135Uploaded byAnonymous 7VPPkWS8O
- Lessons Learned and RecommendationsUploaded byclawsore
- Salt and Pepper Noise Removal Using Median FilteringUploaded bylakha_mahanta
- bang 1 685-688.pdfUploaded byijrcct
- ttd2014020363s.pdfUploaded bynnouman
- MATA33_Final_2010W.pdfUploaded byexamkiller
- high speed networks QuestionsUploaded byganiamuthan
- R05421704-DIGITALIMAGEPROCESSINGUploaded byvanamgoutham
- Algebra Plus Ch00 EnUploaded byWildWolf
- assignment.pdfUploaded bySwapnilRenushe
- Limits Continuity and DifferentiaUploaded bySujoy Das
- Chapter 2 - Section 2-1 - HwUploaded byAnonymous i4CIG14g
- MA1102RChap0Uploaded bysam
- Functions and Graphs Class PresentationUploaded byS.m. Chandrashekar
- Plot FunctionUploaded byShoba Devulapalli
- [doi 10.1109%2FICMTMA.2017.0030]Uploaded byKishore Ck
- 1A Functions Q No 18Uploaded bySalmanAnjans
- Group 9 Extra CreditUploaded byadelady rozha
- graphing linear functions with a calculatorUploaded byapi-437363879
- CPII Functions and ProgramsUploaded bykamal
- 6.6 Function Operations.pptUploaded byCristy Pearl S. Garcia
- 6.6 Function Operations (1)Uploaded bymaine

- Great Fundamentals2Uploaded byCarlos Abreu
- CII IGBC Annual Review_ 2016 2017Uploaded byanupama
- 28549300 Answer Book VIII ScienceUploaded bya1n2u3s4h5a6
- Lbm 1 FitrianUploaded byFitrian Hanif Zulkarnain
- Staying Alive With a Dead EngineUploaded byboeingairbus1957
- The Phoenix BirdUploaded bybresail4
- MThesis_KurkiTUploaded bysachin_badke
- lesson planUploaded byapi-254488857
- 0. RD & CD Dissipative Straight SilencerUploaded byLuis Gabriel Bautista
- 8 Hydroth Breccia Formation WindhoekUploaded byAlberto Lobo-Guerrero Sanz
- Unit 3 Module 1 Volcano Hand-outUploaded byJosaiah De Guzman
- EXB15004 - IEC61439 - June 2015Uploaded bygkdora574
- The Women’s Right in Henrik Ibsen’s A Doll’s House.pdfUploaded byKOOPER FRUITTE
- UIPL-FPS-BOQ-T1Uploaded bySashikumar Narayanakurup
- Basics of EconomicsUploaded byJoseph Dumapit
- The Brilliance of the MinaretsUploaded byMAliyu2005
- letusalonebyjohneckhardtUploaded byLou Koet
- Google Drive CaseUploaded byOLGA RODRIGUEZ
- SPE 12895-1984-P.,Griffith- Multiphase Flow in Pipes.pdfUploaded byGustavo Valle
- sap MacrosUploaded byFarooq Ahmed
- Mind, Self and SocietyUploaded bythanethomson
- Broken Delta ApplicationsUploaded byAnonymous vcadX45TD7
- ReviewUploaded byJayvee Balino
- Jan 07 NewsletterUploaded byVijaya Simha
- Experiment 2 lab experimentUploaded byAnthony Campbell
- mptss assessmentUploaded byapi-431372229
- Computer Vision ch1.pdfUploaded byLee RickHunter
- Final Report en (1)Uploaded bymejalli
- REGIONAL RECIPESUploaded byapi-3749066
- MCS+SpacerUploaded byAquiles Carrera

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.