White pixel value different from 255

asked 2014-03-12 03:36:35 -0600

updated 2014-03-12 03:42:58 -0600

berak gravatar image

Hello,

I am working on image processing in C + + and opencv, I treat images in grayscale, ie the pixel values ​​it must be between 0 (black) to 255 (white).

Mat img; img = imread (file, -1); for ( int i = 0; i < img. rows ; i ++) { for ( int j = 0; j < img. cols ; j ++) {

val_pixel=img.at < double >(i,j);

printf( "%d ",val_pixel); } printf( "\n"); }

when displaying the pixel value from two loop, I get values ​​to 0 and it is normal for propablement black areas, but for whites I find the value -2147483648. I don't understand why this value is not 255.

Is there an explanation for this has value. Thank you for your support.

edit retag flag offensive close merge delete

Comments

2

img.at < double >(i,j); // the 'double' is wrong.

the type inside the brackets has to match the Mat's type (uchar if grayscale, or Vec3b if color)

berak gravatar imageberak ( 2014-03-12 03:46:04 -0600 )edit