Pixel values differ between opencv and matlab

asked 2015-06-25 01:46:17 -0600

When I am displaying the pixel values of an image (a RGB image converted to grayscale) using "display" function in matlab, I found that the pixel values are less than 1 (all values are between 0 and 1). Whereas when I do the same in opencv, I am getting higher values. Why the change in values happen ?

edit retag flag offensive close merge delete


In matlab I think that index are in [1, rows] and in C++ if you use it in [0. rows-1]. Is it help you?

LBerger gravatar imageLBerger ( 2015-06-25 06:11:02 -0600 )edit

@LBerger: I don't think that's the problem he's facing. Matlab, depending on the functions/data used automatically normalizes pixel values between 0 and 1. OpenCV doesn't do such normalization (afaik), so data is between 0 and 255. @lakshmi8: just apply a linear transformation [0,1]->[0-255] and viceversa to find correspondesces, or force Matlab to use uint8 data (instead of double, which is probably the format used right now)

LorenaGdL gravatar imageLorenaGdL ( 2015-06-27 03:03:44 -0600 )edit