Pixels are stored internally as IPL_DEPTH_8U, which means 8-bit unsigned char, ranging from 0 to 255. But you could also pack them as IPL_DEPTH_16S (signed integer) and even IPL_DEPTH_32F (single precision floating point number).
cvConvertScale() probably will do the job! But if you want to convert it manually:
http://stackoverflow.com/questions/882066/opencv-need-to-convert-ipl-depth-32s-to-ipl-depth-32f
The basic idea is to create a new image with cvCreateImage() and the format you need them to be, then use cvConvertScale() to copy the original data to new format. In the end, your code might look something like the following:
IplImage* img = cvLoadImage("file.png", CV_LOAD_IMAGE_ UNCHANGED);
// then retrieve size of loaded image to create the new one
IplImage* new_img = cvCreateImage(img_size, IPL_DEPTH_16S, 1);
cvConvertScale(img, new_img, 1/255.0, -128);
I think this answers the question of the thread.
Answering your comment, you could access the pixel information like this:
IplImage* pRGBImg = cvLoadImage(input_file.c_str(), CV_LOAD_IMAGE_UNCHANGED);
int width = pRGBImg->width;
int height = pRGBImg->height;
int bpp = pRGBImg->nChannels;
for (int i=0; i < width*height*bpp; i+=bpp)
{
if (!(i % (width*bpp))) // print empty line for better readability
std::cout << std::endl;
std::cout << std::dec << "R:" << (int) pRGBImg->imageData[i] <<
" G:" << (int) pRGBImg->imageData[i+1] <<
" B:" << (int) pRGBImg->imageData[i+2] << " ";
}
Dont forget to vote up and mark this answer as accepted in case it did.