Imread() Giving incorrect intensities for a uint8 Tiff [C++]

asked 2018-05-02 23:20:10 -0500

TryingToLearn gravatar image

updated 2018-05-03 00:13:06 -0500

I used the imread() function to read a 5000 x 5000 UINT8 TIFF(with an indexed color map), however the actual intensities or indexes in the MAT are completely incorrect. I have tried reading the image using the following flags:

cv::IMREAD_UNCHANGED = -1,

cv::IMREAD_GRAYSCALE = 0,

cv::IMREAD_ANYDEPTH = 2,

However, the image intensities are still incorrect. The Image intensities are always displayed correctly in Matlab and ImageJ; however openCV appears to be having some issues. An example of how openCV is currently mapping the intensity values is shown below.

Correct Intensity=> OpenCV Intensity

164=>166

167=>163

146=>186

129=>204

128=>255

5/3 I looked at the issue again and realized that imread() appears to be reading the colormap values instead of the index values. I need the index values.

Please let me know if you have any questions.

edit retag flag offensive close merge delete

Comments

what is the problem ? imread gives you grey level values ?

LBerger gravatar imageLBerger ( 2018-05-03 03:01:46 -0500 )edit

Imread() is not giving me index image of the indexed color image.. I want the index image, not an approximated greyscale image. You can read about index color images in the link above.

These people had similar problems with openCVpython.( Please note that I am using c++ opencv )

https://stackoverflow.com/questions/4...

https://stackoverflow.com/questions/3...

TryingToLearn gravatar imageTryingToLearn ( 2018-05-03 08:08:11 -0500 )edit

That's not possible using imread function: You can write your own function to read tiff format or you can try to make your color histogram and you should find 256 colors in your image and then retrieve a color index

LBerger gravatar imageLBerger ( 2018-05-03 12:51:12 -0500 )edit