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

Assignment Help:

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.


Related Discussions:- How many non-boundary pits and peaks are on the map

Write code in visual studio 2010, I have a mini project where I need to wri...

I have a mini project where I need to write a code .wonder if someone can help me.I already have the forms and webmaster page done just need to code portion

Subtraction of numbers, Two numbers to be subtracted using bitwise operatio...

Two numbers to be subtracted using bitwise operations

.luminous jewels, Byteland county is very famous for luminous jewels. Lumin...

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

Add words in dictionary - c++ program, Add words in Dictionary: void D...

Add words in Dictionary: void Dictionary::add( Object& objectToAdd ) {     if( !objectToAdd.isAssociation() )         ClassLib_error( __ENOTASSOC );     else

Area under curve, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.

Describe how a structure differs from a union, Question : (a) How does...

Question : (a) How does a structure differ from an array? (b) Describe how a structure differs from a union? (c) Declare a union called ‘clothes' which consists of the

Explain member functions of a class, Member Functions of a Class A memb...

Member Functions of a Class A member function of the class is similar as an ordinary function. Its declaration in a class template must explain its return value as well as the

Add the two complex no.s given by user - c++ program, THIS PROGRAM IS TO AD...

THIS PROGRAM IS TO ADD THE TWO COMPLEX NO.S GIVEN BY THE USER  */ #include #include #include struct complex     {     int real;     int imag;     }; void main()  {  clrs

Flowchart, how to define a contanst in a flowchart like we do in c language...

how to define a contanst in a flowchart like we do in c language

Write Your Message!

Captcha
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