0% found this document useful (0 votes)
7 views12 pages

CGR 21212555855

Uploaded by

chowhanaayan1
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)
7 views12 pages

CGR 21212555855

Uploaded by

chowhanaayan1
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
You are on page 1/ 12

• Pixel Pixel or Pel is defined as "the smallest addressable screen element".

• Frame Buffer The frame buffer is the video memory (RAM) that is used to hold or map the image
displayed on the screen.

Raster Scan • In Raster scan, the electron beam from electron gun is swept horizontally across the
phosphor one row at time from top to bottom. • The electron beam sweeps back and forth from left to
right across the screen. The beam is on, while it moves from left to right. The beam is off, when it moves
back from right to left. This phenomenon is called the horizontal retrace. • As soon as the beam reaches
the bottom of the screen, it is turned off and is rapidly retraced back to the top to start again. This is called
the vertical retrace. • Raster scan displays maintain the steady image on the screen by repeating scanning
of the same image. This process is known as refreshing of screen.
two line drawing algorithms. Digital Differential Analyzer (DDA) Algorithm Digital Differential Analyzer
algorithm generates a line from differential equations of line and hence the name DDA. Merits of DDA
algorithms: • It is the simplest algorithm and it does not require special skills for implementation.
Bresenham’s Algorithm The Bresenham algorithm is another line drawing algorithm which uses integer
calculations for drawing line. Merits of Bresenham’s Algorithm: • Bresenhams algorithm is faster than
DDA algorithm • Bresenhams algorithm is more efficient and much accurate than DDA algorithm

Polygon can be of two types:- • Convex polygon • Concave polygon

Various polygon filling algorithms : • Flood Fill Algorithm • Boundary Fill Algorithm • Scan Line Algorithm.
Aspect ratio Aspect ratio is the ratio between width of an image and the height of an image.
virtual reality Virtual reality (VR) means experiencing things through our computers that don't really
exist. Advantages: • Virtual reality creates a realistic world • Through Virtual Reality user can
experiment with an artificial environment. • Virtual Reality make the education more easily and comfort.
• It enables user to explore places.
Convex Polygon: It is a polygon in which if you take any two positions of polygon then all the points on the
line segment joining these two points fall within the polygon itself.
Concave Polygon: It is a polygon in which if you take any two positions of polygon then all the points on
the line segment joining these two points does not fall entirely within the polygon.
character generation methods 1) Stroke Method 2) Bitmap Method 3) Starburst Method
1) STROKE METHOD • Stroke method is based on natural method of text written by human being. In this
method graph is drawing in the form of line by line. • Line drawing algorithm DDA follows this method for
line drawing. • This method uses small line segments to generate a character. The small series of line
segments are drawn like a stroke of pen to form a character. • We can build our own stroke method
character generator by calls to the line drawing algorithm. Here it is necessary to decide which line
segments are needed for each character and then drawing these segments using line drawing algorithm.

Various polygon filling algorithms : • Flood Fill Algorithm • Boundary Fill Algorithm • Scan Line Algorithm
homogeneous co-ordinates matrix Homogeneous coordinates are used extensively in computer vision
and graphics because they allow common operations such as translation, rotation, scaling and perspective
projection to be implemented as matrix operations.
Applications of computer graphics • Animations Used for creating motion pictures, music video,
television shows, cartoon animation films. • Computer Art Using computer graphics we can create fine
and commercial art which include animation packages, paint packages. • Image processing Various kinds
of photographs or images require editing in order to be used in different places.
• Computer-Aided Learning (Cal) Computer Aided Learning (CAL) is the application of computers as an
integral part of the learning system for learning and teaching process.
• Entertainment Computer graphics finds a major part of its utility in the movie industry and game
industry. Used for creating motion pictures, music video, television shows, cartoon animation films.
• Education and training Computer generated models are extremely useful for teaching huge number of
concepts and fundamentals in an easy to understand and learn manner.

Bitmap Graphics • A bitmap is an image or shape of any kind-a picture, a text character, a photo-that's
composed of a collection of tiny individual dots. A wild landscape on your screen is a bitmapped graphic,
or simply a bitmap. • It is a pixel based image, not scalable and size of image is high.

Augmented Reality. • Augmented reality (AR) is made up of the word “augment” which means to make
something great by adding something to it. • Augmented Reality is a type of virtual reality that aims to
duplicate the world's environment in a computer. • Augmented reality is a method by which we can alter
our real world by adding some digital elements to it. • This is done by superimposing a digital image on
the person’s current view thus it enhances the experience of reality.
3D Scaling Matrix It specifies three co-ordinates with their own scaling factors. If scale factors, Sx = Sy =
Sz = S > 1 then the scaling is called as magnification. Sx = Sy = Sz = S < 1 then the scaling is called as
reduction. Therefore, point after scaling with respect to origin can be calculated as, P=P . S.
Transformations A transformation is a function that maps every position (x, y) into a new position (x',
y'). Instead of applying the transformation function to every point in every line that makes up the object,
we simply apply the function to the object vertices and then draw new lines between the resulting new
endpoints. 1)Translation 2)Scaling 3)Rotation
scan line algorithm of polygon clipping. Step 1 : Find out the Ymin and Ymax from the given polygon.
• Step 2 : ScanLine intersects with each edge of the polygon from Ymin to Ymax. Name each intersection
point of the polygon. As per the Fig. 2.21 shown, they are named as p0, p1, p2, p3. • Step 3 : Sort the
intersection point in the increasing order of X coordinate i.e. (p0, p1), (p1, p2), and (p2, p3).
• Step 4 : Fill all those pair of coordinates that are inside polygons and ignore the alternate pairs.
Write algorithm to clip line using Liang Barsky line clipping algorithm.
1. Set tmin=0, tmax=1. 2. Calculate the values of t (t(left), t(right), t(top), t(bottom)), (i) If t < tmin ignore
that and move to the next edge. (ii) else separate the t values as entering or exiting values using the inner
product. (iii) If t is entering value, set tmin = t; if t is existing value, set tmax = t.
3. If tmin < tmax, draw a line from (x1 + tmin(x2-x1), y1 + tmin(y2-y1)) to (x1 + tmax(x2-x1), y1 + tmax(y2-
y1))
4. If the line crosses over the window, (x1 + tmin(x2-x1), y1 + tmin(y2-y1)) and (x1 + tmax(x2-x1), y1 +
tmax(y2-y1)) are the intersection point of line and edge.
DDA line drawing algorithm Explain • This algorithm generates a line from differential equations of line
and hence the name DDA. • DDA algorithm is an incremental scan conversion method. • A DDA is
hardware or software used for linear interpolation of variables over an interval between start and end
point. • DDAs are used for rasterization of lines, triangles and polygons. •DDA method is referred by this
name because this method is very similar to the numerical differential equations. The DDA is a mechanical
device that solves differential equations by numerical methods. Algorithm: Steps 1: Read the end points
of line (x1,y1) and (x2,y2). Steps 2: Δx = abs (x2 – x1) and Δy = abs (y2 – y1) Step 3: if Δx ≥ Δy then
length = Δx else length = Δy end if Step 4: Δx = (x2 – x1)/length Step 5: Δy = (y2 – y1)/length
Step 6: x= x1 + 0.5 * sign (Δx) y= y1 + 0.5 * sign (Δy) Step 7: i = 1 while (i ≤ length) {
plot (integer (x), integer (y)) x = x + Δx y = y + Δy i=i+1 } Step 8: End
Cohen-Sutherland Line clipping algorithm. Step 1: Scan end points for the line P1(x1, y1) and P2(x2, y2)
Step 2: Scan corners for the window as (Wx1, Wy1) and (Wx2, Wy2) Step 3: Assign the region codes for
endpoints P1 and P2 by Bit 1 - if (x < Wx1) Bit 2 - if (x < Wx2) Bit 3 - if (x < Wy2) Bit 4 - if (x < Wy1)
Step 4: Check for visibility of line P1, P2 • If region codes for both end points are zero then the line is
visible, draw it and jump to step 9. • If region codes for end points are not zero and the logical and
operation of them is also not zero then the line is invisible, reject it and jump to step 9. • If region codes
for end points does not satisfies the condition in 4(i) and 4(ii) then line is partly visible. Step 5: Determine
the intersecting edge of the clipping window by inspecting the region codes for endpoints. • If region
codes for both the end points are non-zero, find intersection points P1 and P2 with boundary edges of
clipping window with respect to point P1 and P2. • If region code for any one end point is non zero then
find intersection point P1 or P2 with the boundary edge of the clipping window with respect to it.
Step 6: Divide the line segments by considering intersection points. Step 7: Reject the line segment if any
of the end point of it appear outside the window. Step 8: Draw the remaining line. Step 9: Exit.
Boundary fill algorithm with pseudo code. Also mention its limitations if any.
Procedure: boundary_fill (x, y, f_colour, b_colour) { if (getpixel (x,y) != h_colour && getpixel (x, y) !=
f_colour) { putpixel (x, y, f colour) boundary_fill (x + 1, y, f_colour, b_colour); boundary_fill (x, y + 1,
f colour, b_colour); boundary_fill (x 1, y, f colour, b_colour); boundary_fill (x, y 1, f colour, b_colour); }
Limitations: • There is a problem with this technique. Consider the case following, where we tried to fill
the entire region. Here, the image is filled only partially. In such cases, 4-connected pixels technique
cannot be used.
Cyrus-Beck line clipping algorithm. Step 1: Read end points of line P1 and P2. Step 2: Read vertex
coordinates of clipping window. Step 3: Calculate D = P2 – P1. Step 4: Assign boundary point b with
particular edge. Step 5: Find inner normal vector for corresponding edge. Step 6:Calculate D.n and W =
P1 – b Step 7:If D.n > 0 tL = – (W.n)/(D.n) else tU = – (W.n)/(D.n) end if Step 8: Repeat steps 4
through 7 for each edge of clipping window. Step 9: Find maximum lower limit and minimum upper
limit. Step 10: If maximum lower limit and minimum upper limit do not satisfy condition 0 ≤ t ≤ 1 then
ignore line. Step 11: Calculate intersection points by substituting values of maximum lower limit and
minimum upper limit in parametric equation of line P1P2. Step 12: Draw line segment P(tL) to P(tU).
Step 13: Stop.
vector scan display techniques • A pen plotter operates in a similar way and is an example of a
randomscan, hard-copy device • This displays to draw all the component lines of picture 30 to 60
frames/second • Random scan system is designed for line drawing applications; hence cannot display
realistic shaded scenes. • Vector displays produces smooth line drawings but raster produces jagged lines
that are plotted points
curve generation using Interpolation technique Specify a spline curve by giving a set of coordinate
positions, called control points, which indicates the general shape of the curve These, control points are
then fitted with piecewise continuous parametric polynomial functions in one of two ways. When
polynomial sections are fitted so that the curve passes through each control point, the resulting curve is
said to interpolate the set of control points. On the other hand, when the polynomials are fitted to the
general control-point path without necessarily passing through any control point, the resulting curve is
said to approximate the set of control points interpolation curves are commonly used to digitize drawings
or to specify animation paths. Approximation curves are primarily used as design tools to structure object
surfaces an approximation spline surface credited for a design application. Straight lines connect the
control-point positions above the surface.
types of Text clipping in brief. 1) All or none string clipping In all or none string clipping method,
either we keep the entire string or we reject entire string based on the clipping window. As shown in the
above figure, Hello2 is entirely inside the clipping window so we keep it and Hello1 being only partially
inside the window, we reject. The following figure shows all or none character clipping –
2) All or none character clipping This clipping method is based on characters rather than entire string. In
this method if the string is entirely inside the clipping window, then we keep it. If it is partially outside the
window, then − You reject only the portion of the string being outside If the character is on the boundary
of the clipping window, then we discard that entire character and keep the rest string. The following figure
shows text clipping –
3) Text clipping This clipping method is based on characters rather than the entire string. In this method
if the string is entirely inside the clipping window, then we keep it. If it is partially outside the window,
then you reject only the portion of string being outside. If the character is on the boundary of the clipping
window, then we discard only that portion of character that is outside of the clipping window.

types of Parallel Projection • Orthographic projection – the projection direction is a normal one to the
plane and it is categorized as o Top projection o Front projection o Side projection
• Oblique projection – the projection direction is not a normal one to the plane; it gives a better view and
it is categorized as o Cavalier projection o Cabinet projection.
Koch curve In Koch curve, begin at a line segment. Divide it into third and replace the center by the
two adjacent sides of an equilateral triangle as shown below. This will give the curve which starts and ends
at same place as the original segment but is built of 4 equal length segments, with each 1/3rd of the
original length. So the new curve has 4/3 the length of original segments. Repeat same process for each of
the 4 segment which will give curve more wiggles and its length become 16/9 times the original. Suppose
repeating the replacements indefinitely, since each repetition increases the length by a factor of 4/3, the
length of the curve will be infinite but it is folded in lots of tiny wiggles.
polygon clipping Polygon clipping is removal of part of an object outside a polygon.
Random Scan Display Raster Scan Display
Vector display only draws lines and characters. Raster display has ability to display areas filled with solid
colors or patterns.
Mathematical functions are used to draw an image Screen points/pixels are used to draw an image
It does not user interlacing It uses interlacing.
Editing is easy. Editing is difficult.
Cost is more Cost is low
It uses beam-penetration method. It uses shadow-mask method

Bitmap Graphics Vector Based Graphic


It is pixel based image It is Mathematical based image
Images are resolution dependent. Images are formula based / dependent.
These images are not easily scalable. Easily scalable with the help of formula.
Poor quality of image as oppose to Vector based Graphics Better image quality as compare to Bitmap Graphics.
Size of image is high. Size of image is low.

Raster Vector
Raster graphics are composed of pixels. Vector graphics are composed of paths.
Raster graphics are resolution dependent. Vector graphics are resolution independent
More expensive Less expensive.
It required separate scan conversion hardware. Scan conversion hardware is not required
It uses interlacing It does not used interlacing
File extensions are: .bmp, .gif, .jpg, .tif File extensions are: .pdf, .ai, .svg, .eps, .dxf

program in ‘C’ to generate Hilbert’s curve. #include <stdio.h> #include <stdlib.h> #include <math.h>
void hilbertCurve(int n, int x, int y, int xi, int xj, int yi, int yj) { if (n <= 0) { // Print the coordinates
printf("(%d, %d) ", x, y); } else { hilbertCurve(n - 1, x + xi * pow(2, n - 1), y + yi * pow(2, n - 1), xi,
yi, xj, yj); hilbertCurve(n - 1, x + xj * pow(2, n - 1), y + yj * pow(2, n - 1), xi, yi, xj, yj);
hilbertCurve(n - 1, x + xj * pow(2, n - 1) + xi * pow(2, n), y + yj * pow(2, n - 1) + yi * pow(2, n), -xj, -yj, -xi, -
yi); hilbertCurve(n - 1, x + xi * pow(2, n) + xj * pow(2, n - 1), y + yi * pow(2, n) + yj * pow(2, n - 1), xi,
yi, xj, yj); } } int main() { int order; printf("Enter the order of Hilbert's curve: ");
scanf("%d", &order); int size = pow(2, order); printf("Coordinates of Hilbert's curve of
order %d:\n", order); hilbertCurve(order, 0, 0, 1, 0, 0, 1); return 0; }
‘C’ for DDA Circle drawing algorithm #include<stdio.h> #include<conio.h> #include<graphics.h>
#include<math.h> void main() { int gdriver=DETECT,gmode,errorcode,tmp,i=1,rds;
float st_x,st_y,x1,x2,y1,y2,ep; initgraph(&gdriver,&gmode,"C:\\TC\\BGI"); printf("Enter Radius:");
scanf("%d",&rds); while(rds>pow(2,i)) i++; ep=1/pow(2,i); x1=rds; y1=0; st_x=rds; st_y=0;
do { x2=x1+(y1*ep); y2=y1-(x2*ep); putpixel(x2+200,y2+200,10); x1=x2; y1=y2; }
while((y1-st_y)<ep || (st_x-x1)>ep); getch(); }
midpoint subdivision line clipping algorithm Step 1: Scan two end points for the line P1(x1, y1) and
P2(x2, y2). Step 2: Scan corners for the window as (Wx1, Wy1) and (Wx2, Wy2). Step 3: Assign the region
codes for endpoints P1 and P2 by initializing code with 0000. Bit 1 - if (x < Wx1) Bit 2 - if (x > Wx2) Bit
3 - if (y < Wy1) Bit 4 - if (y > Wy2) Step 4: Check for visibility of line P1, P2. • If region codes for both
end points are zero then the line is visible, draw it and jump to step 6. • If region codes for end points are
not zero and the logical Anding operation of them is also not zero then the line is invisible, reject it and
jump to step 6. • If region codes for end points does not satisfies the condition in 4 (i) and 4 (ii) then line is
partly visible Step5: Find midpoint of line and divide it into two equal line segments and repeat
steps 3 through 5 for both subdivided line segments until you get completely visible and completely
invisible line segments. Step 6: Exit.
procedure to fill polygon with flood fill. flood_fill(x,y,old_color,new_color) { if(getpixel(x,y) =
old_color) { putpixel(x,y,new_color); flood_fill(x+1,y,old_color, new_color); flood_fill(x-
1,y,old_color, new_color); flood_fill(x,y+1,old_color, new_color); flood_fill(x,y-1,old_color,
new_color); flood_fill(x+1,y+1,old_color, new_color); flood_fill(x-1,y-1,old_color, new_color);
flood_fill(x+1,y-1,old_color, new_color); flood_fill(x-1,y+1,old_color, new_color); } }

DDA Arc generation algorithm. 1. Read the centre of curvature, say(x0,y0) 2. Read the arc angle, say Ɵ
3. Read the starting point of the arc, say(x,y) 4. Calculate dƟ dƟ=min(0.01,1/3.2*(|x-x0|+|y-y0|)))
5. Initialize angle = 0 6. while (angle < Ɵ) do { Plot(x,y) x=x-(y-y0) *dƟ y=y-(x-x0) *dƟ
Angle =Angle + dƟ } 7. Stop.
Algorithm for Sutherland-Hodgeman Polygon Clipping: Step 1: Read co-ordinates of all vertices of the
polygon. Step 2: Read co-ordinates of the clipping window. Step 3: Consider the left edge of window.
Step 4: Compare vertices of each of polygon, individually with the clipping plane. Step 5: Save the
resulting intersections and vertices in the new list of vertices according to four possible relationships
between the edge and the clipping boundary. Step 6: Repeat the steps 4 and 5 for remaining edges of
clipping window. Each time resultant list of vertices is successively passed to process next edge of clipping
window. Step 7: Stop.
Bresenham’s algorithm to plot 1/8t The key feature of circle that it is highly symmetric. So, for whole 360
degree of circle we will divide it in 8-parts each octant of 45 degree. In order to that we will use
Bresenham’s Circle Algorithm for calculation of the locations of the pixels in the first octant of 45 degrees.
It assumes that the circle is centered on the origin. So for every pixel (x, y) it calculates, we draw a pixel in
each of the 8 octants of the circle as shown below: Algorithm: Step 1: Read the radius of circle (r).
Step 2: Set decision parameter d = 3 – 2r. Step 3: x=0 and y=r. Step 4: do { Plot (x,y) If(d<0) then {
d = d + 4x + 6 } Else { d=d + 4(x-y) + 10 y=y-1 } X=x-1 } While(x<y) Step 5: stop.
Plotting 8 points, each point in one octant Call Putpixel (X + h, Y + k). Call Putpixel (-X + h, Y + k).
Call Putpixel (X + h, -Y + k). Call Putpixel (-X + h, -Y + k). Call Putpixel (Y + h, X + k).
Call Putpixel (-Y + h, X + k). Call Putpixel (Y + h, -X - k). Call Putpixel (-Y + h,-X + k).

You might also like