Computer Graphics Chapter-3
Computer Graphics Chapter-3
Step 3. At each Xk along the line, starting at K=0, perform the following test:
Bresenham's Circles Algorithm …
If pk < 0 then
• Xk+1 = xk +1 and yk+1 = yk
• pk+1 = pk + 4 Xk+1 + 6
otherwise, if pk > 0
• Xk+1 = xk +1 and yk+1 = yk - 1
• pk+1 = pk + 4(Xk+1 - yk+1) + 10
• Step 4. Determine symmetry points at the other seven octants
• Step 5. Move each calculated pixel position (x,y) onto the circular path
centered on (Xc,Yc) and plot the coordinate value as x=x+xc and y=y+yc
Bresenham's Circles Algorithm …
Step 6. Repeat step 3 to 5 until x>=y.
Exercise:
1. Consider a line from (2, 3) to (6, 6). Use Bresenham's line drawing
algorithm to rasterize this line.
2. Draw a line with end points (20,10) and (30,18) using Bresenham’s
line drawing algorithm.
Antialiasing
If you try to implement the various scan conversion algorithms
discussed so far in a computer you will soon discover that sometimes
same pixel is unnecessarily set to same intensity multiple times;
sometimes some objects appear dimmer or brighter though all are
supposed to have same intensity; and most of the objects generated
are not smooth and appear to have rough edges.
All these are standard side effects of scan conversion: the first type is
called over striking effect, the second is unequal intensity effect while
the third type which is the most common and most pronounced,
known as aliasing effect.
Antialiasing …
In fact, aliasing is a typical image quality problem on all pixel devices,
including a computer screen.
Aliasing is the stair-step effect or jaggies on the edges of objects
displayed on computer screens – all diagonal and curved lines are
displayed as a series of little zigzag horizontal and vertical lines and
can be extremely distracting for PC users.
Antialiasing …
Antialiasing …
Among the other effects of aliasing, jagged profiles and disintegrating
textures are very common.
Antialiasing …
These jaggies are essentially caused by the problem of trying to map a
continuous image onto a discrete grid of pixels.
This continuous-to-discrete transformation (known as scan conversion) is
performed by sampling the continuous line, curve etc. at discrete points
(integer pixel positions) only followed by generating image pixels at integer
locations that only approximate the true location of the sampled points.
Pixels so generated at alias locations constitute aliases of the true objects
or object edges.
Therefore, we can say aliasing occurs as a result of an insufficient sampling
rate and approximation error (or more specifically quantization error).
Antialiasing …
In fact, aliasing is a potential problem whenever an analog signal is
point sampled to convert it into a digital signal.
It can occur in audio sampling, for example, in converting music to
digital forms to be stored on a CD-ROM or other digital devices.
Whenever an analog audio signal is not sampled at a high enough
frequency*, aliasing manifest itself in the form of spurious low
frequencies.
Now coming to Antialiasing, quite obviously it implies the techniques
used to diminish the jagged edges of an image so that the image
appears to have smoother lines.
Antialiasing …
As aliasing problem is due to low sampling rate for low resolution,
one easy solution is to increase the resolution, causing sample points
to occur more frequently.
This in turn will reduce the size of the pixels.
The size of the ‘jaggy’ or stair-step error is never larger than the size
of the actual pixel.
Hence, reducing the size of the pixel reduces the size of these steps.
But the cost of image production becomes higher with increased
resolution as it calls for more graphics memory.
Antialiasing …
The computational overhead increases for maintaining a high frame
rate (60 fps) for bigger frame buffer.
Thus, within the present limitations of hardware technology
increased screen resolution is not a feasible solution.
There are quite a few standard methods for antialiasing.
What antialiasing basically does is change the pixels around the edges
to intermediate colors or grayscales.
This has the effect of making the edges look smoother although it
also makes them fuzzier.
Antialiasing …
Antialiasing … (Super sampling or Postfiltering)
One of the methods of antialiasing is Super sampling or Postfiltering.
In this method more than one sample is sampled per pixel. How?
Every pixel area on the display surface is assumed to be subdivided
into a grid of smaller subpixels (super samples).
Thus, the screen is treated as having higher resolution than what
actually is.
A virtual image is calculated at this higher spatial resolution and then
mapped (displayed) to the actual frame resolution after combining
(averaging) the results of the subpixels.
Antialiasing … (Super sampling or Postfiltering)
The intensity value of a pixel is the average of the intensity values of
all the sampled subpixels within that pixel.
The following illustration describes the concept of super sampling.
Antialiasing … (Super sampling or Postfiltering)
Antialiasing … (Super sampling or Postfiltering)
Antialiasing … (Super sampling or Postfiltering)
Antialiasing … (Super sampling or Postfiltering)
This method is also known as postfiltering because filtering is carried
out after sampling.
Filtering means eliminating the high frequencies, i.e., combining the
super samples to compute pixel colour.
This type of filtering is known as unweighted filtering because each
super sample in a pixel, irrespective of its position, has equal
influence in determining the pixel’s colour.
In other words, an unweighted filter computes an unweighted
average. The other type of filter is a weighted filter.
Antialiasing … (Super sampling or Postfiltering)
Through this filter each super sample is multiplied by its
corresponding weight and the products are summed to produce a
weighted average, which is used as the pixel colour.
The weighting given to each sample should depend in some way on
its distance from the center of the pixel.
The center sample within a pixel has maximum weight.
An array of values specifying the relative importance (weights) of
subpixels can be set for different-sized grids and is often referred to as
Pixel-Weighting Masks.
Antialiasing … (Area Sampling or Prefiltering)
The other standard method of antialiasing is Area Sampling or
Prefiltering.
Prefiltering method treats a pixel as an area, and computes pixel
colour based on the overlap of the scene’s objects with a pixel’s area.
These techniques compute the shades of grey based on how much of
a pixel’s area is covered by an object.
Compared to postfiltering, prefiltering technique doesn’t take into
account calculating subpixel intensities (thus eliminates higher
frequencies) before determining pixel intensities.
Antialiasing … (Area Sampling or Prefiltering)
A better technique, weighted area sampling uses the same basic
approach, but gives greater weight to area near the center of the
pixel.
Prefiltering thus amounts to sampling the shape of the object very
densely within a pixel region.
For shapes other than polygons, this can be very computationally
intensive.
Antialiasing …
There are other methods as well besides these two like Adaptive
Sampling, Stochastic Sampling, Raytracing etc.
But as an introduction to this topic we may stop here now.
However, it should be noted that aliasing is an inherent part of any
discrete process, its effect can be minimized but not eliminated.
Character generation
There are three basic methods to generate characters on a computer
screen:
(1). hardware-based
(2). vector-based and
(3). bit map-based methods.
Character generation … (Hardware-based)
In the hardware-based method, the logic for generating character is
built into the graphics terminal.
Though the generation time is less the typefaces* are limited due to
hardware restrictions.
Character generation … (Vector-based)
In the vector-based method the characters are developed using a set
of polylines and splines that approximates the character outline.
This form of character representation is completely device-
independent.
Memory requirement is less as boldface, italics or different size can
be produced by manipulating the curves outlining the character
shapes – it doesn’t require separate memory blocks for each
variation.
Character generation … (Vector-based)
Character generation … (Bitmap-based)
In the bitmap-based method small rectangular bitmap called
character mask (containing binary values 1 and 0) is used to store
pixel representation of each character in a framebuffer area known as
font cache.
Relative pixel locations corresponding to a character bitmap are
marked depending on the size, face and style (font) of character.
Size of each character masks range from 5 × 7 to 10 × 12.
A single font in 10 different font sizes and 4 faces (normal, bold, italic,
bold italic) would require 40 font caches.
Character generation … (Bitmap-based)
Characters are actually generated on display by copying the appropriate
bitmaps from the frame buffer to the desired screen positions.
A mask is referenced by the coordinate of the origin (lower left corner)
of the mask w.r.t frame buffer addressing system.
In bit map-based method a bold face character is obtained by writing
the corresponding ‘normal’ character mask in consecutive frame buffer
x-locations.
Italics character is produced by necessary skewing of ‘normal’ character
mask while being written in the frame buffer.
Character generation … (Bitmap-based)
In fact, a typeface designer can create from scratch new fonts using a
program like Windows Paint.
The overall design style (font and face) for a set of characters is called
a typeface.
The End
Any Questions?