Finding Red Pixels Prof. Ramin Zabih

Slides:



Advertisements
Similar presentations
A number of MATLAB statements that allow us to control the order in which statements are executed in a program. There are two broad categories of control.
Advertisements

Curse of Dimensionality Prof. Navneet Goyal Dept. Of Computer Science & Information Systems BITS - Pilani.
Recursion. Recursion is a powerful technique for thinking about a process It can be used to simulate a loop, or for many other kinds of applications In.
Data Structures Using C++ 2E
Sorting and Selection, Part 1 Prof. Noah Snavely CS1114
Algorithm Analysis (Big O) CS-341 Dick Steflik. Complexity In examining algorithm efficiency we must understand the idea of complexity –Space complexity.
Sorting and selection – Part 2 Prof. Noah Snavely CS1114
Prof. Ramin Zabih (CS) Prof. Ashish Raj (Radiology) CS5540: Computational Techniques for Analyzing Clinical Data.
Prof. Ramin Zabih (CS) Prof. Ashish Raj (Radiology) CS5540: Computational Techniques for Analyzing Clinical Data.
CS 1114: Introduction to Computing Using MATLAB and Robotics Prof. Noah Snavely
CORNELL UNIVERSITY CS 764 Seminar in Computer Vision Ramin Zabih Fall 1998.
Reduction in Strength CS 480. Our sample calculation for i := 1 to n for j := 1 to m c [i, j] := 0 for k := 1 to p c[i, j] := c[i, j] + a[i, k] * b[k,
Reconfigurable Computing (EN2911X, Fall07)
Finding Red Pixels – Part 2 Prof. Noah Snavely CS1114
Parallelizing Compilers Presented by Yiwei Zhang.
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
Linked lists and memory allocation Prof. Noah Snavely CS1114
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
CS 206 Introduction to Computer Science II 10 / 08 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
1 Chapter 2 Matrices Matrices provide an orderly way of arranging values or functions to enhance the analysis of systems in a systematic manner. Their.
Introduction Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See
Interpolation, extrapolation, etc. Prof. Ramin Zabih
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
CS 1114: Introduction to Computing Using MATLAB and Robotics Prof. Noah Snavely CS1114
Voronoi diagrams and applications Prof. Ramin Zabih
EECE 310 Software Engineering Lecture 0: Course Orientation.
Program Design CMSC 201. Motivation We’ve talked a lot about certain ‘good habits’ we’d like you guys to get in while writing code. There are two main.
Loops: Handling Infinite Processes CS 21a: Introduction to Computing I First Semester,
Storage allocation issues Prof. Ramin Zabih
Image segmentation Prof. Noah Snavely CS1114
Working with arrays (we will use an array of double as example)
240 3/30/98 CSE 143 Object-Oriented Design [Chapter 10]
Q and A for Chapter 7 Students of CS104, and me, your benevolent professor, Victor T. Norman, PhD.
CSC1401 Classes - 1. Learning Goals Computing concepts Identifying objects and classes Declaring a class Declaring fields Default field values.
Medians and blobs Prof. Ramin Zabih
1 Design and Integration: Part 3 To prepare for today’s class, visit Cookie Clicker and plan with it for a few minutes:
Finding Red Pixels – Part 1 Prof. Noah Snavely CS1114
1 CS161 Introduction to Computer Science Topic #17.
Clustering Prof. Ramin Zabih
CPSC1301 Computer Science 1 Chapter 4 Manipulating Pictures, Arrays, and Loops part 5.
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
Fitting image transformations Prof. Noah Snavely CS1114
Sorting and selection – Part 2 Prof. Noah Snavely CS1114
CS 161 Computer Science I Andrew Scholer
Fundamentals of Digital Images & Photography. Pixels & Colors The pixel (a word invented from "picture element") is the basic unit of programmable color.
An array example: the transpose A 2-D array corresponds to a mathematical matrix: One simple matrix operation transposes the matrix.
CS 1114: Finding things Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
Arrays and Loops. Learning Objectives By the end of this lecture, you should be able to: – Understand what a loop is – Appreciate the need for loops and.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
CSC 108H: Introduction to Computer Programming
Prof. Ramin Zabih Implementing queues Prof. Ramin Zabih
CS1010 Discussion Group 11 Week 8 – Searching and Sorting.
Garbage collection; lightstick orientation
Quickselect Prof. Noah Snavely CS1114
Prof. Ramin Zabih Beyond binary search Prof. Ramin Zabih
CS 1114: Introduction to Computing Using MATLAB and Robotics
Linked lists Prof. Noah Snavely CS1114
Bounding Boxes, Algorithm Speed
CSC1401 Manipulating Pictures 2
Quicksort and selection
Getting to the bottom, fast
Sorting and selection Prof. Noah Snavely CS1114
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Finding Red Pixels Prof. Ramin Zabih

2 Administrivia  You should all have access to the lab and passwords for the computers  Section tomorrow (Wed) will cover more about handling images in Matlab  Assignment 1 will be out tomorrow, due in a week

3 Finding red pixels in Matlab  We will spend the first part of CS100R trying to track a red lightstick –On the way we will cover important CS themes Fundamental algorithms Good programming style  Main idea: begin by identifying the parts of the picture that are bright red –Today we will start doing this in Matlab –CS100R assignment 1: code this

4 Images in Matlab  Matlab is a language focused on arrays –Sometimes referred to as a “matrix”  All programming languages support arrays –The elements of an array are called “cells”  Matlab will be taught mostly by example –Programming by example is very powerful  We will focus heavily on 1D and 2D arrays –Especially 2D arrays, i.e. images

5 Basic Matlab examples A = [ ] A(2) A(2) – A(1) A(2) > A(1) A(1) == A(2) A(1) = A(1) + 1; A(2) = A(2) + 1; A(3) = A(3) + 1;

6 Avoiding duplicate code  Programming languages are designed to make this easy –It’s a huge theme in CS language design –Most 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? –Suppose we increment every cell of an array by 1 (as shown in the previous example) What goes wrong?

7 Code duplication is bad  Hard to understand –It’s vital that humans can read your code The person you rescue by writing readable code might turn out to be: yourself! Automatically figuring out what a program does turns out to be incredibly hard If it were easy, no computer viruses would exist  Hard to modify –A conceptually small change (like adding 2 to each array cell instead of 1) is a pain  Programmer’s “intent” is obscured

8 Iteration in Matlab  A basic way to avoid code duplication  You can think of the Matlab statements: for i = 1:3 A(i) = A(i)+1; end; as being short for the statements: A(1) = A(1) + 1; A(2) = A(2) + 1; A(3) = A(3) + 1;

9 Many advantages to iteration  Easy to understand and modify the code  Better expresses programmer’s “intent”  Can even do things with iteration that you can’t do by just writing lots of statements  Example: increment every array cell –Without knowing the length of the array! len = length(A); % New Matlab function for i = 1:len A(i) = A(i)+1; end;

10 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 A(1) = 1; A(2) = 2; % This is getting tedious… for i = 1:3 % Much better! A(i) = i; end;