good day all,
i am using openCV to load a color bmp file, i use:
the data is stored as a char*
IplImage* image = cvLoadImage("Color.bmp",1);
i wish to convert this data into a RGB float array.
however if i simply go through the string and convert each char using a (float) cast, i sometimes end up with negative numbers.
is there a proper way of converting chars that represent color values into proper floats without getting negs ??
You need to cast your char to unsigned char first, as the RGB values can range from 0~255, which is the range of unsigned chars. Signed chars' range is -128~127. When a RGB value is greater than or equal to 128 and you convert it directly, you get a negative.
fantastic it works :) thanks, i was beginning to run out of hair to pull out :)