File Exchange

image thumbnail

Read RAW camera images

version 18.913 (617 KB) by Emmanuel Farhi
Read RAW camera images from within Matlab, using DCRAW


Updated 22 Jul 2020

GitHub view license on GitHub

Read RAW camera images from within Matlab, using DCRAW

The use of this class boils down to simply creating the object. Then, you
may simply use the imread and imfinfo call as usual, and RAW files
will magically be handled.


In the following example, we just call readraw once, and then all is done
with imread and imfinfo as you would do with other image formats.

dc = readraw;
im = imread('file.RAW');
info = imfinfo('file.RAW'); % this creates a file.tiff
delete('file.tiff'); % to save disk space
delete(dc); clear dc


NOTE: Each RAW file will be converted to a 16-bits TIFF one at the same
location as the initial RAW file. This file is then read again by imread
to actually get the image RGB channels. If you have created these files
(which are each 146 Mb), you may either remove them, or further access
them without requiring conversion.

Supported RAW camera image formats include:


If you which to import the RAW files with specific DCRAW options, use the
readraw class method 'imread' with options as 3rd argument e.g:

dc = readraw;
im = imread(dc, 'file.RAW', '-a -T -6 -n 100');

and if you wish to get also the output file name and some more information:

[im, info, output] = imread(dc, 'file.RAW', '-T');

Some useful DCRAW options are:

-T write a TIFF file, and copy metadata in
-w -T -6 -q 3 use camera white balance, and best interpolation AHD
-a -T -6 use auto white balance
-i -v print metadata
-z set the generated image date to that of the camera
-n 100 remove noise using wavelets
-w use white balance from camera or auto


- readraw class instantiation. No argument.
- compile check for DCRAW availability or compile it
- delete remove readraw references in imformats. Then use clear
- imread read a RAW image using DCRAW. Allow more options
- imfinfo read a RAW image metadata using DCRAW


- DCRAW is a great tool <>
- Reading RAW files into MATLAB and Displaying Them <>
- RAW Camera File Reader by Bryan White 2016 <>

License: (c) E. Farhi, GPL2 (2018)

Cite As

Emmanuel Farhi (2020). Read RAW camera images (, GitHub. Retrieved .

Comments and Ratings (11)

Wes Baldwin

Worked perfectly for my Nikon NEF data. To read the RAW unaltered digitized values I used the following:
im = imread(dc,filename,'-D -4');

Thomas King

The fix for this error:

Error using imread (line whatever)
Name must be a string scalar or character vector.

is to have no spaces in any of the folder names that lead to your image.

Hi Emmanuel,

I'm wondering if there is a reason for the size of the image it loads and if there is a way to change this as it is larger than it should be.


Hi Emmanuel,
I receive the same error message as Ahmet:

Error using imread (line 438)
Name must be a string scalar or character vector.

I want to import "ARW" files. I tried your suggested test image but it does not work either. My MATLAB version is 2019a running on Win 10.

Thank you.

Stan Thorez

Hi Emmanuel,

I am having some trouble with the software while trying to convert/open .nef images. As a test, I have downloaded the test image from your last reply to Ahmet and I get the same error:

>> readraw;
readraw: installed ReadRaw as loader for RAW camera images.
>> im = imread('E1DXINBI000800.CR2'); % this creates a file.tiff
Error using delete
Argument must contain a character vector.

Error in readraw/imread (line 182)
if self.clean, delete(output); end

Error in readraw>@(f)imread(self,f) (line 124) = @(f)imread(self, f);

Error in imread (line 403)
[X, map] = feval(, filename, extraArgs{:});

Any idea what the problem here could be? My Matlab version is 2016b. On another system with 2017b, I get the same ("Argument must contain a character vector.") error. I am running it on Windows.

Hello Ahmet, I have bee using the test image and the commands:
>> readraw;
>> a=imread('E1DXINBI000800.CR2');
All works OK on my side. Can you try it out yourself ? What system do you have ? Matlab version ?



gives error

Error using imread (line 440)
Name must be a string scalar or character vector.

Hi Imran, I do not have access to your image, and can not inquire what's wrong. Perhaps you're accessing the thumbnail image/size.

Hello, It always give width and height 120*16*3 although my images have size much bigger size.
dc = readraw;
im = imread(filenames{2});
info = imfinfo(filenames{2}); % this creates a file.tiff

Hi Jack, I've updated the contribution to include Windows and MacOSX executables. Try it again, and it should run immediately.


Hi, I think this would be a great tool. Unfortunately, though, I cannot try it since am not able to compile dcraw.c 9.28 via dcraw_compile_binary.m. result shows 'collect2.exe: error: ld returned 1 exit status'



Now distributed with precompiled executables for systems that fail to compile.


Properly read EXIF data even when TIFF file exists.

Updated Title

Updated Matlab Central Description

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux