Chapter 6 Conditionals - part 4

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.
Chapter 6 Color Image Processing Chapter 6 Color Image Processing.
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.
Alice and Media Computation: Goals for this session Show interesting things you can do combining Alice and Media Computation. Provides a story-telling.
© GCSE Computing Candidates should be able to:  explain the representation of an image as a series of pixels represented in binary  explain the need.
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.
Alice in Virginia Beach A Continuing Experiment John Harrison Princess Anne High School Virginia Beach, VA.
CSC1401 Viewing a picture as a 2D image - 1. Review from the last week We used a getPixels() to get all of the pixels of a picture But this has been somewhat.
Georgia Institute of Technology Movies part 5 Barb Ericson Georgia Institute of Technology April 2006.
1. 2 What do these things have in common?
CPSC1301 Computer Science 1 Chapter 14 Creating and Modifying Movies part 2.
TOPIC 11 RETURNING VALUES FROM METHODS PICTURE TRANSFORMATIONS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
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.
Python Programming in Context Chapter 6. Objectives To understand pixel based image processing To use nested iteration To use and understand tuples To.
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.
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.
ITEC 109 Multimedia Lecture Lecture 23. Photo manipulation Review Lists / Arrays.
NestedLoops-part21 Nested Loops – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
Copyright © Curt Hill Further Picture Manipulation Considering position.
1 2/28/05CS120 The Information Era Chapter 4 Basic Web Page Construction TOPICS: Anchors and Tables.
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.
Image Processing & Perception
Barb Ericson Georgia Institute of Technology Dec 2009
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
Georgia Institute of Technology
Indiana U t Wendy Balmer
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
Barb Ericson Georgia Institute of Technology April 2006
CSE 113 A February , 2009.
Two-Dimensional Arrays and Nested Loops – part 3
Two-Dimensional Arrays and Nested Loops – part 6
Colors Computers build colors from Red, Green, and Blue; not Red, Blue, and Yellow. RGB = Red Green Blue Creating Colors Red + Blue = Purple No Red, No.
Manipulating Pictures, Arrays, and Loops
Georgia Institute of Technology
Manipulating Pictures, Arrays, and Loops
February , 2009 CSE 113 B.
Color Image Processing
Manipulating Pictures, Arrays, and Loops part 6
CSC1401 Viewing a picture as a 2D image - 2
Barb Ericson Georgia Institute of Technology May 2006
CSC1401 Manipulating Pictures 2
Barb Ericson Georgia Institute of Technology April 2006
Manipulating Pictures, Arrays, and Loops part 6
Presentation transcript:

Chapter 6 Conditionals - part 4 CPSC1301 Computer Science 1 Chapter 6 Conditionals - part 4

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

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?

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

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

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++)

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()); }

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).

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.

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

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.

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();

Summary To swap the background of a picture To chromakey 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)