Detecting flat surface but not constant depth, pls help

I’m not sure to understand your problem.
Are you looking for something like this?