Modifying raw image data for experiments

Started Apr 5, 2021 | Discussions thread
Jack Hogan Veteran Member • Posts: 8,356
Matlab Hack
3

Good one Horshack. It's not as elegant as your approach but for reference I've been using the following hack in Matlab via Adobe DNG Converter to achieve the same objective (don't know about Octave).

1) Convert the original raw file to DNG with Adobe's DNG Converter, Uncompressed option ticked, and place it in the working directory. Then read the raw data directly into Matlab

t = Tiff(fileName,'r');
offsets = getTag(t,'SubIFD');
setSubDirectory(t,offsets(1));
cfa = read(t);
close(t);

2) Modify the raw data in array cfa as desired while ensuring that at the end it is still the same size and in its native uint16 format. Then write it back to the DNG file above

t = Tiff(fileName,'r+');
setSubDirectory(t,offsets(1));
t.write(cfa)
close(t);

3) Now open the modified DNG file in the raw converter of choice. The simple code above does not update checksums etc. so for instance PS ACR complains that the file appears to be damaged but opens it fine anyways.

Jack

Keyboard shortcuts:
FForum PPrevious NNext WNext unread UUpvote SSubscribe RReply QQuote BBookmark MMy threads
Color scheme? Blue / Yellow