CSC1401 Using Decisions in Java 2 - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

CSC1401 Using Decisions in Java 2

Description:

For TV and movie special effects they use a blue or green screen ... Picture newBack = new Picture(FileChooser.getMediaPath('moon-surface.jpg' ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 19
Provided by: Wanda6
Category:
Tags: csc1401 | decisions | java | moon | movie | new | using

less

Transcript and Presenter's Notes

Title: CSC1401 Using Decisions in Java 2


1
CSC1401Using Decisions in Java - 2
2
Learning Goals
  • Understand at a conceptual and practical level
  • How to use conditionals with gt 2 possibilities
  • How to sepia-tint a picture
  • How to do chroma key?

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

4
Sepia-toned Algorithm
  • First make the picture grayscale.
  • Loop through the pixels in the picture
  • Change the shadows (darkest grays) to be even
    darker (0 lt red lt 60)
  • Make the middle grays a brown color (60 lt red lt
    190)
  • Make the highlights (lightest grays) a bit yellow
    (190 lt red)
  • Increase red and green
  • Or decrease blue

5
Using Multiple If Statements
  • If we are doing different things based on a set
    of ranges
  • 0 lt x lt 5
  • 5 lt x lt 10
  • 10 lt x
  • if (0 lt x x lt 5)
  • Statement or block
  • if (5 lt x x lt 10)
  • Statement or block
  • if (10 lt x)
  • Statement or block

6
Using else if for gt 2 Options
  • If we are doing different things based on a set
    of ranges
  • 0 lt x lt 5
  • 5 lt x lt 10
  • 10 lt x
  • You dont need to check if x gt 5 since the first
    if block would have executed if it was
  • if (0 lt x x lt 5)
  • Statement or block
  • else if (x lt 10)
  • Statement or block
  • else
  • Statement or block

7
Conditionals with gt 2 Choices
  • if (0 lt x x lt 5)
  • else if (x lt 10)
  • else // what is x?

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

9
Sepia-toned Method - Cont
  • // loop through the pixels
  • for (int x 0 x lt this.getWidth() x)
  • for (int y 0 y lt this.getHeight() y)
  • // get the current pixel and color values
  • pixelObj this.getPixel(x,y)
  • redValue pixelObj.getRed()
  • greenValue pixelObj.getGreen()
  • blueValue pixelObj.getBlue()

10
Sepia-toned Method - Cont
  • // tint the shadows darker
  • if (redValue lt 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 lt 190)
  • blueValue blueValue 0.8

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

12
Testing sepiaTint
  • String file FileChooser.getMediaPath(gorge.jpg
    )
  • Picture p new Picture(file)
  • p.explore()
  • p.sepiaTint()
  • p.explore()

13
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

14
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 lt blue)
  • Replace the pixel color with the color from the
    new background pixel (at the same location)

15
Testing chromakey
  • Picture markP new Picture(FileChooser.getMediaPa
    th(blue-mark.jpg))
  • Picture newBack new Picture(FileChooser.getMedia
    Path(moon-surface.jpg))
  • markP.chromakey(newBack)
  • markP.show()

16
Summary
  • Use if, else if, and else for gt 2 possibilities
  • Add additional else ifs 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

17
Summary
  • To chromakey
  • Take a picture of a person in front of a blue
    screen
  • Change the pixel color to the new background
    color
  • If the blue value is greater than the red green
    (for blue screen)

18
Assignment
  • Read Media Computation Chapter 6, Sections 3-7
Write a Comment
User Comments (0)
About PowerShow.com