HW3 - UCSB SoC Design and Test Lab

plainspecialΛογισμικό & κατασκευή λογ/κού

14 Δεκ 2013 (πριν από 3 χρόνια και 9 μήνες)

118 εμφανίσεις

Assignment
3

Due
Monday

Jan.
31

at
10:45am

1. Using native methods in Android

Android NDK provides tools for embedding components written by native languages, such as C/C++, for
Android applications. This enables the reuse of existing codes and libraries.
It also provides potential
perf
ormance boost for compute
-
intensive tasks. This assignment is to help you get familiar with Android
NDK, to equip you with knowledge of building C/C++ codes to share libraries and embedding them into
Android applications.

a)

(1
0%)

Install NDK
: follow the instructions in
http://developer.android.com/sdk/ndk/index.html

to
download and install Android NDK.

The NDK includes
multiple

sample Android applications
, in the di
rectory of
android
-
ndk
-
r5/samples/,

which

illustrate how to use native code in your Android applications
. Each example
includes a complete Android application project, the C code, and a build script.

Look into the example
hello
-
jni
.

Browse every subdirect
ory to identify the Android project source
codes and resource files (HelloJni.java and *
.xml), the C code (hello
-
jni.c
), and the build script
(Android.mk).
Modify the file hello
-
jni.c to return
Hello ece194/594BB

from JNI
!
.
Build this C code as
a shared li
brary, and then run the Android application to display the string specified in hello
-
jni.c on
Android emulator or device.


b)

(
35
%)
Medical image
viewer

and denoising
application.

Write an image viewer application to
view

medical images from
a
specific URL,
display the image,
and perform
denosing

on the image.
The
objective for this part of the assignment is to practice the
use of the native method in Android.








Fig. 1
-
b
-
1: displayi
ng original Fig. 1
-
b
-
2: displaying denoised


image slices




image slices

After the application is launched, check if an MRI image file

with a known

file name

you
pre
-
specify
,

exists
in
the
/sdcard/mri/ dir
ectory. If the file
does exist

in this location, download it from
a known
UR
L
you
pre
-
specify,

and store

the file

in the /sdcard/mri/ directory.

The
data
file contains 181 brain image slices. The size of each slice is 181x217. Each pixel is
represented by
a

16
-
bit
integer
. There is no header in the file.

Allow the user to browse the entire
set of 181
slice
s
.
One

way to
implement this

is using a “SeekBar”
(as
illustrated

in the figure above).
The screen will display one of the slices


depending on the
loc
ation of the thumb. If the “denoise” button, shown in

Fig. 1
-
b
-
1
, is pressed,
the
current

slice,
along with
its previous two and
the next

two slices (
i.e.
total
ly

5 slices)
,
are

passed on

to
a
C

program which

perform
s

the denosing
function. The C program

t
hen pass
es

the denoised result
back to Java
which

display
s

the current, denoised slice
on the screen

as shown in Fig. 1
-
b
-
2
.

A package for this part of
the assignment

is available
here
. This zip file consists of four files:

1.

riciandenoise.zip
: A denoising package from UCLA. This package includes both Matlab and C
implementations of the Rician denoising algorithm, a test program,
a

test image

and the
documentation

(
riciandenoise.pdf
)
. This package was developed by
Pascal Getreuer

from the
Applied Mathematics Department at UCLA. You can directly use the C implementation

of 3D
denoising
in the package and wrap it by JNI.

You should
check out

the 3D denoising demo
program
riciandenoise3
_demo.m

to get some idea of how to use this C function.

2.

brainweb.raws
:
a

data file consisting of 181 gray
-
scale brain image slices. This file is called by the
demo program
riciandenoise3_demo.m

in
riciandenoise.zip
.

3.

Viewer.zip
: an Android application
which

displays
the first

slice
of the data in
brainweb.raws
.
Use this
app
as the starting point for
the

assignment. You would need to add
a

SeekBar to allow
viewing of other slices (
Fig. 1
-
b
-
1)
, and th
e
”denoise” button to trigger the calling of the
denosing C
function
(Fig. 1
-
b
-
1), which will switch the display to a screen similar to Fig. 1
-
b
-
2
which shows
a denoised slice
.

4.

brainweb_noisy_uint_be.bin
:
A

data file
, used in the Viewer app of (3),

following

the s
ame
format as
brainweb.ra
ws
, but with racian noise a
dded

in
to

each slice.

5.

readme.txt
:
a
short description of each file.

Reference:

JNI:
http://en.wikipedia.org/wiki/JNI




http://ja
va.sun.com/docs/books/jni/html/jniTOC.html


2.
3D graphics

The second part of the
assignment

is to help you
get familiar with

3D graphics

using OpenGL ES
,
including drawing 3D objects and making simple animation.

a)

(
25
%)

Use OpenGL ES 1.0 or 1.1 to d
raw a

cube
, with
a
different color on each face
t
.

Display the
cube like the one in
Fig. 2
-
a
-
1

so that
three face
t
s of the cube can be seen
.





Fig. 2
-
a
-
1: displaying
a cube

Fig. 2
-
a
-
2:
adding menu items


Then
a
dd
t
he following
menu items to
:


(1)

zoom
out

(i.e. scale
-
down

by 2)
:
through adjustment to the arguments of glFrustum() or
gluLootAt();

(2)

zoom in (i.e. scale
-
up by 2):
through adjustment to the arguments of glFrustum() or gluLootAt();

(
3
)


start or stop for automa
tically moving

the cube
in
the
X direction back and forth

(changing
direction after the cube hitting the side
-
wall of the screen)
: by using glTranslatef()
;

(
4
)

attach

or de
-
attach

a
texture
to

the top side

of the cube
: choose an image of your choice for t
his
texture mapping task.


b)

(
2
0
%)

Redo part a
)
us
ing

OpenGL ES 2.0
. You will need to modify your implementation
from a)
for
migration to OpenGL ES 2.0.

Reference:



A rotating textured triangle using OpenGL ES 1.0: APIDemo/Graphics/OpenGL ES/Textured Triangl
e



A rotating textured triangle using OpenGL ES 2.0: APIDemo/Graphics/OpenGL ES/OpenGL ES 2.0


3
.
Demo videos
-

(10%)
Create
two

short video
s

(~
30
-
45
seconds

each
) demonstrating your
apps for
part 1
-
b

and
part 2
-
a

respectively
.

Each of these two demo vid
eos account
s

for 5%.

Instruction for homework submission

Create a folder for each of part
1
-
a,

1
-
b, 2
-
a, and 2
-
b
. Name the folders as hw1
-
a,
hw1
-
b,

hw2
-
a,

and
hw2
-
b
respectively. Each of
the four parts

should be implemented as one application. Write one
RE
ADME file that includes your name and brief description of your designs.
For the

demo
video
s
, include
the link
s

in your README file or attach the video file
s

with your submission. Create a tar ball (.rar or .zip)
of
all folders and the README file.

Name th
e tarball with the prefix of
YourLastName_PermNumber_HW
3
.

Use Dropbox to submit this single file. S
end an
email to the TA at
yichuwang@umail.ucsb.edu

with
subject line “
HW3

Submission”

and include the dropbox
link in the body of your email.