You are on page 1of 68

Curves and

Fractals
introduction
Curves are one of the most essential objects to create
high-resolution graphics.

Curves can be stored much easier

can be scaled to any resolution without losing


smoothness

Provide a much easier way to specify real-world


objects.
Curve Generation
There are two approaches to generate a curve

1.To develop a curve generation algorithm such as DDA


with this approach a true curve is created

2.Approximate curve by a number of small straight line


segments(interpolation technique is used for this
second approach)
 DDA algorithm for generating arc
The Eqs. for the arc coordinates in the angle
parameter as
X =R*cosɵ + Xo (eq.1)
Y =R*sinɵ + Yo
 Where Xo and Yo is the centre of the curvature and R is the radius

 Differentiating the equation


dx =- R*sinɵ*dɵ
dy = R*cosɵ*dɵ (eq.2)

From eq(1) we will get the values of Rcosɵ and Rsinɵ


R cosɵ = X-X0
R sinɵ = Y-Y0
If we put the values of Rcosɵ and Rsinɵ in eq 2 we will
get
dx = -(Y-Yo)dɵ
dy= (X-Xo)dɵ
This dx and dy tell us the amount to increment to an
old point on the arc to get a new point
X2=X1+dx
Y2=Y1+dy
X2=X1-(Y1-Yo)dɵ
Y2=Y1+(X1-Xo)dɵ
A
R

(Xo,Yo)
DDA Algorithm

Read the center of the curvature (X0,Y0)


Read the arc angle ɵ
Read the starting point of the arc (x,y)
Calculate dɵ
dɵ = min(0.01,1/(3.2*(|x-x0|+|y-y0|))
Initialize the angle=0
While(angle<ɵ)
Do
{plot(x,y)
X=X-(y-y0)*dɵ
Y=Y+(X-X0)*dɵ
Angle=angle+dɵ
}
stop
INTERPOLATION
To draw a complex curve no mathematical function is
available
Such type of curve can be drawn using approximation
methods
We can draw an approximate curve if we have an array
of sample points
If we have a set of sample points which lie on the curve
, then we can draw the required curve by filling
portions of the curve with the pieces of known curve
which pass through the nearby sample points
Unknown curve

Known sample points

Fit a region with a


known curve
X XX X
X Calculate more points
X
from known curve

X X Actually draw straight line


X X segments connecting points

Fig:-interpolation process
 B- Spline
To produce a smooth curve through a designated set of
points a flexible strip called spline is used.

 If we don’t force the curve to pass through the sample


points, but rather gently pull it into the neighborhood of
the sample point.

So B- spline curve not necessarily passing through the


control points.

The curve which necessarily passing through the control


points are called interpolating curve
B-Splines and Corners
The B-spline blending functions were designed to
eliminate sharp corners in the curve and the curve
does not usually pass through sample points.
A sharp corner and passage through a sample point
can be produced in a B-spline curve, if desired.
The way that this is done is to use several identical
sample points.
The call
CURVE-ABS-2(X0,Y0,Z0)
Produces one sample point at(X0,Y0,Z0), pulling the
curve in that direction.
Bezier curve
 Most graphics application uses Cubic Bezier curve

 The cubic Bezier curve requires four control points and these points
completely specifies the curve.

 Unlike B-splines curve, we cannot add additional point and


smoothly extend the cubic bezier curve, but we pick four more
points and construct a second curve which can be attached to the
first

 The curve begins at the first control point and ends on the fourth.

 If we want to connect two bezier curve we just make the first control
point of the second curve match the last control point of its first
curve
At the start of the curve ,it is tangent to the line
connecting the first and second control points, likewise
at he end of the curve ,it is tangent to line connecting
third and fourth control points

A cubic Bezier
spline
c cd d

bcd

bc abcd

abc

a
ab
b

Another approach to construct the bezier curve is mid point


approach.
The curve can be constructed simply by taking the mid points
 Hilbert’s Curve
This curve can be built by the following successive
approximation
Bigin with square
First approximation will be divide square into 4
quadrants and draw the curve which connects the
centre points of each
The second approximation will be further subdivide
each of the quadrants and connect the centre of each
of these finer divisions before moving to the next
major quadrant
 The third approximation again subdivides it again
connects the centre of the finest level before moving
to the next level of detail
Characteristics of Hilbert’s Curve

At each subdivision, the curve fills with the smaller


quadrants ,but never crosses into an area where it
already exists

The curve is arbitrarily closed to every point in the


square

With each subdivision scale changes by 2 but length


increases by a factor of 4

Since we imagine no limit to the subdivision so the


length of the curve is infinite
Triadic koch curve
Begin with line segment
Divide it into thirds and replace the centre third by two
adjacent sides of the equilateral triangle

This gives us a curve which begins and ends at the same


place as the original segment but is built of 4 equal length
segments each 1/3 the original length

Replacement for a line segment for the triadic koch curve


So the new curve has 4/3 the length of the original
segment
Repeat the step for each of the four segment
The curve has gained more wiggles and its length is now
16/9 times the original
Imagine repeating the replacements indefinitely
Since each repetition increases the length by a factor of
4/3
The length of the curve will be finite, but it is folded in
lots of tiny wiggles
Fractals
The objects occuring in nature often have rough ,jagged,random
edges
Attempting to draw things like mountains,trees,rivetrs or lightning
bolt directly with lines or polygons requires a lot of specification
It is desirable to let the machine do the work of specifying the
jagged lines
We would like to give the machine two endpoints and let the
machine draw a jagged line between them
Not only the rough line but it will closely approximate the behavior
of nature
Recently the branch of mathematics has been developed algorithm
to describes such rough structure. they are called fractals
A rough or fragmented geometric shape that can be subdivided in
parts, each of which is (at least approximately) a reduced/size copy
of the whole.
What is a Fractal?
A fractal is generally,

“A rough or fragmented geometric shape that can


be subdivided in parts, each of which is (at least
approximately) a reduced-size copy of the whole,“

This is a property called self-similarity. The term


was coined by Benoît Mandlebrot in 1975 and was
derived from the Latin fractus meaning "broken"
or "fractured".
Important Characteristics of Fractals

 They are recursive; that is, the process of their


creation gets repeated indefinitely;
 They are self-similar; that is, copies of the entire
fractal may be found, in reduced form, within the
fractal.
Color & Color Models
Color Basics
Importance of color in computer graphics will continue to
increase as color monitors & color hard copy devices
become more & more popular.
Color is a complex subject that draws on concepts & results
from physics,art & graphics design.
Color of an objects depends not only on the object itself,
but also on the light source illuminating it, on the color of
surrounding area & on the human visual system.
Color Model
Color Model: It is an abstract mathematical model
describing
the way color can be represented as tuple of numbers,
typically
it is three or four.

Color Space : When color model is associated with a precise


description of how the components are to be interpreted the
resulting set of colors is called color space.
CIE XYZ color space
One of the first mathematically defined color spaces is
the CIE XYZ color space created by the International
Commission in 1931.

The CIE( Commission International del Eclairage) has


defined a set of three color-matching functions.
CIE COLOR SPACE
CIE COLOR SPACE
Chromaticity
Chromaticity is an objective specification of the
quality
of a color regardless of its luminance.

It is determined by its hue and colorfulness

Hue determines the weakness or intensity of a color .

Colorfulness is the difference between a color


against gray
Chromaticity Diagram
When we plot the normalized amount x and y for colors
visible in the spectrum we obtain the tongue shaped
curve.

This curve is called the chromaticity diagram.

Points along the curve are the pure color in the spectrum,
labeled according to the wavelength in nanometer from
red end to violet end.
Chromaticity Contd…
The chromaticity of a color was specified by the two
derived parameters x and y, two of the three
normalized values which are functions of all three
values X, Y, and Z.

Since we have normalized against the luminance


,Parameter x and y are called the chromaticity value
because they only depends on the hue & purity.
Chromatic diagram
Terminology
1) Gamut : Usually ,any color model use combination of two to
three colors to produce wide range of colors, called the color
gamut for that model.

2) Primary color: The basic color used to produce color gamut in a


particular model are called primary color.

3) Secondary Color: The different color obtained by mixing the


primary color are called the secondary color.

4) Complementary color : When two color sources are combined


to produce white color . e.g
Red & Cyan, green & magenta, blue & yellow are the
complementary colors.
Color Model
A color model is a method for explaining the
properties or behavior of color within some particular
context.
No single color model can explain all aspects of
color,so we make use of different models to describe
the different perceived characteristics of color.
RGB COLOR MODELS
• In the RGB model, each color appears as a combination of red,
green, and blue.

• This model is called additive, and the gamut of this model are
red, green and blue.

• These three primary colors can be added to produce the


secondary colors.

• Magenta (red + blue), Cyan (green + blue), and Yellow (red +


green). The combination of red, green, and blue at full
intensities makes white.
RGB & CMY
RGB COLOR MODEL
Cyan (011)

Yellow (110)

White (111)

Black (000)

Magenta (101)
CMY COLOR MODEL
In this model Cyan , magenta and yellow colors
are used as (Gamut) primary color.

The Cartesian co-ordinate system are same as


that of RGB except that white instead of black at
the origin.
CMY COLOR MODEL
RGB & CMY
HIS model
Hue: it indicates pure color of light.
Saturation: it indicates how much white light is mixed
with color.
Intensity: it tells about the shade.
HSV model
HSV stands for Hue-Saturation-Value

Described by a hexcone derived from the RGB


cube
HSV model,cont’d
Hue (0-360°); ”the
color”, (128)

Saturation (0-1); ”the


amount of white” (130)

Value (0-1); ”the


amount of black” (23)
HSV cond..
1) Hue is represented as an angle about the vertical axis,
ranging from (0-360). 0 degree at red , Yellow at 60 degree,
Vertices of the hex cone are separated by 60 degree.

2) Saturation is represented as the ratio of purity of a selected


hues. The maximum purity is at S=1.
e.g at S=0.5 the hue is said to be half pure.

3) Values V varies from 0 at the apex and 1 at the top of the


hexcon. The apex represents the black. At the top of the hex
cone colors have the maximum intensity. When we have v=1
& s=1 we have the pure hue.
Adding the black decreases the setting for v ,while s is
held constant.
e.g: To get a dark blue , v could be set at 0.4, s=1 &
h=240.

Similarly ,when white is to be added ,parameter s is


decreased while keeping v constant.
e.g: A light blue can be designated as s=0.3, v=1 , h=240.
HSV model,cont’d
The human eyes are capable to distinguish 128
different hues, 130 different saturation and 23
shades can be detected . It means that we can
distinguish 128*130*23 = 382720

In Computer Graphics, 128 hues , 8 saturation


levels and 15 values settings are suffecient
ie 128*8*15 = 15360 colors.
HLS Model
• Three color parameter in this model are
H: HUE
L:Lightness
S: Saturation

1) HUE:
• It has the same meaning as in the HSV model.It specifies
an angle about vertical axis that locates a chosen hue.
• In this model H= 00 corresponds to blue.The remaining
colors are specified around the perimeter of the cone.
• Magenta is at 600, Red is at 1200 , Cyan is at H=1800
HLS Contd…
2) Lightness:
• The vertical axis in this model is called the lightness L.
At L =0 we have Black and at L=1,it is white.
• Gray scale is along the L axis and the “Pure
hues” lies on L=0.5.

3) Saturation:
• Saturation parameter S again specifies relative
purity of the color .This parameter varies from 0-1, and
pure hues are those for which S= 1 and L=0.5.
• As S decreases the hue are said to be less pure.
• At S=0 we have Gray scale
HLS COLOR Model
YIQ Color Model
Y : Luminance (Brightness)
I : Inphase
Q: Qudrature.

This Model is used by NTSC to form the


composite video signal used for television.
YIQ Contd….
• Parameter Y is used to represent the Luminance or brightness
while chromaticity information (hue & purity) is
incorporated into I and Q.

• Since Y contains the luminance information so black & white


television monitors uses only the Y signal.

• Parameters I contains orange-Cyan hue information that


provide the tone shading and having a bandwidth of 1.5 MHZ.

• Parameters Q carries green-magenta hue information in a


bandwidth of 0.6 MHZ.
Signal conversion
• An RGB Signal can be converted to a television signal
using an NTSC encoder, which converts the RGB values to
YIQ values, then modulate and superimpose the I and Q
information on the Y signal.

• Similarly an NTSC signal can be converted to an RGB


signal using an NTSC decoder, which separate the video
signal into the YIQ components then converts to the RGB
values.
Color Table
Color table has 8 bit of control over each of the red , green
& blue . Therefore they have the 256 intensity levels

So with the 256 intensity levels of each color we can


produce 16,777,216 different colors.

 So to specify color of any pixel 24 bits(ie 8 bit per color) are


required.

 To store 24 bit information of each color (ie 16,777,216) is


not cost effective.
Color Table
Therefore in normal practice only few color is specified in
the table called color table.

A color table allows us to map between a color index in the


frame buffer and a color specification.

If a color table has 256 color entries then the table can
show any of the 256 of 16,777,216 possible colors.
Color table
Each entry in the table is 24 bit specifying one color.The
colors specified in the color table are available for selection
color.

We can change the available color in the color table by


changing the color information, however at a time only 256
color can be displayed.

The colors in the color table are referred by the color index.
Color Mixing
Two or more color can be added together to produce a new color . There are two
types of color mixing

1) Additive color mixing:


An additive color model involves light emitted directly from a source or
illuminant of some sort. The additive reproduction process usually uses red,
green and blue light to produce the other colors.

Combining one of these additive primary colors with another in equal


amounts produces the additive secondary colors cyan, magenta, and yellow.

Combining all three primary colors in equal intensities produces white.


Additive Color Mixing
Color Mixing
2) Subtractive color mixing:
Subtractive color mixing involves the selectively absorption of
the wavelength. Cyan , Magenta and yellow are subtractive
primaries.

If a white light will pass through a yellow filter the yellow filter
absorb blue and transmit red & green , therefore yellow can be
considered as B Filter.

Similarly magenta subtract or absorb green from the white light


and cyan subtract or absorb Red from the white light.
Subtractive color mixing
A subtractive color model explains the mixing of paints,
dyes, inks, and natural colorants to create a full range of
colors, each caused by subtracting (that is, absorbing)
some wavelengths of light and reflecting the others.

The color that a surface displays depends on which colors


of the electromagnetic spectrum are reflected by it and
therefore made visible.
Subtractive color mixing
Applications of Colors
Use in marketing
Specific color meaning
Attractive attension
Indivisual differences

You might also like