## Computer Graphics And Multi Media Techniques

Category : Computer Graphics and Multimedia Techniques

**Computer Graphics notes** :2D & 3D Co-ordinate system: Homogeneous Co-ordinates, Translation, Rotation, Scaling, Reflection, Inverse transformation, Composite transformation. Polygon Representation, Flood Filling, Boundary filling.

Point Clipping, Cohen-Sutherland Line Clipping Algorithm, Polygon Clipping algorithms.

so this is the syllabus for the computer graphics and multimedia techniques. Now you can easily go through the most important question, according to the RTU exam point of view.

## Download Computer Graphics Notes in pdf

You Can easily download the computer graphics and Multimedia techniques notes from the link given at the end of the Slove question paper.

This paper is designed according to the rtu 6th sem CSE branch, computer graphics, and Multimedia techniques Chapter.

**1. Explain flood algorithm. Differentiate it with boundary Fill algorithm?**

Answer of the given question is given below and you can easily download the computer graphics notes from the below

**Answer :**

**Seed Fill **

The seed fills calculation advances as surge fill calculation and boundary fill calculation. Calculations that do inside characterized segment are called surge fill calculations and those that complete boundary-characterized area is called boundary-fill calculations or edge-fill calculations.

**Boundary Fill Algorithm**

In this strategy, the boundary of the polygons is drawn. At that point start with some seed, anytime inside the polygon we survey the adjacent pixels to ponder whether the boundary pixel is connected.

In the event that boundary pixels are not connected out, pixels are calling attention to and the procedure proceeds as late as boundary pixels are connected.

Boundary defined section may be either 4-connected or 8-connected as shown in the figure. If a section is 4-connected, then every pixel in the section may be reached out by a blend of moves in only four directions: left, right, up and down.

For an 8-connected section, every pixel in the section may be reached out by a blend of moves in the two horizontal, two vertical, and four diagonal directions.

In a few cases, an 8- connected algorithm is much well-aimed than the 4- connected algorithm. This illustrated in the following figure, here a 4-connected algorithm produces the partial carry out.

The further process explain the recursive tactic for filling a 4-connected section with color define in parameter fill color (f-color) up to a boundary color define with parameter boundary color (b-color)

Process:

boundary_fill (x, y, f_colour, b_colour)

{

if (getpixel (x,y) ! = b_colour&&getpixel (x, y) ! = f_colour)

{

putpixel (x, y, f_colour)

boundary_fil l (x + 1, y, f_colour, b_colour);

boundary _fill (x, y + l , f _colour, b_colour);

boundary _fill (x – 1, y, f_colour, b_colour);

boundary_fill (x, y – 1, f_colour, b_colour);

}

}

Note: ‘ getpixel’ role gives the color of define pixel and ‘putpixel’ role draws the pixel with define color.

**Program for Boundary fiill Algorithm 8 connected section in C**

void boundryFill(int, int, int, int);

int midx=319, midy=239;

void main()

{

int gdriver=DETECT, gmode, x,y,r;

initgraph(&gdriver, &gmode, “c:\\tc\\bgi”);

cleardevice();

printf(“Enter the Center of circle (X,Y) : “);

scanf(“%d %d”,&x,&y);

printf(“Enter the Radius of circle R : “);

scanf(“%d”,&r);

circle(midx+x,midy-y,r);

boundryFill(midx+x,midy-y,13,15);

getch();

closegraph();

}

void boundryFill(int x, int y, int fill, int boundry)

{

if( (getpixel(x,y) != fill) && (getpixel(x,y) != boundry) )

{

putpixel(x,y,fill);

delay(5);

boundryFill(x+1,y,fill,boundry);

boundryFill(x-1,y,fill,boundry);

boundryFill(x,y+1,fill,boundry);

boundryFill(x,y-1,fill,boundry);

}

}

**Flood Fill Algorithm**

Sometimes it is essential to fill in an area that is not specified, within a single color boundary.

In such cases, we can carry out areas by replacing a define interior color on second thought of searching for a boundary color.

This manner is called a flood-fill algorithm. Like boundary fill algorithm, here we begin with some seed and study the nearby pixels. However, here pixels are studied for a define interior color on second thought of boundary color and they are replaced by new color.

Using either a 4-connected or 8-connected manner, we can step up from pixel location until all interior point has been• filled. The following method illustrates the recursive method for filling the 8-connected section using the flood-fill algorithm.

Process: flood_fill (x, y, old_colour, new _colour)

{

if (getpixel (x, y) = old_colour)

{ putpixel (x, y, new _colour);

flood_fill (x + 1, y, old_colour, new _colour);

flood_fill (x – 1, y, old_colour, new _colour);

flood_fill (x, y + 1, old_colour, new _colour);

flood_fill (x, y – 1, old_colour, new _colour);

flood_fill (x + 1, y + 1, old_colour, new _colour);

flood_fill (x – 1, y – 1, old_colour, new _colour);

flood_fill (x + 1, y – 1, old_colour, nevv _colour);

flood_fill (x – 1, y + 1, old_colour, new _colour);

}

}

Note: ‘getpixel’ role gives the colour of specified pixel and ‘putpixel’ role draws the pixel with define colour .

**2.** **Explain Cohen Sutherland line clipping Algorithm?**

Answer of the given question is given below and you can easily download the computer graphics notes from the below :

**Clipping**

The process that points out the section of a picture that is either inner or outer of a definition section of space calls attention to as clipping, the section opposed which an entity is to be clipped this term is called a clip window or clipping window.

It generally is a rectangular shape, as to be seen in the figure.

**Point Clipping**

The points are called to the interior to the clipping window if

Xw min <= X <=Xw max and

Yw min <= Y <=Yw max

The equal sign shows that points on the window boundary are comprised within the window.

**Line Clipping**

The lines are said to be interior to the clipping window and hence seeable if both ending points are interior to the window.

Example, line P1 P2 in the figure, however, if both endpoints of a line are outside to the window, the line is not necessarily entirely outside to the window example, line P7 P8 in the figure.

If both endpoints of a line are entire to the right of entirely to the left of, entirely above or entirely below the window, then the line is entirely outside to the window and hence invisible.

**Sutherland and Cohen Subdivision Line Clipping Algorithm**

This is one of the long in the tooth or most popular line clipping algorithm invented by Dan Cohen and Ivan Sutherland.

To deal with the speed this algorithm performs starting tests that make a smaller number of intersections that must be calculated and this algorithm uses a four-digit (bit) code to specify which of nine sections holds the end point of the line.

The four-bit codes are called section codes or out codes. These codes check the location of the point corresponding to the boundaries of the clipping rectangle as displays in the figure.

Each and every bit position in the section code is used to show one of the four corresponding coordinate positions of the point with regard to the clipping window to the left, right, top or bottom.

The rightmost bit is the first bit and the bits are set to 1 derive from on the following strategy:

SetBit 1 – if the endpoint is to the left of the window.

SetBit 2 – if the endpoint is to the right of the window

SetBit 3 – if the endpoint is the below the window

SetBit 4 – if the endpoint is above the window

Once we have fixed section codes for all the lines endpoints, we can discover which lines are entirely inside the clipping window and which are distinctly outside.

Any lines that are all together inside the window limits have a segment code of 0000 for the two endpoints and we inconsequentially acknowledge these lines.

Any lines that have a 1 in the similar bit location in the section codes for every endpoint are entirely outside the clipping rectangle, and we trivially decline these lines. A procedure used to test lines for all-out cut-out is plainly equivalent to the coherent AND administrator.

In the event that the consequence of the consistent AND activity with two endpoint codes isn’t 0000, the line is completely outside the plunging segment. The lines that can’t be recognized as completely inside or altogether outside a section window by these test are checked for convergence with the window limits.

**Example:**

Think about the section window and the lines appeared in the figure. Discover the area codes for every single endpoint and perceive whether the line is to a constrained noticeable or totally imperceptible.

Above figure displays the clipping window the lines with section codes. These codes are indexed, and end points codes are logically ANDed to identify the profile of the line in the table

**Sutherland and Cohen subdivision line clipping algorithm**

- Read two endpoints of the line say P1 (x1, y1) and P2 (x2, y2).
- Read two corners (left-top and right-bottom) of the window, say (Wx1, Wy1, and Wx2, Wy2)
- Allocate the section codes for two endpoints P1 and P2. using following steps : Initialize code with bits 0000SetBit- 1 if (x < Wx1SetBit- 2 if (x > Wx2)SetBit- 3 if (y < Wy2)SetBit- 4 if (y> Wy1)
- Check for permeability of line P1 P2

a) If area codes for the two endpoints P1 and P2 are 0 then the line is altogether noticeable. Henceforth take a stand and go to stage

b) If area codes for endpoints are not 0 and the coherent ANDing of them is additionally nonzero then the line is altogether unfit to see, so decrease the line and go to stage 9.

c) If area codes for two endpoints don’t satisfy the conditions in 4a) and 4b) the line is somewhat unmistakable.

5. Determine the converging edge of the plunging window by analyzing the area codes of two endpoints.

a) If area codes for both the endpoints are non-zero, discover convergence focuses P1 and P2the with limit edges of section window with respect to point P1 and point P2, separately.

b) If area code for anybody and endpoint is nonzero then discover convergence point P1 or P2 with the limit edge of the cut-out window regarding it.

6. Divide the line area considering convergence focuses.

7. Reject the line area on the off chance that anybody endpoint of it end up unmistakable exterior the section window.

8. Draw the rest of the line portions.

9. Stop.

**3. What is Homogenous co-ordinate? Discuss the composite transformation matrices for two successive translation and scaling?**

Answer of the given question is given below and you can easily download the computer graphics notes from the below

Very nearly all graphics system allow the developer to define a picture that shows the variety of transformation.

For example, the developer is able to enhance a picture so that depth appears more crystal clean, or narrow it so that some more of the picture is visible. The developer is as well as able to rotate the picture so that he can see it in different angles.

**Homogeneous coordinates for translation**

**Homogeneous coordinates for rotation**

**Homogeneous coordinates for scaling**

**4. Describe Polygon Clipping?**

Answer of the given question is given below and you can easily download the computer graphics notes from the below

**Polygon Clipping**

In the last request, we have seen line clipping figurings. A polygon is just the social event of lines. Hence, we may envision that the line clipping count can be used straight for polygon clipping.

Regardless, when a not open polygon is clipped as a social affair of lines with line clipping computation the veritable quiets polygon slows down no less than one open polygon or discrete lines as showed up in the figure.

So in this manner, we need to restyle the line clipping figuring to cut polygons.

We think about polygon as a close solid domain. Thusly in the wake of clipping, it should remain closed. To get this we require a count that will develop additional line portion which acknowledges the polygon as a closed region.

For example, in the figure the lines a -‘b, c – d, d – e, f – g and h – i are added to polygon description to make it closed.

Adding lines c – d and d – e is particularly hard. The considerable difficulty also occurs when clipping a polygon results in respective disjoin smaller polygons as the display in the figure. For example, the lines a – b, c – d, d – e and g – fare very often included in the clipped polygon description which is not desired.

**Sutherland – Hodgeman Polygon Clipping**

A polygon can be clipped by handling its boundary all in all against every window this is accomplished by preparing all polygon vertices against each clasp square shape boundary thusly.

Starting with the first arrangement of polygon vertices, we could initially cut the polygon against the left square shape boundary to deliver another grouping of vertices.

The new arrangement of vertices could then be progressively passed to a correct boundary clipper, the best boundary clipper and base boundary clipper as appeared in the figure at each stage another arrangement of polygon vertices is created and go to the following window boundary clipper.

This is the central thought utilized in the Sutherland – Hodgeman Polygon Clipping

These outcomes in four conceivable connections between the edge and the cut-out limit or plane.

Experiencing the over four cases we can understand that there are two key procedures in this calculation.

- Deciding the permeability of a point or vertex (Inside – Outside test) and
- Deciding the crossing point of the polygon edge and the cut-out plane. One method for deciding the permeability of a point or vertex is portrayed here.

Think about that two an and B characterize the window limit and point under thought is V, at that point these three points characterize a plane. Two vectors which lie in that plane are AB and AV.

On the off chance that this plane is considered in the ~y – plane, the vector cross item AV x AB has just a z segment given by( Xv – Xa) (Yb – Ya) – (Yv – Ya) (Xb – Xa). The indication of the z part chooses the situation of guide V with deference toward window limit.

On the off chance that z is: Positive

Zero Negative

Point is on the correct side of the window limitPoint is on the window boundary Point is on the left side of the window boundary.

**Sutherland-Hodgeman Polygon Clipping Algorithm**

- Read coordinates of all vertices of the polygon.
- Read coordinates of the clipping window.
- Consider the left edge of the window
- Compare the vertices of each edge of the polygon, individually with the clipping plane
- Save the resulting intersection and vertices in the new list of vertices according to four possible relationships between the edge and the clipping boundary discussed earlier.
- Repeat the steps 4 and 5 for remaining edges of the clipping window. Each time the resultant list of vertices is successively passed to process the next edge of the clipping window.
- Stop.

**5. Explain Scaling and Rotation with an example?**

**Rotation **

A two-dimensional revolution is connected to an article by repositioning it alongside around way in the XY plane. To produce a pivot, we indicate a revolution angle0 and the situation of the turning point about which the article is to be turned.

**Scaling**

A scaling transform changes the span of an object. This task can be done for polygons by increasing the coordinate qualities (x, y) of every vertex by scaling factors Sx and Sy to deliver the changed coordinates (x, y ).

X’ = X.Sx and

y ‘ = X.Sy

Scaling factor Sx scales object in the x-direction and scaling factor Sy scales object in the y-direction. The equations 5.10 can be written in the matrix form as given below.

Any positive numeric qualities are substantial for scaling factors Sx and Sy.

Qualities not exactly decrease to the span of the objects and qualities more noteworthy than one deliver a broadened object.

For both Sx and Sy values equivalent to one, the extent of the object does not change. To get uniform scaling it is important to assign a similar incentive for Sxand .

Sy. Unequal qualities for Sx and Sy result s in a differential scaling.

so these are the computer graphics notes according to the rtu syllabus. Thanks for reading and you can easily download these computer graphics and multimedia techniques notes from the link given below

Computer Graphics notes and multimedia notes pdf