You are on page 1of 3

ENG1060

 MATLAB  ASSIGNMENT  
Due  Date:  6pm,  20th  of  May  2011  (Friday,  Week  11)  
Late   submissions   will  suffer  a  50%  penalty  to  the  assignment  mark.  Late  submissions  only  allowed  
until  9am,  23rd  of  May  2010  (Monday,  Week  12)  
 
This   assignment   should   be   completed   INDIVIDUALLY.   Plagiarism   will   result   in   a   mark   of   zero.  
Plagiarism   includes   letting   others   copy   your   work   and   using   code   without   citing   the   source.   If   a  
part   of   your   code   is   written   in   collaboration   with   classmates,   say   so   in   your   comments   and   clearly  
state  the  contributions  of  each  person.  

I NSTRUCTIONS  
Download  template.zip  from  Blackboard  and  update  the  M-­‐Files  named  q1a.m,  q1b.m  etc  with  
your  assignment  code.  DO  NOT  rename  the  M-­‐Files  in  the  template  or  modify  run_all.m.  Check  
your  solutions  to  Q1  and  Q2  by  running  run_all.m.    

S UBMITTING  YOUR   A SSIGNMENT  


Submit  your  assignment  online  using  Blackboard.  You  must  include  the  following  attachments:  
1) An  assignment  cover  sheet  with  your  name  and  ID  (do  not  include  this  in  (2)  zip  file)  
2) A  ZIP  file  named  after  your  student  ID  (NOT  .rar  or  any  other  format)  containing  the  following:  
a. Solution  M-­‐Files  for  assignment  tasks  named:  q1a.m,  q1b.m  etc…  
b. Any  additional  function  files  required  by  your  M-­‐Files  (euler  function  etc)  
c. All  data  files  needed  to  run  the  code,  including  the  input  data  provided  to  you  
Follow  “ENG1060  Assignment  ZIP  file  instructions.pdf”  to  prepare  your  zip  file  for  submission.  
 
We  will  extract  (unzip)  your  ZIP  file  and  mark  you  based  on  the  output  of  run_all.m.  It  is  your  
responsibility  to  ensure  that  everything  needed  to  run  your  solution  are  included  in  your  ZIP  file.  

M ARKING   S CHEME  
This  assignment  is  worth  10%  (1  Mark  ==  1%).  Code  will  be  graded  using  the  following  criteria:  
1) run_all.m  produces  results  automatically  (no  additional  user  interaction  needed)  
2) Your  code  produces  correct  results  (printed  values,  plots,  etc…)  and  is  well  written.  

A SSIGNMENT   H ELP  
1) You  can  ask  questions  in  the  Assignment  Discussion  Board  on  Blackboard  
2) Hints  and  additional  instructions  are  provided  as  comments  in  the  assignment  template  M-­‐Files  
3) Hints  may  also  be  provided  during  lectures  
ENG1060  Assignment     Page  1  of  3  
Q UESTION   1                                   [4   M ARKS ]  

Depth   cameras   give   a   3D   distance  


measurement   for   each   image   pixel.  
These   sensors   are   increasingly   popular  
in   Engineering   applications   such   as  
automation,   manufacturing,   structural  
surveys,   robotics,   computer   vision,   3D  
markerless   motion   capture   and   home  
entertainment.  
 
The  image  on  the  left  shows  a  Microsoft  
Kinect   sensor   (which   includes   a   depth  
camera)   pointing   at   the   corner   of   a  
room.   The   orange   rectangle   gives   a  
rough   boundary   of   the   depth   image  
captured   by   the   sensor.   The   depth  
image   is   provided   as   separate   metric   x,y,z   values   for   each   pixel   in   the   image.   These   values   are  
available  from  the  text  files  named  x.txt,  y.txt  and  z.txt.  
 
The  goal  of  this  question  is  to  write  a  MATLAB  program  that  will  extract  the  left  and  right  walls  from  
the  depth  image  and  visually  identify  the  door  handle  (which  protrudes  from  the  wall).  The  latter  is  
extremely  useful  for  any  scenario  where  an  automatic  system  must  find  objects  that  do  not  belong  
to  a  plane  (detecting  manufacturing  defects,  intelligent  robotics,  object  tracking,  3D  modelling  etc)  
 
a) Load  the  x,y,z  data  into  MATLAB.  Reject  the  last  8  columns  of  the  data  as  it  contains  noisy  values.  
Plot   every   10th   pixel  (data  point)  in  both  rows  and  columns  using  the  plot3()  function.  Make  sure  
to  label  your  plot  with  the  correct  metric  units.  
HINT:  You  may  find  the  end  keyword  useful  for  matrix  addressing  
b) Produce  a  blueprint-­‐like  floor  plan  of  the  walls  by  averaging  each  column  of  the  x  and  z  data  into  
vectors  avg_x  and  avg_z.  Plot  the  results  as  black  dots  using  the  appropriate  axis()  settings.  
HINT:  The  floor  plan  should  show  two  lines  of  dots  meeting  at  a  90-­‐degree  corner  
c) Manually   inspect   the   results   of   (b)   and   find   the   location   of   the   corner.   Using   this   information,   fit  
two   straight   lines   to   the   floor   plan   to   model   the   two   walls   (avg_z   =   a0   +   a1*avg_x).   Plot   the  
results  by  showing  avg_x  and  avg_z  as  black  dots,  the  left  wall  as  a  red  line  and  the  right  as  a  blue  
line.  Make  sure  that  the  fitted  lines  are  clearly  visible  on  the  plot.  Label  your  plot  with  a  legend.  
HINT:  You  can  use  polyfit  and  polyval  to  perform  the  fitting  
d) Compare   each   row   in   the   original   x   and   z   pixel   data   (loaded   into   MATLAB   by   task   a)   with   the  
fitted  model  found  in  task  c.  Do  this  for  the  left  wall  only.  Calculate  the  squared  error  between  
the  raw  z  value  and  the  predicted  z  value  of  the  wall  model.  Show  the  squared  error  as  an  image  
using   the   imshow()   command   and   use   the   ‘jet’   colormap().   The   door   handle   should   be   clearly  
visible  (glow)  in  your  image  results  as  it  has  large  z  errors  relative  to  the  fitted  wall  model.  

ENG1060  Assignment     Page  2  of  3  


Q UESTION   2                                     [5   M ARKS ]  

You   are   part   of   a   team   working   for   the   United   Nations  


Environment   Programme   (UNEP)   to   investigate   the  
disappearance   of   the   Aral   Sea.   The   demise   of   the   Aral  
Sea   in   central   Asia   was   caused   primarily   by   the  
diversion   of   the   inflowing   Amudarya   and   Syrdarya  
rivers  to  irrigate  local  croplands.  
 
a) You   have   been   given   AralSeaData.txt,   which  
contains   the   rate   of   change   of   sea   surface   area  
(SSA)   of   the   Aral   Sea   from   year   1911   to   2006.   The  
initial   SSA   in   1911   is   67.5   km2.   Find   the   SSA   from  
1912  to  2006  by  numerical  integration.  Plot   the   SSA  
from  1911  to  2006  using  dots  joined  by  a  solid  line.    
HINT:  You  should  perform  integration  iteratively  in  a  “cumulative”  manner  
   
b) You   have   been   given   aerial   images   of   the   Aral   Sea   over   several   years   [1].   Convert   these   color  
images  to  grayscale  using  the  built-­‐in  function  rgb2gray().  Identify  a  suitable  threshold  value  for  
each  image  where  pixels  less  than  this  value  (sea)  are  set  to  255  and  other  pixels  (non-­‐sea)  are  
set   to   0.   The   possible   thresholds   are   201,   172,   168,   165   and   160.   Assume   an   SSA   in   1957   of  
68km2.  Plot  the  real  world  SSA  for  all  images  using  red  square  makers  and  the  SSA  from  (a)  as  a  
blue  solid  line  on  the  same  figure.  Print  the  threshold  for  each  image  in  the  command  window.  
HINT:  Use  the  plot  to  verify  the  threshold  for  an  image.  Thresholds  may  vary  between  images.  
 
c) Fit  a  2nd  order  polynomial  model  to  the  SSA  results  calculated  in  (a).  Use  the  polynomial  model  to  
estimate  SSA  data  from  1955  to  2030  with  an  interval  of  5  years.  Plot  the  SSA  calculated  in  (a)  
with  blue  dot  markers  and  the  estimated  SSA  as  a  red  solid  line.  Print  the  polynomial  model  in  
the  command  window.  
 
d) Estimate   the   annual   SSA   from   1957   to   2030   using   the   ODE   model   below   (SSA   in   1957   is   68   km2).  
Plot  the  SSA  calculated  in  (a)  with  blue  dot  markers  and  the  estimated  SSA  as  a  red  solid  line.  
dA
= −1.0477  
dy
e) Write   a   MATLAB   program   to   find   out   in   which   year   the   Aral   Sea   will   disappear   using   both   the  
Polynomial   model   in   (c)   and   the   ODE   model   in   (d).   (Assume   the   current   rate   of   decline).   Print  
ONE  sentence  in  the  command  window  that  identifies  which  model  gives  a  better  estimate  and  
justifies  your  choice  of  model.  There  is  no  need  to  output  anything  else  for  this  task.  

Good  Programming  Practices  (Coding  style  and  Comments)                        [1  Mark]  


 
[1] The  disappearance  of  the  Aral  Sea  ."  UNEP/GRID-­‐Arendal  Maps  and  Graphics  Library.  2009.  UNEP/GRID-­‐Arendal.  15  
Apr  2011  <http://maps.grida.no/go/graphic/the-­‐disappearance-­‐of-­‐the-­‐aral-­‐sea>  

ENG1060  Assignment     Page  3  of  3  

You might also like