*

Graphics Lecture 2

Images on computers

Reference: Computer Confluence, Beekman et. al, Addison-Wesley, 1997.

Topics.

Images

  1. Palettes

Graphics representation.
  1. An image on a computer screen is made of a matrix of pixels arranged in rows.

  2. Pixel: tiny dot of white, black, or color.

  3. Create pictures, words, etc by controlling the pixel pattern.

  4. Most programs generate the pixel pattern automatically. Example: characters, numbers, charts (in Excel) are all created by the program in which you are working.

  5. Some programs allow you to control what goes on the screen to create graphics. These programs use two major approaches: bit-mapped graphics and vector graphics.

  6. Bit-mapped graphics. Also called raster graphics. These are pictures that are, to the computer, a map showing how the pixels on the screen should be represented.

    1. For black and white graphics, a single bit of coputer memory represents each pixel. Each bit contains one of two possible values, 0 or 1.

    2. If allocate more bits-per-pixel can get more sophisticated pictures. Can use 8-bits to represent 256 shades of gray. This is more shades than the human eye can see.

    3. Can also use 8-bits to represent 256 different colors. This is common on older machines.

    4. Some machines support 16-bits (for 16 thousand colors) or 24 bits (for 16 million colors).

    5. The number of bits devoted to each pixel is called color depth or bit depth . See previous section of lecture notes.

    6. Another factor limiting realistic on-screen images is the number of pixels displayed on the screen. This depends on the amount of VRAM in the computer. Called resolution and is described by the number of pixels in a row X column, e.g., 1024 X 780. This can often be changed on the fly (note: not in William 203 machines).

    7. A final factor is the density of pixels. Also called resolution . Described in terms of dots per inch or dpi . See last set of lecture notes. Normal resolution of a computer is about 72 dpi.

    8. How do these two resolutions compare. I'm not sure, but think that you may have more than one pixel make up a "dot". Thus changing your screen resolution from 640X480 to 1024X780 shows more pixels on the screen. But your screen is still showing the same number of dpi, for example 72. Thus the size of the graphic doesn't seem to change, though there are now more pixles per dot. I'm trying to varify this, but can't find a source. No one seems to talk about it directly!

    9. Note that the resolution of a computer is different than the resolution of a printer. A picture will look fine on a computer at 72dpi, but will look pixelated or jaggy when printed. This is because of the physical difference between ink on paper and the phosphors on a screen.

    10. You can get around this problem by storing a picture in greater resolution. For example, when you scan in a graphic, you can choose to store it at 300 dpi.

    11. Note that a screen can only show 72 (or 96) dpi. So a graphic stored at 300 dpi will take up more than a screen.

    12. Printing a 300 dpi graphic will take up a single page and will look better beacuse of the higher number of dots in each inch.

  7. Vector graphics. Images are stored in a different manner. Don't keep a collection of dots, but a collection of lines and shapes that are represented by equations.

    1. When you draw a line, the line is not stored as a pixel map, but as a mathematical formula representing the position, direction, and size of the line.

    2. Graphics saved this way are collections of lines, shapes and other objects. Thus the approach is also called object-oriented graphics.

    3. Advantage: can manipulate objects independently, even if they overlap. In a bitmapped program, when an object or shape overlaps another shape, their bitmaps are joined and you can never separate them. In a vector graphic, once you create the shape, you can always move, resize, rotate, etc. that shape, even if it overlaps another shape.

    4. Advantage 2: vector graphics take much less room to store than bit-mapped graphics. This is because we must only store an equation for each shape, and not information about every pixel.

    5. Thus vector graphics are prefered for the web. They are smaller and can be downloaded more quickly.

    6. Disadvantage: harder to achieve painting-like effects. Can't apply filter effects etc. on vector objects (though this is starting to change).
Graphics Storage

  1. Graphics must be stored somewhere. Graphics files tend to be very large. Thus people have created a number of ways of storing graphics that retains the information about the picture, yet minimizes the amount of storage required. A method of storing graphics is called a format.

  2. Unfortunately, there are many different formats available and some will only work on certain platforms.

  3. Some different formats include:

  4. Web Graphics. Two formats are widely recognized by Web browsers, CompuServe GIF and JPEG. Another format, PNG is gaining in popularity and is recognized by the most recent versions of Netscape and Explorer.

    • Color on the Web. As discussed above, many monitors are limited to displaying 256 colors. System software (Mac OS and Windows) and browsers typically reserve up to 40 colors for their own use.

      When displaying images on these monitors, the browsers are left with 216 colors to display images. Browsers use a particular palette of 216 colors called a browser safe palette.

      If the images on your page contain more than 216 colors, or if they contain colors other than the 216 in the browser safe palette (and you're monitor only displays 256 colors), then the browser will try to combine existing colors to reproduce the missing ones. This is called dithering . Results are usually very bad.

      Only a problem if someone has a 8-bit monitor.

    • Transparency. Process of making some colors in your image clear. Allows you to see through an image to an underlying image. Good for overlapping images or to give an image a non-rectangular outline. GIF and PNG allow transparency. JPEG does not.

    • Speed. Must keep download time to a minimum. Methods:

      • Make your images smaller.

      • Compress the image.

    • Compression. There are three popular compression methods:

      • LZW (used in GIF images)

      • JPEG

      • PNG

    • LZW is particularly effective for computer-generated art like logos, rendered text, and other images that have large areas of a single color.

      Often, if you can reduce the number of colors in an image, LZW can compress the image even more.

      Problem: LZW is patented, so developers have to pay royalties on software that uses it. This is why PNG was developed.

      Problem: GIF images are limited to 256 colors.

    • JPEG is better at compressing photographs and other images that have many different colors.

      If you blur an image, thereby creating even more colors, JPEG compression is often more effective.

      Problem: It is lossy compression (see above).

      Problem: Compression information takes up a lot of space and is not worth it for smaller images.

    • PNG compresses better than LZW without losing information like JPEG.

    • Interlacing. A storage mechanism that allows a form of progressive display, i.e., viewers will see successively more detailed pictures displayed as the image is decompressed. All three formats support interlacing.

    • Animation. Only GIF images can be animated.

Return to John Barr's Home Page

Last Modified: 8 September 2000

THIS PAGE MAINTAINED BY:
John Barr, Ithaca College