When experimenting with sensor analysis it might be useful to modify the raw data and then see how that modification translates visually by loading the modified raw data into your favorite demosaicing app like ACR/PS, LR,RawTherapee, etc..
The ideal conversion scenario would be simply replacing the raw data in its existing vendor-specific raw or DNG container. That way you retain all the metadata and profile info. I'm still working on finding an existing tool chain that will do that, or writing my own. In the meantime I found a tool chain will at least get to a working DNG file:
Tools needed
A7 III ISO 100 Studio sample with lower 12-bits of raw data masked off
The ideal conversion scenario would be simply replacing the raw data in its existing vendor-specific raw or DNG container. That way you retain all the metadata and profile info. I'm still working on finding an existing tool chain that will do that, or writing my own. In the meantime I found a tool chain will at least get to a working DNG file:
Tools needed
- Build an executable from the pgm2dng GitHub source. A pre-built Windows binary is included in the repository - direct link here
- Get dcptool. Windows executable here (free) and OSX here ($9.99)
- Matlab ($$$) or Octave
- LibRaw's unprocessed_raw.exe, available here
- exiftool
- Convert any original out-of-camera raw for the camera model you're working with to a DNG using Adobe's DNG Conveter
- Build an XML representation of the Adobe Digital Camera Prfile for that DNG by running dcpTool -d <raw image file> out.dcp.xml
- Convert the XML file into a binary DCP by running dcpTool -c out.dcp.xml out.dcp. Ignore any informational warnings displayed
- Convert the raw file to a PGM by running unprocessed_raw <raw filename>. This builds a greyscale image with the original raw bayer data. The output filename will be the same as the input raw name plus PGM. For example, a73.ARW becomes a73.ARW.pgm
- Load the PGM file into octave via imgData = imread("<pgm filename>") and do whatever modifications you want on the raw data contained in the imgData matrix. You may also choose to delete the masked pixel rows to match the actual dimensions of the image. For example, the A73 with masked pixels is 6048x4024 and 6024x4024 without
- Write the modified raw data using imwrite(imgData, "<modified pgm filename>")
- Convert the modified PGM file into a DNG via pgm2dgn with the following parameters:
- --in=<modified pgm filename>, where the filename is the one used in imwrite
- --out=<modified DNG filename>, where the filename is of your choosing
- --dcp=out.dcp
- --pattern=RGGB (or GBRG for raws that start a G2-B row)
- --wp=<R,G,B>, specifies the white balance. One way to get this is to load the original raw into a demosaicing tool that doesn't apply WB and sampling the RGB of a neutral patch. However, since WB is so easy to set after the fact, I just use any triplet, like --wp=128,128,128
- Optional: --white=<whitepoint> , which you can get via exiftool -whitelevel <raw filename>. Use only one of the three values. For example, --white=15360
- Optional: --black=<blackpoint>, which you can get via exiftool -blacklevel <raw filename>. Use only one of the three values. For example, --black=512
- Load the modified DNG into your favorite image processing app and set the white balance
A7 III ISO 100 Studio sample with lower 12-bits of raw data masked off
Attachments
Last edited: