{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

09PixelsByIndexNumber

# 09PixelsByIndexNumber - CS1315 Introduction to Media...

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

CS1315: Introduction to Media Computation Referencing pixels directly by index number

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

View Full Document
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.
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…

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

View Full Document
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]
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.

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

View Full Document
We can use range to generate index numbers to use with our image matrix
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 18

09PixelsByIndexNumber - CS1315 Introduction to Media...

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

View Full Document
Ask a homework question - tutors are online