Georgia Institute of Technology

Slides:



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

Georgia Institute of Technology Movies part 3 Barb Ericson Georgia Institute of Technology April 2006.
Green Screen. Objectives: 2. Understand what the difference is between a Luma key and a Chroma key. By the end of todays lesson students will: 3. Understand.
Conditionals-part11 Barb Ericson Georgia Institute of Technology Nov 2009.
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.
Image Processing & Perception Sec 9-11 Web Design.
TOPIC 7 MODIFYING PIXELS IN A MATRIX NESTED FOR LOOPS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by.
NestedLoops-part11 Nested Loops – part 1 Barb Ericson Georgia Institute of Technology Nov 2009.
Georgia Institute of Technology Movies part 5 Barb Ericson Georgia Institute of Technology April 2006.
NestedLoops-Mod7-part31 Two-Dimensional Arrays and Nested Loops – part 3 Bugs in the garden Originally by Barb Ericson 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.
Day 8: Fruit Loops: Color. Loop Review What does the following loop print? for (int i= 0; i
CPSC1301 Computer Science 1 Chapter 4 Manipulating Pictures, Arrays, and Loops part 5.
Conditionals-Mod8-part41 Conditionals – part 4 Replace background Barb Ericson Georgia Institute of Technology May 2007.
CSC1401 Using Decisions in Java - 1. Recall from Alice We only wanted to shoot a lightning bolt at a philosopher So, we used the If statement.
Conditionals-part21 Conditionals – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
Georgia Institute of Technology Movies part 4 Barb Ericson Georgia Institute of Technology April 2006.
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,
Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
NestedLoops-part21 Nested Loops – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
Conditionals-Mod8-part21 Conditionals – part 2 Edge Detection Barb Ericson Georgia Institute of Technology May 2007.
ManipulatingPictures-part31 Manipulating Pictures, Arrays, and Loops part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
Georgia Institute of Technology Two-Dimensional Arrays and Nested Loops – part 2 Barb Ericson Georgia Institute of Technology August 2005.
Georgia Institute of Technology Introduction to Java, and DrJava part 1 Dr Usman Saeed Assistant Professor Faculty of Computing and Information Technology.
Georgia Institute of Technology Drawing in Java – part 2 Dr Usman Saeed Assistant Professor Faculty of Computing and Information Technology North Jeddah.
Georgia Institute of Technology Dr Usman Saeed Assistant Professor Faculty of Computing and Information Technology North Jeddah Branch King Abdulaziz University.
Georgia Institute of Technology Two-Dimensional Arrays and Nested Loops – part 4 Barb Ericson Georgia Institute of Technology August 2005.
Manipulating Pictures, Arrays, and Loops part 1
Manipulating Pictures, Arrays, and Loops part 2
Introduction to Java part 2
Georgia Institute of Technology
Image Processing & Perception
Barb Ericson Georgia Institute of Technology Dec 2009
Manipulating Pictures, Arrays, and Loops part 3
Topic 10 The if statement Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
Multimedia Summer Camp
Barb Ericson Georgia Institute of Technology August 2005
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
Manipulating Pictures, Arrays, and Loops part 5
Two-Dimensional Arrays and Nested Loops – part 5
Two-Dimensional Arrays and Nested Loops – part 1
Georgia Institute of Technology
Workshop for Programming And Systems Management Teachers
Arrays versus ArrayList
Barb Ericson Georgia Institute of Technology April 2006
Two-Dimensional Arrays and Nested Loops – part 4
Two-Dimensional Arrays and Nested Loops – part 3
Two-Dimensional Arrays and Nested Loops – part 6
Two-Dimensional Arrays and Nested Loops – part 2
Manipulating Pictures, Arrays, and Loops
Two-Dimensional Arrays and Nested Loops – part 6
Georgia Institute of Technology
Manipulating Pictures, Arrays, and Loops
Manipulating Pictures, Arrays, and Loops part 6
Chapter 6 Conditionals - part 4
Two-Dimensional Arrays and Nested Loops – part 6
Barb Ericson Georgia Institute of Technology May 2006
Barb Ericson Georgia Institute of Technology April 2006
Manipulating Pictures, Arrays, and Loops part 6
Presentation transcript:

Georgia Institute of Technology Conditionals – part 4 Dr Usman Saeed Assistant Professor Faculty of Computing and Information Technology  North Jeddah Branch King Abdulaziz University Georgia Institute of Technology

Georgia Institute of Technology Learning Goals Understand at a conceptual and practical level How to change the background on a picture? How to do chroma key? Georgia Institute of Technology

Background Replacement If you have a picture of a person in front of some background And a picture of the background itself Can you replace the pixel colors for the background to be from another image? Georgia Institute of Technology

Georgia Institute of Technology Replace Background Replace the colors at all the pixels in the source image That are within some range of the background color Use pixels from another background image Georgia Institute of Technology

Replace Background Algorithm Works on the source picture Pass in the original background and the new background pictures Loop through all the pixels in the source image Check if the distance from the source pixel color is within 15.0 of the background picture pixel color If so replace it with the color at the new background pixel Georgia Institute of Technology

Replace Background Method public void swapBackground(Picture oldBackground, Picture newBackground) { Pixel currPixel = null; Pixel oldPixel = null; Pixel newPixel = null; // loop through the columns for (int x=0; x<this.getWidth(); x++) // loop through the rows for (int y=0; y<this.getHeight(); y++) Georgia Institute of Technology

Georgia Institute of Technology Swap Background - Cont // get the current pixel and old background pixel currPixel = this.getPixel(x,y); oldPixel = oldBackground.getPixel(x,y); /* if the distance between the current pixel color * and the old background pixel color is less than the 15 * then swap in the new background pixel */ if (currPixel.colorDistance(oldPixel.getColor()) < 15.0) { newPixel = newBackground.getPixel(x,y); currPixel.setColor(newPixel.getColor()); } Georgia Institute of Technology

Testing swapBackground Picture p1 = new Picture(FileChooser.getMediaPath(“kid-in-frame.jpg”)); Picture oldBack = new Picture(FileChooser.getMediaPath(“bgframe.jpg”)); Picture newBack = new Picture(FileChooser.getMediaPath(“moon-surface.jpg”)); p1.swapBackground(oldBack,newBack); p1.show(); You can type all of the first bullet on one line in DrJava (it just didn’t fit on the slide here). Georgia Institute of Technology

Replace Background Result The background color was too close to the shirt color The source picture was kid-in-frame.jpg in mediasources. The old background was in bgframe.jpg. The new background was in moon-surface.jpg. Georgia Institute of Technology

Chroma Key – Blue Screen For TV and movie special effects they use a blue or green screen Here just a blue sheet was used Professionally you need an evenly lit, bright, pure blue background With nothing blue in the scene See http://entertainment.howstuffworks.com/blue-screen.htm for more information Georgia Institute of Technology

Georgia Institute of Technology Chroma Key Exercise Write the method chromakey that takes a new background picture as an input parameter It will loop through all the pixels If the pixel color is blue (red + green < blue) Replace the pixel color with the color from the new background pixel (at the same location) The source picture is blue-mark.jpg. The blue background is blue-empty.jpg. The moon picture is moon-surface.jpg. Georgia Institute of Technology

Georgia Institute of Technology Testing chromakey Picture markP = new Picture(FileChooser.getMediaPath(“blue-mark.jpg”)); Picture newBack = new Picture(FileChooser.getMediaPath(“moon-surface.jpg”)); markP.chromakey(newBack); markP.show(); Georgia Institute of Technology

Georgia Institute of Technology Summary To swap the background of a picture Take a picture with a person in the scene And a picture without the person in the scene Change the pixel color to the new background color If the distance from the current pixel is within a distance to the old background color To chromakey Take a picture of a person in front of a blue screen If the blue value is greater than the red + green (for blue screen) Georgia Institute of Technology