cg
cg
01 Dated 10/12/2022
DDA Algorithm-
DDA Algorithm is the simplest line drawing algorithm.
The points generation using DDA Algorithm involves the following steps-
Step-01:
Calculate ΔX, ΔY and M from the given input.
These parameters are calculated as-
ΔX = Xn – X0
ΔY =Yn – Y0
M = ΔY / ΔX
Step-02:
Find the number of steps or points in between the starting and ending coordinates.
if (absolute (ΔX) > absolute (ΔY))
Steps = absolute (ΔX);
else
Steps = absolute (ΔY);
Step-03:
Suppose the current point is (Xp, Yp) and the next point is (Xp+1, Yp+1).
Keep repeating Step-03 until the end point is reached or the number of generated new points (including the starting and ending points) equals to the steps
count.
Problem-01:
Calculate the points between the starting point (5, 6) and ending point (8, 12).
Solution-
Given-
Starting coordinates = (X0, Y0) = (5, 6)
Ending coordinates = (Xn, Yn) = (8, 12)
Step-01:
Calculate ΔX, ΔY and M from the given input.
ΔX = Xn – X0 = 8 – 5 = 3
ΔY =Yn – Y0 = 12 – 6 = 6
M = ΔY / ΔX = 6 / 3 = 2
Step-02:
Calculate the number of steps.
Step-03:
As M > 1, so case-03 is satisfied.
5 6 5.5 7 (6, 7)
6 8 (6, 8)
6.5 9 (7, 9)
7 10 (7, 10)
7.5 11 (8, 11)
8 12 (8, 12)
Step-03:
Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).
Find the next point depending on the value of decision parameter Pk.
Follow the below two cases-
Step-04:
Keep repeating Step-03 until the end point is reached or number of iterations equals to (ΔX-1) times.
Step-01:
Calculate ΔX and ΔY from the given input.
ΔX = Xn – X0 = 14 – 9 = 5
ΔY =Yn – Y0 = 22 – 18 = 4
Step-02:
Calculate the decision parameter.
Pk
= 2ΔY – ΔX
=2x4–5
=3
So, decision parameter Pk = 3
Step-03:
As Pk >= 0, so case-02 is satisfied.
Thus,
Pk+1 = Pk + 2ΔY – 2ΔX = 3 + (2 x 4) – (2 x 5) = 1
Xk+1 = Xk + 1 = 9 + 1 = 10
Yk+1 = Yk + 1 = 18 + 1 = 19
Similarly, Step-03 is executed until the end point is reached or number of iterations equals to 4 times.
(Number of iterations = ΔX – 1 = 5 – 1 = 4)
9 18
3 1 10 19
1 -1 11 20
-1 7 12 20
7 5 13 21
5 3 14 22
S.NO DDA Line Algorithm Bresenham line Algorithm
DDA algorithm is less efficient than While it is more efficient than DDA
2.
Bresenham line algorithm. algorithm.
The points for other octacts are generated using the eight symmetry property.
Procedure-
Given-
Centre point of Circle = (X0, Y0)
Radius of Circle = R
The points generation using Bresenham Circle Drawing Algorithm involves the following steps-
Step-01:
Step-02:
Calculate the value of initial decision parameter P0 as-
P0 = 3 – 2 x R
Step-03:
Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).
Find the next point of the first octant depending on the value of decision parameter Pk.
Step-4
If the given centre point (X0, Y0) is not (0, 0), then do the following and plot the point-
Xplot = Xc + X0
Yplot = Yc + Y0
Step-05:
Problem-1
Given the centre point coordinates (0, 0) and radius as 8, generate all the points to form a circle.
Solution-
Given-
Centre Coordinates of Circle (X0, Y0) = (0, 0)
Radius of Circle = 8
Step-01:
Assign the starting point coordinates (X0, Y0) as-
X0 = 0
Y0 = R = 8
Step-02:
Step-03:
Step-04:
This step is not applicable here as the given centre point coordinates is (0, 0).
Step-05:
(Xk+1,
Pk Pk+1
Yk+1)
(0, 8)
-
-3 (1, 8)
13
-3 11 (2, 8)
11 5 (3, 7)
5 7 (4, 6)
7 (5, 5)
Algorithm Terminates
These are all points for Octant-1.
Now, the points of octant-2 are obtained using the mirror effect by swapping X and Y coordinates.
(0, 8) (5, 5)
(1, 8) (6, 4)
(2, 8) (7, 3)
(3, 7) (8, 2)
(4, 6) (8, 1)
(5, 5) (8, 0)
Now, the points for rest of the part are generated by following the signs of other quadrants.
The other points can also be generated by calculating each octant separately.
Here, all the points have been generated with respect to quadrant-1-
POLYGON FILLING
New Point
HOMOGENOUS COORDINATE
1. (0,0)
2. (0,1)->1+2*0=1
(0,1)
3. (2,0)->0+2*2=4
(2,4)
4. (2,2)->2+2*2=6
(2,6)
UNIT IV
UNIT V
COLOR MODELS
WHITE
W White
W
What is GIMP
GIMP (GNU Image Manipulation Program) is a free and open-source image
editor tool. It is a cross-platform tool available for different operating systems such
as GNU/Linux, macOS, Windows, etc. As it is open-source, its source code can be
downloaded. It is packaged with most of the Linux distros.
It is a useful tool for Graphic Designers, Photographer, and other professionals. It
supports various third-party plug-in to make it a more advanced editing tool. We
can enhance our creativity with the help of these plug-ins.
It is a useful tool for various image manipulation tasks such as photo editing,
image composition, image construction, logo designing, painting, and many more.
It is capable enough of being used as a simple paint tool, an advanced photo
editing tool, a mass production image renderer, or an image format converter tool.
One of the other reasons for its popularity is that it is a free tool while other editing
tools such as photoshop are paid. Most Linux distributions include it as a standard
application. But, it can be downloaded for other platforms such as macOS and
Windows as well.
Gimp is licensed under the GPL (General Public License). The tools that are
licensed under the GPL provides the freedom to alter the source code.
Features of GIMP
Some key Features of GIMP are as following:
Free and Open Source
It is a free and open-source tool.
Cross-Platform
It is a cross-platform tool available for different operating systems such
as GNU/Linux, macOS, Windows, and more
High-Quality Photo Manipulation
It has massive supports for the tools needed for high-quality image editing. It can
perform some advanced tasks such as image retouching, image restoring, image
composing, etc.
Original Artwork Creation
It is enough capable and flexible to transform an image into truly unique creations.
Graphic Design Elements
The Gimp is a vital tool for creating icons, logos, graphical design elements,
interactive arts for UI, and mockups.
Programming Algorithms
It also provides an advanced framework for scripted image manipulation with
multiple programming language support like C, C++, Python, Perl, etc.
Key Component in a Desktop Publishing Workflow
It provides color management features to ensure the high-quality fadable color
reproduction across media. Further, It provides an interactive workflow in other
tools such as Scribus, Inkscape, and SwatchBooker.
Apart from all the above features, it also provides the following list of features:
o It provides a full suite of painting tools such as brushes, airbrush, pencil, cloning,
etc.
o It provides a tile-based memory management tool to limit the image size by
available disk space.
o It provides a sub-pixel sampling for high-quality and anti-aliasing.
o It provides full alpha channel support for transparency.
o It provides several layers an channels.
o It supports a procedural database for calling internal GIMP functions from an
external program.
o It has advanced scripting capabilities.
o It provides several undo/redo options.
o It provides several transformation tools such as rotate, scale, shear, and flip.
o It supports a wide range of file formats such as GIF, JPEG, PNG, TIFF, PDF,
BMP, etc.
o It provides several selection tools such as rectangle, ellipse, circle, fuzzy, bezier,
etc.
o It supports various plug-ins for the easy addition of new file formats and filters.