final project report - rit center for imaging science · final project report author: ... motion of...

23
1 final project report Author: Ying Li Course: computer for imaging science

Upload: lydat

Post on 04-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

1

final project report

Author: Ying Li

Course: computer for imaging science

2

Problem Statement:

The main purpose of this project is to reallize a GUI program using IDL. In thisproject, I reallized a program, which demo some basic digital image processing toolswith 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 offilter:low pass filter, high pass filter, band pass filter and butterworth filter. By doing thisthe 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 displaythe spectrum of the original image, or the surface plot of the image's spectrum, or theshade 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 originalimage, and display it. Use can press the 'equlization' button to see the effect ofhistogram 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 threekind of basic filters in the filter family: low pass filter, high pass filter and band passfilter.

Low Pass Filter:

Low pass filter block the high frequency of the input signal, so low pass filter willblur the image, but it also can get ride of noise. Because noises are all of highfrequency, use a low pass filter to get ride of noise is a good way.

High Pass Filter:

3

High pass filte is inverse to the low pass filter: it block the low freqency of the imputsignal and thus high pass filter can highlight the edges in image that is sharpen theimage. 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. Weknow that the Fourier Transform of the RECT function is a SINC function. Justbecause of that, a step signal go pass a ideal filter will oscillate. The following figureshows 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 akind of filter. The equation of a butterworth filter is:

Nc

B2)/(1

1|)(|

ξξξ

+=

4

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

5

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 thevalue of the kth gray level and Nk is the number of pixels in the image that have greylevel rk.

Histogram Equalization is to re-map gray levels so that they equally fill the full graylevel range. The equation to do histogram equalization is:

∑=

=a

i tot

i

N

naf

0

)(

4. Motion blur restoration:

Motion of the detector or the object is a very commom way to bring blur into theimage. The purpose of image restoration is to "compensate for" or "undo" defectswhich degrade an image such as motion blur.

The block diagram for a general degradation model is:

6

where g is the corrputed image obtained by passing the original image f through alow pass filter (blurring fuction) B and adding noise to it. There are different ways torestore a motion blurred image. Here I mentioned two methods: inverse filter andconvolve.

Inverse filter:We can model a blurred image by

where F is the original image, B is some kind of a low pass filter and G is our blurredimage. So to get back the original image, we would just have to convolve our blurredfunction with some kind of a high pass filter H. In the ideal case, we would justinvert all the elements of B to get a high pass filter. But we know the most data in Bare 0 or near to 0. So we need to specify a threshold when the module of the data isless than the threshold we can set it to be 1(or some value else, here I choose 1). Andget a modifyed inverse filter. From the program, we can see that when there are nonoise 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 theexposure thim T. That is:

So,

Iterate the procedure, we can get the following equation:

Software Design:

),(),(),(),( ηξηξηξηξ NFBG +⋅=

∫ −−=T

dttyytxxgyxf0 00 ))(),(().(

)()(')(')(

)()(')(

)()()('

xxfaxfaxg

xxfxg

axgxgxf

φφ

+++=++=

−−=

∑=

++=+m

l

xlaxfmaxg0

)()(')( φ

7

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 foreach 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 dialogueform.

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 thewidgets 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_bottomcorner of the rectangle, rx: x coordinate of the rectangel's right_top corner, ry: ycoordinate of the right_top corner of the rectangle.oldrect={Rect_struct, lx,ly,rx,ry} To indicate the old rectangle to be erased asthe mouse moving.oldbutton A flag to indicate whether the mouse button 1is beging pressed down now.imagesize size of the imagedistx The distance from the mouse to the left_bottom corner ofthe rectange( which indicate a region of interest) on x direction.disty The distance from the mouse to theleft_bottom corner of the rectange( which indicate a region of interest) on y direction.

8

Rect_width the width of the region of interestRect_hight the height of the region of interest

Filter module:

Cutoff The frequency cutoff of the filterbandwidth The bandwidth of the band pass filterorder The order of the butterworth filter

motion blur and restoration module

velocity Moving velocity of the detectorBlurimage Blurred imagerestoredimage Result of the restoration using inverse filtersumimage 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 canopen a gray level image of the format of JPEG.User can open a new image in everymodel with any operation has been done. By choose the radio buttons, which arealways appear on the interface, user can get reach to corresponding module.

In Zooming Module, user can drag the red rectangle appearing on the image anywhere of the image to see a zoomed in image on the left side. The program calculatethe position of the red rectangle to prevent it from going outside of the image.

9

figure1 the interface of the zooming module

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

10

figure 2 the interface of filter module

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

11

figure 3 the interface of the fourier transform module

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

12

figure5 histogram

13

figure 6 histogram equalilzation result

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

14

figure 7 motion blur restoration result (inverse filter)

15

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 rectangelmove with the mouse?Yes.Try to drag the red rectangel, with the mouse out of the rectangel, does the rectangelmove with the mouse?No.Try to drag the red rectangel out of the region of the image, does the rectangle go outside of the image?

16

No.Try to drag the red rectangel, with the mouse in the rectangel, does the correspondedzoomed in region of the image apear in theother 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 appearon 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 windowchanged 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 wellas a blured image displayed?Yes.Drag the velocity slider bar, does the blured image change according to the value ofthe velocity slider bar?Yes.Press down the 'inverse filter' button, are the restored image with the power spectrumof 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.

17

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.

18

Appendix 1:

19

20

21

22

23