{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lab8_source_coding

lab8_source_coding - MASSACHUSETTS INSTITUTE OF TECHNOLOGY...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
6.02 Spring 2008 1 of 1 Lab #8 M ASSACHUSETTS I NSTITUTE OF T ECHNOLOGY D EPARTMENT OF E LECTRICAL E NGINEERING AND C OMPUTER S CIENCE 6.02: Introduction to EECS II Spring 2008 Lab #8: Source Coding Goal: Using MATLAB, develop and evaluate a method for compactly encoding images of scanned text. Instructions: 1. There is no pre-lab this week. Complete the activities for Wednesday’s lab (see second section below). 2. Prepare the requested material and think about the questions posed on the Check- off Sheet, the find a staff member to complete your post-lab interview. In the lab (Wed., April 16, 2008) Start by going through the usual steps to initialize the 6.02 environment, copy over the Lab 8 files from /mit/6.02/Labs/Lab8, and start up MATLAB. During this week’s lab your task is to develop and evaluate an algorithm for compactly encoding images of scanned text – this is the type of encoding used by fax machines to transmit page images from the sending machine to the receiving machine. For the post- lab activity we’ll ask you to write up a brief description of your algorithm and summarize its performance when encoding the test image. Obviously we could transmit a black-and-white image pixel-by-pixel using one bit to encode each pixel. Our goal is to develop a lossless encoding that transmits fewer bits but still enables the original image to be reconstructed by the receiver. Step 1: examine a test image of scanned text. Fire up MATLAB, change to the lab 8 directory and load up the test image along with some other useful pre-computed information: load lab8.mat The black-and-white test image is available in a 500-by-500 array of pixels called lorem_img . Note that in MATLAB pixels are encoded by their brightness, so black has a pixel value of 0, and white a pixel value of 1. You can examine the test image using MATLAB’s image manipulation tools:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
6.02 Spring 2008 2 of 2 Lab #8 imshow(lorem_img) In the window that pops up, click on the magnification tool in the toolbar (it’s the magnifying glass with the “+”) and then click on the image itself to zoom in a couple of times. Think about transmitting the image row-by-row: each row would consist of alternating runs of white pixels and black pixels. What’s your sense of the distribution of run lengths? Does it differ between white runs and black runs? Perhaps we can compress the image by using run-length encoding where we send the lengths of the alternating white and black runs instead of sending the pixel pattern directly. For example, consider the following MATLAB representation of a 4x7 bit image: 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 which can represented as a sequence of run lengths: [2 2 6 2 6 2 8]. If the receiver knows that runs alternate between white and black (with the first run being white) and that the width of the image is 7, it can easily reconstruct the original bit pattern.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}