Write a c program to access PGM image files

Assignment Help C/C++ Programming
Reference no: EM132168018

Description

In this assignment, you are going to write a C program to access PGM image files (description was given in Assignment 4). In addition, you need to save the image data into 8 x 8 blocks using the struct defined below.

#define N 8

typedef struct _Matrix { double element[N][N];
} Matrix;

If the image size is not divisible by 8; then pad the boundary blocks with zeros.

First, you need to read two arguments from the command prompt, which will be used for input file and output file Then, do the following steps.

1. Open and Read the PGM image

2. Dynamically allocate the memory and Read the data into a buffer

3. Convert the data into 8 x 8 blocks and return the pointer to the main function

4. Pass the pointer to the Write function

5. Write the data buffer to the file using a binary format (either P5 or P6)

6. Release the memory

Your main function should look like the following

int main(int argc, char **argv)
{
if (argc == 3) {
int w, h, nBlock, channel;
Matrix *data = ReadImage(argv[1], &w, &h, &nBlock, &channel);
WriteImage(argv[2], data, w, h, channel); free(data);
}
else {
fprintf(stderr, "Usage: %s image_path output_path\n", argv[0]);
exit(1);
}
return 0;
}

Reference no: EM132168018

Questions Cloud

Different operating systems within organizations : What are the different cultures and different operating systems within organizations?
How could the given values be estimated : A new university parking structure is being considered. Name at least four each of benefits, disband fits, and costs. How could these values be estimated?
Finding benefit-cost ratios in the given situations : The right-of-way for a new highway will cost $1.5 million. The roadbed and earthworks will cost $3 million. The pavement will cost $2.5 million.
Shaped organizational culture in positive-negative fashion : Describe how Oprah Winfrey behavior shaped organizational culture in positive or negative fashion.
Write a c program to access PGM image files : Write a C program to access PGM image files (description was given in Assignment 4). In addition, you need to save the image data into 8 x 8 blocks
Calculate the project benefit-cost ratio : A busy intersection in Metro Center needs renovation. Plans call for adding a turn lane, a new computer-controlled signal, and new sidewalks.
Human capital is important to overall economic health : Explain why you feel that Increases in Human Capital is important to the overall economic health of an urban area in Chicago?
What annual benefit is required : A new airport expansion will cost $85 million. The largest amount, $55 million, is for land acquisition and major earthworks.
Which of the five forces in porter five forces model : Which of the five forces in Porter’s five forces model do you anticipate will most strongly affect Andy’s potential business and why?

Reviews

len2168018

11/16/2018 1:26:20 AM

II. Grading Submit your source files along with a readme indicating how to compile your files via blackboard. All assignments will be tested under Unix. Compile and Link Successfully – 10 points Correct makefile with main.c, pgm.c, and pgm.h (10 points) Correctly read the P2 image, store in the Matrix struct, and save with the P5 image format (20 points) Correctly read the P5 image, store in the Matrix struct, and save with the P5 image format (20 points) Correctly read the P6 image, store in the Matrix struct, and save with the P6 image format (20 points)

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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