Author Topic: Image Dimensions of Nikon RAW (NEF) Files Changed on Load  (Read 1698 times)

Offline dcarr

  • Newcomer
  • Posts: 20
PixInsight appears to change the dimensions of images opened from Nikon RAW (.NEF) files. The native resolution of my Nikon D750 camera is 6016 x 4016 pixels, but when opened by Pixinsight, the dimensions are changed to 6032 x 4032 pixels. 

On load, the PixInsight output includes the following:

Camera ........... Nikon D750
Timestamp ........ xxxxx
Exposure ......... 20s
ISO speed ........ 1600
Focal length ..... 14 mm
Aperture ......... f/2.8 = 5 mm
CFA pattern ...... Bayer RGGB
Raw dimensions ... w=6032 h=4032

However, the correct RAW dimensions should be 6016 x 4016 pixels. If I use Nikon’s ‘Capture NX-D’ software to output a TIF file, PixInsight will indeed open the image with the original RAW dimensions of 6016 x 4016 pixels.

For my current project, I would prefer to work with the original geometry if/where possible.

The NEF files opened by PixInsight appear to display a padding of (at least) 3 pixels on all edges. I can crop the edge padding (after image calibration of course), but I wish to check whether the padding is a necessary implementation before I do so.

Also, cropping 6 (=2x3) pixels per dimension would only account for 6 of the 16 extra pixels.  Should I crop or resample to regain the original image size.

Or is there a better approach.

Any advice would be appreciated.

Regards
Dean

Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
Re: Image Dimensions of Nikon RAW (NEF) Files Changed on Load
« Reply #1 on: 2019 August 02 17:32:43 »
For my Canon EOS 600D, the Process Console shows more important information, namely:

------------------------
-> Image geometry

Raw decoding parameters:
-> Output mode
-> Auto crop
  .
  .
  .
-> Output image
------------------------

What values / settings are displayed for the marked categories when opening a NEF file of your Nikon D750?


Bernd

Offline dcarr

  • Newcomer
  • Posts: 20
Re: Image Dimensions of Nikon RAW (NEF) Files Changed on Load
« Reply #2 on: 2019 August 02 18:45:54 »
Hi Bernd,

Thanks for the early response.

The full output from the Process Console is pasted below.

Cheers
Dean

Reading metadata: done

Camera ........... Nikon D750
Timestamp ........ 2019-06-12T07:50:52Z
Exposure ......... 20s
ISO speed ........ 1600
Focal length ..... 14 mm
Aperture ......... f/2.8 = 5 mm
CFA pattern ...... Bayer RGGB
Raw dimensions ... w=6032 h=4032
Image geometry ... x=0 y=0 w=6032 h=4032

Raw decoding parameters:
Output mode ............... cfa
Auto crop ................. enabled
Wavelet noise threshold ... 0
White balancing ........... disabled
Black point correction .... disabled
Highlights clipping ....... disabled
Auto rotate ............... disabled
Output image .............. w=6032 h=4032 n=1 Gray

Reading RAW data: done
« Last Edit: 2019 August 02 19:11:57 by dcarr »

Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
Re: Image Dimensions of Nikon RAW (NEF) Files Changed on Load
« Reply #3 on: 2019 August 03 01:58:40 »
This is indeed strange. In most (all?) DSLR cameras the sensor contains some optically black pixels at the edge, usually above and left of the actual image region. For my Canon 600D:

-------------------------------------------------
Raw dimensions ... w=5344 h=3516
Image geometry ... x=142 y=51 w=5202 h=3465

Raw decoding parameters:
Output mode ............... cfa
Auto crop ................. enabled
   .
   .
   .
Output image .............. w=5202 h=3465 n=1 Gray
-------------------------------------------------

The coordinates of the upper left corner of the actual image is specified in 'Image geometry' as x and y. If Auto crop is enabled, the region of the optically black will be cropped at the left by x and at the top by y, and
w(output) = w(raw) - x
h(output) = h(raw) - y

The above Process Console outputs stem from LibRaw which is used by PixInsight for camera raw format decoding. Obviously x and y are missing in case of the D750, and no cropping is performed. So this seems to be a flaw in the current LibRaw version, maybe this is corrected in the next LibRaw version (0.19.3).

In no case the correction can be done with Resample. Did you notice a black horizontal strip at the top and a black vertical strip at the left margin of the light frames? If this is the case, crop 16 pixels at the left and 16 pixels at the top of ALL of your images in PixInsight. This can be done with an ImageContainer and the Crop process. Note that it is crucial to use even values for both parameters in this procedure. Otherwise you will jumble the bayer/CFA pattern of the raw data.

Bernd

Offline dave_galera

  • PixInsight Addict
  • ***
  • Posts: 261
    • QDigital Astro
Re: Image Dimensions of Nikon RAW (NEF) Files Changed on Load
« Reply #4 on: 2019 August 03 02:18:30 »
The sensor resolution is actually 6038 x 4025 according to the specification
Dave

Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
Re: Image Dimensions of Nikon RAW (NEF) Files Changed on Load
« Reply #5 on: 2019 August 03 02:55:51 »
I downloaded a NEF file of a Nikon D750 from www.photographyblog.com/reviews/nikon_d750_review/sample_images . The Process Console output was as you specified. It made no difference whether 'No image crop' was unchecked (which is the default) or checked.

When opening the file in PixInsight, no black strips were detectable. This means that you don't have to crop your images at all. Important: capture all images (lights and calibration frames) in Nikon raw format (NEF) and do the complete preprocessing in one software, preferably PixInsight. No problems are to be expected then.

@dave_galera:
> The sensor resolution is actually 6038 x 4025 according to the specification
A height of 4025 pixels is certainly not correct. Where do the extra pixels (I see 4032) come from if not from the sensor?


Bernd

Offline dave_galera

  • PixInsight Addict
  • ***
  • Posts: 261
    • QDigital Astro
Re: Image Dimensions of Nikon RAW (NEF) Files Changed on Load
« Reply #6 on: 2019 August 03 03:37:32 »
Bernd,

Good question....the spec just says Max Image Resolution 6016 x 4016, Sensor resolution 6038 x 4025, but of course you never know what the software in the camera does with the actual raw data, because the NEF Raw format is not raw data in real terms, the camera software has messed about with the data to produce the NEF formatted file including compressing it.
Dave

Offline dcarr

  • Newcomer
  • Posts: 20
Re: Image Dimensions of Nikon RAW (NEF) Files Changed on Load
« Reply #7 on: 2019 August 03 19:13:11 »
Thanks Bernd and Dave.

Thanks for taking a look at this.

I see no black borders or black stripes; but there does appear to be a form of padding (or at least invalid data) on all four edges. On the of debayered images, there are small (3 pixel) vertical stripes at the top and bottom, and horizontal stripes at the left and right edges. Pixels in a stripe have the same RGB values.  See the extremely small previews attached, with exaggerated saturation to show the effect.

The offending pixels can be easily cropped.  As a minimum, I would need to crop at least three pixels from each edge. This is somewhat mute, because I often crop more than this after ImageIntegration to remove ragged edges before applying DBE etc.
 
Not sure about the extra 10 pixels in each axis. So, I can crop the extra pixels from each edge, or put my head in the sand, leave alone and be happy I’ve gained a few extra columns/rows 😊

Cheers
Dean

Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
Re: Image Dimensions of Nikon RAW (NEF) Files Changed on Load
« Reply #8 on: 2019 August 04 01:35:06 »
Dean,

preprocessing is done on the raw (CFA) data. My suggestion is not to crop before preprocessing. If you still decide to crop the raw data, you have to use EVEN values in the Crop process in order not to jumble the bayer/CFA pattern. However, the better point in the workflow for cropping is after integration of the calibrated, debayered, registered images.

Bernd