Outline Image Filtering

cs.rit.edu

Outline Image Filtering

Outline

Problem
Introduction


ImageFiltering

Scene
Classification


Serial
Algorithm


Parallel
Algorithm


Speedup


Conclusions


ImageFiltering

David
Rubel


Haohui
Yin


Bryan
Woodard


Image
processing
technique
that
allows
you
warp
an


image
in
a
predefined
way


A
small
matrix
(called
the
kernel
or
filter)
defines
how


the
image
is
warped


5/15/08

1


ImageFiltering

Say
you
have
an
image
you
wish
to
smooth


ImageFiltering

.0751 .1238 .0751

.1238 .2043 .1238

.0751 .1238 .0751

0 1 1 1 1

0 0 1 1 1

0 0 0 1 1

0 0 0 0 1

0 0 0 0 0

0 1 1 1 1

0 0 1 1 1

0 0 0 1 1

0 0 0 0 1

0 0 0 0 0

Filter Image Result

ImageFiltering

.0751 .1238 .0751

.1238 .2043 .1238

.0751 .1238 .0751

0 1 1 1 1

0 0 1 1 1

0 0 0 1 1

0 0 0 0 1

0 0 0 0 0

Filter Image Result

.12

5/15/08

2


ImageFiltering

.0751 .1238 .0751

.1238 .2043 .1238

.0751 .1238 .0751

0 1 1 1 1

0 0 1 1 1

0 0 0 1 1

0 0 0 0 1

0 0 0 0 0

.12 .40

Filter Image Result

ImageFiltering

.0751 .1238 .0751

.1238 .2043 .1238

.0751 .1238 .0751

0 1 1 1 1

0 0 1 1 1

0 0 0 1 1

0 0 0 0 1

0 0 0 0 0

.12 .40 .65

Filter Image Result

ImageFiltering

.0751 .1238 .0751

.1238 .2043 .1238

.0751 .1238 .0751

0 1 1 1 1

0 0 1 1 1

0 0 0 1 1

0 0 0 0 1

0 0 0 0 0

.12 .40 .65 .73

Filter Image Result

5/15/08

3


ImageFiltering

.0751 .1238 .0751

.1238 .2043 .1238

.0751 .1238 .0751

0 1 1 1 1

0 0 1 1 1

0 0 0 1 1

0 0 0 0 1

0 0 0 0 0

.12 .40 .65 .73 .53

Filter Image Result

ImageFiltering

.0751 .1238 .0751

.1238 .2043 .1238

.0751 .1238 .0751

0 1 1 1 1

0 0 1 1 1

0 0 0 1 1

0 0 0 0 1

0 0 0 0 0

.12 .40 .65 .73 .53

Filter Image Result

ImageFiltering

.0751 .1238 .0751

.1238 .2043 .1238

.0751 .1238 .0751

0 1 1 1 1

0 0 1 1 1

0 0 0 1 1

0 0 0 0 1

0 0 0 0 0

.08

.12 .40 .65 .73 .53

.08 .32 .68 .92 .73

0 .08 .32 .86 .65

0 0 .08 .32 .40

0 0 0 .08 .12

Filter Image Result

5/15/08

4


ImageFiltering

Final
result:


Boundary
Options


The
simple
method
produces
some
nasty
edge
effects


One
way
to
fix
this
is
to
replicate
edges


0 0 1 1 1 1 1

0 0 1 1 1 1 1

0 0 0 1 1 1 1

0 0 0 0 1 1 1

0 0 0 0 0 1 1

0 0 0 0 0 0 0

0 0 0 0 0 0 0

Applications


Incredibly
versatile
operation


Blur/Motion
Blur


Sharpen


Emboss


Edge
detection


Template
Matching


5/15/08

5


Motion
Blur


.1 .1 .1 .1 .1 .1 .1 .1 .1 .1

Motion
Blur


.1 .1 .1 .1 .1 .1 .1 .1 .1 .1

Emboss


-1 -1 0

-1 0 1

0 1 1

5/15/08

6


Emboss


-1 -1 0

-1 0 1

0 1 1

Sobel
Edge
Detection


1 2 1

0 0 0

-1 -2 -1

1 0 -1

2 0 -2

1 0 -1

Sobel
Edge
Detection


1 2 1

0 0 0

-1 -2 -1

1 0 -1

2 0 -2

1 0 -1

5/15/08

7


Template
Matching


Template
Matching


Template
Matching


0 0 1 1 0 0

0 0 1 1 0 0

0 0 0 0 0 0

1 1 1 1 0 0

0 0 1 1 0 0

0 0 1 1 0 0

0 0 1 1 0 0

1 1 1 1 1 1

5/15/08

8


Template
Matching


Template
Matching


Scene
Classification


Problem:


Look
at
a
set
of
images
and
classify
them
as
one
of
four


types
of
scene


5/15/08

9


Scene
Classification


Can
a
computer
classify
raw
images?


Probably
not


Far
too
much
information
in
the
scene


Image
pre‐processing


Reducing
the
information
in
the
scene


Sums
of
filtered
images


Filter

Image

Sum

Result

Original
Image

F1
 F2
 F3
 … F16


Sum 1 Sum 2 Sum 3 … Sum 16

Gaussian
Kernels


5/15/08

10


Parallelism


Image
filtering


Each
result
pixel
can
be
calculated
independently


Each
result
pixel
only
relies
on
a
small
portion
of
the


original
image


Scene
Classification
Implementation


Image
pieces
must
be
spread
to
each
processes


Less
information
to
send
back
to
first
process


Serial
Algorithm


filterImage ( img, kernel, bConv) {

pad_size = size of kernel / 2

if bConv is true

rotate the kernel by 180 degree

end if

for i from pad_size to (img_rows – pad_size)

for j from pad_size to (img_cols – pad_size)

sum = 0;

for m from –pad_size to pad_size

for n from –pad_size to pad_size

sum += img[i+m][j+n] *kernel[m+pad_size][n+pad_size]

end for

end for

outputImg[i – pad_size][j – pad_size] = sum

end for

end for

return outputImg

}

Parallelization


Parallel
Java


Comm.init(args);

Comm World = Comm.world();

int numProcesses = World.size();

int myRank = World.rank();

...

if (myRank == 0)‏

// Root process

else

// Slaves

5/15/08

11


Parallelization


Communication


Send


ObjectBuf sendBuf = ObjectBuf.buffer();

sendBuf.put(index, result); // pack it!

World.send(ReceiverRank, sendBuf); // send it!

Receive


ObjectBuf recvBuf = ObjectBuf.buffer();

World.receive(SenderRank, recvBuf); // receive it!

otherResult = recvBuf.get(index); // unpack it!

Parallelization


Idea:


Use
one
process
to
split
the
image
up
into
overlapping


rows


Send
each
row
to
a
different
processor


Each
processor...processes
its
row


Pass
each
filter
over
the
row


Sum
the
pixel
values


Single
float
value
per
filter


Each
sum
is
returned
and
added
to
that
filter's
overall
sum


Parallelization


MEGATRON!!


5/15/08

12


Parallelization


Root

if (Root)‏

Split up the image

myPiece = first image slice

foreach processor:

Send the processor its image slice

Parallelization


Slaves


if (not Root)

Receive our slice of the image

Parallelization


All


GenerateFilters

Foreach generated filter:

pass filter over original image

sum pixels in filtered image

5/15/08

13


Speedup


Parallelization


Combine
Results


35


30


25


20


15


10


5


0


if (not Root)‏

send Root array of sums

else if (Root)‏

Receive each array

Combine array with total sum array

Speedup


1
 2
 3
 4
 5
 6
 7
 8
 9
 10
11
 12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32


#
of
Processors


Lessons
Learned


Image
filtering
can
be
sped
up,
even
with
message


passing


Formulation
of
the
problem
is
important!


Small
changes
can
lead
to
large
changes
in
speedup


Learned
how
to
use
Parallel
Java


Ideal


Coast
(256)


Forest
(512)


Mountain
(768)


5/15/08

14


Speedup


4


3


2


1


0


1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
16
 17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32


Future
Work


Previ0us
Speedup


#
of
Processors


Implement
a
SMP
version


Removes
communication
overhead


Process
video


Optimize
gathering
of
result
images


For
example,
some
edge
methods
return
binary
images


In
Summary


Ideal


Small
Image

Large
Image

Image
filtering
is
a
powerful
tool
to
warp
images


Can
be
used
in
a
Scene
Classification
system
as
pre‐

processing
(reduces
complexity
of
the
problem)


Our
parallel
algorithm
did
provide
decent
speedup


Reading
the
image
&
grayscale
conversion
is
still
a
serial


process


5/15/08

15

More magazines by this user
Similar magazines