Maximum value is not 65535 in the raw image

Hi everyone,

There's something I cannot understand: when extracting the maximum value in the raw image, I obtain a small value whatever the camera used (Nikon D90 or PhaseOne IQ180).
Here is a piece of code to better understand my query:

LibRaw iProcessor;
iProcessor.open_file(name);
 
dimx = iProcessor.imgdata.sizes.width;
dimy = iProcessor.imgdata.sizes.height;
 
// Reserve memory for image (code not shown)
 
iProcessor.unpack();
 
int width = iProcessor.imgdata.sizes.raw_width;
int yoffset = iProcessor.imgdata.sizes.top_margin;
int xoffset = iProcessor.imgdata.sizes.left_margin;
 
unsigned short max = 0;
for (int x = 0 ; x < dimx ; ++x) {
	for (int y = 0 ; y < dimy ; ++y) {
		image[i][x][y] = iProcessor.imgdata.rawdata.raw_image[(x+xoffset)+width*(y+yoffset)];
		max = (max > image[i][x][y]) ? max : image[i][x][y];
	}
}
cout << min << endl;
cout << max << endl;

I obtain something like 3840 with a raw image from D90. I can see on the histogram that it should not be like this!
Can someone give me some clues?
Thanks.

Forums: 

D90 is 12-bit camera, so

D90 is 12-bit camera, so maximum possible value is 4096.
It may be slightly less if 'zero level' (bias) is subtracted by camera.

IQ180 is 16-bit, so maximum value should be 64k (and it is in my tests)

-- Alex Tutubalin

Thank you so much!

Thank you so much!
It is now clear for the NEF file. I need however to test if the problem comes from my IIQ picture...

I've check one more time and I still get a maximum value of 11040 for the 16bits data from the PhaseOne IQ180 (even if there's some white zones in the photograph).
Thanks to Alex, I'm now confident with the piece of code used, and I will investigate the problem in the settings of the digital back.

Another question:
is it a normal behavior to have different values for imgdata.color.maximum and max (the latter being computed by looping over the raw pixels)? Here is what I obtain:

max = 11040
iProcessor.imgdata.color.maximum = 64508

Thank you again.