im2double, double and adapthisteq

Hello, I'm writing a PIV algorithm, I need to read two grayscale images divide them in interrogation windows and do cross-correlation using xcorr2. I'm having troubles converting the images from uint8 to double: firstly, I don't know if it is better to use double or im2double for converting the images, will corss-correlation give different results? Secondly, I need to do adaptive histogram equalization, if I convert to double using double, before doing it, it produces bad output. If i use im2double instead, it does work; I then think it requires input of type double to be between 0 and 1, I searched the documentation, but it does not say anything about it. I am right? Lastly, is there there any difference if I convert to double before or after the equalization? Thank you very much.

 Accepted Answer

Guillaume
Guillaume on 20 Feb 2017
"will corss-correlation give different results"
Yes, since the range of values will be different. Will it matter? For PIV, not at all, since it will just change the scale of all the peaks by the same amount. The location of the peaks will still be the same.
"if I convert to double using double, before doing it, it produces bad output"
Yes, it will. matlab image processing functions expect all double images to be in the range [0,1]. Anything above 1 is considered the same as 1. Therefore a uint8 image converted using double will be in effect an image with black for uint8 0 and white for all intensities between 1 and 255.
So in your case, im2double is better. Note that for a uint8 image, the only thing that im2double does is divide by 255 after conversion to double.

3 Comments

Thank you very much! One last question, is it better to convert to double before or after equalization? Or the difference between doing it in uint8 or double is negligible?
It will result in minute differences in the equalised image since the integer version will be slightly more discretised.
For the cross-correlation, I doubt it'd matter. But then, how come you've got to apply histogram equalisation on PIV images? With a decent setup, your particles intensity should be well above background.
CD
CD on 20 Feb 2017
Edited: CD on 20 Feb 2017
Yes, the images correlates well without equalization, but it is for an exam project and I'm trying different pre-processing methods like min/max filtering, gauss filtering and adaptive equalization, in order to see how well they do. Thank you very much again!

Sign in to comment.

More Answers (0)

Categories

Find more on Fluid Dynamics in Help Center and File Exchange

Asked:

CD
on 20 Feb 2017

Edited:

CD
on 20 Feb 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!