0% found this document useful (0 votes)
18 views

21CS63 Computer Graphics and Fundamentals of Image Processing

Uploaded by

ozsa21cs
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

21CS63 Computer Graphics and Fundamentals of Image Processing

Uploaded by

ozsa21cs
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

VTU Question Paper - Solutions

Sub Computer Graphics and Fundamentals of Image


Sub Code: 21CS63 Branch: CSE
: Processing

MARK
Solution
S
1 (a) 10 M

a. Graphs and Charts


​ An early application for computer graphics is the display of simple data
graphs usually plotted on a character printer. Data plotting is still one of the
most common graphics application.

​ Graphs & charts are commonly used to summarize functional, statistical,


mathematical, engineering and economic data for research reports,
managerial summaries and other types of publications.

​ Typically examples of data plots are line graphs, bar charts, pie charts,
surface graphs, contour plots and other displays showing relationships
between multiple parameters in two dimensions, three dimensions, or
higher-dimensional spaces
✓ Computer-Aided Design

✓ A major use of computer graphics is in design processes-particularly for


engineering and architectural systems.
​ CAD, computer-aided design or CADD, computer-aided drafting and design
methods are now routinely used in the automobiles, aircraft, spacecraft,
computers, home appliances.

​ Circuits and networks for communications, water supply or other utilities are
constructed with repeated placement of a few geographical shapes.

​ Animations are often used in CAD applications. Real-time, computer animations


using wire-frame shapes are useful for quickly testing the performance of a
vehicle or system.

c. Data Visualizations
✓ Producing graphical representations for scientific, engineering and medical data
sets and processes is another fairly new application of computer graphics, which
is generally referred to as scientific visualization. And the term business
visualization is used in connection with data sets related to commerce, industry
and other nonscientific areas.

(b) 10M
Display-Window Management Using GLUT

✓ We can consider a simplified example, minimal number of operations for displaying a

picture.

Step 1: initialization of GLUT

 We are using the OpenGL Utility Toolkit, our first step is to initialize GLUT.

 This initialization function could also process any command line arguments, but we
will not need to use these parameters for our first example programs.

 We perform the GLUT initialization with the statement

glutInit (&argc, argv);

Step 2: title

 We can state that a display window is to be created on the screen with a given
caption for the title bar. This is accomplished with the function

glutCreateWindow ("An Example OpenGL Program");

 where the single argument for this function can be any character string that we want
to

use for the display-window title.

Step 3: Specification of the display window

 Then we need to specify what the display window is to contain.

 For this, we create a picture using OpenGL functions and pass the picture definition
to the GLUT routine glutDisplayFunc, which assigns our picture to the display window.
 Example: suppose we have the OpenGL code for describing a line segment in a
procedure called lineSegment.

 Then the following function call passes the line-segment description to the display
window:

glutDisplayFunc (lineSegment);

Step 4: one more GLUT function

 But the display window is not yet on the screen.

 We need one more GLUT function to complete the window-processing operations.

 After execution of the following statement, all display windows that we have
created, including their graphic content, are now activated:

2 (b) 10 M
✓ In windows to include OpenGL core libraries and GLU we can use the following
header files:-

#include <windows.h> //precedes other header files for including Microsoft windows ver
of OpenGL libraries

#include<GL/gl.h> #include <GL/glu.h>


✓ The above lines can be replaced by using GLUT header file which ensures gl.h and
glu.h are included correctly,

✓ #include <GL/glut.h> //GL in windows

✓ In Apple OS X systems, the header file inclusion statement will be, ✓ #include
<GLUT/glut.h>

Display-Window Management Using GLUT

✓ We can consider a simplified example, minimal number of operations for displaying a

picture.

Step 1: initialization of GLUT

 We are using the OpenGL Utility Toolkit, our first step is to initialize GLUT.

 This initialization function could also process any command line arguments, but we
will not need to use these parameters for our first example programs.

 We perform the GLUT initialization with the statement

glutInit (&argc, argv);

Step 2: title

 We can state that a display window is to be created on the screen with a given
caption for the title bar. This is accomplished with the function

glutCreateWindow ("An Example OpenGL Program");

 where the single argument for this function can be any character string that we want
to

use for the display-window title.

Step 3: Specification of the display window

 Then we need to specify what the display window is to contain.

 For this, we create a picture using OpenGL functions and pass the picture definition
to the GLUT routine glutDisplayFunc, which assigns our picture to the display window.
 Example: suppose we have the OpenGL code for describing a line segment in a
procedure called lineSegment.

 Then the following function call passes the line-segment description to the display
window:

glutDisplayFunc (lineSegment);

Step 4: one more GLUT function

 But the display window is not yet on the screen.

 We need one more GLUT function to complete the window-processing operations.

 After execution of the following statement, all display windows that we have
created, including their graphic content, are now activated:

glutMainLoop ( );

 This function must be the last one in our program. It displays the initial graphics and
puts the program into an infinite loop that checks for input from devices such as a mouse
or keyboard.

Step 5: these parameters using additional GLUT functions

 Although the display window that we created will be in some default location and
size,

we can set these parameters using additional GLUT functions.

3. a. Need for Homogenous Coordinate System:


• Multiplicative and translational terms for a two-dimensional geometric
transformation can be combined into a single matrix if we expand the
representations to 3 × 3 matrices
• We can use the third column of a transformation matrix for the translation terms, and
all transformation equations can be expressed as matrix multiplications.
P’=M.P
• P’=M. P (general form) M- Transformation Matrix
• A standard technique for accomplishing to expand each two dimensional
coordinate-position representation (x, y) to a three-element representation (xh,
yh, h), called homogeneous coordinates, where the homogeneous parameter h
is a nonzero value such that

Translation:
3. b

Scaling – Pivot Point


4. a.
4.b. 3-D Transformation Matrix:
Translation:

Rotation:
Scaling:
5.a.
5. b USING POINTING DEVICES
• Pointing devices like mouse, trackball, data tablet allow programmer to indicate a position
on the display.
• There are two types of event associated with pointing device, which is conventionally
assumed to be mouse but could be trackball or data tablet also.
• MOVE EVENT – is generated when the mouse is move with one of the button
being pressed. If the mouse is moved without a button being pressed, this event is
called as “passive move event”.
• MOUSE EVENT – is generated when one of the mouse buttons is either pressed or
released.
• The information returned to the application program includes button that
generated the event, state of the button after event (up or down), position
(x,y) of the cursor. Programming a mouse event involves two steps:
6.a
Design of Animation Sequences
Animation sequence in general is designed in the following steps.

1. Storyboard layout

2. Object definitions.

3. Key-frame specifications
4. Generation of in-between frames.

● This approach of carrying out animations is applied to any other applications as


well, although some applications are exceptional cases and do not follow this
sequence.
● For frame-by-frame animation, every frame of the display or scene is generated
separately and stored. Later, the frame recording can be done and they might be
displayed consecutively in terms of movie.
● The outline of the action is storyboard. This explains the motion sequence. The
storyboard consists of a set of rough structures or it could be a list of the basic
ideas for the motion.
● For each participant in the action, an object definition is given. Objects are
described in terms of basic shapes the examples of which are splines or polygons.
The related movement associated with the objects are specified along with the
shapes.
● A key frame in animation can be defined as a detailed drawing of the scene at a
certain time in the animation sequence. Each object is positioned according to the
time for that frame, within each key frame.
● Some key frames are selected at extreme positions and the others are placed so
that the time interval between two consecutive key frames is not large. Greater
number of key frames are specified for smooth motions than for slow and varying
motion.
● And the intermediate frames between the key frames are In-betweens. And the
Media that we use determines the number of In-betweens which are required to
display the animation. A Film needs 24 frames per second, and graphics terminals
are refreshed at the rate of 30 to 60 frames per second
● Depending on the speed specified for the motion, some key frames are duplicated.
For a one minutes film sequence with no duplication, we would require 288 key
frames. We place the key frames a bit distant if the motion is not too complicated.
● A number of other tasks may be carried out depending upon the application
requirement for example synchronization of a sound track.

OpenGL Animation Procedures


Double-buffering operations, if available, are activated using the following GLUT command:
glutInitDisplayMode (GLUT_DOUBLE);
This provides two buffers, called the front buffer and the back buffer, that we can use alternately
to refresh the screen display
We specify when the roles of the two buffers are to be interchanged using
glutSwapBuffers ( );
To determine whether double-buffer operations are available on a system, we can issue the
following query:
glGetBooleanv (GL_DOUBLEBUFFER, status);

A value of GL_TRUE is returned to array parameter status if both front and back buffers are
available on a system. Otherwise, the returned value is GL _FALSE.

For a continuous animation, we can also use


glutIdleFunc (animationFcn);
This procedure is continuously executed whenever there are no display-window events that must
be processed.
To disable the glutIdleFunc, we set its argument to the value NULL or the value 0.
6 b.
7 a. Digital image processing is an area that uses digital circuits, systems, and software
algorithms to carry out the image processing operations. The image processing operations
may include quality enhancement of an image, counting of objects, and image analysis.
Digital image processing has become very popular now, as digital images have many
advantages over analog images. Some of the advantages are as follows:
7 b.
7 c.

The shortest m path is 1–1–1–1, So, Dm = 3

8 a. So interpolation techniques are required to solve these issues.


8 b.
9 a. Image segmentation has emerged as an important phase in image-based applications.
Segmentation is the process of partitioning a digital image into multiple regions and
extracting a meaningful region known as the region of interest (ROI). Regions of interest
vary with applications. For example, if the goal of a doctor is to analyse the tumour in a
computer tomography (CT) image, then the tumour in the image is the ROI.
9 b.
10 a. i.
ii.
10 b.
3 (a) With a neat diagram, explain Bresenham’s line drawing algorithm for slope >1 5M
Bresenham’s Algorithm:

➔ It is an efficient raster scan generating algorithm that uses incremental integral


calculations
➔ To illustrate Bresenham’s approach, we first consider the scan-conversion
process for lines with positive slope less than 1.0.

➔ Pixel positions along a line path are then determined by sampling at unit x intervals.
Starting from the left endpoint (x0, y0) of a given line, we step to each successive
column (x position) and plot the pixel whose scan-line y value is closest to the line
path.

➔ Consider the equation of a straight line y=mx+c where m=dy/dx

Bresenham’s Line-Drawing Algorithm for |m| > 1.0


1. Input the two line endpoints and store the left endpoint in (x0, y0).
2. Set the color for frame-buffer position (x0, y0); i.e., plot the first point.
3. Calculate the constants ∆x, ∆y, 2∆y, and 2∆y − 2∆x, and obtain the starting
value for
the decision parameter as
p0 = 2∆x −∆y
4. At each xk along the line, starting at k = 0, perform the following test:
If pk < 0, the next point to plot is (xk + 1, yk ) and
pk+1 = pk + 2∆x
Otherwise, the next point to plot is (xk + 1, yk + 1) and
pk+1 = pk + 2∆x − 2∆y
5. Repeat step 4 ∆y − 1 more times.

CI CCI HOD

You might also like