# Sharpen ridges and valleys

I am looking for a way of sharpening ridges and valleys in the following heightmap

I think this problem is slightly different than a regular sharpen operation, because sharpening would affect first derivatives, but the sharpness of ridges and valleys must modify the second derivative.

1. I have an idea to decompose into components that represent derivatives of different order up to including at least the second derivative:

$$f(x, y) = f_0(x, y) + a_xf_x(x, y) + a_yf(x, y) + b_{xx}f_{xx}(x, y) + 2b_{xy}f_{xy}(x, y) + b_{yy}f_{yy}(x, y) + \text{H.O.T}$$

and increasing the $$b$$-terms, which should affect the surface curvature. Would this work? If so, how to achieve such decomposition.

1. It could work to use some polynomial decomposition. Notice for example that if

$$p(x) = ax^2 + bx + c$$

Then $$p_xx(x) = 2a$$. Thus, the second derivative is proportional to $$a$$. Some additional steps are then needed because $$p(x)$$ and $$p_x(x)$$ are also affected by $$a$$.

To give some information about mathematical properties of $$f$$ (continuity, differentiability, etc) i present the signal flow that produces the image below. Notice that "Make radial gradient" outputs the distance from the origin squared. Thus, exponential decay will in this case result in a Gaussian blur.

• What's the tool you used with this nice flow of data?
– Royi
Aug 29 '21 at 16:03
• Aug 29 '21 at 19:17
• Have you tried Unsharp Mask?
– Royi
Aug 30 '21 at 5:03
• @Royi From my post "I think this problem is slightly different than a regular sharpen operation, because sharpening would affect first derivatives". Unsharp mask would simply reintroduce the "bumps" removed by the gaussian blur. Aug 30 '21 at 14:25