Implement run-length encoding

Assignment Help Data Structure & Algorithms
Reference no: EM133552359

Advanced Design & Analysis of Algorithms

In class we have looked at the PCX picture format to implement run-length encoding. For this assignment you will implement your version of BI_RLE8 - Microsoft's run-length encoding for 8-bit bitmaps. Reading and writing binary data with correct header (RIFF) information is not part of this assignment.

BI_RLE8 is a format for indexed bitmaps with 8 bits per pixel. The compression format is a two-byte format consisting of a non-zero count byte followed by a byte containing a color index, or an "absolute mode".

- Encode mode
o First byte is nonzero and is the count byte.
o Second byte is the index of the 8-bit color to be repeated count times.

- Absolute mode
o First byte is zero.
» Second byte is 0x03h (3) through 0xffh (255). The second byte represents the number of bytes that follow, each of which contains the color index of a single pixel.
» Second byte is 0x00h encodes an end-of-line. Do not use!
» Second byte is 0x01h encodes end of bitmap. Do not use!
» Second byte is 0x02h. The next two bytes are an x-y-offset for the next pixel. Do not use!

You will implement two methods as outlined below in Python.

0. If your Python environment does not have the (fork of) Python Image Library Pillow, install it first. pip install pillow should work in a standard Python environment with correctly working paths. Alternatively, install from within PyCharm when offered to install a missing library. Load the picture provided using the Pillow library function Image.open. Create a list of pixels using list and the getdata method of Pillow. You should now have a list of indexed colors 0 - 255.

Question 1. Write a function to_BI_RLE8_EM which takes a list of integers (indexed colors ranged 0 - 255) and returns a list of run-length encoded values. Implement the "Encode Mode" only.

Question 2. Write a function to_BI_RLE8 which takes a list of integers (indexed colors ranged 0 - 255) and returns a list of run-length encoded values. Implement it with both the "Encode Mode" and the first case of "Absolute Mode" (which should be used when there are runs of length 1). Within your program you should determine which mode creates a shorter output for the next pixels. Document your reasoning for the choice of mode to select in your code.

Question 3. Test and debug your methods. Provide test runs in form of a main (driver) file. Compare the original size of the picture with the sizes you obtain from 1. and 2.

Reference no: EM133552359

Questions Cloud

Discuss some of the points that sister wendy makes about : discuss some of the points that Sister Wendy makes about the impulse to create works of art from cave paintings to greek art, and discuss your own views on why
When a company has easy access to the target markets : When a company has easy access to the target markets? When the cause can be connected and sustained by the company's products.
What is meant by the classical belief that the economy : Discuss what is meant by the Classical belief that the economy is self-correcting. When did this theory break apart?
Calculate the effect of the us president on economic growth : Why can we not simply look at how the economy changes when the US president changes in order to calculate the effect of the US president on economic growth?
Implement run-length encoding : CS 07540 Advanced Design & Analysis of Algorithms, Rowan University - Implement it with both the "Encode Mode" and the first case of "Absolute Mode"
Who are the unwanted people of your generation : Who are the unwanted people of your generation? What is beautiful about the ways in which they express their own individuality?
What decision refers to the selection of the best means : what decision refers to the selection of the best means to achieve a goal and not to the selection of the goal itself. If an individual wishes to own a car
Explain how you pay your taxes : Explain how you pay your taxes. List some of the taxes you pay and describe the benefits you receive from paying these taxes.
What data might you use to support the likelihood of job : What data might you use to support the likelihood of job loss to robotics by 2030? The number of people employed in a particular industry Unemployment rates

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd