ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

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

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 26 Apr 2017 My Price 8.00

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 unsigned integer 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. 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_t pixel_t; struct pixel_t {
uint8_t red;
uint8_t green;
uint8_t blue;
uint8_t empty;
}; int main(int argc, char** argv) { return 0;
}

Attachments:

Answers

(11)
Status NEW Posted 26 Apr 2017 12:04 AM My Price 8.00

-----------

Not Rated(0)