I was wondering if anybody could help me understand RAW files. I know there are a ton of different formats called "RAW," and that it is often manufacturer and even camera specific. I've read that some supposedly contain some kind of "header" that gives info about the file/camera and such.
I'm trying to analyze different RAW outputs from different cameras in Matlab, none of which have much documentation or support as far as I've been able to find over a few days of searching. The popular conversion utilities (Adobe DNG Converter and dcraw) don't recognize these files. I have 5 picture files from each camera, taken with the camera's proprietary software, which should contain 12-bit grayscale data. Endian-ness is not apparent to me (though might be to someone else?). The only other thing I know is what the dimensions of each picture should be.
Basically, is there a way I can reverse-engineer the RAWs I have so that I can understand how to convert them into .tif or something a little more Matlab friendly? I'm pretty new to all of this.
Just a note - the image sizes you have suggest to me that your images may be stored as 16 bit (possibly with only 12 of those being used in practice).
You really need to contact the manufacturers to be sure. However, if you have the size and know the precision you can use fread and experiment with endianness and direction of dimensions.
So for your Lumenera example, the exact number of bytes is 4,456,448. This suggests the size is right and the bitdepth is 16: width * height * bitdepth / 8. The only question then was which way the size went (1088x2048 or 2048x1088) and endianness. The following looks like a reasonable image to me (not entirely sure what of...)
fid = fopen('Lumenera.raw');
A = fread(fid,[2048 1088],'uint16','l');
fclose(fid);

If there is a header and you have some idea of the size of it you can either read that in with fread first or fseek to the start of the image data if you don't need the contents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With