How to convert CImg float image type to unchar image(0-255) type

1.4k views Asked by At

I am using CImg library and implementing non maximum suppression for Harris Corner Detector. Because calculation of numbers like determinants requires float type image, I declared images as float type. But when exracting local maximum on the harris response float image, I found it hard to set the threshold because I don't know what exactly the values of the pixels on a float image are, and I got some very strange points extracted which actually weren't the ones I wanted. For example I printed out the values of the points, then I found pixel values like 6e+9 or 1.8e+5, and I don't know what they mean. Is there a way to convert a float image into unchar image so that I can set an integer threshold for local maximum extraction? Thanks in advance!

1

There are 1 answers

0
bvalabas On

You just have to normalize your image values, like this :

CImg<unsigned char> img_normalized = img.get_normalize(0,255);

then work on the values of 'img_normalized' instead.