I am using a Nikon D5200. I intend to do some image processing on the raw images shot with the camera. But I am encountering a problem when I read the raw images using GNU Octave. Rather than giving bit depth of 16 (since the .NEF are shot at 14-bit depth), the result is just a 8-bit array. What might be the problem?


ans =

scalar structure containing the fields:

Filename = /media/karthikeyan/3434-3531/DCIM/100D5200/DSC_1094.NEF

FileModDate = 10-Oct-2016 18:10:02

FileSize = 26735420

Format = DCRAW

FormatVersion =

Width = 6036

Height = 4020

BitDepth = 8

ColorType = truecolor

I am using Ubuntu 14.04, Octave 4.0.3.

  • \$\begingroup\$ Could be related to this question: photo.stackexchange.com/questions/20156/… \$\endgroup\$ Oct 12, 2016 at 15:00
  • \$\begingroup\$ What does exiftool DCS_1094.NEF | grep -i bit tell you? \$\endgroup\$
    – chili555
    Oct 12, 2016 at 15:52
  • \$\begingroup\$ @chili555 Here is what your command tells me - exiftool DSC_1094.NEF | grep -i bit Bits Per Sample : 14 \$\endgroup\$ Oct 12, 2016 at 16:49
  • \$\begingroup\$ That suggests that the RAW file is, indeed 14-bit but that there is an issue with Octave. \$\endgroup\$
    – chili555
    Oct 12, 2016 at 20:07

1 Answer 1


Check out this page:

Tips for reading a camera raw file into MATLAB

According to this you are actually reading the thumbnail image and not the RAW file itself. You must convert the .NEF to .DNG and then utilize a Tiff class.

  • \$\begingroup\$ If the file size is 26 Mb, then I doubt he is reading the thumbnail. \$\endgroup\$
    – chili555
    Oct 12, 2016 at 15:46
  • \$\begingroup\$ @chili555 Is that the compressed or decompressed size? \$\endgroup\$
    – Michael C
    Oct 12, 2016 at 17:01
  • \$\begingroup\$ @MichaelClark How do it check that? I guess its compressed based on official tech-specs. Or did you mean something like zip? \$\endgroup\$ Oct 12, 2016 at 17:14
  • \$\begingroup\$ @karthikeyan I don't know. I don't use MATLAB. But when it is displayed on your monitor a compressed jpeg has to be decompressed first. The size of the decompressed file will be based on the resolution times the bit depth for each color channel. \$\endgroup\$
    – Michael C
    Oct 12, 2016 at 17:17
  • \$\begingroup\$ @chili555 I don't work with NEF files but I'm pretty sure they have both a small thumbnail and either a half or full size jpeg embedded in them. \$\endgroup\$
    – Michael C
    Oct 12, 2016 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.