Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Computer Graphics Question Bank

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

S.

No Questions
1 What is computer Graphics and what Write the applications of computer graphics?
Ans.
It is the use of computers to create and manipulate pictures on a display device. It comprises of software techniques to create, store, modify, represents
pictures.
Application of computer Graphics.
1. Education and Training: Computer-generated model of the physical, financial and economic system is often used as educational aids.
2. Computer-Generated Maps: Town planners and transportation engineers can use computer-generated maps which display data useful to them
in their planning work.
3. Presentation Graphics: Example of presentation Graphics are bar charts, line graphs, pie charts and other displays showing relationships
between multiple parameters.
4. Computer Art: Computer Graphics are also used in the field of commercial arts. It is used to generate television and advertising commercial.
5. Entertainment: Computer Graphics are now commonly used in making motion pictures, music videos, and television shows.
6. Visualization: It is used for visualization of scientists, engineers, medical personnel, and business analysts for the study of a large amount of
information.
7. Printing Technology: Computer Graphics is used for printing technology and textile design.

2 What do you mean by Random scan display and Raster scan display? Write the differences between them?
Ans.
1. Random Scan Display:
Random scan display, also known as vector display, is a display technology that uses a beam of electrons to draw lines directly on the screen. The
electron beam is guided by a set of instructions that specify the starting and ending points of each line, as well as its thickness and color. Random
scan displays were commonly used in the past for high-performance graphics applications such as CAD, but have largely been replaced by raster
scan displays.
2. Raster Scan Display:
Raster scan display, also known as bitmap display, is a display technology that divides the screen into a grid of small rectangular pixels, each of
which can be individually controlled to display a specific color. The display is created by scanning the electron beam across the screen from left
to right and top to bottom, illuminating each pixel in turn. Raster scan displays are commonly used in modern computer graphics applications,
including computer monitors, televisions, and mobile devices.

Differences between by Random scan display and Raster scan display.

Random Scan Raster Scan

1. It has high Resolution 1. Its resolution is low.

2. It is more expensive 2. It is less expensive

3. Any modification if 3.Modification is tough


needed is easy

4. Solid pattern is tough to 4.Solid pattern is easy to fill


fill

5. Refresh rate depends or 5. Refresh rate does not


resolution depend on the picture.

6. Only screen with view on 6. Whole screen is scanned.


an area is displayed.

7. Beam Penetration 7. Shadow mark technology


technology come under it. came under this.
3 Explain DDA line drawing algorithm with example? Write the advantages and disadvantages of DDA line drawing algorithm?
Ans.
DDA line algorithm:
DDA (Digital Differential Analyzer) algorithm is a line drawing algorithm used to draw a line between two given points on a computer screen. It is a
simple and efficient algorithm that uses the concept of the slope of a line to calculate the next pixel position.
Step1: Start Algorithm
Step2: Declare x1,y1,x2,y2,dx,dy,x,y as integer variables.
Step3: Enter value of x1,y1,x2,y2.
Step4: Calculate dx = x2-x1
Step5: Calculate dy = y2-y1
Step6: If ABS (dx) > ABS(dy)
Then step = abs(dx)
Else
Step7: Xinc =dx/step
Yinc=dy/step
Assign x=x1
Assign Y=y1
Step8: Set pixel (x, y)
Step9: X= x+ Xinc
Y= y + Yinc
Step10: Repeat step 9 until x = x2
Step11: End Algorithm
Example: If a line is drawn from (2, 3) to (6, 15) with use of DDA. How many points will needed to generate such line?
Solution: P1 (2,3) P11 (6,15)
X1=2 y1=3 x2=6 y2=15
Calculate the slope of the line (m) using the two given end points (2, 3) and (6, 15) of the line:
dx = 6 -2=4
dy=15-3=12
m=dy/dx=12/4=3

For calculating next value of x takes x = x +

Advantage:

1. It is a faster method than method of using direct use of line equation.


2. This method does not use multiplication theorem.
3. It allows us to detect the change in the value of x and y ,so plotting of same point twice is not possible.
4. This method gives overflow indication when a point is repositioned.
5. It is an easy method because each step involves just two additions.

Disadvantage:

1. It involves floating point additions rounding off is done. Accumulations of round off error cause accumulation of error.
2. Rounding off operations and floating point operations consumes a lot of time.
3. It is more suitable for generating line using the software. But it is less suited for hardware implementation.

4 Explain Bresenham’s line drawing algorithm with example? Write the advantages and disadvantages of Bresenham’s line drawing algorithm?
Ans.
Bresenham’s line drawing algorithm:
The Bresenham algorithm is another incremental scan conversion algorithm. The big advantage of this algorithm is that, it uses only integer
calculations. Moving across the x axis in unit intervals and at each step choose between two different y coordinates.
Step 1: start algorithm
Step 2 : Declare p, q, x, y, r, d variables
p, q are coordinates of the center of the circle
r is the radius of the circle
Step3: Enter the value of r
Step4: Calculate d = 3 - 2r
Step5: Initialize x=0
&nbsy= r
Step6: Check if the whole circle is scan converted
If x > = y
Stop
Step7: Plot eight points by using concepts of eight-way symmetry. The center is at (p, q). Current active pixel is (x, y).
putpixel (x+p, y+q)
putpixel (y+p, x+q)
putpixel (-y+p, x+q)
putpixel (-x+p, y+q)
putpixel (-x+p, -y+q)
putpixel (-y+p, -x+q)
putpixel (y+p, -x+q)
putpixel (x+p, -y-q)
Step8: Find location of next pixels to be scanned
If d < 0
then d = d + 4x + 6
increment x = x + 1
If d ≥ 0
then d = d + 4 (x - y) + 10
increment x = x + 1
decrement y = y – 1

Step9: Go to step 6

Step10: Stop Algorithm

Example: Plot 6 points of circle using Bresenham Algorithm. When radius of circle is 10 units. The circle has centre (50, 50).
Solution: Let r = 10 (Given)
Step1: Take initial point (0, 10)
d = 3 - 2r
d = 3 - 2 * 10 = -17
d < 0 ∴ d = d + 4x + 6
= -17 + 4 (0) + 6
= -11
Step2: Plot (1, 10)
d = d + 4x + 6 (∵ d < 0)
= -11 + 4 (1) + 6
= -1
Step3: Plot (2, 10)
d = d + 4x + 6 (∵ d < 0)
= -1 + 4 x 2 + 6
= 13
Step4: Plot (3, 9) d is > 0 so x = x + 1, y = y - 1
d = d + 4 (x-y) + 10 (∵ d > 0)
= 13 + 4 (3-9) + 10
= 13 + 4 (-6) + 10
= 23-24=-1
Step5: Plot (4, 9)
d = -1 + 4x + 6
= -1 + 4 (4) + 6
= 21
Step6: Plot (5, 8)
d = d + 4 (x-y) + 10 (∵ d > 0)
= 21 + 4 (5-8) + 10
= 21-12 + 10 = 19
So P1 (0,0)⟹(50,50)
P2 (1,10)⟹(51,60)
P3 (2,10)⟹(52,60)
P4 (3,9)⟹(53,59)
P5 (4,9)⟹(54,59)
P6 (5,8)⟹(55,58)
Advantages:

1. It is a highly efficient algorithm that uses only integer arithmetic operations, making it faster than other line drawing algorithms that require floating-point
operations.
2. It is easy to implement and requires less memory, making it suitable for low-level programming environments.
3. It produces accurate and visually appealing lines, even for steep lines and low-resolution displays.
4. The algorithm can be extended to draw circles, ellipses, and other curved shapes using the same approach.
Disadvantages :
1. It can only draw lines with slopes between 0 and 1, making it unsuitable for drawing lines with slopes greater than 1 or less than 0.
2. It does not produce perfectly straight lines and may produce jagged or uneven lines, especially at high slopes.
3. It may introduce rounding errors that accumulate over time, causing the line to drift or jitter slightly with each iteration.
4. The algorithm does not support anti-aliasing, making it unsuitable for producing high-quality, smooth images.
5. The algorithm is not suitable for curves and complex shapes, requiring other algorithms to handle these shapes.
5 Explain mid point line drawing algorithm with example? Write the advantages and disadvantages mid point line drawing algorithm?
Ans.
MidPoint Circle Algorithm:
Midpoint line drawing algorithm is a popular and efficient algorithm used for rasterization of lines in computer graphics. It works by determining the pixels closest to
the true line path to draw the line.
Step1: Put x =0, y =r in equation 2
We have p=1-r
Step2: Repeat steps while x ≤ y
Plot (x, y)
If (p<0)
Then set p = p + 2x + 3
Else
p = p + 2(x-y)+5
y =y - 1 (end if)
x =x+1 (end loop)
Step3: End
Example:
Suppose we want to draw a line between two endpoints, (2, 3) and (6, 9).
X0=2 , x1=6 , y0=3 ,y1=9
1. Calculate the slope of the line:

m = (y1 - y0) / (x1 - x0) = (9 - 3) / (6 - 2) = 1.5

2. Since the slope is less than 1, we can use the x-axis as the dominant axis and increment x in each step.

3. Calculate the decision parameter (d) using the formula:

d = 2 * dy - dx = 2 * (y1 - y0) - (x1 - x0) = 2 * 6 - 4 = 8

4. Set the initial values of x and y coordinates to (2, 3).

5. Draw the starting pixel at (2, 3).

6. For each step along the x-axis from x0 to x1:

At x = 3: d = 8 - 2 * (9 - 3) = -4, so move to the next pixel at (3, 4) and increment d by 2 * (9 - 3) = 12.
At x = 4: d = 12 - 2 * (9 - 3) = 0, so move to the next pixel diagonally at (4, 5) and increment d by 2 * (9 - 3) - (6 - 2) = 8.
At x = 5: d = 8 - 2 * (9 - 3) = -4, so move to the next pixel at (5, 6) and increment d by 2 * (9 - 3) = 12.
At x = 6: d = 12 - 2 * (9 - 3) = 0, so move to the next pixel diagonally at (6, 7) and increment d by 2 * (9 - 3) - (6 - 2) = 8.
7.
The last pixel (6, 9) has been reached, so the line has been drawn.
8.
Points :
2, 3
3,4
4,5
5,6
6,7
Advantage:
1. Efficiency: The algorithm is very efficient as it uses only integer arithmetic operations, which are faster and less computationally expensive than
floating-point operations.

2. Accuracy: The algorithm produces straight and accurate lines without jagged edges, regardless of the slope of the line.

3. Flexibility: The algorithm can be easily adapted to draw lines of any thickness, style or color.

4. Simplicity: The algorithm is relatively simple and easy to understand and implement.

Disadvantages:

1. Limited to straight lines: The algorithm can only be used to draw straight lines and cannot be used for curves or other complex shapes.

2. Requires integer coordinates: The algorithm only works with integer coordinates, which can limit the precision of the drawn line.

3. Limited to positive slopes: The algorithm only works for lines with positive slopes, and requires additional processing to handle lines with
negative slopes.

4. Aliasing: The algorithm can produce aliasing effects, especially when drawing thin lines, which can cause the lines to appear jagged or distorted.
6 What do you mean by point and line?
Ans.
Points
a point is a simple geometric primitive that represents a single location in two or three-dimensional space. A point is typically represented by a coordinate pair (x,y) in
two-dimensional space, or by a triplet (x,y,z) in three-dimensional space. A point has no size or shape and is often used as a basic building block for more complex
geometric objects, such as lines, curves, and shapes.
Line:
A line is another fundamental geometric primitive in computer graphics, representing a straight path between two points. A line is defined by two points, called
endpoints, and can be described by a mathematical equation in the form y = mx + b, where m is the slope of the line and b is the y-intercept. In computer graphics,
lines can be used to create a variety of shapes, such as polygons and curves, and are often used to create outlines or contours of objects.
7 What do you mean by frame buffer and video controller?
Ans.
Frame:
A frame buffer is a dedicated area of memory in a computer or other electronic device that stores the graphical image or video data that is being
displayed on the screen. The frame buffer holds the information for every pixel on the screen, including color, brightness, and other attributes. The
frame buffer is used by the video controller to quickly refresh the display and show new frames of video or graphical images.
Vedio Controller:
A video controller is an electronic circuit that is responsible for generating and sending video signals to a display device, such as a computer monitor,
television, or projector. The video controller reads data from the frame buffer and converts it into the signals that are needed to display the images on
the screen. The video controller may also have other functions, such as scaling or transforming the image, adjusting the color or brightness, and
performing other image processing operations. The video controller is an essential component in any computer or device that displays video or graphical
images on a screen.
8 Draw the line between the starting coordinates (5, 9) and ending coordinates (12, 16) using the mid-point line drawing algorithm?
Ans.
Given-
 Starting coordinates = (X0, Y0) = (5, 9)
 Ending coordinates = (Xn, Yn) = (12, 16)
Step-01:

Calculate ΔX and ΔY from the given input.


 dX = Xn – X0 = 12 – 5 = 7
 dY =Yn – Y0 = 16 – 9 = 7
Step-02:

Calculate Dinitial and ΔD as-


 Dinitial = 2dY – dX = 2 x 7 – 7 = 7
 ΔD = 2(dY – dX) = 2 x (7 – 7) = 0
Step-03:

As Dinitial >= 0, so case-02 is satisfied.

Thus,
 Xk+1 = Xk + 1 = 5 + 1 = 6
 Yk+1 = Yk + 1 = 9 + 1 = 10
 Dnew = Dinitial + ΔD = 7 + 0 = 7
 Similarly, Step-03 is executed until the end point is reached.

Dinitial Dnew Xk+1 Yk+1

5 9

7 7 6 10

7 7 7 11

7 7 8 12

7 7 9 13

7 7 10 14

7 7 11 15

7 12 16

9 If a line is drawn from (0, 0) to (8, 4) with use of DDA. How many points will needed to generate such line?
Ans.
Solution:
P1 (0,0) P2 (8,4)
x1=0 , y1=0 , x2=8 ,y2=4

dx = 8 - 0 =8
dy= 4 – 0 = 4

m=dy/dx= 4/8 = ½

For calculating next value of x takes x = x +


If slop(m) is less than 1(m<1) then increment x as x1+1 and calculate y as y1=y1+m.

P1(0,0)
P2(1,1/2)
P3(2,1)
P4(3,3/2)
P5(4,2)
P6(5,5/2)
P7(6,3)
P8(7,7/2)

10 Apply the Bresenham's Line algorithm, draw a line between the points (3, 5) and (12, 8) on a Cartesian plane. Show the steps taken and the final output.
Ans
Solution:
x1=3 ,y1=5 , x2=12 ,y2=8
Step1 :
dy=8 – 5 = 3
dx = 12 – 3 = 9
m=dy/dx=3/9=1/3
Step 2:
If m>1 than calculate d=2*dx - dy
If m<1 than calculate d = 2*dy – dx
So, m<1 than
Step 3:
Calculate d= 2*(y2-y2) – (x2-x1)
d=2*3 – 9 = -3
Step 4 :
If d < 0, then the next point is (x+1, y).
If d >= 0, then the next point is (x+1, y+1).
Step 5:

d<0 then,
point (4,5)

calculate d=2*(8-5) – ( 12 – 4) = -2
d<0 then,
point (5,5)

calculate d=2*(8-5) – (12-5)= -1


d<0 then,
point (6,5)

calculate d=2*(8-5) – (12-6)= 0


d=0 then, point (x+1 , y+1)
point (7,6)

calculate d=2*(8-6) – (12-7)= -1


d<0 then,
point (8 , 6)

calculate d=2*(8-6) – (12 – 8)=0


d=0 then,
point (9,7)

calculate d=2*(8-7) – (12-9)= -1


d<0 then ,
point (10,7)

calculate d= 2*(8-7) – (12- 10) = 0


d=0 then,
point (11,8)

calculate d= 2*(8-8) – (12 – 11)= -1


d<0 then,
point (12,8)

11 Explain the working principles of random scan displays and raster scan displays.
Ans
Random-Scan Display Working:
Input in the form of an application program is stored in the system memory along with graphics package. Graphics package
translates the graphic commands in application program into a display file stored in system memory. This display file is then
accessed by the display processor to refresh the screen. The display processor cycles through each command in the display
file program.

Raster-Scan Display Working:


Input in the form of an application program is stored in the system memory along with graphics package. Graphics package
translates the graphic commands in application program into a display file stored in system memory. This display file is then
accessed by the Video controller to refresh the screen. The Video controller cycles through each command in the display file
program.

12 Apply the Mid-Point Line Drawing Algorithm to draw a line between the points (5, 7) and (10, 15) on a Cartesian plane. Show the steps taken and the final
output.
Ans.
Given-
 Starting coordinates = (X0, Y0) = (5, 7)
 Ending coordinates = (Xn, Yn) = (10, 15)
Step-01:

Calculate ΔX and ΔY from the given input.


 dX = Xn – X0 = 10 – 5 = 5
 dY =Yn – Y0 = 15 – 7 = 8
Step-02:

Calculate Dinitial and ΔD as-


 Dinitial = 2dY – dX = 2 x 8 – 5 = 11
 ΔD = 2(dY – dX) = 2 x (8 – 5) = 6
Step-03:

As Dinitial >= 0, so step-2 is satisfied.

Thus,
 Xk+1 = Xk + 1 = 5 + 1 = 6
 Yk+1 = Yk + 1 = 7 + 1 = 8
 Points (6,8)

 Xk+1 = Xk + 1 = 6 + 1 = 7
 Yk+1 = Yk + 1 = 8 + 1 = 9
 Points (7,9)

 Xk+1 = Xk + 1 = 7 + 1 = 8
 Yk+1 = Yk + 1 = 9 + 1 = 10
 Points (8,10)

 Xk+1 = Xk + 1 = 8 + 1 = 9
 Yk+1 = Yk + 1 = 10 + 1 = 11
 Points (9,11)

 Xk+1 = Xk + 1 = 9 + 1 = 10
 Yk+1 = Yk + 1 = 11 + 1 = 12
 Points (10,12)

13 Analyze the advantages and disadvantages of using vector graphics over bitmap graphics in computer graphics.
Ans.
Advantages of Vector Graphics:

Scalability: Vector graphics are resolution-independent and can be scaled to any size without loss of quality. This is because vector graphics are created
using mathematical equations that define the shapes, lines, and curves. As a result, vector graphics are ideal for logos, icons, and other graphics that need
to be resized frequently.

Small file size: Vector graphics use less storage space compared to bitmap graphics because they only store mathematical equations and coordinates of
the lines, curves, and shapes. As a result, vector graphics load faster than bitmap graphics.

Easy to edit: Vector graphics are easy to edit because they consist of individual objects that can be manipulated independently. This makes it easy to
change the color, shape, and size of individual elements.
Consistent quality: Vector graphics are consistent in quality regardless of the resolution or size of the image. This makes vector graphics ideal for
printing on various materials such as banners, billboards, and business cards.

Disadvantages of Vector Graphics:

Limited details: Vector graphics cannot handle complex details or shading, which makes them less suitable for creating realistic images or photographs.

Requires skill: Vector graphics require specialized software and skills to create. This makes vector graphics less accessible to casual users who do not
have experience with vector graphics software.

Limited color options: Vector graphics have limited color options compared to bitmap graphics. This is because vector graphics are created using
mathematical equations that define the shapes, lines, and curves, which can only be filled with solid colors.
14 Compare and contrast the working principles along with advantages and disadvantages of raster and random scan displays.
Ans.
Raster:
ADVANTAGES:
 Real life images with different shades can be displayed.
 Color range available is bigger than random scan display.
DISADVANTAGES:
 Resolution is lower than random scan display.
 More memory is required.
 Data about the intensities of all pixel has to be stored.
Random :
ADVANTAGES:
 Higher resolution as compared to raster scan display.
 Produces smooth line drawing.
 Less Memory required.
DISADVANTAGES:
 Realistic images with different shades cannot be drawn.
 Colour limitations.

Random Scan Raster Scan

1. It has high Resolution 1. Its resolution is low.

2. It is more expensive 2. It is less expensive

3. Any modification if 3.Modification is tough


needed is easy

4. Solid pattern is tough to 4.Solid pattern is easy to fill


fill

5. Refresh rate depends or 5. Refresh rate does not


resolution depend on the picture.

6. Only screen with view on 6. Whole screen is scanned.


an area is displayed.

7. Beam Penetration 7. Shadow mark technology


technology come under it. came under this.

8. It does not use 8. It uses interlacing


interlacing method.

9. It is restricted to line 9. It is suitable for realistic


drawing applications display.

15 Draw circle first quadrant points assume that radius of circle is 5cm and center at origin.
Ans.
STEP1: Draw a circle with centre at point O and radius 5 cm.

STEP2: Draw its cord AB.

STEP3: With centre A as centre and radius more than half of AB, draw two arcs, one on each side of AB.

STEP4: With B as centre and the same radius as in step3, draw arcs cutting the arcs drawn in the previous step at C and D respectively.

STEP5: Draw the line segment with C and D as end-points.

16 Draw circle first quadrant points assume radius of circle is 10 cm and centre at (4,-4) .
Ans.

You might also like