a White pixel value different from 255

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.
Last edited on
That's most likely a problem with converting unsigned to signed. Didn't you get a compiler warning regarding this issue somewhere?
No, I don't get a compiler warning :
--------------------------------------
10:11:16 **** Incremental Build of configuration Debug for project Ess ****
make all
make: Nothing to be done for `all'.

10:11:16 Build Finished (took 172ms)
-----------------------------------------
Err, compiling process is not even started. DO make clean before make all
also, you've got to enable warnings.

1
2
val_pixel=img.at < double >(i,j);
printf( "%d ",val_pixel);
¿is `val_pixel' a double or an integer?
Topic archived. No new replies allowed.