1 / 15

Lab 2: Rose-Colored Glasses or Jaded

Lab 2: Rose-Colored Glasses or Jaded. Michael Stewart. Colors as points in 3D color space. Today we will continue to take advantage of the distance between two colors as representing those colors’ similarity. This is facilitated by our encoding of color. One way to view this encoding is :

pepin
Download Presentation

Lab 2: Rose-Colored Glasses or Jaded

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 2: Rose-Colored Glasses or Jaded Michael Stewart

  2. Colors as points in 3D color space • Today we will continue to take advantage of the distance between two colors as representing those colors’ similarity. • This is facilitated by our encoding of color. • One way to view this encoding is : • http://en.wikipedia.org/wiki/File:RGB_color_solid_cube.png

  3. New JES methods • pixel.getRed… • color.getRed… • setColor(pixel, newColor) • distance(color1, color2) • dir

  4. Driver Function • Sometimes when programming, you may want to test many different functions • Or you may want to test a function that requires several arguments • Writing one function which makes these tedious calls for you can be useful

  5. Conditionals and Branching http://xkcd.com/210/

  6. Conditionals and Branching (cont’d.) • So far our code has been rather declarative • However we can write recipes that perform differently in different circumstances. • This is usually called “branching” or “conditionals”

  7. Conditionals and Branching (cont’d.) • The simplest kind of branch statement is the “if” statement. • In this example, the function “doSomething” will only be called sometimes. if somethingIsTrue: doSomething()

  8. Boolean • In normal numerical arithmetic, you use numerical operators (+, -, *, /) and multiple numbers, to produce a numerical result. • In BOOLEAN arithmetic, you use boolean operators (==, <, >, not, and, or, etc.), and multiple boolean/numerical values(True, False), to produce a boolean result.

  9. Boolean (cont’d.) • Let’s try some in the command window: • 1 > 2 • 1==1 • True and False • Not True

  10. Lab Assignment • Download the skeleton for the lab from today’s page • Start with an image like this

  11. Lab Assignment (cont’d.) • First, tint the image to a desired color, like this:

  12. Lab Assignment (cont’d). • Swap Roles with your partner. • Now, change the color of a certain range of colors. So using the same starting point as tint, produce this:

  13. Lab Assignment (cont’d.) What’s the difference?!

  14. Lab Assignment (cont’d.) In the first picture, you’re making every pixel closer to the target color. In the second, you only change pixels of similar color to a color of your choice.

  15. Lab Assignment (cont’d.) • Submit your work to the Lab 2 Moodle assignment

More Related