Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Finding path to highest neighboring pixel?

Asked by Johny on 17 Nov 2013
Latest activity Commented on by Image Analyst on 18 Nov 2013
This question was flagged by Image Analyst

h

1 Comment

Image Analyst on 18 Nov 2013

This is getting really bad. So many people this weekend asking us for help and then editing away their question.

Johny

Products

No products are associated with this question.

2 Answers

Answer by Walter Roberson on 17 Nov 2013
P = [];
s = size(map);
[X, Y] = ndgrid(1:s(1), 1:s(2));
mask = abs(X-x) + abs(Y-y) <= 1000;
mask(x,y) = false;
highestground = max(map(mask));
if highestground <= map(x,y)
  disp('There is no higher ground to go to within 1000 steps');
  return
end

1 Comment

Walter Roberson on 17 Nov 2013

Yup. I didn't say I was going to answer the entire question for you. The first thing you need to do is figure out where "higher ground" is that is within distance; this code does that. It only needs one small change to tell you exactly where the higher ground is. Have a look at max()

Walter Roberson
Answer by Image Analyst on 17 Nov 2013

Well, the watershed transform won't work because that doesn't guarantee that the path is monotonically increasing. So see Steve's 5 part blog series on path finding: http://blogs.mathworks.com/steve/2011/11/01/exploring-shortest-paths-part-1/

You could also try doing it yourself and find an optimized path with methods like A* http://en.wikipedia.org/wiki/A* and dynamic programming http://en.wikipedia.org/wiki/Dynamic_programming#Checkerboard where you can plug in your own criteria.

0 Comments

Image Analyst

Contact us