Encoding Schemes

Abstraction in Imagery

Have you ever heard the colloquialism, “There’s more than one way to skin a cat"? Taken literally, the sentence is somewhat morbid, but figuratively, it means that there is often more than one way to accomplish a task, whether that be skinning a cat, coding a program, or representing an image digitally.

Common misconception: Images have to be stored pixel by pixel.
  • Abstraction allows for virtually any representation as long as a program knows how to interpret it and convert it into some visual artifact.

Look at the image below, and consider how you would describe it and how a computer would “describe” (i.e., encode) it:

You would probably describe aspects like:

  • repeated patterns
  • names of objects
  • color (RGB, wavelength, intensity)
  • size (length, width, height)
  • shape
  • location (coordinates)
  • brightness (greyscale, darkness, power allocation)
  • texture

These are all characteristics that we notice visually, and they are therefore factors that we need to consider when we represent images digitally, so that the computer can accurately interpret the abstraction and display the image as we intend.

Image Type Matters

Digital photos tend to be color-rich, digital diagrams tend to be shape-dependent, and digital drawings rely on a great deal of contrast/brightness. Encoding schemes must account for and suit the factors that impact different image types more heavily than others. “There is more than one way to skin a cat,” but sometimes one way is better than another! Consider the following factors that impact how an image is to be used:

  • information—What kind of image is it? Is it a photograph, a drawing, black & white?
  • size—How big is it?
  • use—What is the image used for? Is it used for a fax machine, digital photography, a diagram?
  • scalability—Does the image need to be scaled? Does it need to be reduced, enlarged, rotated?

Each of these factors determine which encoding schemes are best suited to represent an image. For example, let’s consider a black & white diagram of an arrow, like this one:

In this case, the color is not as important as the shape, location, and direction of the arrow, which provide meaning to the diagram. A vector encoding would be much more suitable for this image than a raster representation, because shape, location, and direction information can be expressed more concisely and require less data.

Certain encoding schemes are better than others for representing shape, location, and direction. On the other hand, other encoding schemes are more effective for encoding an array of colors than they are for encoding shape, location, or direction.

When you choose the encoding scheme for a digital image representation, consider the most important aspects of the image and determine what type of image formats would work best for you to realize them.

Just as text can be represented with binary by conventional mappings, so can media (images, video, audio, etc.). Unlike the fairly standardized encoding of text, images are represented in many different ways.

Line Contour Drawing

Consider “line contour drawing,” where the artist puts the pencil on the paper and traces out an outline of an object without picking up the pencil. How might an image be encoded to imitate this style of rendering? Direction and extension are the important components here, whereas location is always relative to the starting point, rather than absolute.

Example list of instructions:

  • Start at position (x,y).
  • Move 10 pixels in direction 132º.
  • Move 8 pixels in direction 278º.
  • Stop.


Image Types

Imagine that an image file is opened, and the first few bits read:


What does the computer do with them? What does it interpret them to mean? Computers and images make the encoding bits meaningful with a file type that describes the method of encoding (e.g., BMP, JPG, GIF, SVG, etc.). These file formats provide instructions for interpreting the bits and providing the abstraction that you see as an image on your screen.

If the image file is a raster image, these bits represent color information for a specific picture element (or pixel) on the screen. The most common color model used for computer displays is RGB (red-green-blue). In this scheme, the binary encoding may represent the color of the first pixel in the image as follows:

Red Green Blue
01110111 11001101 00011110

If the image file is a vector image, these bits represent instructions for drawing shapes. This is much like the Processing programs that contain instructions to draw on the screen:


An example encoding may produce a rectangle if it were for a vector image encoding:

Width Length Thickness
01110111 11001101 00011110

Here, the same bits that determined color before are abstracted to draw a rectangle with a 119 pixel width, 205 pixel length, and a line thickness of 30 pixels.

Note how simple it would be to double the thickness of the line. Simply multiplying 00011110 by 2 produces 00111100. If this were a raster format, each of the corresponding pixels of the new larger rectangle would need redefining.

Common Misconception: Bits map directly to an image.
  • Abstraction rears its beautiful head once again. Bits mean nothing inherently; their meaning depends upon the instructions to decode them. You could conceivably view ASCII text as a JPG. It would probably be ugly noise – or perhaps exhibit a distinct pattern?
    • Try the reverse—open a JPG in Notepad or TextEdit.
    • Open a file in “hexdump” to see its hexadecimal representation (BASE16).
    • If you are using a Unix-based operating system (e.g., Linux or Mac OS), try using the command “xxd -b” on a file to see its contents in binary bitstrings of 1s and 0s.

Different file formats (abstractions) lend themselves well to specific purposes. For example:

  • Compressed raster formats save hard drive space.
  • Vector formats offer scalability.
  • Raw formats preserve the exact sensor data from a camera or other image capture device.