Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C. COMMENT FOR SOURCE CODE Ex 5 Submit Assignment Due Mar 14 by 11:59pm Points 6 Submitting a file upload File Types Available after

IN C. COMMENT FOR SOURCE CODE

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Ex 5 Submit Assignment Due Mar 14 by 11:59pm Points 6 Submitting a file upload File Types Available after Mar 1 at 12am Exercise 5 - Floo-Fill! As part of the team of leading scientists working on a project to explore the surface of the newly discovered planet Floo, you have managed to send a little robotic probe to the planet. Right before the probe landed, it was able to get some aerial scans and figure out the elevation maps for the surface. Here's what the elevation map for the entire surface of the planet looks like: The image above (credit: NASA, Public Domain), and is actually for Mars. Elevation is encoded as brightness, with lower-altitude regions being darker and higher altitude regions being brighter. One critical consideration to for your exploration is the amount of power required to drive the probe around while it's exploring and collecting samples - we want to find a region of the planet where the terrain is more or less level, so that our probe does not spend unnecessary energy driving uphill to get to where it's going. A planet-sized map is too big of course! We'll work with much smaller elevation maps for this exercise. For instance, here's a smaller section of the above map: Elevation is encoded as brightness, with lower-altitude regions being darker and higher altitude regions being brighter. One critical consideration to for your exploration is the amount of power required to drive the probe around while it's exploring and collecting samples - we want to find a region of the planet where the terrain is more or less level, so that our probe does not spend unnecessary energy driving uphill to get to where it's going. A planet-sized map is too big of course! We'll work with much smaller elevation maps for this exercise. For instance, here's a smaller section of the above map: Our task for this exercise is to write a function that takes as input an array containing an elevation map just like the image shown above, and given initial coordinates in this elevation map, detects and extracts the connected region in the map that has the same elevation as the initial coordinates. This can be used, for instance, to determine which areas in the map a robot could drive over without having to climb or descend! Download Starter Code: ex5.zip Make sure all the files are in the same directory when compiling and running your code. Your terminal must be in the same directory as well. The starter code contains documentation and some example output for the functions, as well as a few tests to help you check your code. The tests in the main() function are not comprehensive. You should test your code on many different input parameters yourself to ensure that they actually work as intended. Carefully read the comments in the function. What to do: Implement the function as needed. Add helper functions if you want to make your code clearer, though in this case you really shouldn't need to. . Check to see if your output makes sense on other test cases. The expected output for the given tests is below. What NOT to do: Change the name of any functions in the starter code . Remove the #ifndef _testing and #endif lines Compilation: Compile your code with the -Wall and -Werror flags. For instance, you might compile this exercise using: gcc-Wall-Werror exs.c What to submit: You will submit your ex.c program file only. The file name does not matter. Do not submit imgutils.c. Sample Output: If the images below are run with the starting position marked in red, then the corresponding output is expected: floo-region-1.pgm, starting position = (24, 16) floo-region-2.pgm, starting position = (4.35) Note on Image formats: We're going to be working with an image format called PGM (Portable Gray Map) since it's one of the easiest formats to read/write images with. However, Windows does not natively support this file type and will not let you view the image without any external tools. Google can help you find an image viewer so you can see your images! (I recommend GIMP as a free tool to view and also create these files to make your own tests). We'll be using this format going forward with your assignments and possibly other exercises, so make sure you're comfortable with using it. Note on Image formats: We're going to be working with an image format called PGM (Portable Gray Map) since it's one of the easiest formats to read/write images with. However, Windows does not natively support this file type and will not let you view the image witho external tools. Google can help you find an image viewer so you can see your images! (I recommend GIMP as a free tool to view and also create these files to make your own tests). We'll be using this format going forward with our assignments and possibly other exercises so make sure you're comfortable with using it Ex 5 Submit Assignment Due Mar 14 by 11:59pm Points 6 Submitting a file upload File Types Available after Mar 1 at 12am Exercise 5 - Floo-Fill! As part of the team of leading scientists working on a project to explore the surface of the newly discovered planet Floo, you have managed to send a little robotic probe to the planet. Right before the probe landed, it was able to get some aerial scans and figure out the elevation maps for the surface. Here's what the elevation map for the entire surface of the planet looks like: The image above (credit: NASA, Public Domain), and is actually for Mars. Elevation is encoded as brightness, with lower-altitude regions being darker and higher altitude regions being brighter. One critical consideration to for your exploration is the amount of power required to drive the probe around while it's exploring and collecting samples - we want to find a region of the planet where the terrain is more or less level, so that our probe does not spend unnecessary energy driving uphill to get to where it's going. A planet-sized map is too big of course! We'll work with much smaller elevation maps for this exercise. For instance, here's a smaller section of the above map: Elevation is encoded as brightness, with lower-altitude regions being darker and higher altitude regions being brighter. One critical consideration to for your exploration is the amount of power required to drive the probe around while it's exploring and collecting samples - we want to find a region of the planet where the terrain is more or less level, so that our probe does not spend unnecessary energy driving uphill to get to where it's going. A planet-sized map is too big of course! We'll work with much smaller elevation maps for this exercise. For instance, here's a smaller section of the above map: Our task for this exercise is to write a function that takes as input an array containing an elevation map just like the image shown above, and given initial coordinates in this elevation map, detects and extracts the connected region in the map that has the same elevation as the initial coordinates. This can be used, for instance, to determine which areas in the map a robot could drive over without having to climb or descend! Download Starter Code: ex5.zip Make sure all the files are in the same directory when compiling and running your code. Your terminal must be in the same directory as well. The starter code contains documentation and some example output for the functions, as well as a few tests to help you check your code. The tests in the main() function are not comprehensive. You should test your code on many different input parameters yourself to ensure that they actually work as intended. Carefully read the comments in the function. What to do: Implement the function as needed. Add helper functions if you want to make your code clearer, though in this case you really shouldn't need to. . Check to see if your output makes sense on other test cases. The expected output for the given tests is below. What NOT to do: Change the name of any functions in the starter code . Remove the #ifndef _testing and #endif lines Compilation: Compile your code with the -Wall and -Werror flags. For instance, you might compile this exercise using: gcc-Wall-Werror exs.c What to submit: You will submit your ex.c program file only. The file name does not matter. Do not submit imgutils.c. Sample Output: If the images below are run with the starting position marked in red, then the corresponding output is expected: floo-region-1.pgm, starting position = (24, 16) floo-region-2.pgm, starting position = (4.35) Note on Image formats: We're going to be working with an image format called PGM (Portable Gray Map) since it's one of the easiest formats to read/write images with. However, Windows does not natively support this file type and will not let you view the image without any external tools. Google can help you find an image viewer so you can see your images! (I recommend GIMP as a free tool to view and also create these files to make your own tests). We'll be using this format going forward with your assignments and possibly other exercises, so make sure you're comfortable with using it. Note on Image formats: We're going to be working with an image format called PGM (Portable Gray Map) since it's one of the easiest formats to read/write images with. However, Windows does not natively support this file type and will not let you view the image witho external tools. Google can help you find an image viewer so you can see your images! (I recommend GIMP as a free tool to view and also create these files to make your own tests). We'll be using this format going forward with our assignments and possibly other exercises so make sure you're comfortable with using it

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

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

Azure Analytics is a suite made up of which three tools?

Answered: 1 week ago