10
\$\begingroup\$

How can I resize RAW image files (.NEF) from 12 Megapixels to about 5 megapixels without converting them to JPG?

\$\endgroup\$
3

3 Answers 3

12
\$\begingroup\$

You have to convert them to some other format, but that format doesn't have to be JPEG. For example, you could save the files as TIFF or PNG instead of JPEG. RAW files are data read more or less straight from the sensor, so it doesn't make sense to "resize" such files. You have to instead process them into a useable image format, which you can then manipulate to suit your purposes.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Some cameras can produce raw files in different sizes. For example, the Canon 70D can produce small, medium, and large RAW files, so clearly the notion of resizing a RAW file makes sense (at least to Canon). \$\endgroup\$
    – Gabe
    Oct 14, 2014 at 5:31
  • \$\begingroup\$ Interesting; Canon seems to have introduced a "M-RAW" and "S-RAW" formats, which dump half or a three quarters of the sensors pixels. Advantage seems to be that you still get control over interpolation and higher bitdepth, but at reduced resolution and filesize \$\endgroup\$
    – Sam Mason
    Oct 14, 2014 at 14:11
8
\$\begingroup\$

You could use dcraw to convert the raw image data to a "raw" tiff file that only contains the raw image data. You do that by giving the command "dcraw -D filename". This will produce a tiff file without any demosaicing or scaling. Such a tiff file is then smaller than an ordinary tiff file because each pixel is then only either a "red", "green" or a "blue" one. You can then edit the tiff file using e.g. ImageJ and resize it, but you then need to take into account the Bayer pattern. This can be done by considering only the pixels corresponding to each of the colors. You can split the image up in 3 parts such that each new image only contains the pixels of one of the color channels. You then resize each part and then compile a combined image by taking the 3 images and arrange the pixels from them according to a Bayer pattern again.

\$\endgroup\$
5
\$\begingroup\$

To understand why you can't do this, it's helpful to understand how RAW works.

A RAW doesn't actually contain colored pixels, it's a single channel ("gray scale") image representing alternating red blue and green pixels called a Bayer pattern. To actually get the "actual" pixels, you have to extrapolate from each of the pixels neighbors using a complex algorithm called de-bayering.

To down-sample a RAW image without first de-bayering ("converting to jpeg"), the only solution is to down-sample by a integer factor in each dimension. This means the image size can shrink only by factors of 4,9, 16 etc.

In your case, this means that the largest 12 MP can be scaled down is 3 MP, assuming you do not want to de-bayer in the process.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ It's more complicated than this. The Canon 70D can produce raw files at 5472x3648, 4104x2736, 2736x1824 (source). Those correspond to 20MP and 5MP, which are in the 4:1 ratio you describe but also an intermediate 11MP, which isn't even in the 2:1 ratio that one might expect! \$\endgroup\$ Oct 14, 2014 at 14:03

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.