0% found this document useful (0 votes)
4 views73 pages

Computer Graphics Final Notes

The document discusses line drawing algorithms in computer graphics, emphasizing their importance for accurately rendering lines on raster displays due to pixel limitations. Key algorithms include the Incremental Line Algorithm, DDA Algorithm, and Bresenham Line Algorithm, each with distinct advantages and disadvantages. It also covers circle drawing techniques, the challenges involved, and the significance of the graphics pipeline in rendering images on screens.

Uploaded by

h.vedioeditor
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views73 pages

Computer Graphics Final Notes

The document discusses line drawing algorithms in computer graphics, emphasizing their importance for accurately rendering lines on raster displays due to pixel limitations. Key algorithms include the Incremental Line Algorithm, DDA Algorithm, and Bresenham Line Algorithm, each with distinct advantages and disadvantages. It also covers circle drawing techniques, the challenges involved, and the significance of the graphics pipeline in rendering images on screens.

Uploaded by

h.vedioeditor
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

WEEK 7 – LINE DRAWING ALGORITHMS

One of the most fundamental tasks in Computer Graphics is drawing a line on a screen.
Although drawing a line may seem simple, computers cannot draw a perfect mathematical line
directly because screens consist of tiny square pixels. Therefore, special algorithms are used to
determine which pixels should be illuminated to produce a line that appears continuous to the
human eye.

Line drawing algorithms are designed to generate lines accurately while minimizing
computational cost. Efficient line drawing is extremely important because complex graphics
scenes may contain thousands or even millions of lines. The most important line drawing
algorithms in computer graphics are the Incremental Line Algorithm, DDA Algorithm, and
Bresenham Line Algorithm.

Expected Exam Question:

Why are line drawing algorithms needed in Computer Graphics?

Introduction to Raster Line Generation


Computer screens are raster devices composed of pixels arranged in rows and columns. When
a line is drawn between two points, the graphics system must decide which pixels best
represent that line.

The challenge is that line coordinates are usually continuous values, whereas pixels exist only
at discrete positions. Therefore, line drawing algorithms approximate the mathematical line
using the nearest available pixels.

A good line drawing algorithm should:

• Produce accurate lines.


• Be computationally efficient.
• Minimize memory usage.
• Generate smooth visual output.

Expected Exam Question:

What is Raster Line Generation? Explain its challenges.


Incremental Line Algorithm
The Incremental Line Algorithm is one of the earliest methods used for drawing lines. The basic
idea is simple: starting from one endpoint, the algorithm repeatedly increments the x-coordinate
and calculates the corresponding y-coordinate using the line equation.

The equation of a line is:

y = mx + c

where:

• m = slope
• c = y-intercept

For each increment in x, the corresponding value of y is calculated. The nearest pixel is then
selected and displayed.

Although the algorithm is easy to understand, it involves floating-point calculations and rounding
operations, making it relatively slow compared to more advanced algorithms.

Advantages

• Simple concept.
• Easy implementation.

Disadvantages

• Uses floating-point arithmetic.


• Slower execution.
• Accumulated rounding errors.

Expected Exam Question:

Explain the Incremental Line Algorithm with its advantages and disadvantages.

DDA (Digital Differential Analyzer)


Algorithm
The DDA Algorithm is one of the most important line drawing algorithms in Computer Graphics.
It improves upon the Incremental Algorithm by calculating intermediate points more
systematically.

The basic idea is to determine the number of steps required and then increment x and y
coordinates gradually until the endpoint is reached.

Suppose a line starts at:

(x₁, y₁)

and ends at:

(x₂, y₂)

First calculate:

Δx = x₂ − x₁

Δy = y₂ −

y₁

Number of Steps:

Steps = max(|Δx|, |Δy|)

Then calculate:

Xincrement = Δx / Steps

Yincrement = Δy / Steps

Starting from the first point, these increments are repeatedly added until the final point is
reached.

Working Procedure

• Input starting and ending points.


• Calculate Δx and Δy.
• Determine number of steps.
• Compute Xincrement and Yincrement.
• Plot the initial point.
• Repeatedly add increments and plot new points.
• Continue until endpoint is reached.
Example

Draw a line from:

(2,2) to (8,5)

Step 1:

Δx = 8 − 2 = 6

Δy = 5 − 2 = 3

Step 2:

Steps = max(6,3)

Steps = 6

Step 3:

Xincrement = 6/6 = 1

Yincrement = 3/6 = 0.5

Generated Points:

(2,2)

(3,2.5)

(4,3)

(5,3.5)

(6,4)

(7,4.5)

(8,5)

These points are rounded to the nearest pixels and displayed.

Advantages

• Easy implementation.
• Better accuracy than Incremental Algorithm.
• Suitable for simple graphics applications.
Disadvantages

• Uses floating-point operations.


• Rounding errors may occur.
• Slower than Bresenham Algorithm.

Expected Exam Question:

Explain the DDA Algorithm with a numerical example.

Limitations of DDA Algorithm


Although DDA represented a major improvement over earlier approaches, it still has some
limitations.

Because DDA uses floating-point arithmetic, calculations require more processing time.
Additionally, repeated rounding operations may introduce small errors that accumulate over long
lines.

For modern graphics systems where speed is critical, a more efficient algorithm is preferred.

This led to the development of the Bresenham Line Drawing Algorithm.

Expected Exam Question:

Discuss the limitations of the DDA Algorithm.

Bresenham Line Drawing Algorithm


The Bresenham Algorithm is one of the most efficient and widely used line drawing algorithms in
Computer Graphics.

Unlike DDA, Bresenham uses only integer arithmetic. Since integer operations are faster than
floating-point operations, the algorithm executes much more efficiently.

The algorithm determines which pixel is closest to the actual mathematical line by evaluating a
decision parameter at each step.
Basic Idea

At each step, the algorithm chooses between two possible pixels:

• East Pixel (E)


• North-East Pixel (NE)

The decision parameter determines which pixel provides the best approximation of the line.

Because only integer calculations are used, the algorithm is significantly faster than DDA.

Working Procedure

• Input line endpoints.


• Calculate Δx and Δy.
• Initialize decision parameter.
• Plot starting point.
• Evaluate decision parameter.
• Select appropriate pixel.

• Update decision parameter.


• Continue until endpoint is reached.

Advantages

• Uses integer arithmetic.


• Faster execution.
• High accuracy.
• Minimal memory requirements.

Disadvantages

• Slightly more complex than DDA.


• Original version works best for slopes between 0 and 1.

Expected Exam Question:

Explain Bresenham Line Drawing Algorithm and discuss its advantages.

DDA vs Bresenham Algorithm


Both algorithms are used for line generation, but they differ significantly in efficiency and
implementation.

Feature DDA Bresenham

Arithmetic Floating Point Integer

Speed Slower Faster

Accuracy Good Better

Memory Usage More Less

Complexity Simpler Slightly Complex

Efficiency Moderate High

Because of its speed and accuracy, Bresenham's algorithm is generally preferred in practical
graphics systems.

Expected Exam Question:

Compare DDA and Bresenham Line Drawing Algorithms.

Parallel Line Algorithms


In modern graphics systems, multiple lines often need to be drawn simultaneously. Examples
include CAD software, scientific visualization, and gaming environments.

Parallel Line Algorithms divide line drawing tasks among multiple processors or processing
units.

Instead of drawing one line at a time, several lines can be generated concurrently.

Advantages

• Faster rendering.
• Better hardware utilization.
• Suitable for GPUs.
• Improved performance in large graphics applications.

Modern GPUs use parallel processing extensively to render complex scenes in real time.

Expected Exam Question:

What are Parallel Line Algorithms? Discuss their advantages.

Applications of Line Drawing Algorithms


Line drawing algorithms are used in many areas of Computer Graphics, including:

• Computer-Aided Design (CAD)


• Video Games
• Graph Plotting
• Engineering Drawings
• Geographic Information Systems (GIS)
• Animation Systems
• User Interface Design

Any application that displays lines relies on efficient line generation techniques.

Expected Exam Question:

Discuss the applications of Line Drawing Algorithms.

WEEK 8 – CIRCLE DRAWING


TECHNIQUES
Just as line drawing is a fundamental task in Computer Graphics, drawing circles efficiently is
also extremely important. Circles are used in many graphical applications such as games, CAD
software, engineering designs, user interfaces, simulations, and scientific visualization.

A mathematical circle consists of infinitely many points, but a computer screen is made up of
discrete pixels. Therefore, special algorithms are required to determine which pixels should be
illuminated to create a circle that appears smooth and accurate.
An efficient circle drawing algorithm should generate circles quickly, accurately, and with
minimum computational cost.

Expected Exam Question:

Why are special algorithms required for drawing circles in Computer Graphics?

Circle
A circle is a closed geometric shape consisting of all points that are at an equal distance from a
fixed point called the center.

The fixed distance is known as the radius.

The standard equation of a circle is:

x² + y² = r²

where:

• x and y represent coordinates


• r represents radius

For example:

If the radius is 5:

x² + y² = 25

Every point satisfying this equation lies on the circle.

In Computer Graphics, circles are represented using pixels that approximate the mathematical
circle.

Applications of Circles

• Clock Design
• Radar Systems
• Vehicle Wheels
• Game Objects
• Engineering Drawings
• User Interface Components

Expected Exam Question:


Define a circle and explain its equation and applications.

Challenges in Circle Drawing

Drawing a circle on paper is easy because the circle appears continuous. However, computer
screens contain square pixels arranged in rows and columns.

The major challenges are:

• Pixel approximation
• Maintaining smoothness
• Avoiding distortion
• Reducing computational cost

A naive approach would calculate every point using the circle equation, but this requires
expensive square-root calculations.

Therefore, more efficient algorithms are preferred.

Expected Exam Question:

Discuss the challenges involved in drawing circles on raster displays.

Simple Circle Drawing Algorithm


The simplest method for drawing a circle is to use the circle equation directly.

The algorithm works by calculating y for each x value.

From:

x² + y² = r²

we obtain:

y = √(r² − x²)

The calculated points are then plotted on the screen.


Working Procedure

• Input radius r.
• Start from x = 0.
• Calculate y using the circle equation.
• Plot the point.
• Increase x.
• Repeat until the entire circle is generated.

Advantages

• Easy to understand.
• Direct implementation.

Disadvantages

• Requires square-root calculations.


• Slow execution.
• Not suitable for real-time graphics.

Because of these disadvantages, more efficient methods such as the Midpoint Circle Algorithm
are preferred.

Expected Exam Question:

Explain the Simple Circle Drawing Algorithm and discuss its limitations.

Symmetry in Circles
One of the most important properties of circles is symmetry.

A circle looks identical when divided into several equal sections.

Instead of calculating every point of the circle, we can calculate only a few points and obtain the
remaining points using symmetry.

This significantly reduces computational effort.

Circle algorithms make extensive use of symmetry to improve efficiency.

Expected Exam Question:


Why is symmetry important in circle drawing algorithms?

Eight-Way Symmetry
A circle possesses Eight-Way Symmetry.

This means that if one point on the circle is known, seven additional points can be generated
automatically through reflection.

Suppose a point:

(x,y)

lies on the circle.

The following points will also lie on the circle:

• (x,y)
• (y,x)
• (-x,y)
• (-y,x)
• (-x,-y)
• (-y,-x)
• (x,-y)
• (y,-x)

Therefore, only one-eighth of the circle needs to be calculated directly.

The remaining seven-eighths can be generated automatically.

Advantages of Eight-Way Symmetry

• Reduces calculations.
• Improves speed.
• Simplifies implementation.
• Increases efficiency.

Most circle drawing algorithms use this principle.

Expected Exam Question:

Explain Eight-Way Symmetry in Circle Drawing.


Midpoint Circle Drawing Algorithm
The Midpoint Circle Algorithm is one of the most important circle generation algorithms in
Computer Graphics.

It determines which pixel is closest to the actual circle by evaluating a decision parameter.

The algorithm uses only integer arithmetic and avoids costly square-root calculations.

Because of its efficiency, it is widely used in practical graphics systems.

Basic Idea

At each step, two possible pixels exist:

• East Pixel (E)


• South-East Pixel (SE)

The algorithm determines which pixel is closer to the actual circle.

A decision parameter is used to make this choice.

Expected Exam Question:

What is the basic idea behind the Midpoint Circle Algorithm?

Working of Midpoint Circle Algorithm


The algorithm begins at:

(0,r)

because the topmost point of the circle is known.

The initial decision parameter is:

P₀ = 1 − r

For every step:


If P < 0

Choose East Pixel.

Update:

P = P + 2x + 3

If P ≥ 0

Choose South-East Pixel.

Update:

P = P + 2(x − y) + 5

The process continues until:

x≥y

Using Eight-Way Symmetry, the remaining points are generated automatically.

Expected Exam Question:

Explain the working procedure of the Midpoint Circle Algorithm.

Numerical Example of Midpoint Circle


Algorithm
Suppose:

Radius = 5

Starting Point:

(0,5)

Initial Decision Parameter:

P₀ = 1 − 5
P₀ = -4

Since P₀ < 0:

Choose East Pixel.

Next Point:

(1,5)

Update:

P₁ = -4 + 2(0) + 3

P₁ = -1

Again:

P₁ < 0

Choose East Pixel.

Continue until:

x≥y

The remaining points are obtained through Eight-Way Symmetry.

In exams, teachers usually focus on understanding the decision parameter rather than lengthy
calculations.

Expected Exam Question:

Solve a numerical example using the Midpoint Circle Algorithm.

Advantages of Midpoint Circle Algorithm


The Midpoint Circle Algorithm became popular because of several advantages.

High Efficiency

Uses only integer arithmetic.


Fast Execution

Avoids square-root calculations.

High Accuracy

Produces circles that closely approximate mathematical circles.

Low Computational Cost

Requires fewer operations.

Suitable for Real-Time Graphics

Used in games and interactive systems.

Expected Exam Question:

Discuss the advantages of the Midpoint Circle Algorithm.

Limitations of Midpoint Circle Algorithm


Although the algorithm is highly efficient, it has a few limitations.

• Primarily designed for raster displays.


• Produces approximations rather than perfect circles.
• Slight pixel distortion may occur for very large circles.

Despite these limitations, it remains one of the most widely used circle drawing algorithms.

Expected Exam Question:

Discuss the limitations of the Midpoint Circle Algorithm.

Comparison: Simple Circle Algorithm vs


Midpoint Circle Algorithm
Feature Simple Circle Algorithm Midpoint Circle Algorithm

Arithmetic Floating Point Integer

Speed Slow Fast

Accuracy Moderate High

Complexity Simple Moderate

Square Root Required Not Required


Calculation

Efficiency Low High

The Midpoint Circle Algorithm is generally preferred because it provides better performance and
accuracy.

Expected Exam Question:

Compare the Simple Circle Algorithm and Midpoint Circle Algorithm.

Applications of Circle Drawing Algorithms


Circle drawing algorithms are used extensively in computer graphics applications.

Common uses include:

• Video Games
• Radar Systems
• Mechanical Design
• CAD Software
• Graphical User Interfaces
• Scientific Simulations
• Animation Systems

Any graphical system that requires circles or curved objects relies on efficient circle generation
techniques.
Expected Exam Question:

Discuss the applications of circle drawing algorithms.

WEEK 9 – TRADITIONAL GRAPHICS


PIPELINE
When a graphical object is created inside a computer, it does not immediately appear on the
screen. Before the final image is displayed, the object passes through several processing
stages. This sequence of stages is called the Graphics Pipeline.

The Graphics Pipeline is one of the most important concepts in Computer Graphics because it
explains how mathematical descriptions of objects are converted into visible images on a
display device. Every modern graphics system, including OpenGL, DirectX, Unity, Unreal
Engine, and GPUs, uses some form of graphics pipeline.

The pipeline consists of multiple stages such as transformation, lighting, clipping, scan
conversion, and pixel processing. Each stage performs a specific task and passes its output to
the next stage until the final image is produced.

Expected Exam Question:

What is the Graphics Pipeline? Explain its importance in Computer Graphics.

Overview of the Traditional Graphics


Pipeline
The traditional graphics pipeline can be represented as:

Modeling → Transformation → Lighting → Clipping → Scan Conversion → Pixel Processing


→ Display

At each stage, graphical information is refined and prepared for display.

The pipeline ensures that graphics are rendered accurately, efficiently, and realistically.

Expected Exam Question:


Draw and explain the stages of the Traditional Graphics Pipeline.

Transformation Stage
The first major stage of the graphics pipeline is transformation.

Objects are initially created in their own local coordinate systems. However, these coordinates
are not suitable for direct display on the screen. Therefore, transformations are applied to
position objects correctly within the graphical scene.

Transformation operations include:

• Translation
• Rotation
• Scaling

For example, a car model may be created around the origin. Transformation allows the car to be
moved to a road, rotated in the correct direction, and resized appropriately.

Without transformations, every object would remain fixed at its original location.

Importance

Transformations allow:

• Object movement
• Object rotation
• Object resizing
• Scene organization

Expected Exam Question:

Explain the role of transformations in the Graphics Pipeline.

Viewing Transformation
After objects are positioned within the scene, the graphics system determines how the scene
should appear from the viewer's perspective.
This process is called Viewing Transformation.

It is similar to a camera taking a photograph.

The camera position determines:

• What objects are visible


• Which direction is viewed
• How the scene appears

Viewing transformation converts world coordinates into viewing coordinates.

Applications

• Video Games
• Virtual Reality
• Simulation Systems
• 3D Modeling Software

Expected Exam Question:

What is Viewing Transformation? Why is it necessary?

Projection Transformation
Three-dimensional objects cannot be displayed directly on a two-dimensional screen.

Therefore, a projection transformation is used.

Projection converts 3D coordinates into 2D screen coordinates.

The two main types are:

Parallel Projection

Projection lines remain parallel.

Characteristics:

• No perspective effect
• Object size remains constant

Applications:

• Engineering Drawings
• CAD Systems

Perspective Projection

Projection lines converge at a viewpoint.

Characteristics:

• Realistic appearance
• Distant objects appear smaller

Applications:

• Games
• Movies
• Simulations

Expected Exam Question:

Differentiate between Parallel Projection and Perspective Projection.

Lighting Stage
Once objects have been transformed, lighting calculations are performed.

Lighting determines how bright or dark different surfaces appear.

Without lighting, all objects would look flat and unrealistic.

The lighting stage simulates the behavior of light sources interacting with object surfaces.

Several factors affect lighting:

• Light Source Position


• Surface Orientation
• Material Properties
• Viewer Position
Lighting helps create realistic depth and appearance.

Importance

Lighting provides:

• Realism
• Depth Perception
• Surface Details

• Visual Quality

Expected Exam Question:

Explain the Lighting stage in the Graphics Pipeline.

Types of Light Sources


Different light sources are used in graphics systems.

Point Light

Emits light equally in all directions from a single point.

Example:

Light bulb.

Directional Light

Light rays travel in a fixed direction.

Example:

Sunlight.

Spotlight

Light is focused in a specific direction.

Example:
Torchlight.

Each light source affects object appearance differently.

Expected Exam Question:

Discuss different types of light sources used in Computer Graphics.

Clipping Stage
After transformation and lighting, some objects may still lie outside the viewing region.

Rendering these invisible portions wastes computational resources.

Therefore, clipping is performed.

Clipping removes:

• Invisible lines
• Invisible polygons
• Invisible objects

Only the visible portions remain for further processing.

Advantages

• Improves performance
• Reduces calculations
• Saves memory

Clipping was discussed in detail during Week 6 and forms an important stage of the graphics
pipeline.

Expected Exam Question:

What is Clipping and why is it used in the Graphics Pipeline?

Scan Conversion
Scan Conversion is the process of converting geometric descriptions into pixels.

Until this stage, objects are represented mathematically.

However, display devices operate using pixels.

Scan conversion determines:

• Which pixels should be illuminated


• What color each pixel should have

Examples include:

• Line Rasterization
• Circle Rasterization
• Polygon Filling

The DDA and Bresenham algorithms studied earlier are examples of scan conversion
techniques.

Importance

Scan conversion bridges the gap between mathematical objects and raster displays.

Expected Exam Question:

What is Scan Conversion? Explain its role in rendering.

Rasterization
Rasterization is often considered part of scan conversion.

It converts graphical primitives such as:

• Lines
• Circles
• Triangles
• Polygons

into pixels.

Modern GPUs perform rasterization extremely quickly.


Most real-time graphics systems depend heavily on rasterization.

Applications

• Video Games
• Interactive Graphics
• Mobile Applications

Expected Exam Question:

Explain Rasterization and its significance in Computer Graphics.

Pixel Processing
After rasterization, the graphics system performs pixel processing.

Each generated pixel is assigned properties such as:

• Color
• Brightness
• Transparency
• Texture Information

Pixel processing helps improve image quality and realism.

Operations may include:

• Color Correction
• Texture Mapping
• Blending
• Anti-Aliasing

Importance

Pixel processing enhances visual appearance and image quality.

Expected Exam Question:

What is Pixel Processing? Discuss its importance.


Frame Buffer
The final pixel values are stored in a memory area called the Frame Buffer.

The frame buffer contains information about every pixel that will appear on the screen.

Each pixel stores:

• Color Information

• Brightness Information

The display controller reads the frame buffer and sends the image to the monitor.

Expected Exam Question:

What is a Frame Buffer and what role does it play in graphics rendering?

Display Stage
The final stage of the graphics pipeline is displaying the image.

The processed pixel data is transferred to the display device where it becomes visible to the
user.

Modern displays refresh the image many times per second.

Common refresh rates include:

• 60 Hz
• 120 Hz
• 144 Hz

A higher refresh rate results in smoother motion.

Expected Exam Question:

Explain the Display Stage of the Graphics Pipeline.


Importance of the Graphics Pipeline
The graphics pipeline is essential because it organizes the rendering process into separate
stages.

Benefits include:

• Faster rendering
• Better image quality
• Efficient hardware utilization

• Realistic graphics
• Modular design

Without the graphics pipeline, modern graphics systems would be extremely inefficient and
difficult to manage.

Expected Exam Question:

Discuss the importance of the Graphics Pipeline.

Bilkul yaar, ye baat sahi hai. Week 10–16 final portion hai, aur aksar teachers finals mein
recent weeks se zyada questions bana dete hain. Isliye ab main notes ko thoda aur
exam-focused, easy to memorize, aur conceptually strong banaunga. Matlab unnecessary
details nahi, lekin itna content hoga ke 10–15 marks ke long questions bhi cover ho jayen.

WEEK 10 – COLOR MODELS


Color is one of the most important elements in Computer Graphics. Without color, graphics
would appear dull and less informative. Different devices such as monitors, printers, cameras,
and scanners use different methods to represent colors. These methods are called Color
Models.

A color model is a mathematical system used to represent colors using numerical values.
Different color models are designed for different purposes. For example, monitors use RGB
while printers use CMYK.

Expected Exam Question:


What is a Color Model? Why are color models needed in Computer Graphics?

What is Color?
Color is a visual sensation produced when light of different wavelengths reaches the human
eye. The human eye contains special cells called cones that detect different colors.

Every color that we see can be created by combining a small number of primary colors in
different proportions.

In Computer Graphics, colors are represented digitally using numerical values.

Expected Exam Question:

What is color and how is it represented in Computer Graphics?

Types of Color Models


Several color models are used in graphics systems. The most important ones are:

• RGB Color Model


• CMYK Color Model
• HSV/HSI Color Model

Each model represents colors differently and is suitable for specific applications.

Expected Exam Question:

Discuss the major types of color models used in Computer Graphics.

RGB Color Model


The RGB Color Model is the most commonly used color model in computer graphics.

RGB stands for:


• Red
• Green
• Blue

These are called additive primary colors.

Different colors are produced by combining varying amounts of red, green, and blue light.

For example:

• Red = (255,0,0)
• Green = (0,255,0)
• Blue = (0,0,255)

• White = (255,255,255)
• Black = (0,0,0)

Modern displays such as monitors, TVs, smartphones, and projectors use RGB.

Why RGB is Important

Every pixel on a screen contains red, green, and blue components. By adjusting the intensity of
these components, millions of colors can be generated.

Advantages

• Easy implementation.
• Ideal for display devices.
• Supports millions of colors.

Disadvantages

• Not suitable for printing.


• Less intuitive for artists and designers.

Expected Exam Question:

Explain the RGB Color Model with examples and applications.

Additive Color Model


RGB is called an Additive Color Model because colors are produced by adding light.

Starting Color:

Black

As more light is added, brighter colors are produced.

Examples:

Red + Green = Yellow

Green + Blue = Cyan

Red + Blue = Magenta

Red + Green + Blue = White

This principle is used in all electronic displays.

Expected Exam Question:

What is an Additive Color Model? Explain with examples.

CMYK Color Model


CMYK is primarily used in printing systems.

CMYK stands for:

• Cyan
• Magenta
• Yellow
• Key (Black)

Unlike RGB, CMYK works by absorbing light rather than emitting it.

Printers place colored ink on paper. The paper reflects only certain wavelengths of light,
creating visible colors.

Why Black (K) is Used


In theory:

Cyan + Magenta + Yellow = Black

In practice, the result is often dark brown rather than true black.

Therefore, a separate black ink cartridge is added.

Applications

• Books
• Newspapers
• Magazines
• Posters
• Packaging Design

Advantages

• Ideal for printing.


• Produces high-quality printed output.

Disadvantages

• Smaller color range than RGB.


• Not suitable for displays.

Expected Exam Question:

Explain the CMYK Color Model and its applications.

Subtractive Color Model


CMYK is called a Subtractive Color Model because colors are produced by subtracting light.

Starting Color:

White Paper

As ink is added, more light is absorbed.

Result:
The image becomes darker.

Examples:

Cyan + Yellow = Green

Magenta + Yellow = Red

Cyan + Magenta = Blue

Cyan + Magenta + Yellow + Black = Black

Difference Between Additive and Subtractive Models


Additive Subtractive
Uses Light Uses Ink

Starts with Black Starts with White


RGB CMYK
Used in Displays Used in Printers

Expected Exam Question:

Differentiate between Additive and Subtractive Color Models.

HSV Color Model


HSV stands for:

• Hue
• Saturation
• Value

The HSV model was developed to represent colors in a way that is closer to human perception.

Instead of using RGB values, colors are described using characteristics that humans naturally
understand.

Hue
Hue represents the actual color.

Examples:

• Red
• Green
• Blue
• Yellow

Hue is measured in degrees from 0° to 360°.

Saturation

Saturation represents color purity.

High Saturation:

Bright and vivid colors.

Low Saturation:

Dull and faded colors.

Value

Value represents brightness.

Higher value produces brighter colors.

Lower value produces darker colors.

Applications

• Image Editing
• Computer Vision
• Color Selection Tools
• Digital Art

Expected Exam Question:

Explain the HSV Color Model and its components.


HSI Color Model
HSI stands for:

• Hue
• Saturation
• Intensity

It is very similar to HSV.

The main difference is that HSV uses Value while HSI uses Intensity.

Intensity represents the overall amount of light present in a color.

HSI is commonly used in image processing because it closely matches human color perception.

Expected Exam Question:

Differentiate between HSV and HSI Color Models.

Comparison of RGB, CMYK, and HSV


Feature RGB CMYK HSV
Primary Use Displays Printing Image Editing
Components R,G,B C,M,Y,K H,S,V
Type Additive Subtractive Perceptual
Easy for Humans Moderate Moderate High
Device High High Low
Dependence

Expected Exam Question:

Compare RGB, CMYK, and HSV Color Models.


Importance of Color Models
Color models provide a standardized way to represent colors in digital systems.

Without color models:

• Images would not display correctly.


• Printers would produce incorrect colors.
• Graphics software would not function properly.

Color models ensure consistency across devices and applications.

Expected Exam Question:

Why are Color Models important in Computer Graphics?

WEEK 11 – LIGHTING IN COMPUTER


GRAPHICS
Lighting is one of the most important parts of Computer Graphics because it controls how
realistic an object looks. Without lighting, objects appear flat and dull. Lighting models simulate
how light interacts with surfaces to produce brightness, shadows, and highlights. In real-time
graphics like games and OpenGL applications, lighting is calculated for every visible surface to
create realism.

A lighting model is basically a mathematical method that calculates the final color of a pixel
based on light sources, material properties, and viewer position.

Expected Question:

What is lighting in Computer Graphics? Why is it important?

• Ambient Lighting Model


Ambient lighting represents the general background light present in a scene. It is indirect light
that comes from all directions equally and affects all objects in the scene uniformly. It ensures
that objects are still visible even if they are not directly exposed to a light source.
Ambient light does not depend on the position of the light or viewer. It only adds a constant
brightness to the object.

However, too much ambient light makes the scene look unrealistic because it removes
shadows.

Formula Idea:

I = Ia × Ka
Where:

• Ia = Ambient light intensity


• Ka = Material ambient reflection coefficient

Expected Question:

Explain Ambient Lighting Model.

• Diffuse Lighting Model


Diffuse lighting occurs when light hits a rough surface and scatters in all directions. It depends
on the angle between the light source and the surface. If light hits directly, the surface looks
brighter; if it hits at an angle, it looks darker.

This model follows Lambert’s Cosine Law:

I = Id × Kd × cos(θ)

Where:

• Id = light intensity
• Kd = diffuse reflection coefficient
• θ = angle between light and surface

Diffuse lighting gives objects their natural color and realistic appearance.

Example: walls, paper, cloth.

Expected Question:

Explain Diffuse Lighting Model with formula.


• Specular Lighting Model
Specular lighting produces shiny highlights on surfaces. It depends on the viewer’s position. If
the viewer is aligned with the reflection direction, the highlight is stronger.

It creates the “glossy spot” seen on shiny objects like metal, glass, or water.

Formula Idea:

I = Is × Ks × (R · V)^n

Where:

• Is = light intensity
• Ks = specular coefficient

• R = reflection vector
• V = viewer vector
• n = shininess factor

Higher n = sharper highlight.

Expected Question:

Explain Specular Lighting Model.

• Blinn-Phong Lighting Model


Blinn-Phong is an improved version of Phong lighting. Instead of using reflection vector, it uses
a halfway vector between light direction and view direction.

Halfway Vector:

H = (L + V) / |L + V|

Lighting becomes:

I = Ambient + Diffuse + Specular


Specular uses (N · H)^n instead of (R · V)^n.

Why it is used:

• Faster than Phong model


• More stable in real-time rendering
• Used in games and GPUs

Expected Question:

Explain Blinn-Phong Lighting Model. Why is it better than Phong?

• Light Sources in Computer Graphics


Light sources define how light is emitted in a scene. Different types of lights are used depending
on realism requirements.

• Point Light
Light comes from a single point and spreads in all directions equally.
Example: bulb, lamp.

• Directional Light
Light rays are parallel and come from a far distance.
Example: sunlight.

• Spotlight
Light is restricted to a cone-shaped region.
Example: torch, stage light.

Summary:

• Point = all directions


• Directional = parallel rays
• Spotlight = cone shape
Expected Question:

Explain different types of light sources.

• Material Properties
Material properties define how an object reacts to light. Different materials reflect light differently,
which changes their appearance.

Main properties include:

• Ambient reflection (how much background light is reflected)


• Diffuse reflection (surface color response)
• Specular reflection (shininess)
• Shininess coefficient (controls highlight sharpness)

For example:

• Metal → high specular


• Wood → low specular
• Cloth → mostly diffuse

Material properties are important because they make objects look realistic in graphics systems.

Expected Question:

Explain material properties in lighting models.

• Light Example in OpenGL


OpenGL provides a built-in lighting system to simulate real-world light behavior.

Basic steps to enable lighting:

Step 1: Enable Lighting

glEnable(GL_LIGHTING);
Step 2: Enable Light Source

glEnable(GL_LIGHT0);

Step 3: Define Light Properties

• Ambient light
• Diffuse light
• Specular light
• Position

Example idea:

• glLightfv(GL_LIGHT0, GL_AMBIENT, value)


• glLightfv(GL_LIGHT0, GL_DIFFUSE, value)
• glLightfv(GL_LIGHT0, GL_SPECULAR, value)
• glLightfv(GL_LIGHT0, GL_POSITION, value)

Step 4: Define Material

• glMaterialfv()

OpenGL then automatically calculates lighting using Blinn-Phong or similar model.

Expected Question:

Explain lighting example in OpenGL.

WEEK 12 – SHADING & TRIANGULATION


Shading and triangulation are important concepts in Computer Graphics because they improve
the realism of 3D objects. When a 3D object is displayed on a 2D screen, it must look natural,
smooth, and properly lit. Shading determines how light and color are applied on surfaces, while
triangulation is used to break complex surfaces into simpler geometric shapes for easier
processing.

Modern graphics systems use shading techniques and triangulation extensively in games,
simulations, CAD systems, and photorealistic rendering.

Expected Exam Question:


What is Shading? Why is it important in Computer Graphics?

SHADING MODELS
A shading model is a technique used to calculate the color and brightness of surfaces in a 3D
scene. It determines how light interacts with an object at different points. Shading improves
realism by showing depth, curvature, and surface details that cannot be seen in simple
wireframe models.

The main shading models are:

• Flat Shading
• Smooth Shading (Gouraud/Phong Shading)

Expected Exam Question:

Explain different shading models used in Computer Graphics.

REAL-WORLD EXAMPLES OF SHADING


Shading exists everywhere in real life. For example, when sunlight falls on a ball, one side
appears bright while the other side appears darker. Similarly, mountains appear brighter on the
side facing the sun and darker on the opposite side. Human faces also show shading depending
on light direction.

These natural lighting effects are replicated in computer graphics using shading models to make
objects look realistic instead of flat.

Expected Exam Question:

Give real-world examples of shading effects.

FLAT SHADING
Flat shading is the simplest shading technique. In this method, each polygon (usually a triangle)
is assigned a single color. The color is calculated using one surface normal and applied
uniformly across the entire polygon.

This means the whole surface looks flat, and no smooth transition is visible between light and
dark areas.

Flat shading is fast and easy to compute, making it suitable for low-performance systems or
applications where speed is more important than realism.

Advantages

• Very fast
• Simple implementation
• Low computational cost

Disadvantages

• Looks unrealistic
• Visible edges between polygons
• No smooth lighting effect

Expected Exam Question:

Explain Flat Shading with advantages and disadvantages.

SMOOTH SHADING
Smooth shading improves realism by calculating different colors at different points of a surface.
Instead of assigning one color to the whole polygon, smooth shading interpolates colors
between vertices.

Two common types are:

• Gouraud Shading
• Phong Shading

In Gouraud shading, lighting is calculated at vertices and then interpolated across surfaces. In
Phong shading, normals are interpolated and lighting is calculated per pixel, making it more
realistic.
Smooth shading removes the blocky appearance seen in flat shading and produces smooth
transitions of light and color.

Advantages

• Highly realistic
• Smooth surface appearance
• Better visual quality

Disadvantages

• More computation required


• Slower than flat shading

Expected Exam Question:

Differentiate between Flat Shading and Smooth Shading.

OPENGL SHADING (FLAT & SMOOTH)

OpenGL provides built-in functions to apply shading models to objects.

For flat shading, OpenGL assigns a single color per polygon. For smooth shading, it interpolates
vertex colors across surfaces.

In OpenGL, shading mode can be controlled using:

• Flat Shading: GL_FLAT


• Smooth Shading: GL_SMOOTH

Smooth shading is the default in most modern OpenGL applications because it produces more
realistic results.

Expected Exam Question:

Explain how Flat and Smooth Shading are implemented in OpenGL.


TRIANGULATION
Triangulation is the process of dividing a complex surface or polygon into triangles. Triangles
are the simplest geometric shapes used in computer graphics because any complex surface
can be approximated using triangles.

Modern GPUs are optimized to process triangles efficiently, which makes triangulation
extremely important in rendering pipelines.

For example, a curved surface like a sphere is represented using many small triangles.

Expected Exam Question:

What is Triangulation? Why is it used in Computer Graphics?

PROBLEM OF TRIANGULATION
Although triangulation simplifies rendering, it also introduces challenges. Complex surfaces may
require a large number of triangles, which increases computational cost. Poor triangulation can
also lead to visual artifacts such as distortion, cracks between surfaces, or uneven shading.

Another challenge is deciding how to divide irregular polygons into optimal triangles without
losing shape accuracy.

Expected Exam Question:

Discuss the problems associated with Triangulation.

TRIANGULATION PROCESS
The triangulation process involves breaking a polygon into multiple triangles in a structured way.
For a simple polygon, diagonal lines are drawn between vertices to form triangles. In complex
3D models, automated algorithms are used to perform triangulation efficiently.

The quality of triangulation directly affects rendering speed and visual quality.

Expected Exam Question:


Explain the process of triangulation in Computer Graphics.

TRIFOCAL TENSOR (TRITENSOR)


The trifocal tensor is a mathematical concept used in computer vision and 3D reconstruction. It
represents geometric relationships between three different views of a scene.

In simple terms, when an object is captured from three different camera positions, the trifocal
tensor helps relate those images to reconstruct 3D structure.

It is widely used in:

• 3D reconstruction
• Motion tracking
• Computer vision systems

Although advanced, it is important for understanding modern graphics and photogrammetry.

Expected Exam Question:

What is a Trifocal Tensor? Explain its role in computer vision.

PHOTOGRAMMETRY
Photogrammetry is the science of obtaining measurements and 3D information from
photographs. It is widely used to create 3D models of real-world objects using multiple images
taken from different angles.

For example, by taking photos of a building from different sides, a 3D model of that building can
be created using photogrammetry techniques.

Applications include:

• Mapping and surveying


• Architecture
• Archaeology
• Game environment creation
• Drone-based 3D modeling
Photogrammetry is an important bridge between real-world imaging and computer graphics.

Expected Exam Question:

What is Photogrammetry? Discuss its applications.

WEEK 13 – TEXTURE IN COMPUTER


GRAPHICS
Texture is an important concept in Computer Graphics that adds realism to objects. Instead of
using only color and lighting, textures provide surface details such as roughness, patterns, and
material appearance. For example, a simple cube can be made to look like wood, stone, or
fabric using texture mapping.

Textures help reduce modeling complexity because instead of creating detailed geometry, we
apply images or patterns to surfaces.

Expected Exam Question:

What is Texture in Computer Graphics? Why is it important?

Texture Applications
Textures are widely used in real-world graphics applications to improve realism without
increasing geometric complexity.

Common applications include:

• Video Games (realistic environments, characters)


• Movies and Animation (skin, cloth, surfaces)
• Virtual Reality (immersive environments)
• CAD Systems (material simulation)
• Architectural Visualization (walls, floors, tiles)

Textures make objects visually rich while keeping performance efficient.


Expected Exam Question:

Discuss applications of texture in Computer Graphics.

Texture Examples
Textures can represent many real-world surfaces such as:

• Wood grain
• Stone and marble
• Water surfaces
• Grass and soil
• Fabric patterns
• Brick walls

These textures are usually stored as images and mapped onto 3D objects.

Expected Exam Question:

Give examples of textures used in Computer Graphics.

Texture Synthesis
Texture synthesis is the process of generating a large texture image from a small sample.
Instead of storing large images, algorithms create extended textures automatically.

This is useful when high-resolution textures are required but memory is limited.

For example, a small patch of grass texture can be expanded into a full grass field texture using
synthesis techniques.

Expected Exam Question:

What is Texture Synthesis? Explain its importance.

Texture Representation Methods


Textures can be represented in different ways depending on the application. The main methods
include:

• Image-based representation
• Procedural representation
• Statistical representation

Image-based textures use stored images. Procedural textures are generated using
mathematical functions. Statistical methods describe textures using measurable properties.

Each method has its own advantages depending on realism and memory usage.

Expected Exam Question:

Explain different methods of texture representation.

Statistical Methods for Texture


Statistical methods describe textures using numerical values instead of images. These methods
analyze patterns such as intensity distribution, smoothness, and randomness.

Instead of storing every pixel, statistical methods store key features of the texture.

For example, grass texture may be described by variations in green intensity rather than storing
full image data.

Expected Exam Question:

What are Statistical Methods in Texture Representation?

Choice of Statistics
The choice of statistical features depends on the type of texture being analyzed. Different
textures require different statistical measurements.

Common statistical features include:

• Mean intensity
• Variance
• Standard deviation
• Correlation

Smooth textures use low variance, while rough textures show high variance.

Expected Exam Question:

What factors affect the choice of statistics in texture analysis?

Choice of Scale
Scale refers to the level of detail used in texture analysis. Some textures require fine-scale
analysis (small details), while others require large-scale analysis (overall pattern).

Choosing the correct scale is important because:

• Too small scale may miss global patterns


• Too large scale may ignore fine details

Proper scale selection improves accuracy in texture recognition.

Expected Exam Question:

Explain the importance of scale selection in texture analysis.

Representing Texture Using Statistics of


Filter Outputs
In this method, filters are applied to an image to extract texture features. These filters highlight
edges, patterns, and intensity changes.

After applying filters, statistical values are calculated from the output.

For example:

• Edge detection filters highlight boundaries


• Smoothing filters highlight uniform regions
The resulting statistics are used to describe the texture.

This method is widely used in image processing and computer vision.

Expected Exam Question:

How is texture represented using filter outputs?

Histogram-Based Texture Description


A histogram represents the distribution of pixel intensity values in an image. It shows how
frequently each intensity level occurs.

For texture analysis, histograms help describe brightness patterns and contrast.

For example:

• A smooth texture has a narrow histogram range


• A rough texture has a wide histogram range

Histograms are simple but effective for basic texture classification.

Expected Exam Question:

Explain Histogram-based Texture Description.

Grey Level Co-occurrence Matrix (GLCM)


GLCM is one of the most important methods for texture analysis. It considers how often pairs of
pixel values occur together in an image at a specific distance and direction.

In simple words, GLCM studies the relationship between neighboring pixels.

Basic Idea

If a pixel with intensity i is next to a pixel with intensity j, we count this occurrence.

This forms a matrix where rows and columns represent pixel intensity values.
Example Concept

If an image has gray levels 0,1,2:

GLCM records how often:

• (0,0), (0,1), (1,2), etc. occur together

Important Features Derived from GLCM:

• Contrast (difference between pixels)


• Energy (uniformity)
• Homogeneity (smoothness)
• Correlation (relationship between pixels)

Applications

• Medical imaging
• Object recognition
• Texture classification
• Remote sensing

Expected Exam Question:

What is GLCM? Explain its features and applications.

WEEK 14 – RADIOSITY, RAY TRACING &


3D OBJECT COUNTING
This week focuses on advanced rendering techniques used to create realistic images in
Computer Graphics. These techniques are mainly used when simple lighting models (like
Phong) are not enough and we need more realistic global illumination effects.

Radiosity and Ray Tracing are two important rendering methods used in high-quality graphics,
animation, and simulation systems.

RADIOSITY (Global Illumination Model)


Radiosity is a rendering technique used to calculate how light is distributed and reflected
between surfaces in a closed environment. Unlike simple lighting models that consider only
direct light, radiosity also considers indirect light (light bouncing from one surface to
another).

It is mainly used for diffuse (non-shiny) surfaces, where light is scattered evenly in all
directions.

The most important idea in radiosity is energy conservation: light energy entering a system
must be equal to light energy leaving or being absorbed.

Cornell Box (Important Concept)


The Cornell Box is a standard test environment used in computer graphics to study lighting
models like radiosity and ray tracing.

It is a simple closed box with:

• White walls
• One red wall
• One green wall
• One or more objects inside

It is used because it clearly shows:

• Light reflection

• Color bleeding (red/green light reflecting on white walls)


• Indirect lighting effects

👉 Example: If red wall reflects light, nearby white surfaces will show a faint red tint (this is
diffuse interreflection).

Expected Exam Question:

What is Cornell Box and why is it used in Radiosity?

Lighting Effects in Radiosity


Radiosity focuses on realistic lighting effects such as:
• Indirect illumination (light bouncing)
• Color bleeding between surfaces
• Soft shadows (not sharp edges)
• Real-world light distribution

This makes scenes look more natural compared to basic lighting models.

Expected Exam Question:

Explain lighting effects produced by Radiosity.

Radiosity Equation (Important)


Radiosity is based on energy exchange between surfaces:

Bᵢ = Eᵢ + ρᵢ Σ (Fᵢ◻ × B◻)

Where:

• Bᵢ = total energy leaving surface i


• Eᵢ = emitted energy
• ρᵢ = reflectivity of surface
• Fᵢ◻ = form factor (how much surface j influences i)
• B◻ = energy from other surfaces

👉 You don’t need deep solving, but understanding meaning is important.

Expected Exam Question:

Write and explain Radiosity equation.

Diffuse Interreflection
Diffuse interreflection means light reflecting from one surface and illuminating another
surface indirectly.

Example:

• Red wall reflects red light


• White floor nearby becomes slightly red

This is a key feature of radiosity and makes scenes realistic.

Expected Exam Question:

What is Diffuse Interreflection? Explain with example.

Planar Piecewise Constancy Assumption


This assumption simplifies radiosity calculations.

It assumes:

• Each surface (polygon/patch) has constant lighting across its entire area
• No variation within a single plane

This makes calculations easier because each surface can be treated as a single unit instead of
infinite points.

Expected Exam Question:

What is Planar Piecewise Constancy Assumption in Radiosity?

Conservation of Energy (Very Important)

Radiosity is based on a physical law:

👉 Energy is neither created nor destroyed, only transferred or reflected.

In graphics:

• Light hitting surfaces must be equal to light leaving + absorbed light

This ensures realistic rendering and physically correct illumination.

Expected Exam Question:

Explain Conservation of Energy in Radiosity.


RAY TRACING
Ray tracing is a rendering technique that simulates the path of light rays in reverse
direction—from the camera into the scene.

Instead of calculating light from surfaces, ray tracing traces rays from the viewer and checks:

• Which object is hit?


• How light interacts with that object?

It produces very realistic images.

Working of Ray Tracing


• A ray is cast from the eye (camera)
• It travels into the scene
• It hits an object
• Color is calculated using:
• Light source
• Reflection
• Refraction
• Shadows

This process is repeated for every pixel.

Expected Exam Question:

Explain the working of Ray Tracing.

Effects in Ray Tracing


Ray tracing produces highly realistic effects such as:

• Sharp shadows
• Reflections (mirror-like surfaces)
• Refraction (glass, water bending light)
• Global illumination (advanced systems)
Expected Exam Question:

Discuss the effects produced by Ray Tracing.

Ray Tracing vs Radiosity (Important Comparison)

Feature Ray Tracing Radiosity

Type View-dependent View-independent

Best for Specular Diffuse surfaces


surfaces

Light model Light rays Energy transfer

Realism Very high High (diffuse scenes)

Speed Slow Slow (precompute


heavy)

Expected Exam Question:

Differentiate between Ray Tracing and Radiosity.

PHONG SHADING
Phong Shading is a technique used to make surfaces look smooth by calculating lighting at
every pixel instead of every vertex.

It is more accurate than Gouraud shading because lighting is computed per pixel.

Working Idea:

• Surface normals are interpolated


• Lighting is calculated for each pixel
• Produces smooth highlights
Advantages:

• Very realistic
• Smooth shading
• Better highlights

Expected Exam Question:

Explain Phong Shading and its advantages.

COUNTING OBJECTS IN 3D IMAGE


(IMAGE PROCESSING STEPS)
This is a practical image processing technique used to detect and count objects in a 3D or
digital image.

Step 1: Read the Image

First step is to load the image into the system for processing.

Example: Image of multiple objects like coins, cells, or particles.

Step 2: Convert Image to Grayscale


Color image is converted into grayscale to simplify processing.

Grayscale uses intensity values instead of RGB, making calculations easier.

Step 3: Threshold the Image


Thresholding converts image into binary form:
• Black = background
• White = object

Formula idea:
If pixel intensity > threshold → object (1)
Else → background (0)

Step 4: Complement the Image


Image complement inverts pixel values:

• Black becomes white


• White becomes black

This helps in improving object visibility.

Step 5: Find Boundaries of Objects


Boundary detection is used to separate individual objects.

Common techniques:

• Edge detection
• Contour detection

This step identifies object shapes clearly.

Step 6: Results
After processing:

• Objects are counted


• Boundaries are marked
• Final output shows number of objects
MATLAB Code (Simple Exam-Friendly Version)
img = imread('[Link]');

gray = rgb2gray(img);

bw = imbinarize(gray);

bw2 = imcomplement(bw);

[B,L] = bwboundaries(bw2, 'noholes');

imshow(bw2);

hold on;

for k = 1:length(B)

boundary = B{k};

plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 2);

end

title('Detected Objects');

👉 Key idea: MATLAB counts objects using connected components and boundaries.

WEEK 15 – IMAGE SEGMENTATION


Image segmentation is one of the most important topics in image processing and computer
vision. It refers to the process of dividing an image into meaningful parts or regions so that it
becomes easier to analyze. Instead of working on the whole image at once, segmentation
breaks it into smaller components like objects, boundaries, or regions with similar properties.

In simple words, segmentation helps a computer understand “what is where” in an image. For
example, separating a human from the background or detecting different organs in a medical
image.

What is Segmentation?
Segmentation is the process of partitioning an image into multiple segments (regions) where
each region contains pixels with similar attributes such as color, intensity, or texture.

The main goal is to simplify image representation for easier analysis.

Mathematically, segmentation divides an image I(x, y) into regions:

• R1, R2, R3 ... Rn


where each region satisfies a similarity condition.

Expected Exam Question:

What is Image Segmentation? Explain its purpose.

Segmentation Applications
Image segmentation is widely used in real-world applications where automatic analysis of
images is required.

Main Applications:

• Medical Imaging: Detecting tumors, organs, or fractures in X-rays and MRI scans
• Autonomous Vehicles: Detecting roads, pedestrians, and obstacles
• Face Recognition: Separating face region from background
• Satellite Imaging: Land use classification (water, forest, urban areas)
• Industrial Inspection: Detecting defects in manufactured products
• Video Editing: Background removal and object extraction

Segmentation is basically the foundation of intelligent visual systems.

Expected Exam Question:


Discuss applications of image segmentation.

HUMAN VISION AND GESTALT THEORY


Human vision plays a major role in how segmentation algorithms are designed. The human
brain naturally groups visual elements into meaningful patterns. This idea is explained by
Gestalt Theory.

Gestalt theory states that “the whole is greater than the sum of its parts,” meaning humans do
not see individual pixels but instead perceive complete objects.

Grouping and Gestalt Principles


Grouping refers to how the human brain organizes visual elements into structured forms. Even if
an image is incomplete, the brain tries to complete it.

Major Gestalt Factors:

• Proximity

Objects that are close to each other are perceived as a group.

• Similarity

Objects that look similar (shape, color, size) are grouped together.

• Continuity

The human eye prefers smooth continuous patterns instead of broken ones.

• Closure

The brain fills missing parts to form a complete object.

Expected Exam Question:

Explain Gestalt principles in image segmentation.


Parallel Curves
Parallel curves are curves that run side by side and are perceived as related structures by the
human brain. In segmentation, parallel curves help identify boundaries of objects like roads,
edges, or shapes in images.

Symmetric Groups
Symmetry is a strong visual cue in human perception. Objects that are symmetric are easily
recognized as single entities.

For example:

• Human face
• Circles
• Buildings

Symmetry helps segmentation algorithms identify object regions more accurately.

Continuous Curves
The human visual system naturally connects broken edges into continuous curves. Even if parts
of a boundary are missing, the brain completes them.

This property is used in computer vision to reconstruct object boundaries.

Closure Curves
Closure means the brain fills gaps in incomplete shapes to perceive a complete object.

For example, even if a circle is not fully drawn, humans still recognize it as a circle.

This concept is heavily used in edge detection and segmentation algorithms.

Expected Exam Question:

Explain Closure in Gestalt theory with examples.


Visual Illusions
Visual illusions occur when the brain misinterprets visual information. They reveal how human
perception can be influenced by patterns, contrast, and context.

Examples:

• Müller-Lyer Illusion: Lines of equal length appear different due to arrow shapes
• Ebbinghaus Illusion: Same sized circles appear different due to surrounding circles
• Kanizsa Triangle: A triangle is perceived even when it is not fully drawn

These illusions help researchers understand human perception and improve segmentation
algorithms.

Expected Exam Question:

What are visual illusions? Give examples.

SIMPLE SEGMENTATION TECHNIQUES


These are basic methods used to divide images into meaningful regions.

Background Subtraction
Background subtraction is used to separate moving objects from a static background.

It works by comparing the current image with a reference background image.

Formula idea:

Foreground = Current Image – Background Image

If a pixel changes significantly, it is considered part of the object.

Applications:

• CCTV surveillance
• Motion detection
• Traffic monitoring

Expected Exam Question:

Explain Background Subtraction technique.

Shot Boundary Detection


Shot boundary detection is used in video processing to detect changes between two scenes
(shots).

When a scene changes, pixel intensity differences become large.

It is commonly used in:

• Video editing
• Movie indexing
• Content summarization

Expected Exam Question:

What is Shot Boundary Detection? Explain its use.

Segmentation by Clustering

In this method, pixels are grouped based on similarity using clustering algorithms.

Pixels with similar color or intensity are placed into the same cluster.

Common method:

• K-Means Clustering

Steps:

• Choose number of clusters (K)


• Assign pixels to nearest cluster center
• Update cluster centers
• Repeat until stable
Advantages:

• Simple and effective


• Works well for color-based segmentation

Expected Exam Question:

Explain segmentation using clustering.

Displaying Objects in Segmented Image


After segmentation, each region is assigned a label or color so that objects become visually
distinct.

For example:

• Object 1 → Red
• Object 2 → Blue
• Background → Black

This helps in analyzing image structure clearly.

Detecting a Cell Using Segmentation


In medical image processing, segmentation is used to detect cells in microscopic images.

Process:

• Convert image to grayscale


• Apply thresholding
• Separate cell regions
• Remove noise
• Label individual cells

This technique is widely used in medical diagnosis, especially in cancer detection and blood
analysis.

Expected Exam Question:

How can image segmentation be used to detect cells?


WEEK 16 – UNITY 3D & C# SCRIPTING
Unity 3D is a powerful and widely used game development engine that allows developers to
create 2D and 3D games, simulations, and interactive applications. It provides a complete
environment where graphics, physics, animation, audio, and scripting are combined together.

Unity uses C# (C Sharp) as its primary scripting language, which allows developers to control
game behavior, objects, movement, physics, and interactions.

Unity is popular because it is beginner-friendly, cross-platform, and widely used in the gaming
industry.

Expected Exam Question:

What is Unity 3D? Explain its importance in game development.

Introduction to Unity 3D
Unity 3D is a game engine developed to simplify the process of building interactive applications.
It provides a visual editor where developers can drag and drop objects, design scenes, and
apply physics without writing everything from scratch.

Unity supports:

• 2D Game Development
• 3D Game Development
• Virtual Reality (VR)
• Augmented Reality (AR)
• Simulation Systems

A Unity project consists of Scenes, and each scene contains game objects like characters,
cameras, lights, and environments.

Key Components of Unity:

• Game Objects (basic building blocks)


• Components (scripts, physics, rendering)
• Scenes (levels or environments)
• Assets (models, textures, audio, scripts)

Expected Exam Question:

Explain the basic components of Unity 3D.

Unity Game Object Concept


Everything in Unity is a Game Object. A Game Object itself does nothing until components are
attached to it.

For example:
A car in a game is a Game Object, but its movement comes from scripts, its shape comes from
3D models, and its physics comes from Rigidbody components.

This modular system makes Unity flexible and easy to use.

Expected Exam Question:

What is a Game Object in Unity? Explain with example.

Components in Unity
Components define the behavior of Game Objects. A single Game Object can have multiple
components.

Common components include:

• Transform (position, rotation, scale)


• Mesh Renderer (visual appearance)
• Rigidbody (physics behavior)
• Collider (collision detection)
• Script Component (C# behavior)

The Transform component is present in every Game Object by default.

Expected Exam Question:


Explain different components used in Unity 3D.

Unity Scene System


A Scene is a collection of Game Objects arranged in a specific environment.

For example:

• Main Menu Scene


• Level 1 Scene
• Game Over Scene

Scenes help organize large games into manageable parts.

Only one or multiple scenes can run at a time depending on design.

Expected Exam Question:

What is a Scene in Unity? Why is it important?

Introduction to Scripting in Unity (C#)


Unity uses C# scripting to control game behavior. Scripts are attached to Game Objects and
define how they behave during gameplay.

Scripts are used for:

• Player movement
• Enemy AI
• Collision detection
• Scoring system
• Game logic

Unity scripts are written using MonoBehaviour class, which provides built-in functions like
Start() and Update().

Expected Exam Question:


What is scripting in Unity? Why is C# used?

Basic Unity Script Structure (C#)


A basic Unity script looks like this:

using UnityEngine;

public class PlayerMovement : MonoBehaviour

void Start()

// Runs once when game starts

void Update()

// Runs every frame

Explanation:

• Start() → Runs only once at the beginning


• Update() → Runs continuously every frame
• MonoBehaviour → Base class for Unity scripts

Expected Exam Question:

Explain the basic structure of a Unity C# script.


Transform Control in Unity (Mathematical
Part)
Movement in Unity is controlled using the Transform component.

Position is represented as:

(x, y, z)

Example movement formula in Unity:

[Link] += new Vector3(1, 0, 0);

This moves the object along the X-axis.

Rotation is controlled using degrees:

[Link](0, 90, 0);

Scaling is controlled using:

[Link] = new Vector3(2, 2, 2);

Key Idea:

Unity internally uses vector mathematics for movement and transformation.

Expected Exam Question:

How does Unity handle object transformation? Explain with examples.

Input Handling in Unity


Unity allows interaction using keyboard and mouse inputs.

Example:

void Update()
{

if([Link](KeyCode.W))

[Link] += [Link];

Explanation:

• [Link]() detects key press


• [Link] moves object forward

Mouse input example:

if([Link](0))

[Link]("Mouse Clicked");

Expected Exam Question:

Explain input handling in Unity with examples.

Physics in Unity
Unity has a built-in physics engine that simulates real-world behavior.

Important physics components:

• Rigidbody (gravity, mass, velocity)


• Collider (collision detection)

Example:
When a ball falls, Rigidbody applies gravity automatically.

Collision detection example:

void OnCollisionEnter(Collision collision)

[Link]("Collision Detected");

Expected Exam Question:

What is physics system in Unity? Explain Rigidbody and Collider.

Game Loop Concept


Unity works on a continuous loop called the Game Loop.

Main functions:

• Start() → Initialization
• Update() → Frame updates
• FixedUpdate() → Physics updates
• LateUpdate() → After Update processing

This loop runs until the game is closed.

Expected Exam Question:

Explain the Game Loop in Unity.

Advantages of Unity 3D
Unity is widely used because:
• Easy to learn
• Supports multiple platforms (Windows, Android, iOS, Web)
• Strong community support
• Built-in physics engine
• Powerful rendering system
• C# scripting is simple and efficient

Expected Exam Question:

Discuss advantages of Unity 3D.

Applications of Unity 3D
Unity is used in:

• Video Games
• VR/AR Applications
• Simulation Systems
• Architectural Visualization
• Educational Software
• Animation Projects

Expected Exam Question:

Write applications of Unity 3D.

You might also like