SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 2 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 24 Dec 2017 My Price 10.00

program that will discover and index the colour palette

#c code only. not java or c++.

 

Hi, can you please code this in c and make sure it pass all the given tests provided in the doc. thanks

Colour Palette

You are tasked with writing a program that will discover and index the colour palette of an image by iterating through image data and extract the colour value. The colour value is represented by an unsignedinteger value. It is recommended you use stdint.h and utilise uint8_t or uint32_t for reading in the data. We also recommend you implement this program using a linked list or use realloc.

 

The program will take in a filename from the command line.

./index image

 

If no argument is specified, the program should respond with:

No Filename Specified

 

If the file does not exist, your program needs to respond with:

File Does Not Exist

 

The file format is a type of bitmap image in binary format. The top of the file will specify the width and height of the image as well as a 2 byte magic number to confirm that it is a valid type. Each 4 bytes in the image data corresponds to 1 pixel in the image.

true

The magic number in decimal form is: 60535

If the magic number does not match with the file specified. The program respond:

Invalid Image Header

and terminate with exit code 1

 

If the number of pixels in the image do no match the width * height then the program should respond with:

Invalid Image Data

and terminate with exit code 1

 

Each 4 bytes of the image data contains (Red, Green, Blue, and 1byte of 0 Padding).

When you encounter a new pixel, you are to record it into your own 2d array of width * height.

 

The next time you see the same pixel value again, your program is to identify that it exists in your list and use the same index.

 

All image files have been included for you to test your code on.

 

Example1 (5x5):

./index imgd.b

 

[ 0, 0, 1, 1, 0 ]
[ 1, 2, 1, 1, 0 ]
[ 2, 1, 2, 1, 2 ]
[ 1, 0, 0, 0, 0 ]
[ 2, 0, 2, 1, 0 ]

 

Example2 (2x2 image):

./index imge.b

 

[ 0, 0 ]
[ 1, 1 ]

 

 

 

index.c:

 

 

#include <stdio.h>

#include <stdlib.h>

#include <stdint.h>

 

//You may modify/add/remove structs

 

typedef struct pixel_tpixel_t;

 

struct pixel_t {

                uint8_t red;

                uint8_t green;

                uint8_t blue;

                uint8_t empty;

};

 

intmain(intargc, char** argv) {

               

                return 0;

}

Attachments:

Answers

(5)
Status NEW Posted 24 Dec 2017 01:12 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)