How many non-boundary pits and peaks are on the map, C/C++ Programming

Armed with your function from above, we can do some interesting things. For instance, any pixel where the offsets are both zero is a pit (lower than all surrounding points). Note that every boundary pixel is a pit, so make sure you ignore them in your code. For this second part, write a function:

     function rc = findpits(map)

that will return a matrix containing 2 columns  with the row and column indices of all non-boundary pits in map.  Notice that you can actually then find the non-boundary peaks with the same function, by simply calling it another way: findpits(-map) (think about why this works). Report how many non-boundary pits and peaks are on the map, and plot them as follows:

pits = findpits(map);

peaks = findpits(-map);

imagesc(map); colormap(gray); axis equal

hold on

plot(pits(:,2),pits(:,1),'ro');

plot(peaks(:,2),peaks(:,1),'g+');

hold off

Note: Your findpits() function will probably call findLowNhbr() from Part 1. That is, in your findpits function, you will find lowest neighbours for all points, and then figure out which points are pits.

Note: When plotting, notice that rows are y-coordinates and columns are x-coordinates, which explains their order in the plot command (2nd column, then 1st column). We'll keep talking about rows & columns in the hope it is clearer, but remember that rows indices translate into y-coordinates, and column indices into x-coordinates.

To help you check if your code is working, according to my code, test (the 10x10 test map) has pits at (3,6), (6,3), and (6,6) and peaks at (5,5) and (8,5).

What to submit: Include the m-file for findpits in your zip file. In solutionWatersheds.m, call this function with the provided elevation map ('map'), and generate a figure like the one above, showing all the pits and peaks. Also print out the number of peaks and pits you found.

Posted Date: 3/29/2013 2:55:22 AM | Location : United States







Related Discussions:- How many non-boundary pits and peaks are on the map, Assignment Help, Ask Question on How many non-boundary pits and peaks are on the map, Get Answer, Expert's Help, How many non-boundary pits and peaks are on the map Discussions

Write discussion on How many non-boundary pits and peaks are on the map
Your posts are moderated
Related Questions

Need to Fix a code written in c++,SDL2.00 for high CPU and memory leak There is a 2D simple game written with SDL2.00 using c++. The game isn't complete and the code is a little

C Program for SORTING OF NUMBERS   main() {           int a[20],i,j,temp,n;           clrscr();           printf("ENTER THE MAXIMUM LIMIT: ");           scan

F u nction overloading: Functions can be defined with same name.  Depending upon the type of argument passed the function will perform.  This is known function overloading

Ask quIn the Byteland country a string "s" is said to super ascii string if and only if count of each charecter in the string is equal to its ascci value in the byteland country as

There are 3 acceptable answers: "Never," "Rarely "and" When the problem domain cannot be accurately modelled any other way."

write a program that can accept numbers and perform all the four arithmetic operation

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

For this assignment, I've provided a data file called 'elevation.mat', which contains the elevation data you'll be working with.   Type load elevation.mat to get the varia

Explain structured programming The principal idea behind structured programming was as easy as the idea of "divide and conquer." A computer program could be regarded as having