Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a program to output an image that contains only 3 quadrants, upper right, upper left and bottom left. The original image is 256x256 pixels

write a program to output an image that contains only 3 quadrants, upper right, upper left and bottom left. The original image is 256x256 pixels called mri.pgm. Using C and preferrably for loop. It is a 256x256 pixels.

1.Edit or add the code below to get only 3 quadrants.

2. Write a program to keep the even while discarding the odd pixels. The original image is 256x256 pixels. We want it to be 128x128 pixelsimage text in transcribed

#include

#include

int main(int argc, char *argv[]){

unsigned sizeX; //image width

unsigned sizeY; //image height

unsigned char *image; //image array

unsigned levels;

//read image from file

FILE *iFile = fopen("mri.pgm","r");

if(iFile==0) return 1;

if(3!=fscanf(iFile, "P5 %d %d %d ", &sizeX, &sizeY, &levels)) return 1;

image=(unsigned char *) malloc(sizeX*sizeY);

fread(image,sizeof(unsigned char),sizeX*sizeY,iFile);

fclose(iFile);

//write image to file

iFile = fopen("mri2.pgm","w");

if(iFile==0) return 1; //error handling

fprintf(iFile, "P5 %d %d %d ",sizeX,sizeY, 255);//write header

fwrite(image,sizeof(unsigned char),sizeX*sizeY,iFile);//write binary image

fclose(iFile);

return 0;

}

E 100% @ mri.pgm Properties Size 256 256 pixels Type PGM image File Size 65.6 KB Folder Desktop Aperture Exposure Focal Length ISO Metering Camera Date Time E 100% @ mri.pgm Properties Size 256 256 pixels Type PGM image File Size 65.6 KB Folder Desktop Aperture Exposure Focal Length ISO Metering Camera Date Time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago

Question

Write short notes on departmentation.

Answered: 1 week ago

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago

Question

4. How has e-commerce affected business-to-business transactions?

Answered: 1 week ago