Conditionals-part31 Conditionals – part 3 Barb Ericson Georgia Institute of Technology Nov 2009.

Slides:



Advertisements
Similar presentations
We Can Read About Mixing Colors
Advertisements

Color Wheel A tool to use to understand the uses of color.
CSC1401 Using Decisions in Java - 2. Learning Goals Understand at a conceptual and practical level How to use conditionals with > 2 possibilities How.
ManipulatingPictures-Mod6-part21 Manipulating Pictures, Arrays, and Loops part 2 Barb Ericson Georgia Institute of Technology.
Value Element of Art. The luminosity, or range of lightness and darkness, in a picture.
© red ©
Conditionals-part11 Barb Ericson Georgia Institute of Technology Nov 2009.
Art Element: ColorColor. These are: Primary colors Primary colors cannot be made by mixing other colors. Primary colors are mixed to make all of the other.
Georgia Institute of Technology Two-Dimensional Arrays and Nested Loops – part 6 Barb Ericson Georgia Institute of Technology August 2005.
NestedLoops-part31 Nested Loops – part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
Color. -Visual light -An integral part of the sculpture -Creates desired effect -Distinguish items -Strengthen interest.
NestedLoops-part11 Nested Loops – part 1 Barb Ericson Georgia Institute of Technology Nov 2009.
Replacing colors using if We don’t have to do one-to-one changes or replacements of color We can use if to decide if we want to make a change.  We could.
The colour wheel. Primary Colours A primary colour is a colour which cannot be made by mixing other colours What are the three primary colours? The primary.
Photo Editing Terminology. EXPOSURE Exposure controls the lightness in a picture.
Colors By Jes Betzold Red YellowBlue Orange PurpleGreen.
“GREAT ART PICKS UP WHERE NATURE ENDS” – MARC CHAGALL.
ManipulatingPictures-part11 Manipulating Pictures, Arrays, and Loops part 1 Barb Ericson Georgia Institute of Technology Nov 2009.
The Color Wheel. THE COLOR WHEEL REDORANGEYELLOWGREENBLUEVIOLET.
Mixing Colour. All colours are made from variations of one or more of primary colours. 3 Primary Colours.
NestedLoops-Mod7-part31 Two-Dimensional Arrays and Nested Loops – part 3 Bugs in the garden Originally by Barb Ericson Georgia Institute of Technology.
CS 101: Introduction to Computing Color replacements and targeted color replacement (if statement) Developed by Mark Guzdial, Georgia Institute of Technology,
ManipulatingPictures-Mod6-part61 Manipulating Pictures, Arrays, and Loops: Eliminating color, Inversion, grey scale and adjusting for luminance Barb Ericson.
03-ConditionalsInPictures Barb Ericson Georgia Institute of Technology Feb 2010 Working with ranges in pictures.
Georgia Institute of Technology Two-Dimensional Arrays and Nested Loops – part 5 Barb Ericson Georgia Institute of Technology August 2005.
NestedLoops-part41 Nested Loops – part 4 Barb Ericson Georgia Institute of Technology Nov 2009.
NestedLoops-Mody7-part51 Two-Dimensional Arrays and Nested Loops – part 5 Rotations Barb Ericson Georgia Institute of Technology May 2007.
Chapter 5: Advanced Picture Techniques (partial deck)
If you say 8 color the ones in your picture purple. If you say 9 color the ones in your picture blue.
CS1315: Introduction to Media Computation Color replacements and targeted color replacement (IF)
Conditionals-Mod8-part41 Conditionals – part 4 Replace background Barb Ericson Georgia Institute of Technology May 2007.
Conditionals-part21 Conditionals – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
TOPIC 10 THE IF STATEMENT 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
Watercolor Step by step Flowers Watercolor Painting Step by Step Painting Flowers.
Hue: the property of light by which the color of an object is classified as red, blue, green, or yellow in reference to the spectrum. Saturation: the.
Primary Colors are the root of every other hue imaginable. *Think of the three Primaries as the Parents in the family of colors.
Conditionals-Mod8-part21 Conditionals – part 2 Edge Detection Barb Ericson Georgia Institute of Technology May 2007.
The Colors of the Wheel. Primary colors - red, yellow and blue (colors that cannot be created by mixing other colors) Secondary colors - orange, green.
ManipulatingPictures-part31 Manipulating Pictures, Arrays, and Loops part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
04-ManipulatingPictures-part21 Manipulating Pictures, Arrays, and Loops part 2 Barb Ericson Georgia Institute of Technology June 2008.
Georgia Institute of Technology Two-Dimensional Arrays and Nested Loops – part 2 Barb Ericson Georgia Institute of Technology August 2005.
RED, YELLOW, and BLUE These colors cannot be made Used to make all other colors.
COLOR An exciting ELEMENT of ART Which depends on REFLECTED LIGHT.
Get Ready E Your Room Part 2. What colours can you find in the photo? black blue brown green orange red white yellow colour.
Topic 10 The if statement Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
Georgia Institute of Technology
Barb Ericson Georgia Institute of Technology August 2005
Georgia Institute of Technology
Georgia Institute of Technology
Manipulating Pictures, Arrays, and Loops
Barb Ericson Georgia Institute of Technology August 2005
Two-Dimensional Arrays and Nested Loops – part 1
Barb Ericson Georgia Institute of Technology August 2005
Project 5A and 5B: COLOR 5A Color Chart and 5B Color Scheme Portraits Using Oil Paint.
Manipulating Pictures, Arrays, and Loops part 5
Two-Dimensional Arrays and Nested Loops – part 1
Workshop for Programming And Systems Management Teachers
Manipulating Pictures, Arrays, and Loops part 4
Can I color yellow?. Can I color yellow?
Two-Dimensional Arrays and Nested Loops – part 2
Manipulating Pictures, Arrays, and Loops
Manipulating Pictures, Arrays, and Loops
Georgia Institute of Technology
Manipulating Pictures, Arrays, and Loops
What Color is it?.
Manipulating Pictures, Arrays, and Loops part 6
Barb Ericson Georgia Institute of Technology May 2006
CS1315: Introduction to Media Computation
COURSE MARKING COLORS AND DISTANCES
Manipulating Pictures, Arrays, and Loops part 6
Presentation transcript:

Conditionals-part31 Conditionals – part 3 Barb Ericson Georgia Institute of Technology Nov 2009

Conditionals-part32 Learning Goals Understand at a conceptual and practical level –How to use conditionals with > 2 possibilities –How to sepia-tint a picture –How to test for values in ranges –How to posterize a picture

Conditionals-part33 Sepia-Toned Pictures Have a yellowish tint, used to make things look old and western

Conditionals-part34 Sepia-toned Algorithm First make the picture grayscale. Loop through all the pixels in the picture –Change the shadows (darkest grays) to be even darker (red >= 0 && red < 60) –Make the middle grays a brown color (60 <= red < 190) –Make the highlights (lightest grays) a bit yellow (red >= 190) Increase red and green Or decrease blue

Conditionals-part35 Using Multiple If Statements If we are doing different things based on a set of ranges –0 <= x <= 5 –5 < x <= 10 –10 < x if (0 <= x && x <= 5) Statement or block if (5 < x && x <= 10) Statement or block if (10 < x) Statement or block

Conditionals-part36 Using “else if” for > 2 Options If we are doing different things based on a set of ranges –0 <= x <= 5 –5 < x <= 10 –10 < x You don’t need to check if x > 5 since the first if block would have executed if it was if (0 <= x && x <= 5) Statement or block else if (x <= 10) Statement or block else Statement or block

Conditionals-part37 Conditionals with > 2 Choices if (0 <= x && x <= 5) { } else if (x <= 10) { } else // what is x? { }

Conditionals-part38 Sepia-toned Method public void sepiaTint() { Pixel pixelObj = null; double redValue = 0; double greenValue = 0; double blueValue = 0; // first change the current picture to grayscale this.grayscale();

Conditionals-part39 Sepia-toned Method - Cont // loop through the pixels for (int x = 0; x < this.getWidth(); x++) { for (int y = 0; y < this.getHeight(); y++) { // get the current pixel and color values pixelObj = this.getPixel(x,y); redValue = pixelObj.getRed(); greenValue = pixelObj.getGreen(); blueValue = pixelObj.getBlue();

Conditionals-part310 Sepia-toned Method - Cont // tint the shadows darker if (redValue < 60) { redValue = redValue * 0.9; greenValue = greenValue * 0.9; blueValue = blueValue * 0.9; } // tint the midtones a light brown by reducing the blue else if (redValue < 190) { blueValue = blueValue * 0.8; }

Conditionals-part311 Sepia-toned Method - Cont // tint the highlights a light yellow // by reducing the blue else { blueValue = blueValue * 0.9; } // set the colors pixelObj.setRed((int) redValue); pixelObj.setGreen((int) greenValue); pixelObj.setBlue((int) blueValue); }

Conditionals-part312 Testing sepiaTint String file = FileChooser.getMediaPath("gorge.jpg"); Picture p = new Picture(file); p.explore(); p.sepiaTint(); p.explore();

Conditionals-part313 Posterize Reducing the number of different colors in an image Set all values in a range to one value (the midpoint of the range) –Set all < 64 to 31 –Set all <128 to 95 –Set all < 192 to 159 –Set the rest to 223

Conditionals-part314 Posterize Algorithm Loop through all the pixels in an image –Get the red value for the pixel Find the right range and set the new red value –Get the green value for the pixel Find the right range and set the new green value –Get the blue value for the pixel Find the right range and set the new blue value

Conditionals-part315 Posterize Exercise Write the method posterize() in the Picture.java class –that will reduce the number of colors by changing color values to 1 of 4 values Set all from 0 to 63 to 31 (< 64) Set all from 64 to 127 to 95 (< 128) Set all from 128 to 191 to 159 (< 192) Set all from 192 to 255 to 223 Test with tammy.jpg

Conditionals-part316 Summary Use if, else if, and else for > 2 possiblities –Add additional else if’s as needed To sepia-tint a picture –Change it to grayscale –Make the shadows darker –Make the middle grays brown –Make the lightest grays yellow To posterize a picture –Change each color to the center of a range of colors