Sunteți pe pagina 1din 23

final project report

Author: Ying Li
Course: computer for imaging science

Problem Statement:
The main purpose of this project is to reallize a GUI program using IDL. In this
project, I reallized a program, which demo some basic digital image processing tools
with a friendly interface.

The program has such funcitons as following:


1. Image display. A gray level JPEG image can be displayed.
2. Four kinds of filter. It passes the image opened by the user through 4 kinds of
filter:
low pass filter, high pass filter, band pass filter and butterworth filter. By doing this
the program displayed the result image or the filter's shape(at the user's choice)
besides the original image.
3. Fourier Transform. It can do Fourier Transform of the original image and display
the spectrum of the original image, or the surface plot of the image's spectrum, or the
shade surface of the image's spectrum, or the log power spectrum( at user's choice)
4. Histogram equalization. The program calculate the histogram of the original
image, and display it. Use can press the 'equlization' button to see the effect of
histogram equalization and the histogram after equalized.
5. Motion blur restoration. The program use two ways to restore a blurred image:
one is inverse filter and the other is convolving with a comb function.

Theory and relative equations:


1. Filter:
Fileters are a kind of very powerful tool in digital image processing. There are three
kind of basic filters in the filter family: low pass filter, high pass filter and band pass
filter.
Low Pass Filter:
Low pass filter block the high frequency of the input signal, so low pass filter will
blur the image, but it also can get ride of noise. Because noises are all of high
frequency, use a low pass filter to get ride of noise is a good way.
High Pass Filter:

High pass filte is inverse to the low pass filter: it block the low freqency of the imput
signal and thus high pass filter can highlight the edges in image that is sharpen the
image. But on the other hand it let all the noises remain.
Band Pass Filter:
Band pass filter let seleted frequency passed and block the others.
Butterworth Filter:
The reason why we want a Butterworth filter is the sharp edge of the ideal filters. We
know that the Fourier Transform of the RECT function is a SINC function. Just
because of that, a step signal go pass a ideal filter will oscillate. The following figure
shows the oscillation of the STEP funciton passed an ideal low pass filter.

figure 1 the output signal of a step function though a ideal low pass filter
So we want a kind of filter whose edge is not so sharp. Butterworth filter is such a
kind of filter. The equation of a butterworth filter is:
| B( ) |=

1
1 + ( / c ) 2 N
3

here, N is the order of the butterworth filter. The bigger of N the sharper of the edge.

figure 2 Buttorworth low pass filter whose order = 2

figure 3 Buttorworth low pass fitler whose order = 6


2. Fourier Transform:
Frourier Transform trasnform a signal form spacial space to spectrum space.

3. Histogram and Histogram Equalization:


Define the histogram of gray levels in an image rk=f(x,y) as p(rk)=nk. Where rk is the
value of the kth gray level and Nk is the number of pixels in the image that have grey
level rk.
Histogram Equalization is to re-map gray levels so that they equally fill the full gray
level range. The equation to do histogram equalization is:
a

f (a ) =
i =0

ni
N tot

4. Motion blur restoration:


Motion of the detector or the object is a very commom way to bring blur into the
image. The purpose of image restoration is to "compensate for" or "undo" defects
which degrade an image such as motion blur.
The block diagram for a general degradation model is:

where g is the corrputed image obtained by passing the original image f through a
low pass filter (blurring fuction) B and adding noise to it. There are different ways to
restore a motion blurred image. Here I mentioned two methods: inverse filter and
convolve.
Inverse filter:
We can model a blurred image by

G ( , ) = B( , ) F ( , ) + N ( , )
where F is the original image, B is some kind of a low pass filter and G is our blurred
image. So to get back the original image, we would just have to convolve our blurred
function with some kind of a high pass filter H. In the ideal case, we would just
invert all the elements of B to get a high pass filter. But we know the most data in B
are 0 or near to 0. So we need to specify a threshold when the module of the data is
less than the threshold we can set it to be 1(or some value else, here I choose 1). And
get a modifyed inverse filter. From the program, we can see that when there are no
noise or very small amount of noise, the result is pretty good.
The other way is convolve the derivated blurred image with a COMB function.
The motion blur is coursed by the moving of the detector or the object within the
exposure thim T. That is:
T

f ( x. y ) = g ( x x0 (t ), y y0 (t ))dt
0

So,
f ' ( x) = g ( x) g ( x a )
g ( x) = f ' ( x) + ( x)
g ( x + a) = f ' ( x + a ) + f ' ( x ) + ( x)

Iterate the procedure, we can get the following equation:


m

g ( x + ma) = f ' ( x + la ) + ( x )
l =0

Software Design:

There are 5 modles modules in the program: Zooming Module, Filter Module,
Fourier Transform Module, Histogram Module, and motion blur restoration module.
Each module is not related very much. In order to realize different interface for
each module I use 14 Base_Widgets. I use different kind of widgets in the program:
menu, button, drop list, radio button, label, text, sliderbar, and a module dialogue
form.
1. Flowchart:
Please see it in appendix.
2. Variable Table:
main procedure:
status={whichbase, whichitem, seconditem}
A structure to indicate which module is current module, and the status of the
widgets in the bases.
Zoom module:
Rect={Rect_struct, lx, ly, rx, ry}
A structure to indicate the region of interest, lx:
x coordinate of the left_bottom
corner of rectangle, ly: y coordinate of the left_bottom
corner of the rectangle,
rx: x coordinate of the rectangel's right_top corner, ry: y
coordinate of the right_top
corner of the rectangle.
oldrect={Rect_struct, lx,ly,rx,ry}
To indicate the old rectangle to be erased as
the mouse moving.
oldbutton
A flag to indicate whether the mouse button 1
is beging pressed down now.
imagesize
size of the image
distx
The distance from the mouse to the left_bottom corner of
the rectange( which indicate
a region of interest) on x direction.
disty
The distance from the mouse to the
left_bottom corner of the rectange( which indicate
a region of interest) on y direction.
7

Rect_width
Rect_hight

the width of the region of interest


the height of the region of interest

Filter module:
Cutoff
bandwidth
order

The frequency cutoff of the filter


The bandwidth of the band pass filter
The order of the butterworth filter

motion blur and restoration module


velocity
Blurimage
restoredimage
sumimage

Moving velocity of the detector


Blurred image
Result of the restoration using inverse filter
Result of the restoration using convolution

3. User's Guide:
In this program,the menu bar include two menus: file and help. In file menu you can
open a gray level image of the format of JPEG.User can open a new image in every
model with any operation has been done. By choose the radio buttons, which are
always appear on the interface, user can get reach to corresponding module.
In Zooming Module, user can drag the red rectangle appearing on the image any
where of the image to see a zoomed in image on the left side. The program calculate
the position of the red rectangle to prevent it from going outside of the image.

figure1 the interface of the zooming module

In the Filter Module, user can choose any kind of filter supplied: low pass filter, high
pass filter, band pass filter and buttorworth low pass filter, by select from the filter
drop list. User can also decide the parameters of these fitlers: frequency cutoff, band
width and order for Butterworth filter. By choose from an other drop list, user can
decide which kind of result he want: filtered image, plot of the filter, shade surface of
the filter, the cross section of the filter.

figure 2 the interface of filter module


In the Fourier Transform Module, user can choose which kind of result display he
want: plot of spectrum of the original image, shade surface of the spectrum of the
original image, cross section of the spectrum of the original image, log power
spectrum of the original image.

10

figure 3 the interface of the fourier transform module


In the Histogram Module, user can see the histogram of the original image, and by
pressing down the 'equalize', he can see the iamge after histogram equalized as well
as the equallized histogram.

11

figure5 histogram

12

figure 6 histogram equalilzation result


In the Motion Blur and Restoration Module, user can decide the velocity of the
detector by drag the velocity slider. And he can choose to use which method to
restore the blurred image. Press down the 'inverse filter', he can got a result using
inverse filter. By pressing down the 'convolve', he can get a result using convolution.

13

figure 7 motion blur restoration result (inverse filter)

14

figure 8 motion blur restoration result (convolution)

Testing Procedure:
In Zooming Module, open an gray level JPEG image, is every thing ok?
Yes.
Try to drag the red rectangel, with the mouse in the rectangel, does the rectangel
move with the mouse?
Yes.
Try to drag the red rectangel, with the mouse out of the rectangel, does the rectangel
move with the mouse?
No.
Try to drag the red rectangel out of the region of the image, does the rectangle go out
side of the image?

15

No.
Try to drag the red rectangel, with the mouse in the rectangel, does the corresponded
zoomed in region of the image apear in the
other window?
Yes.
Check the 'filter radio button, does the corresponding filter module appear?
Yes.
Does the image of the result displayed in the window is correct?
Yes.
Choose an other kind of filter, does the result freshed and is it correct?
Yes.
Choose an other kind of result such as the shade surface of the fitler, does it appear
on the right position?
Yes.
Try to open a new image here, is it loaded in?
Yes.
Change to the Zoom module, is the image changed, is the size of the window
changed according to the size of the image?
Yes.
Drag the red rectangle and is every thing alright?
Yes.
Choose to histogram module, is the image and corresponding histogram displayed?
Yes.
Press down the 'equalation' button, is the result displayed?
Yes.
Is it right?
Yes.
Choose to Motion Blur and Restoration Module, is the corresponding image as well
as a blured image displayed?
Yes.
Drag the velocity slider bar, does the blured image change according to the value of
the velocity slider bar?
Yes.
Press down the 'inverse filter' button, are the restored image with the power spectrum
of the PSF displayed?
Yes.
Is them correct?
Looks like so.
Press down the other button to see the result of convolving. Is the output refreshed?
Yes.
16

Open an new image here, is it loaded in without error?


Yes.
Change to histogram module is the display correct?
Yes.
Pull down the help menu, and press the 'about ...' button, does a dialoge appear?
Yes.
Try to change to Motion Blur and Restoration module, can you?
No, because the dialoge form is modual.
Press 'ok' button on the dialogue form, is it destroyed?
Yes.
Change to Zooming module, everything ok?
Yes.
Pull down the file menu, and press the 'quit' button, does the program finished?
Yes.

17

Appendix 1:

18

19

20

21

22

23

S-ar putea să vă placă și