Previous year question · 2022
Final Examination 2022 (10th Batch) — Full Solution
JnU B.Sc. in CSE — 4th Year 1st Semester, Final Examination 2022 (10th Batch, Solved)
Eight questions from the Jagannath University B.Sc. in CSE 4th Year 1st Semester Final Examination 2022 (CSE-4105, 10th Batch) — full worked solutions covering raster vs vector graphics, image vs graphics, plasma vs LED, color CRT, DDA, Bresenham's line, polar/Cartesian circle problems and 8-fold symmetry, mid-point circle derivation, 2D & 3D translation, homogeneous coordinates, 2D rotation, 3D viewing pipeline, parallel vs perspective projection, vanishing points, CMY vs HSV, RGB color model, Z-buffer, Cohen-Sutherland and Sutherland-Hodgman clipping, scan-fill polygon filling, Phong vs Gouraud shading, computer animation & double buffering, animation languages, raster image loss/lossless, LCD components, compression ratio & Huffman coding, and multimedia file formats.
Question 1 — Graphics Applications, Raster vs Vector, Image vs Graphics, Plasma vs LED, Color CRT
(a) Major application areas of graphics.
(b) Contrast between Raster and Vector graphics.
(c) Differentiate between (i) Image and Graphics, (ii) Plasma panel and LED devices.
(d) Explain the color CRT with diagram.
Concept Needed
Computer graphics applications span five major domains; raster and vector are the two fundamental representation models; image and graphics differ in whether pixels or math come first; emissive flat-panel displays (plasma, LED) differ in how each pixel produces light; and the color CRT uses three electron guns and a shadow mask to land red, green, and blue phosphor dots on the screen.
(a) Major Application Areas of Graphics
- User Interfaces & Operating Systems — windows, icons, menus, mouse cursors, animated transitions.
- Computer-Aided Design (CAD) / Engineering (CAE) — drafting, simulation, finite-element visualization.
- Entertainment & Games — 2D/3D video games, animated films, virtual reality (VR).
- Scientific & Information Visualization — molecular models, medical imaging (MRI/CT), astronomical data plots.
- Education & Training — flight simulators, surgical simulators, e-learning animations.
(b) Raster vs Vector Graphics
| Aspect | Raster Graphics | Vector Graphics |
|---|---|---|
| Representation | Grid of pixels, each storing a color | Mathematical primitives (lines, curves, polygons) |
| Storage size | Larger; grows with resolution | Smaller; depends on complexity of geometry |
| Scaling | Becomes blocky / pixelated when zoomed | Scales smoothly to any zoom level |
| Typical formats | BMP, JPEG, PNG, GIF | SVG, PDF, EPS, PostScript, DXF |
| Best for | Photographs, scanned images, complex shading | Logos, type, CAD drawings, line art |
| Hardware use | Stored in framebuffer for display | Converted to raster at render time |
(c-i) Image vs Graphics
| Aspect | Image | Graphics |
|---|---|---|
| Definition | A 2D array of pixels captured or sampled | Mathematical representation of objects |
| Origin | Captured from real world (camera, scanner) | Created by algorithm or hand-drawn digitally |
| Storage | Pixel grid, often compressed (JPEG, PNG) | Geometric primitives, often XML-like (SVG) |
| Edit type | Pixel-level manipulation (filters, crops) | Object-level manipulation (move, scale, rotate) |
| Examples | Photo of a sunset | Logo, technical drawing, CAD model |
(c-ii) Plasma Panel vs LED Devices
| Aspect | Plasma Panel | LED Display |
|---|---|---|
| Light source | Gas discharge (neon + xenon) ionized by electrodes | Light Emitting Diodes (semiconductor junctions) |
| Pixel construction | Each cell holds ionized gas between two glass plates | Each pixel is one or three RGB LEDs |
| Backlight | None — each pixel self-emits | None — each pixel self-emits |
| Lifespan | Shorter (phosphor degradation, ~30k–60k hours) | Longer (~100k hours) |
| Viewing angle & contrast | Very wide, high contrast, deep blacks | Wide; OLED variants are best; backlit LED-LCD less so |
| Power & size | Higher power, mostly larger panels (TVs) | Lower power; works at any size from watches to stadium screens |
| Burn-in | Susceptible | Susceptible (especially OLED) |
(d) Color CRT (Cathode Ray Tube)
A CRT is a vacuum tube that produces images by firing electron beams onto a phosphor-coated screen. In a color CRT, three electron guns (one each for Red, Green, Blue) sit at the back of the tube, slightly tilted toward the centre.
Three Electron Guns
Separate guns emit electron beams for Red, Green, and Blue intensities
Focusing & Deflection Coils
Electromagnetic yoke steers the beams row-by-row across the screen (raster scan)
Shadow Mask
A thin metal plate with a grid of holes; each hole aligns the three beams onto one RGB phosphor triad
Phosphor-Coated Screen
Inner face holds millions of RGB phosphor dots; the beams excite them to glow
Persistent Afterglow
Phosphors keep glowing briefly so the eye perceives a continuous image at refresh rates (60+ Hz)
Working principle: the intensity of each beam is modulated by the corresponding video signal, so every pixel's R, G, B phosphor dots glow in proportion to that pixel's color. Sequential scanning row by row (left to right, top to bottom) redraws the entire frame 60+ times per second.
(a) Five areas: UIs, CAD/CAE, games/entertainment, scientific visualization, education/training.
(b) See table above.
(c) See tables above.
(d) Color CRT uses three electron guns (R, G, B), a shadow mask, and RGB phosphor dots; beams scan row by row, exciting each triad in proportion to the video signal.
Mention at least one specific real-world example per application area (e.g., "medical imaging" rather than just "science"). Examiners reward concrete examples.
Confusing plasma with LCD: plasma cells self-emit because of ionized gas, while LCD cells only block a backlight — they do not emit light on their own. LED is a separate self-emitting technology, not a kind of LCD.
CRT uses a beam + phosphor (analog, depth, curved glass); Plasma uses ionized gas in cells; LED uses semiconductor junctions; LCD modulates a backlight using liquid crystal alignment.
Question 2 — DDA Derivation, Bresenham's Line, Polar/Cartesian Circle Problems & 8-fold Symmetry
(a) Derive the DDA algorithm from the modified line equation and explain different conditions on slope . What are the disadvantages of DDA line drawing algorithm? (4+1)
(b) Calculate the intermediate points for the line with end points and using Bresenham line drawing algorithm and draw the line. (4+1)
(c) What problems arise while calculating points of a circle with polar and Cartesian forms? Explain how 8-fold symmetry solves these problems. (3+1)
(a) DDA Derivation
For a line from to , the standard equation is
The modified (symmetric) form uses both endpoints so that neither depends on which end we sample first:
The slope is what decides the increment strategy.
Step size selection. Let and . Define steps and as:
Three cases based on :
- (shallow slope, dominant): unit step in , advances by . Path: , .
- (steep slope, dominant): unit step in , advances by . Path: , .
- : diagonal; one step in and one in per iteration.
DDA algorithm (pseudocode):
Disadvantages of DDA:
- Floating-point operations — slower than integer-only algorithms (e.g. Bresenham).
- Rounding accumulation — rounding at every step causes visible drift; the line endpoint may not be hit exactly.
- Anti-aliasing needs extra work — DDA gives a hard-edged staircase; smoothing requires post-processing.
- No natural speed-up for hardware — Bresenham's is the standard for GPU line rasterization.
(b) Bresenham's Line Drawing for (20, 10) → (30, 18)
Given: , .
Step 1: Differences and initial decision variable
Since , we step in by each iteration.
Step 2: Update rules
If : choose East. .
If : choose North-East. .
Step 3: Tabulate
| Decision | Plot | ||||
|---|---|---|---|---|---|
| 0 | 6 | >0 → NE | 21 | 11 | (21, 11) |
| 1 | 2 | >0 → NE | 22 | 12 | (22, 12) |
| 2 | -2 | ≤0 → E | 23 | 12 | (23, 12) |
| 3 | 14 | >0 → NE | 24 | 13 | (24, 13) |
| 4 | 10 | >0 → NE | 25 | 14 | (25, 14) |
| 5 | 6 | >0 → NE | 26 | 15 | (26, 15) |
| 6 | 2 | >0 → NE | 27 | 16 | (27, 16) |
| 7 | -2 | ≤0 → E | 28 | 16 | (28, 16) |
| 8 | 14 | >0 → NE | 29 | 17 | (29, 17) |
| 9 | 10 | >0 → NE | 30 | 18 | (30, 18) |
The eight intermediate points (excluding the start and including the end ) are:
.
(c) Polar and Cartesian Circle Problems, and 8-fold Symmetry
Polar form problems:
- , .
- Each step requires computing and — expensive (multiplications, transcendentals).
- Uneven point density along the arc — points cluster near and spread near .
- Sensitive to accumulated floating-point error.
Cartesian form problems:
- Circle equation solves to .
- The square root is expensive.
- Only produces points at integer — gaps near the top/bottom of the circle are larger because becomes small there.
- Repeated squaring and subtraction for every candidate is wasteful.
8-fold symmetry:
A circle is symmetric across the horizontal axis, the vertical axis, and both diagonals. Computing points in just the second octant ( from to , from to ) and reflecting gives all 8 octants:
So instead of computing of points, only needs to be computed — a factor-of-8 reduction in computation, removing all the problems above at once.
(a) DDA uses the modified line form with , incrementing by fractional /; cases: , , . Disadvantages: floating-point, rounding error, slow.
(b) Points (excluding start): .
(c) Polar: trig is expensive, points cluster. Cartesian: square root expensive, uneven density. 8-fold symmetry reduces computation to one octant (45°) and mirrors the rest.
For Bresenham, write down , , , and the two update rules once at the top — then tabulate. Examiners want to see the setup explicitly.
Using vs inconsistently in Bresenham. Decide once based on your textbook's convention and stick to it. In the derivation above: East.
DDA = floating-point, easy to derive, slow. Bresenham = integer-only, decision variable, fast (used in hardware). Mid-point circle = same integer-only philosophy, applied to one octant using .
Question 3 — Mid-Point Circle Derivation, 2D & 3D Translation, Homogeneous Coordinates
(a) Derive the equation for the decision variable (both initial and new) for the mid-point circle algorithm. Also derive the equations for calculating the mid-point (both for E and SE). (3+3)
(b) What is Transformation? Calculate the 2-D and 3-D Translation equations and convert to matrix form. (1+4)
(c) Why are homogeneous coordinates used in transformation? Convert the derived matrix form of question 3(b) in homogeneous form. (3)
(a) Mid-Point Circle Algorithm — Decision Variable Derivation
We draw only the second octant where goes from down to and goes from up to , then mirror.
Implicit circle function. For a circle centered at the origin with radius :
- on the circle
- inside the circle
- outside the circle
At each step, we are at pixel and must choose between East and South-East . The mid-point between them is
Decision variable: .
- : mid-point is inside the circle, so East is closer to the true arc. Choose East.
- : mid-point is on or outside, so South-East is closer. Choose SE.
Initial value at the first step, starting from :
Since we want to keep all values integer, the standard initialization uses (subtracting is harmless because the sign of the decision variable is what matters, and the recurrence below absorbs the offset).
Recurrence:
- If (East chosen, ):
- If (SE chosen, ):
Mid-point coordinates:
- For East: .
- For SE: — the same mid-point is used; only the chosen pixel changes whether decrements.
(b) Transformation, 2D and 3D Translation
Transformation is the mathematical operation that maps a point in one coordinate space to a new point by altering its position, size, orientation, or shape.
2-D Translation. A point is shifted by :
In matrix form:
3-D Translation. A point is shifted by :
In matrix form:
(c) Homogeneous Coordinates
In the (b) matrix form above, translation is an addition, while rotation and scaling are multiplications. These cannot be composed into one product — every time a translation is added, the pipeline must switch from matrix multiplication back to vector addition.
Homogeneous coordinates add an extra dimension (set to ):
Then translation becomes a multiplication by a (2D) or (3D) matrix, so all transformations share the form . This lets us compose arbitrarily long sequences:
2-D Translation in homogeneous form:
3-D Translation in homogeneous form:
(a) ; (East) or (SE). Mid-point in both cases.
(b) 2D: . 3D: . (Matrices above.)
(c) Homogeneous coordinates let translation, rotation, and scaling all become matrix multiplications, enabling a single composite matrix for the whole pipeline.
For the mid-point circle initial value, remember the clean integer form . Examiners usually expect this rather than the floating-point .
Translating in homogeneous form requires a matrix for 2D (not ) and a matrix for 3D (not ). Forgetting the extra row/column turns the operation into a no-op.
In homogeneous form, scale factor is set to for affine transformations. Perspective projection uses — that is what makes the extra dimension useful, not just decorative.
Question 4 — 2D Rotation, 3D Viewing Pipeline, Projection, Vanishing Points
(a) What is rotation? Find the transformed point , caused by rotating about the origin through an angle of . (1+2)
(b) Draw the 3D viewing pipeline. (3)
(c) What is projection? Differentiate parallel and perspective projection. (4)
(d) What is vanishing point? Discuss the different types of vanishing points. (4)
(a) 2D Rotation about the Origin
Rotation is the transformation that moves a point around a fixed pivot by a given angle .
Rotation matrix (counter-clockwise):
For and :
So .
(b) 3D Viewing Pipeline
Modeling Coordinates
Object defined in its own local coordinate system
World Coordinates
Multiple objects placed together in a common scene
Viewing (Camera) Coordinates
Scene re-expressed with the camera at the origin, looking down −z
Projection
3D → 2D mapping (parallel or perspective) producing device coordinates
Clipping & Normalization
Outside-viewport parts removed; coordinates mapped into a unit cube
Viewport / Window-to-Screen
Final 2D mapping onto pixel positions on the display
(c) Projection
Projection is the mapping of a 3D scene onto a 2D plane (the projection plane or view plane).
| Aspect | Parallel Projection | Perspective Projection |
|---|---|---|
| Center of projection | At infinity — projection lines are parallel | At a finite point — projection lines converge |
| Depth cue | Preserves true lengths and angles (no foreshortening) | Farther objects appear smaller (foreshortening) |
| Realism | Less realistic; used in CAD/engineering drawings | More realistic; used in games, films, visualization |
| Parallel lines | Stay parallel after projection | Converge to vanishing points |
| Types | Orthographic (multi-view), oblique (e.g. cavalier, cabinet) | One-point, two-point, three-point |
| Matrix property | Last row | Last row has non-zero entries in (perspective divide) |
(d) Vanishing Points
A vanishing point is the point on the projection plane where the projections of a family of parallel 3D lines (that are not parallel to the projection plane) appear to converge. Each vanishing point corresponds to one set of parallel lines in the scene.
Types:
-
One-point perspective — the set of parallel lines is perpendicular to the projection plane (i.e. parallel to the view direction). All such lines meet at a single vanishing point (the centre of projection on the plane). Common in interior views, road-into-distance scenes.
-
Two-point perspective — two principal sets of horizontal parallel lines (e.g. vertical edges of two facing walls of a building) converge at two vanishing points on the horizon. Common in product shots and architectural renders.
-
Three-point perspective — adds a third set: vertical lines (in a real scene, the up/down direction) converge to a third vanishing point above or below the scene. Used for tall buildings viewed from above or below (dramatic foreshortening).
(a) .
(b) Modeling → World → Viewing (camera) → Projection → Clipping/Normalization → Viewport mapping.
(c) See table.
(d) Vanishing point = where parallel 3D lines appear to converge. One-point, two-point, three-point perspectives correspond to one, two, or three principal directions of parallel lines in the scene.
For 2D rotation questions, draw the picture: in the first quadrant rotates counter-clockwise by to land in the second quadrant at . A quick sketch validates the matrix result.
Confusing clockwise vs counter-clockwise rotation: in the standard matrix above is counter-clockwise. For clockwise rotation, replace with (or use the transpose).
The 3D viewing pipeline ends in two output passes: clipping (remove what's outside the view frustum) and viewport transform (map normalized device coordinates to pixel positions). Modern GPUs implement these as programmable shaders.
Question 5 — CMY vs HSV, RGB, Z-Buffer Polygon Placement
(a) State the differences between CMY and HSV color model. (6)
(b) Describe the RGB color model. (3)
(c) Consider a Z-buffer with a range of 0 to 10 and a pixel image and four polygons. Place the polygons using the Z-buffer method. (5)
(a) CMY vs HSV
| Aspect | CMY (Cyan-Magenta-Yellow) | HSV (Hue-Saturation-Value) |
|---|---|---|
| Type | Subtractive color model (used in printing) | Cylindrical-coordinate perceptual model |
| Primary components | Cyan, Magenta, Yellow (plus black in CMYK) | Hue (color type), Saturation (vibrancy), Value (brightness) |
| Best for | Hardcopy — printers, ink/toner on paper | User-facing color pickers, image editing, design tools |
| Mixing behavior | Subtractive — colors get darker as inks combine | Perceptual — value controls brightness independently of hue |
| Geometry | Cube (cyan, magenta, yellow on three axes) | Hexcone / cylinder (hue = angle, saturation = radius, value = height) |
| Black handling | Mixing C+M+Y gives muddy brown, so CMYK adds a dedicated Black channel | Value=0 always gives black regardless of hue/saturation |
(b) RGB Color Model
The RGB model is an additive color model where every visible color is produced by mixing three primary lights: Red, Green, and Blue. It is the standard model for emissive displays (CRT, LCD, LED, OLED).
- Geometry: a unit cube in RGB space. The origin is black; the far corner is white. Each axis spans intensities from (no contribution) to (full intensity).
- Primary colors: Red , Green , Blue .
- Secondary colors: Yellow = R+G, Magenta = R+B, Cyan = G+B.
- Per-channel storage: typically bits per channel in display hardware, giving million distinct colors.
- Why additive: each pixel's color = sum of the three intensities at that pixel; turning on more channels makes the result brighter, never darker.
(c) Z-Buffer Polygon Placement
Given: Z-buffer range ; pixel image; four polygons (depths listed with vertices given as indices, so ):
- Polygon 1: depth ;
- Polygon 2: depth ;
- Polygon 3: depth ;
- Polygon 4: depth ;
Initialize Z-buffer to maximum (). At each pixel covered by any polygon, compare the polygon's depth with the current Z-buffer value; keep the smaller depth (closer to the viewer).
Z-buffer map after all polygons (smallest depth wins at each pixel):
| Row \ Col | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| 1 | — | 4 (P1) | 4 (P1) | — | — | — |
| 2 | 4 (P4) | 8 (P3) | 4 (P1) / 8 (P3) | 8 (P3) | 8 (P3) | — |
| 3 | 2 (P2) / 4 (P4) | 2 (P2) / 4 (P4) | 2 (P2) / 4 (P1) / 4 (P4) | — | — | — |
| 4 | 4 (P4) | 8 (P3) / 4 (P4) | 8 (P3) / 4 (P4) | 8 (P3) | 8 (P3) | — |
| 5 | 2 (P2) | 2 (P2) | 2 (P2) / 4 (P4) | — | — | — |
| 6 | — | — | — | — | — | — |
Step-by-step algorithm applied:
For each pixel , find the polygons covering it and write the minimum depth:
- Row 1 (covered only by P1 at –): cells get depth from P1.
- Row 2 (covered by P3 at –, P4 at –): cells from P4 → ; is covered by both P3 (depth ) and P4 (depth ) → keep ; is covered by both P1 (depth ) and P3 (depth ) and P4 (depth ) → keep ; from P3 → .
- Row 3 (P2 at –, P4 at –, P1 at –): covered by P2 (depth ) which is closest, keep ; is covered by P1 () and P4 () → keep .
- Row 4 (P3 at –, P4 at –): from P4 → ; covered by both P3 () and P4 () → keep ; from P3 → .
- Row 5 (P2 at –, P4 at –): covered by P2 (depth ) which is closest, keep ; only by P4 → .
- Row 6: no polygons.
(a) See table.
(b) RGB = additive model on a unit cube; primary colors at unit axes; white at , black at ; each pixel's color = R+G+B intensities.
(c) See table above — at every pixel, the smallest depth among covering polygons wins.
Z-buffer is "minimum depth wins" if values increase away from the viewer; flip the comparison if your convention has increasing toward the viewer. Always state your convention explicitly.
Forgetting that Z-buffer initialization is the maximum value (background depth), not . Comparing "depth " against an init of would mean nothing ever gets drawn.
Z-buffer complexity is , so it's simple and parallelizable but memory-hungry: a screen at -bit depth needs MB just for the depth buffer.
Question 6 — Cohen-Sutherland Clipping, Sutherland-Hodgman Polygon Clipping, Scan-Fill Polygon
(a) Define viewport. Describe the basic idea of Cohen-Sutherland clipping algorithm. (1+3)
(b) Determine the clipped region for the polygon ABCDE using the Sutherland-Hodgman polygon clipping algorithm. The rectangle signifies the viewport. (6)
(c) Write the basic scan-fill algorithm for polygon filling. What is interior pixel convention? (2+2)
(a) Viewport & Cohen-Sutherland
Viewport is the rectangular region on the display screen (in device coordinates) where the final image of the scene is drawn — i.e. the on-screen window that maps to the world-coordinate clipping window.
Cohen-Sutherland Line Clipping. Each line endpoint is tagged with a 4-bit outcode indicating which of nine regions it lies in, relative to the clipping rectangle:
| Bit | Meaning when set |
|---|---|
| 1 (top) | |
| 2 (bottom) | |
| 3 (right) | |
| 4 (left) |
The algorithm:
- Compute outcodes for both endpoints of the line segment.
- Trivial accept: both outcodes are — segment is fully inside; draw it.
- Trivial reject: bitwise AND of the two outcodes is non-zero — both endpoints lie outside on the same side; discard the segment.
- Otherwise: pick an endpoint outside the window, clip it against the boundary it crosses (top/bottom/left/right) using parametric line equations, replace it with the intersection point, recompute its outcode, and repeat until trivial accept or reject.
(b) Sutherland-Hodgman Polygon Clipping
Sutherland-Hodgman clips a polygon against a convex clipping window by iterating over each clipping edge (left, right, top, bottom) and processing every polygon edge in sequence. For each input edge (going ):
- Both endpoints inside → keep .
- outside, inside → compute intersection, keep intersection and .
- Both outside → keep nothing.
- inside, outside → compute intersection, keep intersection.
The output of one edge becomes the input to the next. The final output list is the clipped polygon.
Applied to polygon ABCDE against the viewport rectangle in the figure:
The viewport (clipping rectangle) is the inner rectangle shown in the figure. Without the original figure coordinates, the qualitative result is:
- The original pentagon ABCDE is partially inside the viewport.
- After clipping, the result is a clipped polygon whose vertices are:
- The intersections of edges AB, BC, CD (or DE, depending on the orientation) with the viewport boundary, in the order they appear around the clipped shape.
- Plus any original vertices (like A or E) that lie inside the viewport.
The procedure is mechanical: run edges left → right → top → bottom against the rectangle, maintaining the running output list, and the final list is the clipped polygon ABCDE.
(c) Scan-Fill Polygon Filling Algorithm
The intersection count is always even for a non-self-intersecting polygon. Special care is needed at vertices (where a scanline touches two edges at the same point) and at horizontal edges (which produce no interior crossings) — typically, ignore horizontal edges and use the upper-endpoint rule at vertices.
Interior Pixel Convention: a rule that decides which pixels "belong" to the polygon interior when the geometric boundary passes between two pixels. Two common conventions:
- Inside-Outside (parity / even-odd) rule — pixels inside alternate with pixels outside as the scanline crosses edges. Standard for polygons with holes.
- Boundary-inclusive — boundary pixels are also considered interior (drawn in the polygon's color).
- Boundary-exclusive — only strictly interior pixels are drawn in the polygon's color; boundary pixels are drawn separately.
(a) Viewport = on-screen window. Cohen-Sutherland tags endpoints with outcodes; trivial accept if both codes are zero, trivial reject if their bitwise AND is nonzero, otherwise clip against the boundary and iterate.
(b) Apply Sutherland-Hodgman edge by edge against the rectangle; the output list of intersections forms the clipped polygon.
(c) Scan-fill: for each scanline, find intersections, sort, pair, fill. Interior pixel convention = the rule deciding which boundary pixels are considered "inside".
For Cohen-Sutherland, the key shortcut is "trivial reject if both endpoints are outside on the same side" — which outcode bit is set tells you the boundary to clip against.
Sutherland-Hodgman only works for convex clipping windows. For non-convex windows you need Weiler-Atherton or a similar algorithm.
Cohen-Sutherland clips lines; Sutherland-Hodgman clips polygons; both use parametric line-edge intersection formulas as their workhorse.
Question 7 — Phong & Gouraud Shading, Computer Animation, Animation Languages
(a) Explain the Phong and Gouraud Shading. (6)
(b) Define computer animation. What is double buffering? (1+3)
(c) Explain the different animation languages used and explain the design of animation sequences. (4)
(a) Phong and Gouraud Shading
Both are per-pixel surface-shading models used to make a polygon mesh look smoothly lit.
Gouraud Shading:
- A vertex-based shading method.
- For each vertex of the polygon, compute the surface normal (averaged from the normals of all faces sharing that vertex).
- Compute the light intensity at that vertex using the Phong illumination model.
- Linearly interpolate the vertex intensities across the polygon (scanline by scanline) to get the color of each interior pixel.
- Fast — only one shading calculation per vertex — but produces a faceted appearance on meshes with few polygons; specular highlights can look distorted because intensity is interpolated, not the normal.
Phong Shading:
- A per-pixel shading method.
- Interpolate the surface normal itself across the polygon (linearly between vertices), then at each pixel apply the Phong illumination model with that interpolated normal.
- More expensive (a normalization + lighting calculation per pixel) but produces much more accurate specular highlights and realistic shading curves, especially across smooth curved surfaces.
| Aspect | Gouraud Shading | Phong Shading |
|---|---|---|
| Interpolation target | Vertex color (intensity) | Vertex normal (vector) |
| Per-pixel cost | Cheap — linear blend of two colors | Higher — normalize vector + lighting model per pixel |
| Specular highlights | Can look distorted / blob-like | Accurate, can appear anywhere |
| Best for | Matte surfaces, low-poly meshes, real-time games | Glossy surfaces, smooth curved meshes, high-quality renders |
(b) Computer Animation and Double Buffering
Computer animation is the technique of creating the illusion of motion by displaying a rapid sequence of static images (frames), where each frame is a slight variation from the previous one. The eye perceives continuous motion when frames are shown at – fps.
Double buffering uses two framebuffers:
- The front buffer is the one being read out to the display right now.
- The back buffer is the one the program is drawing into.
When the back buffer's frame is complete, the two buffers are swapped — the back becomes the front, and the previous front (now free) becomes the next back buffer. This eliminates flicker and tearing, because the user never sees a partially-drawn frame.
(c) Animation Languages and Animation Sequence Design
Animation languages / systems (examples):
- Key-frame systems (e.g. Maya, Blender) — animator sets poses at key times; the system interpolates the in-between frames.
- Procedural / algorithmic animation — motion is generated by code (boids flocking, particle systems, physics simulations).
- Scripted animation — Timeline-based scripting (e.g. After Effects expressions, Unity Timeline, Unreal Sequencer).
- Motion-capture driven — recorded live motion drives a virtual skeleton.
- Behavior / AI-driven — characters act based on rules, state machines, or goal-seeking AI (game NPCs).
Design of animation sequences follows these stages:
- Storyboard — sketch each key scene with timing and dialogue.
- Keyframes — set the most important poses (start, contact points, end).
- In-betweens — interpolate frames between keyframes.
- Timing & easing — choose durations and acceleration curves; ease-in/out feels natural.
- Layering & effects — add secondary motion (cloth, hair, particles), sound, lighting.
- Rendering & playback — final render, frame-rate conversion, audio sync.
(a) Gouraud interpolates per-vertex intensities across the polygon (fast, vertex-only computation); Phong interpolates normals and runs the lighting model per pixel (more accurate specular).
(b) Computer animation = rapid sequence of frames; double buffering = front/back framebuffer swap to avoid flicker/tearing.
(c) Languages: keyframe, procedural, scripted, motion-capture, behavior. Sequence design: storyboard → keyframes → in-betweens → timing/easing → layering → render.
For Gouraud vs Phong, the right sentence to remember is "Gouraud interpolates color, Phong interpolates normals." That single distinction answers most exam questions.
Confusing Gouraud with flat shading. Flat shading uses one normal per polygon, no interpolation; Gouraud interpolates the vertex intensities computed from the averaged vertex normals — it is still a smooth shading model.
Double buffering is exactly what requestAnimationFrame + <canvas> use under the hood in browsers; tearing is avoided by waiting for the next vsync before swapping buffers.
Question 8 — Raster Loss/Lossless, LCD Components, Compression Ratio & Huffman Coding, Multimedia File Formats
(a) Is a raster image lossless or lossy? Explain. (3)
(b) Name the major components of LCD with diagram. (3)
(c) What is compression ratio? Give an example. How does a Huffman code look like for symbols with statistical symbol occurrence probabilities: ? (2+3)
(d) Explain different file formats used in Multimedia. (3)
(a) Lossless or Lossy?
A raster image itself is neither — it is just a 2D array of pixel values. Whether it is stored losslessly or lossily depends on the file format:
- Lossless raster formats preserve every pixel bit-for-bit: PNG, BMP, TIFF (uncompressed), GIF (for palette images), RAW.
- Lossy raster formats discard information that the human eye is unlikely to notice in exchange for smaller files: JPEG (DCT-based), JPEG 2000 (wavelet, lossy mode), WebP (lossy mode).
So the right answer is: it depends on the format. JPEG is lossy; PNG is lossless. The raster model supports both.
(b) Major Components of LCD
An LCD (Liquid Crystal Display) does not emit light on its own — it modulates light. The major components are:
- Backlight — CCFL tube (older) or LED strip (modern); provides uniform white light from behind.
- Polarizer (rear) — polarizes the backlight to one orientation (e.g. horizontal).
- Rear glass substrate with ITO electrodes — thin transparent electrodes that, when energized, align the liquid crystal molecules in the layer above.
- Liquid crystal layer — rod-shaped molecules whose orientation twists the polarization of light passing through (TN = twisted nematic is the most common mode).
- Front glass substrate with ITO electrodes and RGB color filters — segmented into RGB sub-pixels; each pixel is a triad of R, G, B filters.
- Front polarizer (analyser) — perpendicular to the rear polarizer; only light whose polarization has been rotated by passes through, and only where the LC layer twisted it.
- TFT (thin-film transistor) array — active-matrix addressing: one transistor per sub-pixel controls its voltage precisely.
In operation: a pixel is "on" (bright) when voltage twists the LC to rotate polarization ; "off" (dark) when no voltage is applied and polarization is blocked by the analyser. Color is produced by the RGB sub-pixel filters.
(c) Compression Ratio and Huffman Code
Compression ratio = (size of original data) / (size of compressed data). A ratio of means the compressed file is half the size of the original.
Example: A KB image compressed to KB has ratio .
Huffman coding for the given probabilities (4 symbols, 20 trials total: A=8, B=3, C=7, D=2):
Step 1 — list symbols with probabilities in descending order: A , C , B , D .
Step 2 — combine the two lowest probabilities: B + D = . New list: A , C , BD . Tie — keep order stable.
Step 3 — combine the two lowest again: C + BD = . New list: A , CBD .
Step 4 — combine remaining: A + CBD = (root).
Assign bits ( to first child, to second child, by convention; tree below):
Codes:
| Symbol | Probability | Huffman Code | Length |
|---|---|---|---|
| A | 8/20 = 0.40 | 0 | 1 |
| C | 7/20 = 0.35 | 10 | 2 |
| B | 3/20 = 0.15 | 110 | 3 |
| D | 2/20 = 0.10 | 111 | 3 |
Verify the prefix property: no code is a prefix of another ( is not a prefix of ; is not a prefix of or ; and differ at the last bit). ✓
Average code length:
(d) Multimedia File Formats
Image formats:
- JPEG — lossy, photographic content; DCT-based; small files.
- PNG — lossless; supports transparency; good for graphics with sharp edges.
- GIF — palette-based (256 colors), lossless; supports animation; ideal for simple graphics.
- BMP — uncompressed bitmap; large files; rarely used on the web.
- TIFF — high-quality lossless; used in publishing/printing.
- WebP / AVIF — modern; both lossy and lossless modes; smaller than JPEG/PNG at equivalent quality.
Audio formats:
- WAV — uncompressed PCM; large.
- MP3 — lossy perceptual compression.
- AAC — lossy; better quality than MP3 at same bitrate; used in streaming.
- FLAC — lossless; about half the size of WAV.
- OGG / Opus — open, lossy; excellent for voice/speech.
Video formats:
- MP4 (H.264/AVC, H.265/HEVC) — lossy; ubiquitous on web and streaming.
- AVI — older container; less efficient.
- MKV (Matroska) — open container; can hold many codecs.
- MOV — Apple's QuickTime container.
- WebM — open; VP8/VP9/AV1 codecs; web-friendly.
Streaming/protocol formats: HLS (.m3u8), DASH (.mpd), RTMP.
(a) A raster image is neither inherently — its storage can be lossless (PNG, BMP) or lossy (JPEG), depending on the format.
(b) Backlight, polarizers, LC layer, TFT/electrode arrays, RGB color filters.
(c) Compression ratio = original size / compressed size. Huffman codes: A=0, C=10, B=110, D=111. Average length = 1.85 bits/symbol.
(d) See format table above.
When asked "lossless or lossy?", answer with the format, not the model — JPEG is lossy, PNG is lossless, and the raster model supports both. Examiners look for that nuance.
In Huffman, the "two lowest probabilities get combined" step must use the current smallest two in the rebuilt list — not the original two. After combining B+D = 5/20, that combined node competes with C=7/20 in the next round.
A Huffman code is optimal only when symbol probabilities are independent and known ahead of time. For real streams, adaptive or arithmetic coding usually wins on compression ratio.