Digitization

# 1. Objectives

• To define digitization.
• To understand the process by which information is converted to 0s and 1s.

# 2. Motivation

• Computers store information in binary. Conversion of information to binary numbers requires digitization.

# 3. Priming questions

• You are given the task of representing a black and white picture as bits. You will pay someone to do the actual work, but they need explicit instructions. What are your instructions?

# 4. Notes

## 4.1. Definition

• Digitization is the process of breaking something into pieces.
• In computing it usually means converting some form of information to 1s and 0s for storage on a digital computer.

## 4.2. Digitization Steps

1. Draw the boundary lines for the pieces
2. Decide what category each piece is in
3. Assign a bit pattern to each category

The last step amounts to creating your own encoding table for the list of all possible categories.

## 4.3. Digitizing measurements

 Suppose that I want to keep a record of how much it rains on each night. I put out a test tube with two lines drawn on it corresponding to less than 1 inch of rain, between 1 and 2 inches or rain, and more than 2 inches or rain. Instead of writing out the words, I use bit patterns 00, 01, 11 to correspond to the three possibilities.  Day Rain Amount 1 00 2 01 3 00 4 10 5 11 

In terms of the digitization steps

1. Draw the boundary lines for the pieces - Drew lines for different levels of rain.
2. Decide what category each piece is in - Decided to use less than 1 inch, 1-2 inches, and more than 2 inches.
3. Assign a bit pattern to each category - Decided to use a two-bit bit pattern.

Paper on chemical analog to digital conversion: [1].

## 4.4. Digitizing a photo I

We are going to digitize a black and white photo of a shape.

## 4.5. Digitizing a photo I

Step 1: Draw the boundary lines for the pieces - Overlay a grid; the squares represent the pieces.

## 4.6. Digitizing a photo I

Step 2: Decide what category each piece is in - If more than one-half of the square is black, label square as "B". Otherwise, labels as "W".

## 4.7. Digitizing a photo I

Step 3: Assign a bit pattern to each category - Choose a bit pattern of length 1. If category is B, use bit pattern 1. If category is W, use bit pattern 0.

## 4.8. Digitizing a photo I

Suppose that you gave someone, who did not see the original image, the list of bits

00000000 00011000 00111100 01111110 01111110 01111110 00111100 00011000,

told them that zeros represented a white pixel and ones represented a black pixel, and asked them to draw the object. What would they draw?

## 4.9. Digitizing a photo I

They would probably draw this:

## 4.10. Digitizing a photo II

Suppose that we digitize the same image but overlay the grid as shown in the second panel.

Grid used for first attempt at digitization.
Grid used for second attempt at digitization.

## 4.11. Digitizing a photo II

Following the same steps as above would result in a bit pattern of

00010000 00111000 01111100 11111110 01111100 00111100 00010111 00000000

And a restored image of

## 4.12. Digitizing a photo comparison

Result of first attempt at digitization
Result of second attempt at digitization

## 4.13. Photo digitization summary

At least two things should be apparent from this example:

1. The result of digitization depends on the method by which you break the image into pieces. In this example the result depended on how we placed the grid on the image. The result will also depend on the size of the pieces that you use.
2. Digitization leads to a loss of information - given the final result of either digitization, a list of 1s and 0s which are then converted to the images shown on the previous slide, you could not say with certainty what the original image looked like.

# 5. Questions

## 5.1. Convert bit pattern to digitized image I

On a disk drive you find the following sequence:

000000011110010010010010011110000000

You are told that the pattern represents black and white pixels that forms an image that is 6 pixels by 6 pixels. What does the image represent?

## 5.2. Convert bit pattern to digitized image II

On a disk drive you find the following sequence:

000000011110010010010010011110000000

You are told that the pattern represents black, white, green, and blue pixels that form a square image. In addition, you are told that the encoding rule is 00=black, 01=white, 10=green, and 11=blue.

Draw the image.

## 5.3. Digitizing and Image I

Digitize the following image using the encoding rule white=0, black=1. Write out the bit sequence that corresponds to the image. Write down the rule that you used to determine if a pixel (square) was to be black or white.

## 5.4. Digitizing an Image II

Digitize the following image using the encoding rule white=0, black=1. Write out the bit sequence that corresponds to the image. Write down the rule that you used to determine if a pixel (square) was to be black or white.

## 5.6. Digitizing measurements

Suppose that we wanted to store a number on a computer, but were only allowed to use two bits to represent each measurement. The four possible bit patterns of length two are 00, 01, 10, and 11.

When reading the bits from memory, we can tell the computer that when it encounters a 00 that this means the expression red. Therefore, if I wanted to save the list red green green red magenta, I could just write the bits 00 01 01 00 11. Now when I read back the bits, I know that this person meant red green green red magenta. In a similar way, I can define these combinations of bits to mean numbers other than their decimal equivalent, two examples are shown in the "bit-pattern-to-meaning-table" shown to the right.

bit-pattern-to-meaning table
Bit pattern Meaning 1 Meaning 2
00 red 0
01 green -1
10 blue +1
11 magenta 2

Suppose that your instrument can take on decimal values of 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, and 4.0 and you want to represent each number as a group of three bits that form a "bit pattern". The first part of your "bit-pattern-to-meaning-table" would look like the table to the right.

bit-pattern-to-meaning table
Bit pattern Meaning
000 0.0
001 0.5
010 1.0
011 1.5
100 2.0
... ...

### 5.6.1. Part I

Suppose that you only have the choice of using three bits. How many unique combinations of 1s and 0s are possible?

### 5.6.2. Part II

Suppose that you get a new instrument that can measure values from 0.0, 0.1, 0.2, ..., 4.0, but you still store data using three bits and use the same "bit-pattern-to-meaning-table".

When you write a bit group to record a measurement, you chose the bit grouping that has the closest value to your measurement. In doing so, you lose precision much like when you round a decimal number 1.11111111 to 1.1. When you return to the number 1.1, you won't be able to tell if the original number was, for example 1.11 or 1.12, because the both round to 1.1.

When you read back your measurements after representing each number on your disk as a group of three bits, what will be the largest difference between the read back value and the actual measured value? Explain your answer in words.

1. 0.1
2. 0.5
3. 0.4
4. 1.0
5. 2.0

# 6. Activities

## 6.1. Human Memory I

When the instructor says "go", try to memorize the following sequence.

000000011110010010010010011110000000

1. How many bits per second were you were able to memorize?
2. How does this compare to how many bits per second a computer can store? (Hint: Think about how long it takes you to copy a file from a thumb drive to a computer.)

## 6.2. Convert bit pattern to digitized image

On a disk drive you find the following sequence:

000000011110010010010010011110000000

You are told that the disk drive contained black and white pixels and formed an image that was 6 pixels by 6 pixels. What does the image represent?

## 6.3. Human Memory II

When the instructor says "go", try to memorize the following sequence.

000000111111001100001100001100001100

1. How many bits per second were you were able to memorize?
2. How does this compare to how many bits per second a computer can store? (Hint: Think about how long it takes you to copy a file from a thumb drive to a computer.)

## 6.4. Digitize an Image

In panel A of this file (handed out in class), an image is given with a grid overlayed. In panel B draw a digitized version of the image on the left by filling in squares with black (squares must be all black or all white). Write down the algorithm that you used to determine what squares to fill in.

In panel D, draw in a digitized version of the top 20% of the image in panel C.

I will compare answers on the overhead after the activity is complete.

When you are finished, answer the following questions (you don't need to turn in your answer sheet).

How many more 1s and 0s do you need to digitize image C versus image A?

## 6.5. Other Digitization Discussion

1. How would you convert a color image to a sequence of 1s and 0s?
2. Sound is measured by the displacement of a membrane due to air pressure. Suggest a method for digitizing sound. (Don't look it up! Think about it first!)

## 6.6. Digitization

Introduction

This lab activity is designed to introduce you to a process called digitization You'll demonstrate this process by digitizing a black-and-white image, and then answer a few questions about the process. Along the way you'll learn how images are reduced to binary representations and develop a feel for the size of digitized images. This lab activity also introduces the notion of an algorithm, but not explicitly. For now just pay attention to the “cook-book” steps that you're asked to follow and note that by following these steps in order, you're able to perform specific tasks. But before jumping right in, it will be useful to define what we're going to do.

What is digitization?

Here's a simple definition:

Digitization means breaking something up into pieces.

That's pretty much it. Of course, it's natural to wonder why we would want to digitize something. The answer is that by digitizing something, we bring it into a form that's much easier for a computer to process.

Example 1: A DIGITAL color photograph is a digitization: It's a checkerboard grid pattern of blocks, each of which is colored only one of several color choices. That is, the original image is broken up into colored blocks -- it is digitized.

Example 2: A DIGITAL black and white photograph is a digitization: It's a checkerboard grid pattern of blocks, each of which is colored (only!) black or white. the original image is broken up into black and white blocks -- it is digitized.

Digitization of a black and white image

It's easy to digitize a black-and-white image by following these steps in order:

1. Obtain a black and white image with a checkerboard grid pattern overlay stenciled onto it (see #Resources). Also obtain two sheets of paper with only a checkerboard grid pattern stenciled onto them (again, see Section 6.5, "Resources").
2. Begin in the top row, first square on the left, in the checkerboard grid pattern overlaid on the original image.
3. Decide: Is this block ALL black, or is it ALL white? (NO "in-between" decisions are allowed yet -- that is, no "gray" is allowed!)
4. Implement your decision in the corresponding block of the checkerboard grid pattern, ON THE SEPARATE SHEET OF WHITE PAPER: That is, if you decide a block of the original image is black, then BLACKEN THE CORRESPONDING BLOCK ON THE SEPARATE SHEET OF WHITE PAPER. But if you decide instead that a block of the original image is white, then DO NOT BLACKEN THE CORRESPONDING BLOCK ON THE SEPARATE SHEET OF WHITE PAPER.
5. If you're at the end of a checkerboard grid pattern row, then move down one row and over to the first block (leftmost block) in this new row. Go to Step 3. If you're at the end of the checkerboard grid pattern's last row, then stop. Otherwise, move one block to the right and go to step 3.

That's it! You now have, on the first separate sheet of white paper, a black-and-white digitization of the original black-and-white image.

Questions

1. Write down the rule(s) you used to decide whether any given checkerboard grid pattern block was black or white. Did you write down only one rule, or more than one rule?
2. If you wrote down more than one rule, why was that necessary, that is, why did you decide that only one decision rule wasn't adequate?
3. If you wrote down only one rule, will that rule work in all circumstances (that is, for all checkerboard grid pattern blocks overlaid on the original image)? If not, why not?
4. Now produce a binary digitization of your black-and-white digitization, as follows:
1. Begin in the top row, first square on the left, in the black-and-white digitization you produced.
2. If this block is colored black, then on the SECOND separate sheet of white paper, in the corresponding block, enter the number 1. If the block is not colored black, then on the SECOND separate sheet of white paper, in the corresponding block, enter the number 0.
3. If you're at the end of a checkerboard grid pattern row on your black-and-white digitization, then move down one row and over to the first block (leftmost block) in this new row. Go to Step 4-2. If you're at the end of the checkerboard grid pattern's last row, then stop. Otherwise, move one block to the right and go to step 4-2.
5. The binary digitization has dimensions: We can measure it's length, in blocks, and also its width in blocks. The total number of blocks contained in the binary digitization is simply the area of a rectangle -- that is, the length times the width: an image having a length of 10 blocks and a width of 10 blocks will contain 100 total blocks. Now, each of these blocks will contain either a 1 or a 0 (because it's a binary digitization!) and so, remembering from our our study of binary numbers that each 1 or 0 is represented by one BIT, each individual block of the binary digitization will contain ONE BIT (or, can be represented by ONE BIT). Thus, a binary digitization comprised of 100 total blocks would contain (or, be represented by) 100 BITS. Now calculate the total number of bits contained in the binary digitization you produced in Question 4. Next, calculate the total number of bytes in this binary digitization (round UP to the nearest whole number of bytes).
6. Do you think that the number of bits you calculated in Question 5 is dependent upon the RULES that you wrote down in Question 1 to decide whether any given block in the original image is all black or all white? Why or why not?