# Detect and measure smooth peaks in a 2D image

I have multiple grayscale images where I want to identify elevations: I have to find the convex hull that encloses the base of each hill. An example image:

The images are already normalized, background-gradient-removed, and filtered to get rid of sharp features and noise. Areas with less contrast are due to heavy noise, not much can be done against it.

My method so far is satisfactory, but not perfect.

img= Import["https://i.stack.imgur.com/vxdI4.jpg"];
fun = {
Show[HistogramTransform@img,
Graphics[{EdgeForm@Red, FaceForm@None,
Polygon@#[[First@FindCurvePath@#]] & /@ (Last /@
ComponentMeasurements[#, "ConvexVertices"])}],
ImageSize -> Small] &
};
FoldList[#2[#1] &, img, fun])


My questions are:

• How to properly detect the background elevation? That is, the level of (supposedly) uniform gray against which hills' footlines (area, height, etc.) can be detected?
• How to respect the direction of illumination? Note, that this may change in different images. At present, the detection polygons are shifted toward the lighter part of each hill.
• How to better separate hills? Some hills are not detected due to low contrast, some are joined with neighbouring ones. Since hill-shape and area is important, I prefer not to rely on extensive morphological dilation/erosion (Opening, Closing).
• Have you tried something like ImageApply[Abs[#-mean],img] where mean=Mean@Flatten@ImageData@img? This might help a bit with the problem that the detected peaks are shifted. – Lukas Lang Aug 15 '17 at 16:14
• @Mathe172 How exactly do you suggest using this? If I apply this on img directly, it just separates lighter and darker areas, but then binarization becomes problematic. – István Zachar Aug 16 '17 at 12:35