Homework 3 Image processing

lemonadeviraginityΤεχνίτη Νοημοσύνη και Ρομποτική

6 Νοε 2013 (πριν από 3 χρόνια και 11 μήνες)

85 εμφανίσεις


CO
3011

Audio
-
Video

Signal

Processing





Handout 5

10/
14
/200
9

originated by J. Chou, modified by P.C. Chang


Homework 3 Image processing


Part 1.
Matlab Background



(1) Image Processing functions

To do this lab and all future labs we will be program
ming in Matlab.

To obtain a list of image processing commands

that are available to you, type:


help images

at the Matlab prompt. Matlab contains many images that comes with the toolbox; some of
the images are 'clown', 'trees' and 'forest'.
To
access these images

type


load image_name

where image_name is one of the aforementioned image names.
This command will then
create two variables (X and map).

'X' will be an array of values that indexes a color map
specified by 'map'.
To display

the images

type



imshow(X,map)
or

imshow(image,256);


which will tell Matlab to display the image X with colormap, map.

To load images

that do
not come with the image processing toolbox.
(e.g. image17, image18, suzie40
, suzie50,
etc.) you will have to type the following:




fid=fopen('image_name','r');


image=fread(fid,[xsz,ysz]);


image=image'/256;


The first command provides for a pointer to the image specified by image_name. The
second
command then reads the image into the array 'image' of size xsz * ysz. And finally
the last command takes the transpose of the array 'image' for displaying purposes. Note
that you may need to type


Truesize



to display the true size of the image since Ma
tlab often displays the image with a default ize.
Finally, to display image17, image18, etc. type


imshow(image,256)


which tells Matlab to display the image with a grayscale map of 256 different gray scales.


(2) Useful Matlab Commands

To facilitate doi
ng labs in Matlab it will be useful to write matlab functions.

All matlab functions must have a file name followed by '.m' (e.g. program.m). To access
functions that you have created with an editor, just type the function name at the Matlab
prompt without
the '.m'.



I = imread
('pearlite.tif');

pointer

size xsz * ysz

array

color map



2

2

Part 2. Laboratory Exercise


(1) Creating your Video Sequence


Read in two different images


Then, for the 18 frames in between the first (image17) and last (image18) frame you will
create an image that 'fades' from image17 to image18
. T
o do this, you will take
a linear
combination of image17 and image18

to form the in between images. For example, for
the first frame after image17 you can take


frame1=.95*image17+.05*image18;


frame2=.9*image17+.1*image18;



Put

the 20 images in an image deck ('
immovie
').



use the Matlab function '
movie
' to display this sequence as video. Try using different
frame rates for displaying your image sequences.


(2) Decimation and Interpolation of Video Frames

in the temporal d
omain




Decimating the video sequence that you created above by a factor of

two
. Then using
Matlab, display this decimated sequence. Describe

in your lab report how this decimated
sequence looks.




Reinterpolate this sequence of images by a bilinear

interpolation scheme.




Next, try decimating by a factor of
4

and once again use bilinear

interpolation to

interpolate the 3 frames in between each frame.


(3) Pyramid Decomposition in Time


Pyramid decomposition is useful for compression of vid
eo.
T
he idea behind pyramid
decomposition

is this: first discard every other frame (
downsample
) then
reinterpolate

the

missing frames and
calculate the difference

between the original frame and the reinterpolated
image
.
Then to reconstruct, back to the ori
ginal eight images from the two images, start with the
two images, interpolate and add the difference images to the reinterpolated images. This will
give you four images. If you think about it, you will realize that since we are only transmitting 2
origina
l images, with 6 difference images we can operate at a lower rate (the difference images
have small intensity (less information)).


Part 3.

Laboratory Write
-
Up


You need to submit Matlab programs and a written report. You should write functions

for
imple
menting part 2 of this homework, and mail the matlab functions to TA


(
avsp
-
ta
@
vaplab
.
c
e.ncu.edu.tw) by
6:30 pm,
Wednesday
, 10/
2
8
.


In your lab report, since there is not too much theory, make it brief and describe

what you
learned. Also be s
ure to mention the following points:


(1) How does the video sequence look after decimation? How close is the

reinterpolated image
to the original image for both image sequences (i.e.

the sequence you created and the
sequence I gave you.)? Express it by P
SNRs.


(2) Describe how you would implement
down scaling

in the

spatial domain (
e.g.

create a
256
x256 image from a
512x512 image)

and up scaling (e.g., to reconstruct a 512x512 image)
.


Reference:

1.

Digital image processing 2
nd

edition,
Rafael C. Gonzal
ez, Richard E. Woods.

pp.351

354

2.

Image compression using wavelets and JPEG2000: a tutorial
,
Zhu, J.

,
Electronics & Communication
Engineering Journal , Volume: 14 Issue: 3 , June 2002 Page(s): 112

121

Fig.7, Fig. 12.


Note :
交作業請以「你的學號
_hw3
」為標題,寄給
avsp
-
ta@vaplab.ce.ncu.edu.tw