CS U540 Computer Graphics - PowerPoint PPT Presentation

About This Presentation
Title:

CS U540 Computer Graphics

Description:

A width, formatted as ASCII characters in decimal. Whitespace. A height, again in ASCII decimal. ... The maximum color value again in ASCII decimal. Whitespace. ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 18
Provided by: FELL3
Category:

less

Transcript and Presenter's Notes

Title: CS U540 Computer Graphics


1
CS U540Computer Graphics
  • Prof. Harriet Fell
  • Spring 2009
  • Lecture 4 - January 12, 2009

2
Color
www.thestagecrew.com
3
Red, Green, and Blue Light
4
Adding R, G, and B Values
http//en.wikipedia.org/wiki/RGB
5
From the Hubble
  • Hubble Site Link

6
RGB Color Cube
7
RGB Color Cube The Dark Side
8
Doug Jacobson's RGB Hex Triplet Color Chart
9
Making Colors Darker
(1, 0, 0)
(0, 0, 0)
(.5, 0, 0)
(0, 1, 0)
(0, 0, 0)
(0, .5, 0)
(0, 0, 1)
(0, 0, 0)
(0, 0, .5)
(0, 1, 1)
(0, 0, 0)
(0, .5, .5)
(1, 0, 1)
(0, 0, 0)
(.5, 0, .5)
(0, 0, 0)
(.5, .5, 0)
(1, 1, 0)
10
Getting Darker, Left to Right
  • for (int b 255 b gt 0 b--)
  • c new Color(b, 0, 0) g.setPaint(c)
  • g.fillRect(8003(255-b), 50, 3, 150)
  • c new Color(0, b, 0) g.setPaint(c)
  • g.fillRect(8003(255-b), 200, 3, 150)
  • c new Color(0, 0, b) g.setPaint(c)
  • g.fillRect(8003(255-b), 350, 3, 150)
  • c new Color(0, b, b) g.setPaint(c)
  • g.fillRect(8003(255-b), 500, 3, 150)
  • c new Color(b, 0, b) g.setPaint(c)
  • g.fillRect(8003(255-b), 650, 3, 150)
  • c new Color(b, b, 0) g.setPaint(c)
  • g.fillRect(8003(255-b), 800, 3, 150)

11
Gamma Correction
  • Generally, the displayed intensity is not linear
    in the input (0 ? a ? 1).
  • dispIntensity (maxIntensity)a?
  • To find ?
  • Find a that gives you .5 intensity
  • Solve .5 a?
  • ? ln(.5)
  • ln(a)

12
Gamma Correction
half black half red
(127, 0, 0)
  • Gamma

13
Making Pale Colors
(1, 0, 0)
(1, 1, 1)
(1, .5, .5)
(0, 1, 0)
(1, 1, 1)
(.5, 1, .5)
(0, 0, 1)
(1, 1, 1)
(.5, .5, 1)
(0, 1, 1)
(1, 1, 1)
(.5, 1, 1)
(1, 0, 1)
(1, 1, 1)
(1, .5, 1)
(1, 1, 1)
(1, 1, .5)
(1, 1, 0)
14
Getting Paler, Left to Right
  • for (int w 0 w lt 256 w)
  • c new Color(255, w, w) g.setPaint(c)
  • g.fillRect(3w, 50, 3, 150)
  • c new Color(w, 255, w) g.setPaint(c)
  • g.fillRect(3w, 200, 3, 150)
  • c new Color(w, w, 255) g.setPaint(c)
  • g.fillRect(3w, 350, 3, 150)
  • c new Color(w, 255, 255) g.setPaint(c)
  • g.fillRect(3w, 500, 3, 150)
  • c new Color(255,w, 255) g.setPaint(c)
  • g.fillRect(3w, 650, 3, 150)
  • c new Color(255, 255, w) g.setPaint(c)
  • g.fillRect(3w, 800, 3, 150)

15
Portable Pixmap Format (ppm)
  • A "magic number" for identifying the file type.
  • A ppm file's magic number is the two characters
    "P3".
  • Whitespace (blanks, TABs, CRs, LFs).
  • A width, formatted as ASCII characters in
    decimal.
  • Whitespace.
  • A height, again in ASCII decimal.
  • Whitespace.
  • The maximum color value again in ASCII decimal.
  • Whitespace.
  • Width height pixels, each 3 values between 0
    and maximum value.
  • start at top-left corner proceed in normal
    English reading order
  • three values for each pixel for red, green, and
    blue, resp.
  • 0 means color is off maximum value means color
    is maxxed out
  • characters from "" to end-of-line are ignored
    (comments)
  • no line should be longer than 70 characters

16
ppm Example
  • P3
  • feep.ppm
  • 4 4
  • 15
  • 0 0 0 0 0 0 0 0 0 15 0 15
  • 0 0 0 0 15 7 0 0 0 0 0 0
  • 0 0 0 0 0 0 0 15 7 0 0 0
  • 15 0 15 0 0 0 0 0 0 0 0 0

17
private void saveImage() String outFileName
my.ppm" File outFile new File(outFileName)
int clrR, clrG, clrB try PrintWriter out
new PrintWriter(new BufferedWriter(new
FileWriter(outFile))) out.println("P3") ou
t.print(Integer.toString(xmax-xmin1))
System.out.println(xmax-xmin1) out.print("
") out.println(Integer.toString(ymax-ymin1))
System.out.println(ymax-ymin1) out.println("2
55") for (int y ymin y lt ymax
y) for (int x xmin x lt xmax x)
// compute clrR, clrG, clrB out.pri
nt(" ") out.print(clrR) out.print(" ")
out.print(clrG) out.print(" ")
out.println(clrB) out.close()
catch (IOException e) System.out.println(e.toS
tring())
Write a Comment
User Comments (0)
About PowerShow.com