Docsity

Image Compositing & Shading: Opacity, Alpha Channel, Meshes, Study notes of Computer Graphics

Toggle sidebar
bg1
Opacity — Transparency
100% 80% 60% 40% 20%
!=1 !=0.8 !=0.6 !=0.4 !=0.2
Image Compositing
Often want to combine a sequence of images together
• different parts of final image can come from different sources
• TV stations have been doing this for a long time
Introduce a new alpha channel in addition to RGB channels
• the ! value of a pixel indicates its transparency
–if !=0, pixel is totally transparent
–if !=1, pixel is totally opaque
• alternatively, can think of ! as the fraction of the pixel actually
covered by the stored color
• convenient to work with premultiplied colors
Area !
( , , , ) ( , , , )r g b r g bα α α α α⇒
pf3
pf4
pf5

Partial preview of the text

Download Image Compositing & Shading: Opacity, Alpha Channel, Meshes and more Study notes Computer Graphics in PDF only on Docsity!

Opacity — Transparency

100% 80% 60%^ 40%^

20%

!=1 !=0.8 !=0.6 !=0.4 !=0.

Image Compositing

Often want to combine a sequence of images together

  • different parts of final image can come from different sources
  • TV stations have been doing this for a long time

Introduce a new alpha channel in addition to RGB channels

  • the! value of a pixel indicates its transparency
    • if^ !=0, pixel is totally transparent
    • if^ !=1, pixel is totally opaque
  • alternatively, can think of! as the fraction of the pixel actually

covered by the stored color

  • convenient to work with premultiplied colors (^) Area!

( r , g , b , α ) ⇒( α r , α g , α b , α)

Per-Pixel Opacity: The Alpha Channel

Image Compositing

Compositing one image over another is most common choice

  • can think of each image drawn on a transparent plastic sheet
  • the final image is formed by stacking layers together

Given images A & B , we can compute C = A over B

  • if we pre-multiply! values, this simplifies to

This is only one possible compositing operator

  • there are in fact 12 possible ways of combining 2 images

A A B

C = α A + 1 −α α B

A

C = A + 1 −α B

Triangle Meshes Found in Nature

Drawing Triangle Meshes

Very similar to closed curves

  • emit a long list of vertices
  • every triple assumed to be a

face

  • see also GL_QUADS

Also more efficient types

  • fewer calls to glVertex()
  • GL_TRIANGLE_STRIP
  • GL_TRIANGLE_FAN
  • GL_QUAD_STRIP

Drawing the Mesh:

glBegin(GL_TRIANGLES);

for(int j=0; j<n; j++)

{

glVertex3f(…);

glVertex3f(…);

glVertex3f(…);

}

glEnd();

Two Ways to Shade Triangles

Flat shading

  • one (constant) color per triangle

Smooth shading

  • one color per corner
  • linear interpolation

Linear Interpolation Along Segments

for 1 2

p ( u ) = ( 1 − u ) p + u p 0 ≤ u ≤ 1

1

p

2

p

Flat vs. Smooth Shading

Flat vs. Smooth Shading