Why doesn't more than char work with char?

I am implementing an image processing filter in OTB (C ++ library).

I have weird behavior with some basic testing. When I read my image as "char", the following code always displays the pixel value (in the range 0-200), even if it is greater than 150. However, it works fine when I use the "short int". Is there a special behavior with "char" (for example, instead of comparing with a numerical value instead of comparing), or can there be any other reason?

Of course, my image pixels are stored in bytes, so I prefer to process "char" instead of "int" because the image is quite large (> 10 Gb).

if (pixelvalue > 150)
{
out = 255;
}
else
{
out = pixelvalue;
}
+4
2

unsigned char ( ) 255, char 127.

+11

char , ( , "" ), char), - 8 ( 9, 16, 18, 32 36 , ).

150 , 8- , , char.

, [u]intN_t - , , uint8_t. , , , "" [ unsigned char. , , char 8 , .

+5

All Articles