1 of 89

Overview of Computer Graphics�&& Some Image Display

Instructor: 李同益

2 of 89

Readings

  • Computer Graphics Using OpenGL by F.S Hill, J.R.
    • Chapter 1
    • Section 10.9
    • Section 12.5
    • Case study 12.4~12.7

3 of 89

Overviews

  • History overview
  • Applications

PIXAR INTRO edit Animation

4 of 89

A Standard Graphics Pipeline

5 of 89

OpenGL traditional transformation �pipeline

v

e

r

t

e

x

Modelview

Matrix

Projection

Matrix

Perspective

Division

Viewport

Transform

Modelview

Modelview

Projection

object

eye

clip

normalized

device

window

glTranslate{fd}( x, y, z )

glRotate{fd}( angle, x, y, z )

glScale{fd}( x, y, z )

6 of 89

Polygon Rendering & Photorealistic Rendering

For example: OpenGL rendering v.s. Raytracing

Ray tracing

7 of 89

Scanning the David

height of gantry: 7.5 meters

weight of gantry: 800 kilograms

8 of 89

Point Rendering

9 of 89

Michelangelo’s Pieta

handmade replica

10 of 89

Holes:

Regular

or

Irregular

11 of 89

Molder Package

12 of 89

Sketch or Wireframe

Printing Arbitrary Meshes with a 5DOF Wireframe PrinterACM Transactions on Graphics (Proc. SIGGRAPH 2016)

13 of 89

Depth Cueing

14 of 89

Clipping (Far-plane)

15 of 89

Coloring

16 of 89

Hidden Surface Removal

17 of 89

Sketch�Applications

18 of 89

Constant Rendering

19 of 89

Facet Shading

20 of 89

Smooth Shading

21 of 89

Correct Highlight

22 of 89

Edge Silhouettes

23 of 89

Texture & Shadow

24 of 89

Procedural�and Displacement Texture

25 of 89

Ray tracing

26 of 89

Reflection

27 of 89

Global Illumination

28 of 89

29 of 89

Lighting

30 of 89

Photo image of

the real scene

Non-photorealistic

Rendering

31 of 89

Applying different painterly styles.

  • Top row: “Impressionist.”

  • Middle row: “Expressionist.”

  • Bottom row: “Colorist Wash.”

32 of 89

Hatching(影線) and cross hatch (交叉影線)

33 of 89

Deep learning for NPR

content image in different layers of CNN.

The idea of neural style transferring and content image in different layers of CNN.

34 of 89

Computer Graphics is about Movies!

35 of 89

Computer Graphics is about Movies!

36 of 89

37 of 89

Titanic

38 of 89

Cartoon Movie

39 of 89

Inspirational Video

Keep in mind: this film is entirely Computer-generated.

40 of 89

Games are OK here

41 of 89

How Machine Learning Helps Game Developers Express Creativity

42 of 89

Medical �Imaging

43 of 89

Computer Aided Design

44 of 89

Scientific Visualization

45 of 89

Graphical User Interfaces (GUIs)

46 of 89

WYSIWYG NPR:�Drawing Strokes Directly on 3D Models

http://www.cs.princeton.edu/gfx/proj/wnpr/

47 of 89

Image Display

Tong-Yee Lee

48 of 89

Display Technologies

Cathode Ray Tubes (CRTs)

Most common display device today

Evacuated glass bottle

(last remaining vacuum tube)

Heating element (filament)

Electrons attracted to focusing anode cylinder

Vertical and Horizontal deflection plates

Beam strikes phosphor coating on front of tube

陰極射線管(Cathode ray tube)

LED螢幕的全稱是LED背光源液晶螢幕

49 of 89

Color Video

50 of 89

Raster Displays

TV boomed in the 50s and early 60s

(they got cheap)

B/W TVs are basically oscilloscopes

(with a hardwired scan pattern)

Screen is traversed 60 times/sec

Even/Odd lines on alternate scans

51 of 89

Head-Mounted Displays

52 of 89

Caves and Fish Bowls

53 of 89

Looking at NASA Space Station on display wall

http://www.cs.princeton.edu/~benshedd/

CSDisplayWall8&24/index.html

                                                                         

54 of 89

Review of Raster Displays

55 of 89

56 of 89

Alpha

over

=

57 of 89

Applications for 3D Art Composer 

Demo:

SIG05

By Chuang

58 of 89

59 of 89

60 of 89

The Simplest File

61 of 89

62 of 89

Color Quantization

  • The problem of reducing the number of colors in an image with minimal impact on appearance
    • Extreme case: 24 bit color to black and white
    • Less extreme: 24 bit color to 256 colors, or 256 grays
  • Why do we care?

    • Achieves the greatest compression, but also quality loss
    • Limited intensity level on display device
  • Sub problems:
    • Decide which colors to use (if there is a choice)
    • Decide which of those each original color maps to

24 bit color

63 of 89

Quantization Error

  • A way of measuring the quality of our approximation
  • Define an error for each color, c, in the original image: d(c,c’), where c’ is the color c maps to under the quantization
    • Common is to use squared distance in RGB space
  • Sum up the error over all the pixels

64 of 89

Uniform Quantization

  • Break the color space into uniform cells
  • Find the cell that each color is in, and map it to the center
  • Generally does poorly because it fails to capture the distribution of colors
    • Some cells may be empty, and are wasted
  • Equivalent to dividing each color by some number and taking the integer part
    • Say your original image is 24 bits color (8 red, 8 green, 8 blue)
    • Say you have 256 colors available, and you choose to use 8 reds, 8 greens and 4 blues (8 × 8 × 4 = 256 )
    • Divide original red by 32, green by 32, and blue by 64

65 of 89

Uniform Quantization

  • 8 bits per pixel in this image
  • Note that it does very poorly on smooth gradients
  • Normally the hardest part to get right, because lots of similar colors appear very close together (since they are unfortunately in two different groups)

Unexpected contours

66 of 89

Populosity Algorithm

  • Build a color histogram: count the number of times each color appears
  • Choose the n most commonly occurring colors
  • Map other colors to the closest chosen color
  • Problem: May completely ignore under-represented but important colors

67 of 89

Populosity Algorithm

  • 8 bit image, so the most popular 256 colors
  • Note that blue wasn’t very popular, so the crystal ball is now the same color as the floor

68 of 89

Median Cut

  • Look at distribution of colors
  • Recursively:
    • Find the “longest” dimension (r, g, b are dimensions)
    • Choose the median of the long dimension as a color to use (sorting or average)
    • Split along the median plane, and recurse on both halves
  • Works very well in practice
  • This algorithm is building a kD-tree, a common form of spatial data structure
    • Also used in nearest neighbor computations and many other areas of computer graphics

69 of 89

Median Cut in Action

Original colors in color space

Median in long dimension

Recurse

70 of 89

Median Cut

  • 8 bit image, so 256 colors
  • Now we get the blue
  • Median cut works so well because it divides up the color space in the “most useful” way
  • Other method? Octree-based, optimization

71 of 89

Dithering to Black-and-White

  • Black-and-white is still the preferred way of displaying images in many areas
    • Black ink is cheaper than color
    • Printing with black ink is simpler and hence cheaper
    • Paper for black inks is not special
  • To get color to black and white, first turn into grayscale: I=0.299R+0.587G+0.114B
    • This formula reflects the fact that green is more representative of perceived brightness than blue is

72 of 89

Sample Images

73 of 89

Threshold Dithering

  • For every pixel: If the intensity < 0.5, replace with black, else replace with white
    • 0.5 is the threshold
    • This is the naïve version of the algorithm
  • To keep the overall image brightness the same, you should:
    • Compute the average intensity over the image
    • Use a threshold that gives that average
    • For example, if the average intensity is 0.6, use a threshold that is higher than 40% (e.g. intensity = 0) of the pixels, and lower than the remaining 60% (e.g. intensity = 1). So, 0.4*0+0.6*1=0.6
  • For all dithering we will assume that the image is gray and that intensities are represented as 0-1.0

74 of 89

Naïve Threshold Algorithm

75 of 89

Random Modulation

  • Add a random amount to each pixel before thresholding
    • Random is more acceptable than uniform by human eyes
    • Typically add uniformly random amount from [-a,a]
  • Pure addition of noise to the image
    • As stated above, we are adding uniformly random noise
    • For better results, add better quality noise
    • For instance, use Gaussian noise
  • Should use same procedure as before for choosing threshold
  • Not good for black and white, but OK for more colors
    • Add a small random color to each pixel before finding the closest color in the table

76 of 89

Random Modulation

77 of 89

Classical Halftoning

  • For bi-level display
  • Spatial trade quality

78 of 89

Halftone Patterns

  • Use cluster of pixels to represent intensity

Trade spatial resolution with intensity resolution

Average by human eyes

79 of 89

original

2x2

3x3

80 of 89

Filtering Image

81 of 89

Using Filter Templates

82 of 89

Blurring Filter Examples

83 of 89

Median Filter

  • Instead of simply replacing the pixel with mean of neighboring pixel values, it replaces it with the median of those values. The median is calculated by the first sorting all the pixel values from the surrounding neighborhood into numerical order and then replacing the pixel being considered with the middle pixel value.
  • The median is a more robust average than the mean and so a single very unrepresentative pixel in a neighborhood will not effect the median value significantly.

84 of 89

Gaussian Filter

  • The Gaussian distribution in 1-D has the form:

85 of 89

Gaussian Filter

  • The Gaussian distribution in 2-D has the form:

86 of 89

87 of 89

Edge detection

  • Detect edges in an image by convolving it with an edge detection kernel. In the example below, the kernel used was

88 of 89

Other Filters

  • Salt and pepper filter
  • Edge detection
    • Sobel operator

with threshold

Canny filter

A lots of stuff ……

  • Take Prof. Sun’s Image Processing class

89 of 89

Image Resizing Using Seam Carving