13 views

Uploaded by Malluri Lokanath

image enhancement in spatial domain

- Relation Function 1
- High Boost Filtering
- Jee 2014 Booklet5 Hwt Differential Calculus 1
- 2 Point Operations
- NUS - MA1505 (2012) - Chapter 1
- [EE440] Lab1Report Kien Cuong Hung
- 100 Best Freeware
- Week8 Homework
- Slides Ch6
- PC Inverse functions & 1 to 1
- Maths Methods 3:4 PDF.pdf
- 27. VLSI Implementation of Non Linear Variable Cutoff HPF Algorithm
- Cga Ieee Tec
- Task.1
- Advanced Algebra and Statistics
- Some weighted arithmetic operators and geometric operators with SVNSs and their application to multi-criteria decision making problems
- Count Unique Values Among Duplicates
- Instantaneous Slowness Versus Depth Functions
- C3 Chapter 2
- CS103

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

- Relation Function 1Uploaded bysgv56fu530p
- High Boost FilteringUploaded byK.R.Raguram
- Jee 2014 Booklet5 Hwt Differential Calculus 1Uploaded byvarunkohliin
- 2 Point OperationsUploaded byDrMohamed Assadawy
- NUS - MA1505 (2012) - Chapter 1Uploaded byGilbert Sebastiano
- [EE440] Lab1Report Kien Cuong HungUploaded byvophucluan
- 100 Best FreewareUploaded byturcuiza
- Week8 HomeworkUploaded byyashar2500
- Slides Ch6Uploaded byelectrotehnica
- PC Inverse functions & 1 to 1Uploaded byHector R.
- Maths Methods 3:4 PDF.pdfUploaded byHarry Timms
- 27. VLSI Implementation of Non Linear Variable Cutoff HPF AlgorithmUploaded byPrabhakar Ele
- Cga Ieee TecUploaded byKarthik Mucheli
- Task.1Uploaded byTJ Milne
- Advanced Algebra and StatisticsUploaded byHelios
- Some weighted arithmetic operators and geometric operators with SVNSs and their application to multi-criteria decision making problemsUploaded byMia Amalia
- Count Unique Values Among DuplicatesUploaded byYG
- Instantaneous Slowness Versus Depth FunctionsUploaded byMohand76
- C3 Chapter 2Uploaded byLis Rhea
- CS103Uploaded byLokesh Taneja
- Removing Noise From ImagesUploaded byvinodspec
- Gen.math DLL,July 8-12Uploaded byJhoira Chelystine Soriano Zitro
- new_SR_presentUploaded byJavid Hsueh
- Conics Pre TestUploaded byMarc Lambert
- Relation WengUploaded byFrancez Anne Guanzon
- Lattice Exit ModelsUploaded byjzam1919
- The function equation S(n) = Z(n)Uploaded byMia Amalia
- IE Info Formula SheetUploaded byIvalinov Kolev
- CountourDetectionByMeansOfLevelSet.pdfUploaded bytweenturbo
- Comp102 Fall 2000 Mid TermUploaded bykakatang

- 94Uploaded byFendi Setiawan
- IRJET-Numerical Investigation of Thermal Energy Storage Panel using Nanoparticle Enhanced Phase-Change Material for Micro SatellitesUploaded byIRJET Journal
- [IJCST-V5I1P21]:Sujaya Kumar Sathua, Arabinda Dash, Aishwaryarani BeheraUploaded byEighthSenseGroup
- valvesUploaded bytetiospam
- Fiber Solutions CatalogUploaded bygladwyn_hallatu
- MEL 417 Lubrication Lec 180211Uploaded byBalraj Padmashali
- Bonding Adhesives TextbookUploaded byac.diogo487
- 3_Engineering-critical-analyses-to-BS-7910---in-UK-guide-on-methods-for-assessing-the-acceptability-of-flaws-in-metallic-structurUploaded byRenato Vargas
- Surface Finish of PthUploaded bygre_test_taker
- PETROPHYSICS_AND_STRATIGRAPHIC_INTERPRET.pdfUploaded byGabriel Giraldo
- Advanced Reaction -Lecture 1Uploaded byfekremariam Ambaw
- Diagnostic Codes mazdaUploaded byBryan Edgardo Pineda Galan
- Emerson.2012. the Microbial Ferrous Wheel: Iron Cycling in Terrestrial, Freshwater, And Marine Environments.bookUploaded byMilena Nova
- LCI Install GuideUploaded bygonzalo
- 802_1_1_TRANSMISSION LINE TOWER.pdfUploaded byleua_690001837
- 06 External Memory[1] NewUploaded byEvi Damayanti
- cosas variasUploaded byadri
- Memory, Mental Arithmetic and MathematicsUploaded byduyhoa83
- Recommend Postearthquake Evaluasion and Repair Criteria for Welded Steel Moment - Frame BuildingUploaded byTân Nguyễn
- final_f00.pdfUploaded byVeljko Maric
- GISPL22Uploaded bynedalina
- Mechanical General QuestionsUploaded byZain Sani Butt
- Purple Book Quantitative Risk AssessmentUploaded byRicardo Javier Plasencia
- HP_Hamiltonian Formulation of General RelativityUploaded bysamuelfsj1472
- Lab 9 HT Creep.pdfUploaded byCaleb North
- Duncan #7129 RE OU v6_1Uploaded bypranalar
- Lifting LineUploaded bySrinivasan Srini
- AHRI Standard 1230 - 2010.pdfUploaded byBalaji Dhandapani
- RXPSU+BrochureUploaded byUsharaniy
- (551673073) ACHI-IR6000-Manual-English.docxUploaded byDavid Crova Camerini