This is a very top level question with no code examples attached. I have an interest in using Mathematica to read raw files coming from a Canon camera, before they are converted into jpg's, where data is lost. Are there any existing non proprietary mathematica scripts, which can read a CR2 file from a Canon camera and display its image as it would if a jpeg were imported. At the very least a script that can display data about the image stored in the CR2 file to include intensity, size, pixel value, LRGB histograms, etc...
Asked
Active
Viewed 1,527 times
2 Answers
4
Yes! I have done this before with RAW files.
Use the dcraw command line utility and convert the RAW file to a TIFF. You'll need to use appropriate command line options to prevent any processing of the data.
dcraw -o 0 -D -T -6 infile.cr2
It'll output a TIFF file with un-demosaiced raw sensor data. You can read that with Mathematica.
EXIF data can be extracted using exiftool.
What I don't have a solution for yet is how to put any (Mathematica-processed) data back into RAW files (say, DNG) so it can be read into a RAW converter.
Szabolcs
- 234,956
- 30
- 623
- 1,263


dcrawis a command line tool. You can invoke it from a terminal or using Mathematica'sRuncommand.librawis a C library, which I think is based on the dcraw sources. You have to write a C program to use it. It doesn't involve any GUI/graphical programming (which I also don't do much), but it probably does involve reading a lot oflibrawdocumentation. In this case you'd want to extend Mathematica to be able to uselibrawdirectly from it, so you would also need to learn Mathematica's C interface. Your best choice would probably be using the LibraryLink ... – Szabolcs Feb 13 '14 at 00:49dcrawthroughRunand using an intermediate TIFF format file: mainly you'd be able avoid the temporary TIFF file when invoking any function. This is why I said that it's probably not worth the effort. – Szabolcs Feb 13 '14 at 00:56