Why is my simple contrast algorithm not working with Cimg

Solution 1:

The algorithm above scales the image into [0, 1] range.
Namely the pixels with the lowest values will be mapped to 0 and the pixels with highest values will be mapped to 1.

You need to apply thin on RGB image which its values are in the range [0, 1]. You need to apply it per channel.