Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please Complete the C program. A shell program is pasted below the assignment as a template and starting point /* Edge Detection Your Name: Date:
Please Complete the C program. A shell program is pasted below the assignment as a template and starting point /* Edge Detection Your Name: Date: This program detects edges in a 32X32 image array by comparing the intensity of each pixel and its 4 immediate neighbors (North, South, East, and West), computing the difference of the Max and Min intensity values, and setting the corresponding output pixel to the computed Max-Min difference in intensity. The program handles pixels on the boundaries of the image specially to prevent trying to access neighboring pixels that do not exist (i.e., no image wraparound is allowed). */ #include#include /* TEMPORARY: this is an example of a global variable.*/ int RunningCount; /* TEMPORARY: this is an example function prototype. The function is defined below.*/ void CountHi(int); /* This is also a function prototype. Do not delete this one.*/ int Load_Mem(char *, int[]); int main(int argc, char *argv[]) { int Array[1024]; int Edges[1024]; int NumX; int N; if (argc != 2) { printf("usage: ./HW2-1 valuefile "); exit(1); } NumX = Load_Mem(argv[1], Array); if (NumX != 1024) { printf("valuefiles must contain 1024 entries "); exit(1); } RunningCount = 0; // TEMPORARY (for example only). Remove this. for(N = 0; N = 200) RunningCount++; return; } /* This routine loads in up to 1024 newline delimited integers from a named file in the local directory. The values are placed in the passed integer array. The number of input integers is returned. */ int Load_Mem(char *InputFileName, int IntArray[]) { int N, Addr, Value, NumVals; FILE *FP; FP = fopen(InputFileName, "r"); if (FP == NULL) { printf("%s could not be opened; check the filename ", InputFileName); return 0; } else { for (N=0; N This assignment explores the function and implementation of several basic conditional execution, iteration, and memory access mechanisms to implement a basic edge detection algorithm on an image. Background: Edge detection is a common technique used in many image processing applications to help delineate entities of interest, such as obstacles along a planned path or cell walls in a microscope slide image. One technique for edge detection examines each pixel and compares its intensity with its nearest neighbors (i.e., the four pixels to the North, South, East, and West). It finds maximum and minimum values (MaxI, Minl) of these data and and an output image is created in which each pixel is given the difference between the max and min (Maxi MinI) as its new intensity value. For this assignment, each input 32x32 image is given as an array of 1024 integers, each integer indicating an intensity value. (This array has been previously derived from a color image by taking the average of each pixel's red, green, and blue (RGB) color component intensities.) Pixels on the boundaries of the image must be handled specially to prevent trying to acces neighboring pixels that do not exist (i.e., no image wraparound is allowed. For example, if a pixel is on the top edge of the image, it will not have a northern neighbor, so its intensity wil only be compared with those of the other three neighbors. For this assignment, you will write two programs, one in C and one in MIPS, as described below. HW2-1: In this part of the assignment, design and implement a C program that computes the modified second image where pixels are replaced with the difference of the max and min intensity of the pixel and its neighbors. As a starting point, use the file HW2-1-shell.c. This program includes a reader function Load_Mem that loads the the pixel data from a text file into an array. You should use gcc under Linux/Unix to develop your program. Sample test files (Inputn.txt) are provided, along with corresponding Answern.txt files that contain the expected correct output data. You must copy/rename Hw2-1-shell.c to Hw2-1.c and modify it. The included print statement should be used to print all pixel values following the conclusion of your transformation. Its output format should not be modified
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started