09PixelsByIndexNumber - CS1315: Introduction to Media...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CS1315: Introduction to Media Computation Referencing pixels directly by index number
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Remember that pixels are in a matrix Matrices have two dimensions: A width and a height We can reference any element in the matrix with (x, y) or (horizontal, vertical) We refer to those coordinates as index numbers or indices We sometimes want to know where a pixel is, and getPixels doesn’t let us know that.
Background image of page 2
Tuning our color replacement If you want to get more of Barb’s hair, just increasing the threshold doesn’t work Wood behind becomes within the threshold value How could we do it better? Lower our threshold, but then miss some of the hair Work only within a range…
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introducing the function range Range returns a sequence between its first two inputs, possibly using a third input as the increment >>> print range(1, 4) [1, 2, 3] >>> print range(-1, 3) [-1, 0, 1, 2] >>> print range(1, 10, 2) [1, 3, 5, 7, 9]
Background image of page 4
That thing in [] is a sequence >>> a = [1, 2, 3] >>> print a [1, 2, 3] >>> a = a + 4 An attempt was made to call a function with a parameter of an invalid type >>> a = a + [4] >>> print a [1, 2, 3, 4] >>> a[0] 1 We can assign names to sequences, print them, add sequences, and access individual pieces of them. We can also use for loops to process each element of a sequence. A sequence is often called an array or a list.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
range to generate index numbers to use with our image matrix We’ll do this by working the range from 1 to the height, and 1 to the width
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/26/2012 for the course CS 1315 taught by Professor Sweat during the Fall '08 term at Georgia Institute of Technology.

Page1 / 18

09PixelsByIndexNumber - CS1315: Introduction to Media...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online