CSE344 – System Programming – Homework #1 solution

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

The Tagged Image File Format or Tiff is a format for storing digital images. A digital image can be thought of as a rectangular matrix of non-negative integers, where every point (or pixel) of the image is denoted by a single value. Tiff is a powerful file format that can store multiple scenes in a single file and compress them quite effectively.
This homework’s objective is to write a POSIX compatible C program that admits as command line argument the path of a black & white, uncompressed locally stored tiff file and prints its pixels on the standard output using 0’s for black and 1’s for white.
Example input image (25×25) (test.tif):
Expected output on screen:
$./tiffProcessor test.tif Width : 25 pixels Height : 25 pixels Byte order: Intel 1111111111111111111111110 1111111111111111111111110 1111111111111111111111101 1111111111111111111111011 1111111111111111111110111 1111111111111111111101111 1111111111111111111011111 1111111111111111110111111 1111111111111111101111111 1111111111111111011111111 1111111111111110111111111 1111111111111101111111111 1111111111111011111111111 1111111111110111111111111 1111111111101111111111111 1111111111011111111111111 1111111110111111111111111 1111111101111111111111111 1111111011111111111111111 1111110111111111111111111 1111101111111111111111111 1111011111111111111111111 1110111111111111111111111 1101111111111111111111111 0011111111111111111111111
Rules: a) You are not allowed to use any 3rd party libraries for loading tiff files. Use POSIX and Standard C libraries. You can write your program using C11 standards. b) Your program must handle eventual errors gracefully according to the POSIX way. c) If the command line argument is missing your program must print usage information. d) Your program must work with black & white uncompressed tiff files in either Intel of Motorola byte order. e) Make sure your program doesn’t have any memory leak and runs clean. You can check that and many other things using Valgrind tool. Just run your program from shell like this : valgrind ./tiffprocessor test.tif
It will output whether your program has memory leak or not. Also it will tell you about invalid memory accesses, uninitialized memory and much more. For example, if your program gives segmentation fault, most of the time Valgrind will tell you the reason. So it is also a very powerful tool for debugging. A program with no errors or leaks will give you an output like this:
We will be expecting your homeworks to run just like the one above. For each process the output should be: “all heap blocks are freed – no leaks are possible” and “0 errors” when we run it with Valgrind. A few errors is OK if they are not harmful. f) Your program MUST not give “segmentation fault” or any other fault that causes your program to end in a bad way. It is better for you to send a little part of the homework with clean and executing code instead of full homework with faults like this. g) Provide a makefile to compile your homework. Do not run your program inside makefile. Just compile it.
h) Think smart and try to do the job with as short as possible and easily understandable code. Do not send homeworks with 1000 lines that can be done in 200 lines. When you find a solution to a problem, think like this: “What could be a better solution…”. i) Test your homework using the Virtual Machine given to you. j) No late submissions.
Tip for this homework: You can produce uncompressed tiff files using Gimp and ImageJ.
Homework format: StudentID_HW1_CSE344.tar.gz |→ Makefile |→ StudentID_main.c |→ … (Any other source files)
Teaching assistant: Ahmet Soyyiğit e-mail: asoyyigit@gtu.edu.tr
Good luck.