Section 3.14 Digital Information and Data Compression (2026)
90 minutes
Solving problems with computers often involves working with large amounts of data. In this lesson we explore how to reduce the size of data to save storage space or transmission time.
Data compression is the process of reducing the size of data to save storage space or transmission time. It is an important concept in computer science and is used in many applications, such as image and video compression.
In this lesson we continue the exploration of bits and binary numbers that we began in Unit 1. In this case we learn how to use bits, 1s and 0s, to represent images.
Subsection 3.14.1 Data Representation
All data in a computer is represented in binary, using 1s and 0s. How it is represented depends on the type of data. For example, text is represented using ASCII, and images are represented using pixels.
All data is stored in bits, which are the smallest unit of data in a computer. A bit can have a value of either 0 or 1. A group of 8 bits is called a byte, which is 8 bits. A byte can represent 256 different values, from 0 to 255. For example, the letter "A" is represented as 01000001 in binary, which is 65 in decimal.
American Standard Code for Information Interchange (ASCII) is character code that includes 128 characters. It allows us to represent text in binary format. Check out this ASCII to binary table to see how each character is represented in binary. For example, the letter "A" is represented as 01000001 in binary.
ASCII is one type of character code, but 128 characters is not enough for todayβs computers, which can represent Chinese, Hindi, and scripts from many other languages. Todayβs computers use a system called Unicode, which has more than 100,000 different characters and covers more than 100 different scripts (languages).
Activity 3.14.2 Unicode Characters.
A pixel (from picture element) is the smallest unit of a digital image or graphic that can be displayed and represented digitally. A pixel is a single point in a image; so it is the smallest controllable element of a picture represented on the screen. Each pixel is represented by a color value, which can be represented in binary.
In images and web pages, colors are represented using hexcode for Red, Green, and Blue values. Hexcode represents numbers in base 16. Hereβs a color mixer app that lets you explore the different colors that are used in Web pages. See how the hexcode for each color is represented in binary. Check out this color mixer app to explore colors and their binary representations.
Activity 3.14.3 Common Color Codes.
Subsection 3.14.2 Data Compression
Data compression is the process of reducing the size of data to save storage space or transmission time. It is an important concept in computer science and is used in many applications, such as image and video compression.
A lossless compression algorithm is one in which no data are lost; the original data can be completely recovered. An example of lossless compression is RLE.
A lossy compression algorithm is one in which some data are lost; the original data cannot be completely restored. An example of lossy compression is JPEG. Lossy data compression algorithms can usually reduce the number of bits stored or transmitted more than lossless compression algorithms.
Important things to know about data compression:
-
Fewer bits does not necessarily mean less information.
-
The amount of size reduction from compression depends on both the amount of redundancy in the original data representation and the compression algorithm applied.
-
The amount of compression can vary depending on how many bits are used to represent each pixel in the image.
-
The amount of compression also depends on the number of different colors used in the actual image. For our black and white spaceship there were only 2 colors, so there were relatively few color changes and therefore lots of long runs. If it were a colored spaceship, there would be many color changes and therefore fewer long runs. So we would get much less compression.
Subsection 3.14.3 Image Compression
Images are represented in a computer as a grid of pixels. Each pixel is represented by a color value, which can be represented in binary. The more bits used to represent each pixel, the more colors can be represented, but the larger the image file will be. More bits per pixel means more information, but also more storage space and transmission time. Data compression can be used to reduce the size of image files by reducing the number of bits used to represent each pixel.
Image compression is a type of data compression which can reduce the size (number of bits) of transmitted or stored data. There are many different image compression techniques. Some of the most common are: GIF, JPEG, and PNG.
-
GIF is a lossless compression technique that is best for images with few colors.
-
JPEG is a lossy compression technique that is best for photographs.
-
PNG is a lossless compression technique that is best for images with many colors.
The image representation technique demonstrated in the video below is known as run-length encoding (RLE) and it is an image compression technique. Image compression is a type of data compression which can reduce the size (number of bits) of transmitted or stored data. RLE compression is an example of lossless compression and illustrates some of the ways that images and other data can be represented with binary numbers.
JPEG is an example of a lossy compression algorithm. JPEG, which uses the file extension .jpg or .jpeg, is the most common format used today to represent images.The JPEG algorithm was created by the Joint Photographic Experts Group (JPEG), hence its name. The fact that JPEG is a lossy technique means that some of the information present in the image is lost during compression and cannot be recovered. Here is a video lecture on the JPEG compression algorithm. The compression algorithm involves some math, but the video describes just enough of the math so that you can see how JPEG works. The video is a summary of an excellent, more detailed presentation by Randell Heyman -- you should really check out the Heyman video if you are interested in more of the mathematical details.
Subsection 3.14.4 Other Types of Digital Data
How do Snapchat filters work? If you or someone you know uses the social media app Snapchat, they have probably used one of those cool filters. But, how exactly do those filters work? Watch the video below to learn more about the algorithm and pixel data behind Snapchat filters.
How are audio files digitized? What about audio files? How are they digitized and converted to bits? Watch the following video for a summary of how audio files are converted from analog to digital format. Analog refers to data with values that change continuously, or smoothly, over time, like sound or music files. Analog data is converted to a digital forms, 0s and 1s in binary, using a sampling technique, which means measuring values of the analog signal at regular intervals (usually in time or space) called samples. The samples are measured to figure out the exact bits required to store each sample. The use of digital data to approximate real-world analog data is a great example of abstraction!
Hereβs a fun activity if you have a computer or tablet with a microphone. Go to https://academo.org/demos/virtual-oscilloscope/ or a different audio recorder and see the sound waves that your voice can produce. Think about how they would be represented in 0s and 1s.
Different audio file extensions compress the audio data in different ways. WAV files are huge because they just store snapshots of digitized values at different points of time with no compression. MP3 formatting compresses audio files by removing parts of the audio signal which the human ear cannot easily hear. They save on space while preserving good audio quality.
Subsection 3.14.5 Digital Information and Data Compression Review
Activity 3.14.4 Data Compression Vocabulary.
Activity 3.14.5.
Which of the following is a true statement about data compression?
-
Sending a compressed version of a file ensures that the contents of the file cannot be intercepted by an unauthorized user.
-
There are trade-offs involved in choosing a compression technique for storing and transmitting data.
-
Data compression is only useful for files being transmitted over the Internet.
-
No matter what compression technique is used, once a data file is compressed, it cannot be restored to its original state.
Activity 3.14.6.
Consider the 8-bit binary sequence 01000001. Depending on the context or program reading this byte, it can be interpreted as different types of data. Which of the following statements correctly describes how this single byte can represent different types of information?
-
It inherently contains metadata that forces the computerβs CPU to display it only as the capital letter βAβ.
-
A byte is just a sequence of 8 bits (0s and 1s) and does not inherently carry its own type information or metadata unless additional bits or file formats specify it. The exact same sequence of bits can represent text, numbers, or visual data depending entirely on how the interpreting software processes it.
-
It can represent the integer 65 in decimal, the character βAβ in ASCII, or a component value in an RGB color, depending on the softwareβs interpretation and context.
-
Correct! This demonstrates the principle of digital abstraction. The byte 01000001 converts to the decimal number 65. In ASCII, 65 corresponds to the uppercase character βAβ. In a graphics program using 8 bits per color channel, 65 represents a specific intensity level of Red, Green, or Blue.
-
It must always be converted into a Run-Length Encoding (RLE) sequence before a program can determine whether it represents text, image, or sound data.
-
Run-Length Encoding (RLE) is a lossless compression technique used primarily to reduce data size (such as compressing long runs of identical pixels in an image). Compression is not required for a computer to interpret raw binary data.
-
It represents an analog signal value that can only be understood by a digital-to-analog audio converter.
-
Binary data is digital, whereas analog data consists of continuous, smooth values (such as natural sound waves). While sampling can convert analog signals into digital bits, this specific byte is not restricted strictly to audio data.
Activity 3.14.7.
Describe what it means to say that JPEG is a lossy compression technique and whether or not it affects the quality of camera pictures.
Activity 3.14.8.
Give a specific example of a binary sequence that can represent more than one type of data -- e.g., a number, a color, a character -- and describe how to interpret its different values.
You have attempted of activities on this page.
