CS 1114: Introduction to Computing Using MATLAB and Robotics

Slides:



Advertisements
Similar presentations
1 ECE 495 – Integrated System Design I Introduction to Image Processing ECE 495, Spring 2013.
Advertisements

Working with images and scenes CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.5 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Simple Face Detection system Ali Arab Sharif university of tech. Fall 2012.
Polygons and the convex hull Prof. Noah Snavely CS1114
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)
Figure 1: (A) A microarray may contain thousands of ‘spots’. Each spot contains many copies of the same DNA sequence that uniquely represents a gene from.
CS 1114: Sorting and selection (part one) Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
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.
Finding Red Pixels – Part 1 Prof. Noah Snavely CS1114
R-1 University of Washington Computer Programming I Lecture 17: Multidimensional Arrays © 2000 UW CSE.
Polygons and the convex hull Prof. Noah Snavely CS1114
CSE 113 Week 5 February , Announcements  Module 2 due 2/15  Exam 3 is on 2/15  Module 3 due 2/22  Exam 4 is on 2/25  Module 4 due 2/29.
Computer Science 111 Fundamentals of Programming I Introduction to Digital Image Processing.
Computing transformations Prof. Noah Snavely CS1114
Robust fitting Prof. Noah Snavely CS1114
CS 1114: Introduction to Computing Using MATLAB and Robotics Prof. Noah Snavely CS1114
Spring  Evolving Lists & Lights On!  Caesar Cipher  Looks Good!
Image Processing & Perception Sec 9-11 Web Design.
TOPIC 7 MODIFYING PIXELS IN A MATRIX NESTED FOR LOOPS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by.
Image segmentation Prof. Noah Snavely CS1114
CS1315: Introduction to Media Computation Picture encoding and manipulation.
Finding Red Pixels Prof. Ramin Zabih
Finding Red Pixels – Part 1 Prof. Noah Snavely CS1114
Finding Red Pixels – Part 2 Prof. Noah Snavely CS1114
CS100R: Introduction to Computing Using MATLAB and Robotics Prof. Ramin Zabih
Fitting image transformations Prof. Noah Snavely CS1114
CS 1114: Finding things Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
Lesson 5-4 Example Example 1 Draw an array to model and find 21 ÷ 3. 1.Write the answer if you know it. Otherwise, draw an array.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
Computer Vision Exercise Session 10–Shape from Silhouettes.
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.
AP CSP: Pixelation – B&W/Color Images
Image Processing Objectives To understand pixel based image processing
David Meredith Aalborg University
Pixels, Colors and Shapes
Eigenfaces (for Face Recognition)
AP CSP: The Need for Programming Languages and Algorithms
UNIT 2 – LESSON 3 Encoding B&W Images.
Lesson 2-3 AP Computer Science Principles
CS 1114: Implementing Search
CS1315: Introduction to Media Computation
DIP 9 65 Original 210 Eye Zoomed.
Garbage collection; lightstick orientation
Fundamentals of Programming I Introduction to Digital Image Processing
Lecture 7: Image alignment
Learning to program with Logo
Each column represents another power of the base
A What is the ratio of Area to Width of rectangle A? A W 4 u 20 u2
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.
Object recognition Prof. Graeme Bailey
Representing Images 2.6 – Data Representation.
Resizing for Projection
Gray Scale picture def pixBW(pixel): # given a pixel, change to BW
Assignment 1 Creating a Heart.
CS 106A, Lecture 18 Practice with 1D and 2D Arrays
Open on the student drive
Fundamentals of Programming I Introduction to Digital Image Processing
So where is it anyway? Bounding box, median, centroids, and an introduction to algorithm analysis.
Quickselect Prof. Noah Snavely CS1114
CS-447– Computer Architecture Lecture 20 Cache Memories
CS 1114: Sorting and selection (part two)
Introduction to Programming in MATLAB
Bounding Boxes, Algorithm Speed
Calibration and homographies
Working with images and scenes
Sorting and selection Prof. Noah Snavely CS1114
Is all about sharing and being fair
Presentation transcript:

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

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

Brightening 2D images What if it’s not a 3x5 matrix? 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

Using iteration to count nzeros = 0; [nrows,ncols] = size(D); for row = 1:nrows for col = 1:ncols if D(row,col) == 0 nzeros = nzeros + 1; end; D = [ 10 30 0 106 123 ; 8 49 58 0 145 ; 16 0 86 123 152 ]

Using iteration to count nzeros = 0; [nrows,ncols] = size(D); for row = 1:nrows for col = 1:ncols if D(row,col) == 0 nzeros = nzeros + 1; end; If D is an image, what are we counting?

What if we need to execute this code many times? How many black pixels? nzeros = 0; [nrows,ncols] = size(D); for row = 1:nrows for col = 1:ncols if D(row,col) == 0 nzeros = nzeros + 1; end What if we need to execute this code many times?

Turning this into a function function [ nzeros ] = count_zeros(D) % Counts the number of zeros in a matrix nzeros = 0; [nrows,ncols] = size(D); for row = 1:nrows for col = 1:ncols if D(row,col) == 0 nzeros = nzeros + 1; end Save in a file named count_zeros.m count_zeros([1 3 4 0 2 0])

What about red pixels? = + + R G B red(1,1) == 255, green(1,1) == blue(1,1) == 0

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

We’ve counted the red pixels in Matlab Can anything go wrong? Question: devise a thresholding function

Finding the lightstick 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 lightstick – Take 1 Compute the bounding box of the red points The bounding box of a set of points is the smallest rectangle containing all the points By “rectangle”, we really mean “rectangle aligned with the X,Y axes”

Finding the bounding box 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 gives us some information about the lightstick Midpoint  rough location Aspect ratio  rough orientation (aspect ratio = ratio of width to height) 2.05" 1.08" Aspect ratio: 2.05/1.08 = 1.9

Computing a bounding box Two related questions: Is this a good idea? Will it tell us reliably where the light stick is located? Can we compute it quickly?

Computing a bounding box 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 compute things efficiently (i.e., algorithms) We’re going to learn a lot of these in CS1114

Before next time Go through all of the matlab intro Check to see that your CSUG account works Think about how you might find interesting regions in a static image (don’t just look it up, have fun thinking for yourself).