Page 1 of 1

NEF files have odd colours in after

Posted: 2016-05-19T03:13:18-07:00
by ashishc
Hi All,

I have a raw image .nef file which I am trying to convert in jpg file of particular resolution but after conversion, the color changes from the actual image color. By using photoshop i identified that the image is having Adobe RGB 1998 icc profile but when i am using

identify -verbose <filename>

then no icc profile information is getting displayed.

Command used to convert raw image to jpg format

convert -intent relative -sample "1024x768>" -quality 95 -colorspace sRGB -strip -auto-orient

I tried some other options too but to no avail :

convert -intent relative -sample "1024x768>" -quality 95 -profile AdobeRGB1998.icc -profile sRGB_v4_ICC_preference.icc -auto-orient
convert -intent relative -sample "1024x768>" -quality 95 -profile sRGB_v4_ICC_preference.icc -auto-orient

Re: NEF files have odd colours in after

Posted: 2016-05-19T03:54:33-07:00
by snibgo
Your commands have no input or output files.

What version of IM are you using? On what platform?

Where has your "Actual Image" come from?

If the input to convert is a NEF file, what delegate is doing the work? ("-verbose" will tell you. Please post the entire text output from verbose.)

Re: NEF files have odd colours in after

Posted: 2016-05-19T04:07:56-07:00
by ashishc
1. IM version is 6.8.0
2. Nikon Camera Image

3 . While running the command I had mentioned the file names(both input and output) but I missed to mention here.

Following are the commands with verbose mode.
C:\>convert test.nef -verbose -intent relative -sample "1024x768>" -quality 95 -colorspace sRGB -strip -auto-orient test.jpg
test.nef=>test.jpg NEF 3288x4936=>512x768 512x768+0+0 16-bit sRGB 115KB 0.078u 0:00.034


C:\>imconvert test.nef -verbose -intent relative -sample "1024x768>" -quality 95 -profile AdobeRGB1998.icc -profile sRGB_v4_ICC_preference.icc -auto-orient test.jpg
AdobeRGB1998.icc ICC 1x1 1x1+0+0 16-bit sRGB 560B 0.000u 0:00.000
sRGB_v4_ICC_preference.icc ICC 1x1 1x1+0+0 16-bit sRGB 61KB 0.000u 0:00.001
test.nef=>test.jpg NEF 3288x4936=>512x768 512x768+0+0 16-bit TrueColor sRGB 180KB 0.967u 0:00.572



C:\>imconvert test.nef -verbose -intent relative -sample "1024x768>" -quality 95 -profile sRGB_v4_ICC_preferen
ce.icc -auto-orient test.jpg
sRGB_v4_ICC_preference.icc ICC 1x1 1x1+0+0 16-bit sRGB 61KB 0.000u 0:00.000
test.nef=>test.jpg NEF 3288x4936=>512x768 512x768+0+0 16-bit sRGB 164KB 0.156u 0:00.044

Re: NEF files have odd colours in after

Posted: 2016-05-19T04:33:39-07:00
by Bonzo
From memory NEF files have been a problem in the past; I would searched the forum for any other posts.

Re: NEF files have odd colours in after

Posted: 2016-05-19T04:47:25-07:00
by snibgo
Please put "-verbose" before the input file so we can see what the delegate is doing. Like this:

Code: Select all

f:\web\im>%IM%convert -verbose \pictures\20151226\AGA_2886.nef x.tiff
The text I get is:

Code: Select all

dcraw.exe -6 -w -O "C:/Users/Alan/AppData/Local/Temp/magick-3972bnNx7knQeeSa.ppm
" "C:/Users/Alan/AppData/Local/Temp/magick-39723GdhyBLiPgAB"
C:/Users/Alan/AppData/Local/Temp/magick-3972bnNx7knQeeSa.ppm PPM 4924x7378 4924x
7378+0+0 16-bit sRGB 218MB 0.141u 0:00.140
\pictures\20151226\AGA_2886.nef=>C:/Users/Alan/AppData/Local/Temp/magick-3972bnN
x7knQeeSa.ppm NEF 4924x7378 4924x7378+0+0 16-bit sRGB 218MB 0.016u 0:00.031
\pictures\20151226\AGA_2886.nef=>x.tiff NEF 4924x7378 4924x7378+0+0 16-bit sRGB
218MB 0.219u 0:00.295
This tells me dcraw is the delegate, with options "-6 -w" etc.

Re: NEF files have odd colours in after

Posted: 2016-05-19T07:01:04-07:00
by ashishc
Here is the below output in the required format :

C:\>convert -verbose test.nef -intent relative -sample "1024x768>" -quality 95 -colorspace sRGB -strip -auto-orient test.jpg
dcraw.exe -6 -w -O "C:/Users/test/AppData/Local/Temp/magick-15456aKkQO1WecuTp.ppm" "C:/Users/test/AppData/Local/Temp/magick-15456vdsWs9AMAw2I"
C:/Users/test/AppData/Local/Temp/magick-15456aKkQO1WecuTp.ppm PPM 3288x4936 3288x4936+0+0 16-bit sRGB 97.38MB 0.109u 0:00.104
test.nef=>C:/Users/test/AppData/Local/Temp/magick-15456aKkQO1WecuTp.ppm NEF 3288x4936 3288x4936+0+0 16-bit
sRGB 97.38MB 0.016u 0:00.012
test.nef=>test.jpg NEF 3288x4936=>512x768 512x768+0+0 16-bit sRGB 115KB 0.109u 0:00.036



C:\>convert -verbose test.nef -intent relative -sample "1024x768>" -quality 95 -profile AdobeRGB1998.icc -profile sRGB_v4_ICC_preference.icc -auto-orient test.jpg
dcraw.exe -6 -w -O "C:/Users/test/AppData/Local/Temp/magick-7564ZtJXdQSFlQwl.ppm" "C:/Users/test/AppData/Local/Temp/magick-7564py58uK0wA1g_"
C:/Users/test/AppData/Local/Temp/magick-7564ZtJXdQSFlQwl.ppm PPM 3288x4936 3288x4936+0+0 16-bit sRGB 97.38MB 0.094u 0:00.100
test.nef=>C:/Users/test/AppData/Local/Temp/magick-7564ZtJXdQSFlQwl.ppm NEF 3288x4936 3288x4936+0+0 16-bit sRGB 97.38MB 0.016u 0:00.013
AdobeRGB1998.icc ICC 1x1 1x1+0+0 16-bit sRGB 560B 0.000u 0:00.000
sRGB_v4_ICC_preference.icc ICC 1x1 1x1+0+0 16-bit sRGB 61KB 0.000u 0:00.001
test.nef=>test.jpg NEF 3288x4936=>512x768 512x768+0+0 16-bit TrueColor sRGB 180KB 0.905u 0:00.560



C:\>imconvert -verbose test.nef -intent relative -sample "1024x768>" -quality 95 -profile sRGB_v4_ICC_preference.icc -auto-orient test.jpg
dcraw.exe -6 -w -O "C:/Users/test/AppData/Local/Temp/magick-4748mKGzBt1KLaX4.ppm" "C:/Users/test/AppData/Local/Temp/magick-4748BE1UsfLcjy-M"
C:/Users/test/AppData/Local/Temp/magick-4748mKGzBt1KLaX4.ppm PPM 3288x4936 3288x4936+0+0 16-bit sRGB 97.38MB 0.094u 0:00.100
test.nef=>C:/Users/test/AppData/Local/Temp/magick-4748mKGzBt1KLaX4.ppm NEF 3288x4936 3288x4936+0+0 16-bit sRGB 97.38MB 0.000u 0:00.013
sRGB_v4_ICC_preference.icc ICC 1x1 1x1+0+0 16-bit sRGB 61KB 0.000u 0:00.002
test.nef=>test.jpg NEF 3288x4936=>512x768 512x768+0+0 16-bit sRGB 164KB 0.125u 0:00.041



As per suggestion given at http://www.imagemagick.org/Usage/formats/ I tried removing -6 option in delegate.xml but didn't get the correct output.

Re: NEF files have odd colours in after

Posted: 2016-05-19T07:34:13-07:00
by snibgo
Right, so your installation is like mine, using "dcraw -6 -w" etc. This creates an sRGB output with no embedded profile. So your commands with "-profile" will assign a profile. If that's not an sRGB profile, this is a bad thing to do, as it will change colours.

You haven't answered the question: Where has your "Actual Image" come from? Was it a JPG made by the camera?

Is this an ordinary photo, taken outdoors in daylight? Or was it artificial light? What does the NEF metadata say about the light source?

It seems likely that the "Actual Image" has had a different white balance. So what does the JPG file say about white balance?

You can get this metadata from:

Code: Select all

exiftool file.nef
exiftool file.jpg

Re: NEF files have odd colours in after

Posted: 2016-05-19T21:09:34-07:00
by ashishc
We are getting the image file as end user input, so I don't have much idea on the source of the image.I am also not very sure in what light condition image was captured but exiftool displays light source as unknown.


Below are few of the output information which I have gathered using exiftool for the actual image

Code: Select all

C:\>exiftool test.nef
Bits Per Sample                 : 12
Compression                     : Nikon NEF Compressed
Creator Tool                     : NIKON D4S Ver.1.01
Light Source                     : Unknown
Flash                           : No Flash
Focal Length                    : 165.0 mm
Maker Note Version              : 2.11
Quality                         : RAW
White Balance                   : Auto1
Focus Mode                      : AF-C
Flash Setting                   : Normal
White Balance Fine Tune         : 0 0
WB RB Levels                    : 1.5703125 1.91015625 1 1
Color Space                     : Adobe RGB
Flash Mode                      : Did Not Fire
NEF Compression                 : Lossless
File Source                     : Digital Camera
Scene Type                      : Directly photographed
TIFF-EP Standard ID             : 1 0 0 0
Blue Balance                    : 1.910156
CFA Pattern                     : [Red,Green][Green,Blue]
Image Size                      : 4936x3288
Jpg From Raw                    : (Binary data 1094737 bytes, use -b option to extract)
Red Balance                     : 1.570313
Light Value                     : 9.3
From the converted jpg file, using exiftool, there is no information available about the white balance, except the below information:
  • Media White Point : 0.9642 1 0.82491

Re: NEF files have odd colours in after

Posted: 2016-05-20T06:04:48-07:00
by snibgo
Your "exiftool test.nef" says the camera white balance was set to auto, resulting in RBGG multipliers of "1.5703125 1.91015625 1 1".

The dcraw setting "w" should use those multipliers. If you run the dcraw command with "v" for verbose, it should say it is using those multipliers.

Those values suggest that either the light source was strongly coloured (about 3400 Kelvin), or there was something strange about the photographed subject so the "auto" setting is not the most suitable.

EDIT: I should mention that in-camera automatic and pre-set white balance calculations assume that the light source requires a simple shift towards red or blue, corresponding to daylight or incandescent light bulbs. In fact, a light source may be outside the red/blue spectrum, for example stage lighting may be green or purple or anything else. If we want to correct for that, so the subject appears to be lit by white light, the calculation is a little more complex, for example by picking an area that should be neutral in tone and adjusting for that.

Re: NEF files have odd colours in after

Posted: 2016-05-20T08:21:04-07:00
by ashishc
Thanks a ot for your explanation.
Using dcraw with -v option, I can see that the multipliers are same as expected.

C:\>dcraw -v -6 -w -o test.nef
Loading NIKON D4S image from test.nef ...
Scaling with darkness 0, saturation 4095, and
multipliers 1.570313 1.000000 1.910156 1.000000
AHD interpolation...
Converting to sRGB colorspace...
Writing data to test.ppm ...

But still the jpg image created using convert command is not proper. Am I missing something? Can you please suggest how it can be corrected?

Re: NEF files have odd colours in after

Posted: 2016-05-20T08:32:37-07:00
by snibgo
ashishc wrote:But still the jpg image created using convert command is not proper.
How do you know this? What makes you think it is not correct? What are you comparing the dcraw output to?

Re: NEF files have odd colours in after

Posted: 2016-05-20T10:33:26-07:00
by ashishc
By saying that jpg image created using convert command is not correct, what i meant is that when I am applying convert command to output of dcraw which is .ppm file to get a jpg image or convert cmd directly applied to raw nef file, the output is visually different from actual image when directly opened in photoshop even though RGB multipliers are same. Just trying to understand the difference in visual appearance of image after conversion using convert and before conversion, shouldn't it be same?

Re: NEF files have odd colours in after

Posted: 2016-05-20T10:41:20-07:00
by snibgo
I suppose Photoshop doesn't "directly open" the NEF file. The NEF file has only once channel per pixel, linear grayscale. Photoshop will de-mosaic the image, using some multipliers, and convert to sRGB (just as dcraw does). It may also do further processing. I don't know.

For conversion from NEF files, Photoshop may have options for specifying the multipliers. I don't use Photoshop so can't say.