1 of 97

Overview of Computer Graphics�&& Some Image Display

Instructor:

李同益

2 of 97

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 97

Overviews

  • History overview
  • Applications

PIXAR INTRO edit Animation

4 of 97

A Standard Graphics Pipeline

5 of 97

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 97

Polygon Rendering & Photorealistic Rendering

For example: OpenGL rendering v.s. Raytracing

Ray tracing

7 of 97

Ray tracing�

8 of 97

Scanning the David

height of gantry: 7.5 meters

weight of gantry: 800 kilograms

9 of 97

Point Rendering

10 of 97

Michelangelo’s Pieta

handmade replica

11 of 97

Holes:

Regular

or

Irregular

12 of 97

Molder Package

13 of 97

Sketch or Wireframe

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

14 of 97

Depth Cueing

15 of 97

Clipping (Far-plane)

16 of 97

Coloring

17 of 97

Hidden Surface Removal

18 of 97

Sketch�Applications

19 of 97

Constant Rendering

20 of 97

Facet Shading

21 of 97

Smooth Shading

22 of 97

Correct Highlight

23 of 97

Edge Silhouettes

24 of 97

Texture & Shadow

25 of 97

Procedural�and Displacement Texture

26 of 97

Ray tracing

27 of 97

Reflection

28 of 97

Global Illumination

29 of 97

30 of 97

Lighting

Direct ray

Reflection

Refraction

Shadow

Scattering

…………

…………

31 of 97

Photo image of

the real scene

Non-photorealistic

Rendering (NPR)

32 of 97

Applying different painterly styles.

  • Top row: “Impressionist.”

  • Middle row: “Expressionist.”

 表現主義

  • Bottom row: “Colorist Wash.”

印象派

33 of 97

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

34 of 97

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.

35 of 97

Computer Graphics is about Movies!

36 of 97

Computer

Graphics

is about

Movies!

37 of 97

Computer Graphics is about Movies!

38 of 97

39 of 97

Titanic

40 of 97

Cartoon Movie

41 of 97

Inspirational Video

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

42 of 97

Games are OK here

43 of 97

How Machine Learning Helps Game Developers Express Creativity

44 of 97

Medical �Imaging

45 of 97

Computer Aided Design

46 of 97

Scientific Visualization

47 of 97

Graphical User Interfaces (GUIs)

48 of 97

WYSIWYG NPR:�Drawing Strokes Directly on 3D Models

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

49 of 97

Image Display��Some introduction, concept and applications

Tong-Yee Lee

50 of 97

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背光源液晶螢幕

51 of 97

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

早期

Cathode Ray Tubes (CRTs)

52 of 97

Color Video (RGB 三槍)

53 of 97

VR (Virtual Reality)�Head-Mounted Displays

Eye’s position,

orientation

54 of 97

Caves and Fish Bowls

55 of 97

Looking at NASA Space Station on display wall

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

CSDisplayWall8&24/index.html

                                                                         

56 of 97

Review of Raster Displays

57 of 97

58 of 97

Alpha (transparency)

over

=

59 of 97

Applications for 3D Art Composer 

Demo:

SIG05

By Chuang

60 of 97

Titanic

Matting and

Compositing

61 of 97

Compositing

α

F

B

C

foreground color

alpha matte

background plate

composite

compositing

equation

B

F

C

α=0

62 of 97

Compositing

α

F

B

C

composite

compositing

equation

B

F

C

α=1

63 of 97

Compositing

α

F

B

C

composite

compositing

equation

B

F

C

α=0.6

64 of 97

Matting

C

observation

compositing

equation

α

F

B

65 of 97

An Implementation of Robust Matting Algorithm

66 of 97

67 of 97

68 of 97

The Simplest File

69 of 97

70 of 97

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

71 of 97

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

72 of 97

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
    • Use average color for each r, g, b group

73 of 97

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

74 of 97

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

75 of 97

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

76 of 97

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

77 of 97

Median Cut in Action

Original colors in color space

Median in long dimension

Recurse

78 of 97

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

79 of 97

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

80 of 97

Sample Images

81 of 97

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

82 of 97

Naïve Threshold Algorithm

83 of 97

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

84 of 97

Random Modulation

85 of 97

Classical Halftoning�i.e., newspaper

  • For bi-level display
  • Spatial trade quality

86 of 97

Halftone �Patterns

  • Use cluster of pixels to represent intensity

Trade spatial resolution with intensity resolution

Average by human eyes

87 of 97

original

2x2

3x3

88 of 97

Filtering Image

89 of 97

Using Filter Templates

90 of 97

Blurring Filter Examples

91 of 97

Gaussian Filter

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

92 of 97

Gaussian Filter

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

93 of 97

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.

94 of 97

95 of 97

Edge detection

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

96 of 97

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

97 of 97

Image Resizing Using Seam Carving