Page 1 of 1

Converting NEF to JPEG2000

Posted: 2015-07-08T15:25:34-07:00
by victorfco
I am trying to make lossless conversion of NEF (from a Nikon D800) to JPEG2000 using the ImageMagick-6.9.1-Q16.
The conversion happens. However, I see some contrast difference between the original (NEF) and the output (JP2). Also, the file size increases from 39MB (original) to 142MB (jp2). Is there any kind of "post-processing" happening too?

Converting JPG images to JPG2000 I did not have this issue. The images visually look the same and their file size are 13MB (jpg) and 27MB (jp2).

My goal is keep the images size less than 30~35MB.

The script used is:

Code: Select all

convert input.nef -define jp2:numrlvls=7 -define jp2:tilewidth=256 -define jp2:tileheight=256 -define jp2:mode=int -define jp2:rate=100 -define jp2:lazy -define jp2:prg=rlcp -define jp2:quality=100 output.jp2
And I got it from this website:
ftp://ftp.tuwien.ac.at/graphics/ImageMa ... w/jp2.html


The links for the pictures:
NEF (original) https://www.dropbox.com/s/10r7s8s036z2i ... a.NEF?dl=0
JPG (original) https://www.dropbox.com/s/wi10yphzqy88n ... a.JPG?dl=0
NEF.jp2 https://www.dropbox.com/s/pkqr5lyat4vrn ... 2.jp2?dl=0
JPG.jp2 https://www.dropbox.com/s/l3j3rlpe5f160 ... 2.jp2?dl=0

Re: Converting NEF to JPEG2000

Posted: 2015-07-08T16:32:34-07:00
by snibgo
victorfco wrote:I see some contrast difference between the original (NEF) and the output (JP2).
No, you are not looking at the NEF. You are looking at the NEF converted to a JPG or something else, and the NEF converted to a JP2.
victorfco wrote:Is there any kind of "post-processing" happening too?
A NEF file is linear encoded with a Bayer filter, one channel per pixel, compressed (possibly lossy compressed). Processing includes converting it to three channels per pixel. This roughly triples the size.

If the conversion to JPG was done by Nikon software, it is proprietary. It does various processing to make the picture "look better".

I know nothing about jp2 compression. Have you tried adjusting the "-quality" setting to reduce the size?

Re: Converting NEF to JPEG2000

Posted: 2015-07-09T10:17:47-07:00
by victorfco
All the original images I got directly from the camera, setting it to save the pictures in NEF and JPG for each image.
That is why I did not understand when you said:
No, you are not looking at the NEF. You are looking at the NEF converted to a JPG or something else, and the NEF converted to a JP2.
Here is a screenshot when I open the original NEF (left) and the NEF converted to JP2 (right):

https://www.dropbox.com/s/bggz3bpykbnsm ... t.jpg?dl=0

About the quality value, I did play with it. Using JPEG as input, I got a file size around 9MB and no visually quality loss, which is great. However, comparing the input and output using MSE metric I had a big difference. I am not sure if this metric shows loss of quality or only differences found comparing pixels.

Re: Converting NEF to JPEG2000

Posted: 2015-07-10T06:04:22-07:00
by snibgo
The Nikon D800 camera, like other good cameras, has the option of dumping the un-processed sensor data in a "camera raw" file, called a NEF file. Like all digital cameras, it can also process this data into a JPG file. The processing for the JPG isn't a simple de-Bayer (aka "demosaicing") and conversion to sRGB.

Nikon, Canon, Olympus etc compete with each other to make the "best" cameras. So they don't publish the algorithms used in the conversion to JPG.
victorfco wrote:Here is a screenshot when I open the original NEF (left) and the NEF converted to JP2 (right):
The image on the left isn't "the original NEF". It is the NEF de-Bayered, and converted to sRGB, possibly with other processing.

You may be interested in my web pages on "Demosaicing", "[Adaptive] Contrast-limited equalisation", "Adaptive auto level and gamma" and others.

For comparing photos, I generally use the RMSE metric. Like all metrics, this is an arithmetical comparison. I find that if two versions of a photo have an RMSE less than 0.01 (ie 1%), and this is evenly distributed across the image, I can't see the difference between them.