UNIVERSITY OF KUFA EDUCATION COLLEGE COMPUTER GRAPHICS Lecture #1 Introduction Assoct.Prof. DR. NIDHAL EL ABBADI E-mail : email@example.com
Textbooks: Title: Computer Graphics Author: D. Hearn & M. Baker Publisher: Prentice Hall, 2000 In addition to the above, the students will be provided with handouts by the lecturer.
DEFINTION OF Computer Graphics almost everything on computers that is not text or sound A branch of computer science that deals with the theory and techniques of computer image synthesis. Computers produce images by analyzing a collection of dots • Creating computer graphics requires: • -A digital computer to store and manipulate images • -A display screen • -Input/output devices • -Specialized software that enables the computer to: • Draw • Color • and manipulate images held in memory
Visualize your imagination in computers • Computer graphics = reality + imagination
Why Computer graphics • Graphics is cool • I like to see what I’m doing • I like to show people what I’m doing • Graphics is interesting • Involves simulation, algorithms, architecture… • Almost no area in which graphical displays cannot be used
Why should we study Graphics? • Many of the leading scientists through the ages have been ‘visual thinkers’… • Leonardo da Vinci • Einstein • Clerk Maxwell
Areas of computer graphics •Geometry (Modeling) •Rendering •Motion (Animation)
Modeling: creating and representing the geometry of objects in the 3D world • Representations of geometry ο Curves: splines ο Surfaces: meshes, splines • Procedural modeling ο Sweeps ο Fractals ο Grammars
Rendering: (light, perspective) generating 2D images of the objects • 3D Rendering Pipeline ο Modeling transformations ο Viewing transformations ο Hidden surface removal ο Illumination, shading, and textures ο Scan conversion, clipping ο Hierarchical scene graphics ο OpenGL • Global illumination ο Ray tracing ο Radiosity OpenGL
Animation: (movement) describing how objects change in time • Keyframing ο Kinematics ο Articulated figures • Motion capture ο Capture ο Warping • Behaviors ο Planning, learning, etc.
Applications of Computer Graphics •Video games •Cartoons •Film special effects •CAD/CAM •Simulation •Medical imaging •Scientific & Information visualization
Graphics Applications Entertainment: Cinema
Graphics Applications Entertainment: Games
Film Special Effects •Lord of the rings •King Kong
Graphics Applications Medical Visualization
Medical Imaging MedicView
Graphics Applications Scientific Visualization
Graphics Applications Computer Aided Design (CAD)
1 2 3 4 5 8 7 6 Curve and Surface Modelingin Computer-Aided Design (CAD)
Scientific Visualization Mars Data Visualization Weather Data Visualization
Simulation / Virtual Reality (VR) FlightSafety International Beech 1900D Simulator, at the Orlando Training Center
pixel • The basic unit of the composition of an image on a television screen, • computer monitor, or similar display. • (PIX [picture] ELement) Generally, the smallest addressable unit on a • display screen or bitmapped image • Screens are rated by their number of horizontal and vertical pixels; • for example, 1024x768 means 1024 pixels are displayed in each • row, and there are 768 rows (lines). Likewise, bitmapped images • are sized in pixels: a 350x250 image has 350 pixels across and 250 down. • With color systems, each pixel contains red, green and blue • subpixels, and the subpixel is actually the smallest addressable • unit. The monitor's circuits address subpixels, and the software • may also
In remote sensing, an element of a picture; the basic unit from which • an image may be built up. Pixels can be taken from an area of 5m 2 to • 10 km2, or more. Pixel information for band or brightness varies • according to the sensor system used
Pixels Properties • The pixel is the smallest addressable screen element. • It is the smallest unit of picture that can be controlled. • Each pixel has its own address. • The address of a pixel corresponds to its coordinates. • Pixels are normally arranged in a two-dimensional grid, and are often represented using dots or squares. • Each pixel is a sample of an original image; more samples typically provide more accurate representations of the original • The intensity of each pixel is variable • In color image systems, a color is typically represented by three or four component intensities such as red, green, and blue, or cyan, magenta, yellow, and black
Pixel Coordinate Systems Pixels (1,5), (1.8,7.1), etc.
This example shows an image with a portion greatly enlarged, in which the individual pixels are rendered as little squares and can easily be seen A photograph of sub-pixel display elements on a laptop's LCD screen
A pixel does not need to be rendered as a small square. This image shows alternative ways of reconstructing an image from a set of pixel values, using dots, lines, or smooth filtering
Standard display resolutions • The display resolution of a digital television or display device is the number of distinct pixels in each dimension that can be displayed • The more pixels used to represent an image, the closer the result can resemble the original. • The term "pixels" can be used in the abstract, or as a unit of measure, in particular when using pixels as a measure of resolution, such as: 2400 pixels per inch, 640 pixels per line, or spaced 10 pixels apart.
Bits per pixel Color depth • The number of distinct colors that can be represented by a pixel depends on the number of bits per pixel (bpp). • The measures dots per inch (dpi) and pixels per inch (ppi) are sometimes used interchangeably, but have distinct meanings, especially for printer devices, where dpi is a measure of the printer's density of dot (e.g. ink droplet) placement • 1 bpp, 21 = 2 colors (monochrome) • 2 bpp, 22 = 4 colors • 3 bpp, 23 = 8 colors • 8 bpp, 28 = 256 colors • 16 bpp, 216 = 65,536 colors ("Highcolor" ) • 24 bpp, 224 ≈ 16.8 million colors ("Truecolor")
Megapixel A megapixel (MP or Mpx) is 1 million pixels, and is a term used not only for the number of pixels in an image, but also to express the number of image sensor elements of digital cameras or the number of display elements of digital displays 3.1 megapixels" (2048 × 1536 = 3,145,728).
Displaying the Pixel On a display screen, pixels are either phosphor or liquid crystal elements. For monochrome, the element is either energized fully or not. For gray scale, the pixel is energized with different intensities, creating a range from light to dark. For color displays, the red, green and blue subpixels are each energized to a particular intensity, and the combination of the three color intensities creates the perceived color to the eye Pixel Structures In storage, pixels are made up of one or more bits. The greater this "bit depth," the more shades or colors can be represented. The most economical system is monochrome, which uses one bit per pixel (on/off). Gray scale and color typically use 4 to 24 bits per pixel, providing 16 to 16 million colors
COLORS The RGB color model is an additivecolor model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors A representation of additive color mixing. Projection of primary color lights on a screen shows secondary colors where two overlap; the combination of all three of red, green, and blue in appropriate intensities makes white
Zero intensity for each component gives the darkest color (no light, considered • the black), and full intensity of each gives a white • When the intensities for all the components are the same, the result is • a shade of gray, darker or lighter depending on the intensity • When the intensities are different, the result is a colorized hue, more or less • saturated depending on the difference of the strongest and weakest of the • intensities of the primary colors employed. • When one of the components has the strongest intensity, the color is a hue • near this primary color (reddish, greenish, or bluish). • When two components have the same strongest intensity, then the color is • a hue of a secondary color (a shade of cyan, magenta or yellow). • A secondary color is formed by the sum of two primary colors of equal • intensity: cyan is green+blue, magenta is red+blue, and yellow is red+green
There are two major types of 2D graphics used by designers: • raster (or bitmap) Raster images are also commonly known as bitmaps and are composed of pixels in a grid. • vector images. Vector images are composed of paths creating individual, scalable objects. These objects are defined by mathematical equations to render high quality graphics. Vector graphics consist of lines, curves, and shapes with editable attributes such as color, fill, and outline
Vector-based Images are Resolution Independent • Changing the attributes of a vector graphic does not affect the graphic itself. You can change any number of the graphic attributes without destroying the basic image. Because they’re scalable, vector-based images are resolution independent. You can increase and decrease the size of vector images to any degree and your lines will remain crisp and sharp, both on screen and in print. When increasing the size of a raster image the pixels defining the image can be increased in either number or size. The image will begin to lose detail and clarity when the pixels are spread over a larger area. Scanned graphics and web graphics are the most common forms of raster images.
Raster-based Images Are Resolution Dependent • The resolution of an image is usually stated in dpi (dots per inch) or ppi (pixels per inch). Raster images are displayed on your computer screen at approximately 100 ppi. When printing raster images, your printer needs much more image data than a monitor. To render a bitmap image accurately, the typical desktop printer needs 300-600 dpi. The quality of the print increases when a higher resolution is used. • Bitmaps cannot be scaled without the loss of quality to the image. Because raster images are resolution dependent, it's difficult to increase or decrease their size without sacrificing the overall quality. The image may appear clear on screen, but once printed the loss of quality is more apparent as the image may appear pixelated or blurry.
When To Use Vector Images • Wherever possible use the vector format for all your type, line art and illustrations. Vector images are very useful when developing something for scale or sending to a printing company and are ideal for logo design and illustration. A disadvantage is that vector images are unsuitable for producing photo-realistic imagery • When To Use Raster Images • Raster images are best used for photographs and images with subtle shading. This graphic type is useful when editing, manipulating, or adding special effects to an image. • Raster images should not be used when transparent backgrounds are preferred or on images where high quality needs to be maintained once the image is scaled.
Important Instructions with C++ #include<graphics> // using in header int gdriver = DETECT , gmode ; // auto detection initgraph ( &gdriver, &gmode, “\\tc\\bgi “ ); // graph initialization cleardevice() ; // clear a graphics screen closegraph() ; // close a graphics screen To draw pixel in (x, y) coordinate with specific color, use the instruction: void putpixel (int x, int y, int color);