Applying Photoshop's "Shadow / Highlight" Correction Using Standard Image Processing Algorithms
I think this can be achieved through histogram stretching. Input pixel values (levels) are mapped using linear transform from $&lt;\textbf{min}_{in},\textbf{max}_{in}&gt;$ to $&lt;\textbf{min}_{out},\textbf{max}_{out}&gt;$. The intensity transform for input and output pixel values look like this:

$$I_{out}=\frac{I_{in}-\textbf{min}_{in}}{\textbf{max}_{in}-\textbf{min}_{in}}\cdot(\textbf{max}_{out}-\textbf{min}_{out})+\textbf{min}_{out}$$

The formula can be simpler, but this one is more clear, at is transform input values from one interval to the other.

By default, $\textbf{min}$ is 0 and $\textbf{max}$ is 255 (depending on bit depth). Increasing value of $\textbf{min}_{in}$ emphasizes shadows, while decreasing $\textbf{max}$ emphasizes lights.

There are also "radius" track bars, so I suppose the histogram operation can be done adaptively / locally, i.e. histogram is computed for a window at every pixel instead of whole image.

Gaussian blur on work image prior to histogram computation may be convenient when the window is small to avoid sharp transitions.

Similarly, you can compute difference map which you smooth and then apply.

The adjustment will likely disturb color balance, so applying to luma channel only or computing adjustment of gray value and applying to R,G and B channels should suffice.