Yet Another Version. More Careful Edge Detection def lineDetect(filename): orig = makePicture(filename) makeBw = makePicture(filename) for x in range(0,getWidth(orig)-1):

Slides:



Advertisements
Similar presentations
Looking At Other Digipacks/CD‘s
Advertisements

A Media Computation Cookbook Manipulating Images and Sounds for Use in Alice Part 1: Image Manipulations Part 2: Advanced Image Manipulations, e.g., changing.
Python: Modifying Pictures Using Loops. Review JES command area – program area Defining/using functions specifying a sequence of steps for what the function.
Computer Science 111 Fundamentals of Programming I More Digital Image Processing.
GRID REFERENCES MADE EASY
Contents Page Versions Paige Hetherington. Version 1 Here is my version 1 of my contents page. I like the plain layout of the page because I believe it.
Kayla Dean & Patrick Baker. Original Picture Sunset def sunset(filename): filename = makePicture(pickAFile()) explore(filename) for p in getPixels(filename):
HUE Hue is color.. Hue Hue is the name of a distinct color of the spectrum—red, green, yellow, orange, blue, etc. It refers to the particular wavelength.
01-IntroToMediaComp1 Barb Ericson Georgia Institute of Technology Oct 2010 Introduction to Computer Science and Media Computation.
Variety and Contrast. What is va r ie t y? The use of juxtaposition to make you look at a certain part or make the entire piece more interesting. Variety.
S GRID REFERENCES MADE EASY FOR CAMPING CLUB YOUTH.
Copying and Transforming Pictures. First, finding the min or max… Next homework asks you to write a function to find the darkest and lightest shade of.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 5: Advanced Picture Techniques.
Picture Color Manipulation. Using a Loop Our first picture recipe def decreaseRed(picture): for p in getPixels(picture): value=getRed(p) setRed(p,value*0.5)
Image Processing & Perception Sec 9-11 Web Design.
BFTAW BDPA Workshop Introduction to GIMP Chris
BFTAW BDPA Workshop Introduction to GIMP Chris
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Color Correct and Remove Keystoning A minimalist approach to photographing your art By Paul Marley.
CS1315: Introduction to Media Computation Picture encoding and manipulation.
CS1315: Introduction to Media Computation Picture encoding and manipulation.
Chapter 6: Modifying Pixels by Position. Chapter Learning Goals.
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.
I am ready to test!________ I am ready to test!________
CS1315: Introduction to Media Computation Referencing pixels directly by index number.
Manipulating Pixels by Range and More on Functions.
CS2984: Introduction to Media Computation Using Loops for Pictures Conditionals Copying images.
Image Representation. Objectives  Bitmaps: resolution, colour depth and simple bitmap file calculations.  Vector graphics: drawing list – objects and.
Adobe Photoshop - Basic Terms. Pixel A pixel is a single dot of color information in a digital picture. Anything you see on your computer is comprised.
1. 2 What do these things have in common?
“Introduction to Media Computation” A New Core Area B Course Mark Guzdial, 18 July 2002.
CS1315: Introduction to Media Computation Picture encoding and manipulation.
Program Design and Debugging. How do programmers start? How do you get started with a program? “Programming is all about debugging a blank piece of paper.”
1 CS 177 Week 5 Recitation Slides Mirroring and copying images, Using for Loop, if statement, and range.
CS1315: Introduction to Media Computation How to design and debug a program: Top-down, bottom-up, and debugging. Using background subtraction and chromakey.
CS 101: Introduction to Computing Color replacements and targeted color replacement (if statement) Developed by Mark Guzdial, Georgia Institute of Technology,
03-ConditionalsInPictures Barb Ericson Georgia Institute of Technology Feb 2010 Working with ranges in pictures.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 5: Advanced Picture Techniques.
Chapter 5: Advanced Picture Techniques (partial deck)
Chapter 5: Advanced Picture Techniques. Chapter Objectives.
Sight Word List.
Creating a Silhouette in Illustrator. Go File>Place and place the photo on the artboard. Select the photo and click Live Trace (its on the tool bar right.
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.
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,
Learning PowerPoint Presenting your ideas as a slide show… …on the computer!
POWERPOINT PLUS 11/17/07 Class Notes. WHAT IS A PIXEL A pixel is a number that represents the intensity of light at a square spot in the picture. Pixels.
Sight Words.
CS1315: Introduction to Media Computation Using Loops for Pictures.
A Media Computation Cookbook Manipulating Images and Sounds for Use in Alice Part 1: Image Manipulations Part 2: Changing colors in an area Part 3: Chromakey.
Drawing in Perspective. The first thing you need to know is that in perspective drawing, every set of parallel lines has its own vanishing point. Remember.
RULES TO AVOID BAD DESIGN 1. Don’t annoy your viewers. Don't use frames unless you have to! - Frames are annoying and cause people to lose their way when.
Cartoon Similarity Using cartoons to draw similar figures
A Media Computation Cookbook Manipulating Images and Sounds for Use in Alice Part 1: Image Manipulations Part 2: Advanced Image Manipulations, e.g., changing.
CS 101: Introduction to Computing Programs that change Pictures Developed by Mark Guzdial, Georgia Institute of Technology, 2003–2004; modified by Robert.
Examples from Georgia Tech’s CS 1315: Introduction to Media Computation Class examples and student work.
CS1315: Introduction to Media Computation Transforming pictures by index number.
1 CS 177 Week 4 Recitation Slides for Loop if statement and range.
CS 101: Introduction to Computing Referencing pixels directly by index number Developed by Mark Guzdial, Georgia Institute of Technology, 2003–2004; modified.
How to Start This PowerPoint® Tutorial
Image Processing & Perception
Topic 10 The if statement Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
CS1315: Introduction to Media Computation
Gray Scale picture def pixBW(pixel): # given a pixel, change to BW
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Chapter 15: Topics in Computer Science: Functional Programming
CS1315: Introduction to Media Computation
Multimedia Summer Camp
CS1315: Introduction to Media Computation
Presentation transcript:

Yet Another Version

More Careful Edge Detection def lineDetect(filename): orig = makePicture(filename) makeBw = makePicture(filename) for x in range(0,getWidth(orig)-1): for y in range(0,getHeight(orig)-1): here=getPixel(makeBw,x,y) down=getPixel(orig,x,y+1) right=getPixel(orig,x+1,y) hereL=(getRed(here)+getGreen(here)+getBlue(here))/3 downL=(getRed(down)+getGreen(down)+getBlue(down))/3 rightL=(getRed(right)+getGreen(right)+getBlue(right))/3 if abs(hereL-downL)>10 and abs(hereL-rightL)>10: setColor(here,black) if abs(hereL-downL)<=10 and abs(hereL-rightL)<=10: setColor(here,white) return makeBw Here we look in all four directions.

Background subtraction Let's say that you have a picture of someone, and a picture of the same place (same background) without the someone there, could you subtract out the background and leave the picture of the person? Maybe even change the background? Let's take that as our problem!

Person (Katie) and Background Let's put Katie on the moon!

Where do we start? What we most need to do is to figure out whether the pixel in the Person shot is the same as the in the Background shot. Will they be the EXACT same color? Probably not. So, we'll need some way of figuring out if two colors are close…

Remember this? def turnRed(): brown = makeColor(57,16,8) file = r"C:\Documents and Settings\Mark Guzdial\My Documents\mediasources\barbara.jpg" picture=makePicture(file) for px in getPixels(picture): color = getColor(px) if distance(color,brown)<50.0: redness=getRed(px)*1.5 setRed(px,redness) show(picture) return(picture) Original:

Using distance So we know that we want to ask: if distance(personColor,bgColor) > someValue And what do we then? We want to grab the color from another background (a new background) at the same point. Do we have any examples of doing that?

Where we are so far: if distance(personColor,bgColor) > someValue: bgcolor = getColor(getPixel(newBg,x,y)) setColor(getPixel(person,x,y), bgcolor) What else do we need? We need to get all these variables set up We need to input a person picture, a background (background without person), and a new background. We need a loop where x and y are the right values We have to figure out personColor and bgColor

Swap a background using background subtraction def swapBack(pict,bg,newBg): for px in getPixels(pict): x = getX(px) y = getY(px) bgPx = getPixel(bg,x,y) pxcol = getColor(px) bgcol = getColor(bgPx) if (distance(pxcol,bgcol)<15.0): newcol=getColor(getPixel(newBg,x,y)) setColor(px,newcol) Specifying a threshold.

Works

But why isn't it alot better? We've got places where we got pixels swapped that we didn't want to swap See Katie's shirt stripes We've got places where we want pixels swapped, but didn't get them swapped See where Katie made a shadow

How could we make it better? What could we change in the program? We could change the threshold “someValue” If we increase it, we get fewer pixels matching That won't help with the shadow If we decrease it, we get more pixels matching That won't help with the stripe What could we change in the pictures? Take them in better light, less shadow Make sure that the person isn't wearing clothes near the background colors.

We call this function like this: How do we see the result? (1) explore(kid) (2) explore(wall) (3) explore(jungle)

Playing with this program, you generate the above image. What do you predict changed? (1) You made the threshold value too high so too many pixels are matching both foreground and background (2) You made the threshold value too small so too few pixels are matching between the foreground and the background. (3) You changed the IF so that you inverted the swap (4) The jungle color is too close to the wall color. The moon would have worked better.

Putting a Dog on the Moon

With different thresholds >>> dog = makePicture("dog-bg.jpg") >>> bg = makePicture("nodog-bg.jpg") >>> swapBack(dog,bg,moon) >>> explore(dog)

Another way: Chromakey Have a background of a known color Some color that won't be on the person you want to mask out Pure green or pure blue is most often used I used my son's blue bedsheet This is how the weather people seem to be in front of a map— they're actually in front of a blue sheet.

Chromakey recipe def chromakeyBlue(source,bg): for px in getPixels(source): x = getX(px) y = getY(px) if (getRed(px) + getGreen(px) < getBlue(px)): bgpx = getPixel(bg,x,y) bgcol = getColor(bgpx) setColor(px,bgcol)

Example results

Just trying the obvious thing for Red def chromakey2(source,bg): # source should have something in front of red, bg is the new background for p in getPixels(source): if getRed(p) > (getGreen(p) + getBlue(p)): #Then, grab the color at the same spot from the new background setColor(p,getColor(getPixel(bg,getX(p),getY(p))))

Doesn't always work as you expect

Easy to do with Alice def chromakeyGreen(source,bg): for px in getPixels(source): x = getX(px) y = getY(px) if (getRed(px) + getBlue(px) < getGreen(px)): bgpx = getPixel(bg,x,y) bgcol = getColor(bgpx) setColor(px,bgcol)\end{splpython}

The difference between JPEG and PNG Where did her shoes go? Lossy vs. Lossless

Drawing on images Sometimes you want to draw on pictures, to add something to the pictures. Lines Text Circles and boxes. We can do that pixel by pixel, setting black and white pixels

Consider this program: Which picture below did this generate?

Drawing a border def greekBorder(pic): bottom = getHeight(pic)-10 for px in getPixels(pic): y = getY(px) if y < 10: setColor(px,blue) if y > bottom: setColor(px,white)

What does this program do? (1) Covers a picture with green (2) Creates a border of 10 pixels wide all green around a picture (3) Creates a circle of green in the middle of the picture (4) Covers a picture with a green box, inset 10 pixels on each side.

Lightening ½ of Picture def rightHalfBright(pic): halfway = getWidth(pic) / 2 for px in getPixels(pic): x = getX(px) if x > halfway: color = getColor(px) setColor(px,makeLighter(color))

Consider this program: Which of the below is true about this program (can be more than one): Even pixels are made light Even pixels are made dark Since half the pixels are lighter and half are darker, the picture looks the same. Since half the pixels are lighter and half are darker, pictures with even number of rows and columns end up with patterned look.

Consider this program: Which picture below (zoomed to 500%) did this generate?

Posterizing to 3 levels: With elif and else def posterizeBWR(pic): for p in getPixels(pic): r = getRed(p) g = getGreen(p) b = getBlue(p) luminance = (r+g+b)/3 if luminance < 64: setColor(p,black) elif luminance > 120: setColor(p,white) else: setColor(p,red)