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

  Creating relational database about music performers

Create a relational database having information about music performers, their recordings, and the composers of the music they recorded.

  Edge connectivity of undirected graph-running maximum-flow

Illustrate how edge connectivity of undirected graph G = (V, E) can be determined by running maximum-flow algorithm on at most |V| flow networks, each having O(V) vertices and O(E) edges.

  Estimate the expected value of the share price

SIT718 Real World Analytics - State the condition that share prices have to satisfy in order to be represented by a geometric Brownian motion? Does your data

  Dynamic-programming algorithm for rod-cutting problem

Consider a modification of the rod-cutting problem in which, in addition to a price pi for each rod, each cut incurs a fixed cost of c. Give a dynamic-programming algorithm to solve this modified problem.

  Write comparison-based algorithm used to sort four elements

Prove that any comparison-based algorithm used to sort four elements requires at least five comparisons for some input.

  Question about character array

The 2-most important design issues that are specific to character string types are the given, Should strings be simply a special kind of character array or a primitive type?

  Write the function definition as a recursive search

Write the function definition as a recursive search, assuming a linked list implementation. After you have corrected the function, trace the execution of NumPaths with n = 4 by hand. Why is this algorithm inefficient?

  Develop a dynamic programming algorithm

You have to develop an algorithm to compute how to give change with the minimum number of coins - develop a greedy algorithm to solve problem

  Write sql select statement that would re-organize results

Describe an algorithm that you could implement that would allow you to find a given person's telephone number in the shortest amount of time

  Identify the closed loop system

Identify the closed loop system used in controlling an Industrial process and describe the method of operation of the control loop components.

  What is the primary disadvantage of quick sort

What is the primary disadvantage of Quick Sort? How could this disadvantage be eliminated? What is an advantage of bubble sort over selection sort? What is an advantage of selection sort over bubble sort?

  Draw a flowchart of the function realizing insertion sort

Write the corresponding MATLAB code. You should check (just for yourself) how your function works with an arbitrary unsorted array.

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