CS 1114: Introduction to Computing Using MATLAB and Robotics Prof. Graeme Bailey (notes modified from Noah Snavely, Spring.

Slides:



Advertisements
Similar presentations
Introduction to MATLAB The language of Technical Computing.
Advertisements

Maths for Computer Graphics
CS 1114: Data Structures – memory allocation Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
COMS S1007 Object-Oriented Programming and Design in Java July 8, 2008.
CS 1114: Introduction to Computing Using MATLAB and Robotics Prof. Noah Snavely
Affine Linear Transformations Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
DATA STRUCTURES INTRODUCTION CSC 172 SPRING 2002.
Finding Red Pixels – Part 2 Prof. Noah Snavely CS1114
Announcements Kevin Matzen office hours – Tuesday 4-5pm, Thursday 2-3pm, Upson 317 TA: Yin Lou Course lab: Upson 317 – Card access will be setup soon Course.
Finding Red Pixels – Part 1 Prof. Noah Snavely CS1114
R-1 University of Washington Computer Programming I Lecture 17: Multidimensional Arrays © 2000 UW CSE.
Lecture 3a: Feature detection and matching CS6670: Computer Vision Noah Snavely.
Linked lists and memory allocation Prof. Noah Snavely CS1114
Manipulating 2D arrays in Java
University of British Columbia CPSC 111, Intro to Computation 2009W2: Jan-Apr 2010 Tamara Munzner 1 Yet More Array Practice Lecture 24, Mon Mar
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
Robust fitting Prof. Noah Snavely CS1114
Intelligent Ground Vehicle Competition Navigation Michael Lebson - James McLane - Image Processing Hamad Al Salem.
CS 1114: Introduction to Computing Using MATLAB and Robotics Prof. Noah Snavely CS1114
Computer Systems Nat 4.5 Computing Science Data Representation Lesson 4: Storing Graphics EXTENSION.
Chapter 5. Loops are common in most programming languages Plus side: Are very fast (in other languages) & easy to understand Negative side: Require a.
CS 102 Computers In Context (Multimedia)‏ 01 / 28 / 2009 Instructor: Michael Eckmann.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Image Processing & Perception Sec 9-11 Web Design.
EECE 310 Software Engineering Lecture 0: Course Orientation.
Computer Science 10: Introduction to Computer Science Dr. Natalie Linnell with credit to Cay Horstmann and Marty Stepp.
CS 106 Introduction to Computer Science I 03 / 19 / 2007 Instructor: Michael Eckmann.
Math 3360: Mathematical Imaging Prof. Ronald Lok Ming Lui Department of Mathematics, The Chinese University of Hong Kong Lecture 1: Introduction to mathematical.
CSC Intro. to Computing Lecture 13: PALGO. Announcements Midterm is in one week  Time to start reviewing  We will do more review in class Tuesday.
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
CS100J Spring 2006 CS100J: 11 weeks of programming using Java and 2 weeks using Matlab. David Gries is teaching CS100J. Graeme Bailey is teaching a special.
Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Pictures Looping through pixels.. Lab Review (1) Objects  Instantiated from Class  Turtle myTut = new Turtle(myWorld);  new operator creates an instance.
Two –Dimensional Arrays Mrs. C. Furman Java Programming November 19, 2008.
Image segmentation Prof. Noah Snavely CS1114
Today’s lecture 2-Dimensional indexing Color Format Thread Synchronization within for- loops Shared Memory Tiling Review example programs Using Printf.
CS 1699: Intro to Computer Vision Matlab Tutorial Prof. Adriana Kovashka University of Pittsburgh September 3, 2015.
infinity-project.org Engineering education for today’s classroom 2 Outline How Can We Use Digital Images? A Digital Image is a Matrix Manipulating Images.
Why is computer vision difficult?
Finding Red Pixels Prof. Ramin Zabih
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Lecture 7: Intro to Computer Graphics. Remember…… DIGITAL - Digital means discrete. DIGITAL - Digital means discrete. Digital representation is comprised.
Picture Lab. Manipulating Pictures Discussion and activities with java.awt.Color introduce students to megapixels, pixels, the RGB color model, binary.
CS559: Computer Graphics Lecture 8: 3D Transforms Li Zhang Spring 2008 Most Slides from Stephen Chenney.
Finding Red Pixels – Part 1 Prof. Noah Snavely CS1114
Finding Red Pixels – Part 2 Prof. Noah Snavely CS1114
Matlab tutorial course Lesson 4: Writing your own functions: programming constructs
CS100R: Introduction to Computing Using MATLAB and Robotics Prof. Ramin Zabih
A (VERY) SHORT INTRODUCTION TO MATLAB J.A. MARR George Mason University School of Physics, Astronomy and Computational Sciences.
Fall 2012 Professor C. Van Loan Introduction to CSE Using Matlab GUIs CS 1115.
CIS 601 Fall 2003 Introduction to MATLAB Longin Jan Latecki Based on the lectures of Rolf Lakaemper and David Young.
CSSE463: Image Recognition Matt Boutell Myers240C x8534
1 ITK Lecture 5 Intro to Iterators Methods in Image Analysis CMU Robotics Institute U. Pitt Bioengineering 2630 Spring Term, 2006 Methods in Image.
CS 106 Introduction to Computer Science I 03 / 22 / 2010 Instructor: Michael Eckmann.
Improving Matlab Performance CS1114
CS 1114: Finding things Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
CIS 595 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
CompSci 101 Introduction to Computer Science March 8, 2016 Prof. Rodger.
Recognizing objects Prof. Noah Snavely CS1114
Image Processing & Perception
Introduction to MATLAB
CS 2770: Computer Vision Linear Algebra and Matlab
CS 1674: Intro to Computer Vision Linear Algebra Review
More Image Manipulation
Computer Graphics Module Overview
CSIS110 - Introduction to Computer Science
Simulation And Modeling
CS 1114: Introduction to Computing Using MATLAB and Robotics
2-Dimensional Lists (Matrices) in Python
Bounding Boxes, Algorithm Speed
Presentation transcript:

CS 1114: Introduction to Computing Using MATLAB and Robotics Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)

2 Overview  What is CS 1114? –An honors-level intro to CS using camera-controlled robots (Rovio, Sony Aibo, iRobot Create) –An alternative to CS1112 or CS1132, to fulfill your Matlab computing requirement –Formerly known as CS100R

Goals of CS1114  Give you an intuition about computation problem solving  Teach you useful (and interesting) computer science  Give you fluency in the Matlab programming environment  Have fun with robots 3

Requirements  Exposure to programming (in any language)  Some interest in math –Computer science is about much more than programming, and so is this course 4

Java or Matlab?  Both CS1110 and CS111[2,4] teach fundamental problem solving skills and computer science techniques  The destination is the same…  … but the vehicle is different 5 (inspired by Charlie Van Loan)

Robots:

7 Robots: cute but dumb  What do they know about the world around them? –Without your help, very little –Can’t even notice a bright red lightstick  Your mission: make them smarter  Lots of interesting math and computer science, some computer programming –Lots of experience with programming, even with robots, won’t give you a leg up in 1114

8 CS1114 Logistics  Lectures: Tue Thu 11:15–12:05, PHL 307  Sections: –Wed 1:25 - 2:15, Upson 317 –Wed 2:30 - 3:20, Upson 317 –Wed 3:35 - 4:25, Upson 317 –Please go to same section for the entire course  Occasional evening lectures (optional) –First lecture will be in next week (TBA)

CS1114 Logistics  CS1114 lab: Upson 317  You will soon have access to the lab and passwords for the computers  Office hours will generally be held in the lab (hours to be announced soon) 9

10 Assignments  Several mini-quizes –In class, usually at start of lecture Corollary: be on time, or write fast…  5-6 robot programming assignments with multiple parts –You will demo each part to the lab TA’s  2-3 prelims  Free-form final project (required)

What can we do with computer vision? 11

Human vision 12 Question: How many people are in this image? Source: “80 million tiny images” by Torralba, et al.

Interpreting images 13 Q: Can a computer (or robot) understand this image? A: Yes and no (mostly no)

Human vision has its shortcomings… 14 Sinha and Poggio, Nature, 1996 Credit: Steve Seitz

Human vision has its shortcomings… 15 by Ted Adelson, slide credit Steve Seitz

16

Interpreting images 17 Q: Can a computer (or robot) find the lightstick? A: With your help, yes! * (300, 100)

What is an image? 18 “lightstick1.jpg”

19 Major CS1114 Projects  From a camera, figure out the position of a bright red lightstick –Use this to guide a robot around What we see What the robot sees

What is an image?  A grid of numbers (intensity values)  Intensity values range between 0 (black) and 255 (white) 20 x y … … snoop 3D view

What is an image?  A grid of numbers (intensity values)  In Matlab, a matrix 21 [ … ; … ; … ; … ] { { x 100 matrix

Matrices in Matlab  1D matrix is often called a vector –Similar to arrays in other languages 22 A = [ ] Row vector (or 1 x 5 matrix) B = [ 10 ; 30 ; 40 ; 106 ; 123 ] Column vector (or 5 x 1 matrix) A(1) == 10 A(4) == 106

Matrices in Matlab 23 C = [ ; ; ] 3 x 5 matrix C(1,1) == ? C(2,4) == ? can also assign to a matrix entries C(1,1) = C(1,1) + 1

Image processing  We often want to modify an image by “doing something” to each pixel: 24 BlurBrighten

Brightening an image 25 Q: What does this mean in terms of matrix entries? [ ; ; ] A: Increase each element by some amount (say, 20)

Brightening an image (Take 1) 26 D = [ ] D(1) = D(1) + 20; D(2) = D(2) + 20; D(3) = D(3) + 20; D(4) = D(4) + 20; D(5) = D(5) + 20; D(6) = D(6) + 20; D(7) = D(7) + 20; D(8) = D(8) + 20; D(9) = D(8) + 20; D(10) = D(10) + 20; D(11) = D(11) + 20; D(12) = D(12) + 20; D(13) = D(13) + 20; D(14) = D(14) + 20; D(15) = D(15) + 20; x

27 Avoiding duplicate code  Programming languages are designed to make this easy –It’s a huge theme in language design –Many new programming techniques are justified by this Object-oriented programming, higher-order procedures, functional programming, etc.

Why is it a bad idea to duplicate code? 28  Hard to write  Hard to modify  Hard to get right  Hard to generalize  Programmer’s “intent” is obscured D(1) = D(1) + 20; D(2) = D(2) + 20; D(3) = D(3) + 20; D(4) = D(4) + 20; D(5) = D(5) + 20; D(6) = D(6) + 20; D(7) = D(7) + 20; D(8) = D(8) + 20; D(9) = D(8) + 20; D(10) = D(10) + 20; D(11) = D(11) + 20; D(12) = D(12) + 20;

29 Brightening an image (Take 2)  Using iteration for i = 1:12 D(i) = D(i) + 20; end D(1) = D(1) + 20; D(2) = D(2) + 20; D(3) = D(3) + 20; D(4) = D(4) + 20; D(5) = D(5) + 20; D(6) = D(6) + 20; D(7) = D(7) + 20; D(8) = D(8) + 20; D(9) = D(9) + 20; D(10) = D(10) + 20; D(11) = D(11) + 20; D(12) = D(12) + 20;  Much easier to understand and modify the code  Better expresses programmer’s “intent” D = D + 20; “Vectorized” code Usually much faster than loops

Many advantages to iteration  Can do things with iteration that you can’t do by just writing lots of statements  Example: increment every vector cell –Without knowing the length of the vector! len = length(D); % New Matlab function for i = 1:len D(i) = D(i) + 20; end 30

31 Introducing iteration into code  Programming often involves “clichés” –Patterns of code rewriting –I will loosely call these “design patterns”  Iteration is our first example

Brightening 2D images 32 C = [ ; ; ] 3 x 5 matrix for row = 1:3 for col = 1:5 C(row,col) = C(row,col) + 20; end Called a “nested” for loop

Brightening 2D images 33 for row = 1:3 for col = 1:5 C(row,col) = C(row,col) + 20 end  What if it’s not a 3x5 matrix? [nrows,ncols] = size(C) % New Matlab function for row = 1:nrows for col = 1:ncols C(row,col) = C(row,col) + 20 end

What about red pixels?  A grayscale image is a 2D array –Brightest = 255, darkest = 0 34

What about red pixels?  A color image is 3 different 2D arrays –For red/green/blue values (RGB) –We provide a way to create these 3 arrays  Why are there 3? 35 =

What about red pixels?  Example colors: red(1,1) == 255, green(1,1) == blue(1,1) == 0 red(2,1) == 100 == green(2,1) == blue(2,1) red(3,1) == 0 == green(3,1) == blue(3,1) red(3,1) == 255 == green(3,1), blue(3,1) == 0 36

For next time  ……….. Wait* and see** ……… !!!*** ______________ * Assuming you know how to ‘wait’ ** assuming you know how to ‘see’ *** assuming you know why waiting helps seeing 37