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 ? Open CV code and matlab code is as follows:
for (int i = 0; i < img1.rows; i++)
{
for (int j = 0; j < img1.cols; j++)
{
cout << (unsigned int)img1.at<uchar>(i, j) << endl;
}
}
Matlab code:
gI=rgb2gray(I);
imshow(gI);
double,uint8, some special image class? How do you convert between MATLAB and OpenCV? My guess is that in MATLAB you are dealing with normalizeddoublevalues (0-1) whereas in OpenCV they areuint8(0-255) or something similar. If this is indeed the case, you can find the maximum value of the datatype and convert between the two systems. - Dev-iL