Computer Graphics (GRK)
Lecture I
General terms
Computer Graphics, similarly to all other branches, has some features that are characteristic for the whole branch. This lecture presents selected notions and problems important for the whole branch. Detailed methods of computer graphics will be presented in next lectures.
Image, as any other information in computer, must be represented in digital form. Digital image may be acquired in many different manners. It may be digital photo taken by digital camera. It may be a scan of paper document. It may be an effect of calculations using computer graphics methods - most frequently with the use of one from many application programs making image generation easier.
The goal of computer graphics is to generate new images suitable for particular application. In particular, one of the goals of computer graphics is generation of images with quality as close as possible to images observed in real world. But we must remember that computer graphics uses many simplifications resulting from necessity to adapt to computational power of available hardware and limited capabilities of displays (frame rate, available resolution, dynamic range of luminance).
Digital images may be processed in order to get another form more suitable for particular application especially for improvement of image quality. Example methods of image processing may rely on change of image resolution, change of colours, change of image contents, highlighting of particular areas, image compression etc. These methods are frequently used in postprocessing phase.
In computer graphics we may distinguish methods of planar computer graphic (2D), spatial computer graphic (3D) and animation.
2D computer graphics operates on objects located on a plane. For example the objects are straight lines, curves, planar geometric figures, hand drawings, texts etc. Typical operations include drawing, figure interior filling, geometrical transformations (translations, rotations, scaling), object dimensioning etc. Characteristic feature is lack of illumination. Many application programs for 2D graphics are available. They contain many tools that make image generation easier. Professional editors as Corel Draw and Illustrator are highly evaluated. There exists also free Inkscape.
In 3D graphics scenes with 3D objects are created. Important elements of each scene are the light sources that provide proper object illumination. In consequence we must calculate objects surface colours (shading) and define shadows casted by these objects (shadowing). After finishing the scene modelling process the camera is placed in the scene. The camera placement defines reference point of view for creation of two dimensional view of three dimensional scene, that might be displayed on flat display screen. The process of transfer from 3D scene to 2D view is referred to as rendering. The rendering may be realized in different manner. The most frequently two methods are used: object method (rasterisation concept) and image method.
In object approach, during rendering such operations as projections, definition of object visibility/obscuring, shading, rasterisation etc. take place. It is important that for each object its influence on corresponding pixels (fragments) is calculated. If we know fragments associated with particular pixel we are able to define its final colour.
While in image approach, for each pixel of image all objects that influence this pixel are found and pixel colour is calculated directly. Such method is used in ray tracing, where different algorithms than in object approach are used. In particular rasterisation problem does not occur.
Both 2D graphics and 3D graphics are the base for creation of animation, that means a sequence of images including more or less complex movies starting from simple commercials or cartoons for children, ending with feature films. In these applications the image sequences are generated off-line and then may be displayed with required frame rate. The situation is different in the case of computer games and all kinds of simulators where the interaction with the user is required. Here it is necessary to calculate next image from the sequence on-line.
Among many editors for 3D graphics let us mention professional program 3D Studio Max and free program Blender.
In both 2D and 3D graphics during image generation phase so called vector graphics is used, where the objects are described in mathematical way. For each object a set of data is given, on the basis of which appropriate algorithms are capable to generate digital image of this object, which may be then displayed (Fig. I.1). Vector graphics allows definition and edition of object each time in desired resolution.
Fig. I.1. Connections between vector graphics, digital image and displaying
If the image exists in digital form the information/description of the displayed objects is no longer available. In this case it is impossible to perform any operation on objects. We may only operate on the whole pixel image, on individual pixels or on groups of pixels. In possible change of image resolution we must reckon with some losses in image quality. Also the memory capacity required to store final image is most frequently much greater than in vector graphic, where only the data for creation of final digital image are stored.
In general the process of image generation may be divided into three stages: modelling, rendering and displaying. (Fig. I.2)
Fig. I.2. Basic stages of digital image generation process
Modelling stage includes all calculations connected with scene creation, generation of objects with their parameters, illumination, camera placement.
Rendering include a sequence of calculation resulting in digital image that is ready for displaying.
Displaying stage provides proper image displaying on the display screen.
The most frequently the modelling stage is not computationally demanding and may be realised by Central Processing Unit. While the rendering stage is much more demanding. In typical graphical system vast majority of calculation is performed on vertices of objects generated during modelling stage. While the final effect of calculations in rendering stage are the informations about colours of each digital image point (pixel) which are much more numerous than in input vertices sequence. Moreover, the calculations must be done in very short time defined by the display requirements. In practice fulfilling these requirements is possibly only by using hardware support of calculations. This support is provided by graphical boards containing specialised graphical processors (GPU). Simultaneously the optimisation of used algorithms from the point of view of execution time is very important.
In contemporary displays raster method of displaying is used. The pixels are displayed on the screen in a sequential manner (Fig. I.3). At first, the pixels in first row are displayed one after another. Then the sequence repeats in second row, and so on until the last row. (Let us notice the difference between raster displaying in comparison with cinema, where the whole frame is displayed at once).
Fig. I.3. The order of pixel displaying on display screen
The informations about pixel colours are taken from image memory. As a rule pixel colour is defined by the values of three primary colours R,G,B. General rule of colour pixel displaying relies on displaying in close vicinity three small colour dots respectively R,G and B. Such triad of dots, observed from some distance converges into single coloured pixel (Fig. I.4)
Fig. I.4. Method of generation colour pixels on the screen. At the left side three small R,G,B dots are shown. At right side colour pixel seen from long enough distance
The detailed way of displaying triplets of dots depends on the type of display. In CRT displays there are three dots of luminophores R,G,B (triads) emitting light after excitation by an electron beam. In LCD displays there are three neighbouring LCD cells equipped with R,G and B filters. In OLED displays there are three colour LEDs that form a pixel.
Let us pay attention to few aspects relevant from the point of view of calculations associated with digital image and its displaying. At first the frequency of displaying subsequent images (frame rate) is important. The problem appears with to small frequency when the effect of flickering occurs. Now it is accepted that frame rate should be not less than 70-80 Hz. It means that the time for displaying single image is in the range of ten and a few milliseconds. If we additionally take into account pixel resolution of the image it occurs that the time for displaying a single pixel is in the range of a few nanoseconds.
Example
Let us assume the a display with pixel resolution 1920 x 1080 displays the images at frequency 80 Hz. What is the time devoted to display a single pixel?
Frame period/Time for displaying single image is equal to
$$1/{80\;Hz}=12,5\;ms$$
Number of pixels to be displayed
$$1920\;x\;1080$$
Time for displaying a single pixel is equal to
$${12,5\;s}/{1920\;x\;1080}≅6\;ns$$
Let us notice that it is approximate value, because in calculations we did not take into account the time of passage from displaying one row to displaying the next row and the time of passage from displaying one frame to the next frame.
During displaying the given image the next image is calculated. The calculations should be finished before the end of displaying of given image. Hence the calculation time should be no longer than ten and a few milliseconds mentioned above. It is advisable to store the pixels of new image in a block of memory different from block which actually is sending information about presently displayed image. In practice the concept of double image memory buffer is used which works as follows. When the image is displayed from the first buffer, the new image is stored in the second. After finishing the calculations of new image and finishing present frame the roles of buffers are switched (Fig. I.5). This method is frequently referred to as ping-pong.
Fig. I.5. Double image memory buffer
Sometimes with complex scenes system does not follow up with calculations and is capable to calculate less images during a second than the required frame rate. Then some frames may be displayed twice. In general we face the problem of synchronisation between abilities of the display with given frame rate and abilities of calculation system defined by the number of frames calculated during one second referred to as Frames per Second (FPS).
During this lecture we have learned general notions and problems typical for computer graphics. The knowledge of these issues is relevant for understanding the next lectures. Particularly we paid attention to timing requirements with respect to calculations of the next image and its displaying.
Questions and problems to solve.
- Tell the difference between 2D graphics and 3D graphics.
- Compare the vector graphic and raster graphics.
- Explain the principle of raster displaying.
- Explain the action of double image memory buffer.