Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

The values ​​of a function of two variables z = f (x, y), where x, y, z take integer values are stored in sql db. Calculate (appoint) the largest surface area of ​​the flat. By 'flat area' we mean an area about which for each pair of x and y lying inside the area about the value of the function is constant (z = const).

I have already tried to use this flood fill algorithm, but I am not sure if this is the right way. e.g. if I have pairs(x,y) as follows: (0,0),(0,2),(2,0),(2,2) for which z equals to 5(z=const) and have point (1,1) where z=1 - how should I compute "flat area"?

share|improve this question
    
What have you tried so far? We can help clarify things if you're genuinely stuck, but we won't really do your homework for you. –  Yannis Rizos Apr 21 '13 at 12:57
    
Right, of course. I have already tried to use for this flood fill algorithm, but i am not sure if this is right way. e.g. if i have pairs(x,y) as follows: (0,0),(0,2),(2,0),(2,2) for which z equals to 5(z=const) and have point (1,1) where z=1 - how should i compute "flat area"? –  Marcin Szewczyk Apr 21 '13 at 13:06
1  
you mean getting the convex hull of a set of points? –  ratchet freak Apr 21 '13 at 15:02
add comment

2 Answers

The main question is if your "flat area" has to be convex or not.

If it can be non-convex then flood fill algorithm will work fine, and your example area can be treated as the flat area.

If it has to be convex then the answer from below question will work
http://stackoverflow.com/questions/7332065/what-is-the-best-algorithm-to-find-the-largest-black-convex-area-in-an-image

share|improve this answer
add comment

Use flood fill to identify flat regions with no holes. For each one, solve the problem for that region, remember the answer, identify an adjacent flat region (if any), alter the current region to have the adjacent region's altitude, rinse, lather, repeat. Subtracting the area of the altitude 1 region from the area of the enclosing altitude 5 region is straightforward.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.