Bounding Boxes, Algorithm Speed

Slides:



Advertisements
Similar presentations
Creation of the Boundary Path Jonathan Misurda Math 1110 February 11, 2002.
Advertisements

Finding Red Pixels – Part 2 Prof. Noah Snavely CS1114
CS 1114: Introduction to Computing Using MATLAB and Robotics Prof. Graeme Bailey (notes modified from Noah Snavely, Spring.
Robustness and speed Prof. Noah Snavely CS1114
Finding Red Pixels – Part 1 Prof. Noah Snavely CS1114
Blobs and Graphs Prof. Noah Snavely CS1114
Interpolation, extrapolation, etc. Prof. Ramin Zabih
Voronoi diagrams and applications Prof. Ramin Zabih
DIEGO AGUIRRE COMPUTER VISION INTRODUCTION 1. QUESTION What is Computer Vision? 2.
Image segmentation Prof. Noah Snavely CS1114
Finding Red Pixels Prof. Ramin Zabih
Medians and blobs Prof. Ramin Zabih
Robustness and speed Prof. Noah Snavely CS1114
Finding Red Pixels – Part 1 Prof. Noah Snavely CS1114
Clustering Prof. Ramin Zabih
Finding Red Pixels – Part 2 Prof. Noah Snavely CS1114
1 Computer Science 631 Multimedia Systems Prof. Ramin Zabih Computer Science Department CORNELL UNIVERSITY.
CS100R: Introduction to Computing Using MATLAB and Robotics Prof. Ramin Zabih
Sorting and selection – Part 2 Prof. Noah Snavely CS1114
CS 1114: Finding things Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
Recognizing objects Prof. Noah Snavely CS1114
11 Making Decisions in a Program Session 2.3. Session Overview  Introduce the idea of an algorithm  Show how a program can make logical decisions based.
Implementing stacks Prof. Ramin Zabih
Introduction to CSCI 1311 Dr. Mark C. Lewis
AP CSP: Pixelation – B&W/Color Images
CSSE463: Image Recognition Day 9
Any questions on today’s homework. (Sections 1. 6/1
John Federici NJIT Physics Department
CS 0134 (term 2181) Jarrett Billingsley
LESSON 2 Module 2: XHTML Basics More Basic XHTML.
Lightstick orientation; line fitting
Pixels, Colors and Shapes
Eigenfaces (for Face Recognition)
Prof. Ramin Zabih Implementing queues Prof. Ramin Zabih
EGR 2261 Unit 10 Two-dimensional Arrays
UNIT 2 – LESSON 3 Encoding B&W Images.
Vocabulary byte - The technical term for 8 bits of data.
Vocabulary byte - The technical term for 8 bits of data.
Processing Introduction CSE 120 Spring 2017
Week 1 - Friday CS 113.
CMSC201 Computer Science I for Majors Lecture 12 – Lists (cont)
CompSci 101 Introduction to Computer Science
Vocabulary byte - The technical term for 8 bits of data.
Garbage collection; lightstick orientation
Vocabulary byte - The technical term for 8 bits of data.
Vocabulary byte - The technical term for 8 bits of data.
CSSE463: Image Recognition
Image transformations
Each column represents another power of the base
Color Values All colors in computer images are a combination of red, green and blue Each component is encoded as a number means the color is.
Physics 3232 Optics I Professor Rick Trebino Howey Physics Building
Data Structures – Stacks and Queus
Prof. Ramin Zabih Least squares fitting Prof. Ramin Zabih
Preprocessing to accelerate 1-NN
Gray Scale picture def pixBW(pixel): # given a pixel, change to BW
Numbers and their bases
LESSON 2 Module 2: XHTML Basics More Basic XHTML.
Due Next Monday Assignment 1 Start early
Quickselect Prof. Noah Snavely CS1114
CS5112: Algorithms and Data Structures for Applications
Prof. Ramin Zabih Beyond binary search Prof. Ramin Zabih
Searching, Sorting, and Asymptotic Complexity
Sorting, selecting and complexity
CS 1114: Introduction to Computing Using MATLAB and Robotics
Non-numeric Data Representation
1. Get your bubble lab 2. Flip to the graph
Quicksort and selection
Getting to the bottom, fast
Directions to play game
Sorting and selection Prof. Noah Snavely CS1114
Presentation transcript:

Bounding Boxes, Algorithm Speed Prof. Ramin Zabih http://cs100r.cs.cornell.edu

Administrivia Assignment 1 released, due next Friday On the course web page, cs100r.cs.cornell.edu Look under “Assignments”! You should all have gotten email from me announcing this If not, you aren’t yet on CMS You should also all have lab access and accounts on the lab computers by now Office hours are coming soon Quiz 1 is a week from today

Matlab expressions An expression in Matlab is anything you can type in which has a value Examples: 3, len, A(1) > A(2), etc. Can be the RHS of an assignment statement Most Matlab statements (for, if, etc.) can take expressions as well as numbers for i = EXP1:EXP2 A(i) = EXP3; end; Some of these EXP’s must evaluate to integers Which ones?

Count zero’s in a 2D matrix nzeros = 0; [nrows,ncols] = size(B); for row = 1:nrows for col = 1:ncols if (B(row,col) == 0) nzeros = nzeros + 1; end;

What about red pixels? A (non-color) image is a 2D array Brightest = 255, darkest = 0 A color image is 3 different 2D arrays For red/green/blue values (RGB) We provide a way to create these 3 arrays  Anyone know why there are 3? Examples: red(1,1)==255, blue(1,1) == green(1,1) == 0 red(2,1) == 100 == blue(2,1) == green(2,1) red(3,1) == 0 == blue(3,1) == green(3,1)

How many red pixels? img = imread(‘wand1.bmp’); [Red, Green, Blue] = image_rgb(img); nreds = 0; [nrows,ncols] = image_size(img); for row = 1:nrows for col = 1:ncols if (Red(row,col) == 255) nreds = nreds + 1; end;

Are we done? We have counted the red pixels in Matlab Or have we? What can go wrong? Actually, quite a few things… Suppose we can pick a good constant instead of 255 You need to look at Green and Blue also  Color perception is really hard! We’ve answered the question: is there a red light stick? But the robot needs to know where it is!

Finding the rightmost red pixel We can always process the red pixels as we find them: right = 0; for row = 1:nrows for col = 1:ncols if (Red(row,col) == 255) right = max(right,col); end;

Finding the bounding box The bounding box of a set of points is the smallest rectangle containing all the points By “rectangle”, I really mean “rectangle aligned with the X,Y axes” Bounding box example: Each red pixel we find is basically a point It has an X and Y coordinate Column and row Note that Matlab reverses the order

What does this tell us? Bounding box can give us various information about the lightstick The midpoint of the bounding box tells us roughly where the lightstick is The aspect ratio give us an idea about its orientation Ratio of width to height

Compute a bounding box? Two related questions: Is this a good idea? Will it tell us reliably where the light stick is located? It obviously works some of the time Can we compute it fast? Lots of CS involves trying to find something that is both useful and efficient To do this well, you need a lot of clever ways to efficiently compute things (i.e., algorithms) We’re going to learn a lot of these in CS100R Including quite a few you’ve never seen

Beyond the bounding box Computing a bounding box isn’t hard Hint: the right edge is computed by the code we showed a few slides ago You’ll write this and play with it in A2 But it’s not very robust, as you will see Example: