logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Graphics Interchange Format (GIF) image file is used to store images on a computer.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

2. Overview

The Graphics Interchange Format (GIF) image file is used to store images on a computer. It is known for compressing image files into a smaller size without losing any image quality. For this assignment, you are tasked with writing code that can be used to open a GIF file and access its contents.

This is a real-world assignment, meaning that you are working on a practical problem that requires that you find additional information to complete the task. The official GIF documentation is on blackboard (spec- gif89a.txt) or at https://www.w3.org/Graphics/GIF/spec-gif89a.txt. We expect that all students will use the internet and textbook resources to learn concepts needed for this assignment. There will be many concepts, in-built functions, and other aspects of Python coding, which have not been directly taught in labs or lectures. It is up to you to fill in these gaps in knowledge by engaging in both the course and self-learning.

3. GIF Format

You must adhere to the GIF89a specifications, which includes the ability to open GIF files with both the GIF89a and GIF87a formats. You do not need to implement any GIF extensions and can assume that there will be no GIF extensions in my test GIF image cases. You can assume that only a global colour table is used and that it is present in the GIF file. You can assume that the file will not contain a local colour table. You can also assume that, when reconstructing your image, we will use GIF files that only have a sequential order (no interlaced order will be used) with all sort flags set to 0. You can assume that the GIF files tested have only 1 image in it.

When you reach the Table Based Image data, you will need to extract the image from the LZW data compression format, which has been slightly modified for use in GIF. The algorithm is well described on different websites:

https://www.w3.org/Graphics/GIF/spec-gif89a.txt https://en.wikipedia.org/wiki/GIF http://giflib.sourceforge.net/whatsinagif/index.html

We have uploaded squares.gif as a sample image for you to open and access. However, your code should be able to handle other GIF files. We will certainly test other .gif files to ensure that your code adheres to the GIF documentation (spec-gif89a.txt).

4. GIF Functions

Write 6 functions that can be used with the import system. We will type import gif at the top of our own script (eg, script.py) and then use your functions to perform tasks. For different arguments passed into the function we will assess the returned values for each function. All code examples described here assume that import gif has been executed prior to each function call. While we are providing example code and a GIF file on blackboard, we will mark your code using a far wider range of test code and test GIF files, which are not being provided to you. It is important that you test your code under a wider range of conditions.

 

 

 

 

data, info = load_file(file_name):

Take the file name of a .gif file and return a data object and a description line. The file_name argument should be of type str and is the path to the .gif file.

The returned data should be of type bytes. If the GIF file was found, its entire content should be transferred into data. If the file was not found, return an object of type bytes, which is empty.

The returned info should be of type str. If the file was opened, return the file_name. If the file was not found, return 'file not found'.

header = extract_header(data):

Extract the GIF header from data.

The data argument should be of type bytes and obtained using load_file(). The returned header should be of type str.

width, height, gc_fl, cr, sort_fl, gc_size, bcolour_i, px_ratio = extract_screen_descriptor(data):

Extract the screen descriptors from data.

The data argument should be of type bytes and obtained using load_file().

The returned width, height, gc_fl, cr, sort_fl, gc_size, bcolour_i, and px_ratio should be of type int. The values returned should be as specified in the GIF documentation.

 

gc_map = extract_global_colour_table(data):

Extract the global colour map from data.

The data argument should be of type bytes and obtained using load_file().

The returned gc_map should contain the global colour table of type list. Each item in gc_map should be of type int. gc_map should be a 2-dimensional array with each row representing a different colour in the table and each column representing the colour, such as red, green, and blue.

 

left, top, width, height, lc_fl, itl_fl, sort_fl, res, lc_size = extract_image_descriptor(data):

Extract the image descriptors from data.

The data argument should be of type bytes and obtained using load_file().

The returned left, top, width, height, lc_fl, itl_fl, sort_fl, res, and lc_size, should be of type int. The values returned should be as specified in the GIF documentation.

 

img = extract_image(data)

Extract the image from data.

The data argument should be of type bytes and obtained using load_file().

The returned img should be a 3-dimensional array containing the decompressed GIF image. The first

  dimension should be rows, the second dimension should be columns, and the third dimension should be the

  colours, such as red, green, blue. Each element within img should be of type int. For example,

  print(type(img[0][0][0])) should produce the output <class 'int'>.

5. Coding rules

Do not declare any variables in the global space of gif.py. The global space definitions must have the 6 functions requested. A main() function could be used if you so desire, but is not required. The global space may have additional function definitions that can be called by the 6 functions requested in this assignment. No module is allowed for this assignment.

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

871 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

851 Answers

Hire Me
expert
Husnain SaeedComputer science

725 Answers

Hire Me
expert
Atharva PatilComputer science

774 Answers

Hire Me