I have image data in the Nikon .NEF raw format that I would like to open in MATLAB for some image processing. To accomplish this, I have followed Steve Eddins' blog post on the subject. Specifically, I am converting my .NEF files to digital negative (.dng) files using the Adobe DNG Converter, then using the Tiff class to read in the data.
I should also note that I am able to view my converted .dng files externally to MATLAB, and there are no apparent problems with the conversion.
My images are 4288×2848 px, and simply calling the imread() function on them returns a smaller thumbnail, which seems consistent with the blog post. Since I would like to view them in full resolution, I run the following lines, copied from the blog:
warning off MATLAB:tifflib:TIFFReadDirectory:libraryWarningt = Tiff(fullpath,'r'); %fullpath = path of .dng file
offsets = getTag(t,'SubIFD');setSubDirectory(t,offsets(1));cfa = read(t);close(t);
However, the data read into cfa returns as a 2868×4310 uint16 of zeros. I suspect this has something to do with my offsets, but I don't know enough about .tiff and SubIFDs in particular to really know where to go from here.
A few relevant warnings that appear in the code are copy+pasted below:
The following appears after calling Tiff() and getTag():
Warning: TIFF library warning: TIFFReadDirectory: [full path of .dng redacted]: unknown field with tag 37393 (0x9211) encountered..
This warning appears numerous times with numerous tags listed.
The following appears after attempting to read in the data into cfa:
Warning: TIFF library warning: JPEGPreDecode: Improper JPEG strip/tile size, expected 256x240, got 128x240.. Warning: TIFF library warning: JPEGLib: Must downscale data from 16 bits to 8..
Apologies if it sounds like I am just dumping this on the forum and saying "fix this," as that is not my intention. As I said, I know next to nothing about .tiff files, so if my problem is one that could be solved simply by reading up on them, relevant sources in lieu of a line-by-line solution would be appreciated.
Best Answer