Cropping the sensor for DNG saving - page 3 - Feature Requests - CHDK Forum
supplierdeeply

Cropping the sensor for DNG saving

  • 26 Replies
  • 12323 Views
*

Offline reyalp

  • ******
  • 14118
Re: Cropping the sensor for DNG saving
« Reply #20 on: 15 / June / 2014, 20:42:55 »
Advertisements
Is there any reason not to leave the default crop to the sensor useful data though? I can see this being a small problem at the wide angle, where there are some dark corners, but at full zoom it looks pretty ok.
Most raw programs should let you use the active area if you want.  That should contain all the valid pixels, but might have some borders with different exposure.

What the default crop should be isn't really clear, the jpeg area was just picked because it is convenient and should generally only contain normal image data. The spec says

"Raw images often store extra pixels around the edges of the final image. These extra pixels help prevent interpolation artifacts near the edges of the final image. DefaultCropOrigin specifies the origin of the final image area..."


Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Cropping the sensor for DNG saving
« Reply #21 on: 15 / June / 2014, 21:00:32 »
Is there any reason not to leave the default crop to the sensor useful data though? I can see this being a small problem at the wide angle, where there are some dark corners, but at full zoom it looks pretty ok.
Most raw programs should let you use the active area if you want.  That should contain all the valid pixels, but might have some borders with different exposure.

What the default crop should be isn't really clear, the jpeg area was just picked because it is convenient and should generally only contain normal image data. The spec says

"Raw images often store extra pixels around the edges of the final image. These extra pixels help prevent interpolation artifacts near the edges of the final image. DefaultCropOrigin specifies the origin of the final image area..."

How about a config setting to control the crop size in the DNG file?
Options could be:
- JPEG crop (default)
- Active Area
- Full sensor

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline reyalp

  • ******
  • 14118
Re: Cropping the sensor for DNG saving
« Reply #22 on: 15 / June / 2014, 21:15:31 »
How about a config setting to control the crop size in the DNG file?
Options could be:
- JPEG crop (default)
- Active Area
- Full sensor
We could, not sure if it's worth it. If it is, maybe we should let you go the whole hog and specify the rectangle yourself.

For "Full sensor" we would have to change the active area too, because crop > active is invalid. I'm not sure how much use this would have. Anyone who wanted to analyze the masked pixels would probably just want to extract the data.

As I noted in http://chdk.setepontos.com/index.php?topic=8085.msg113463#msg113463 using the jpeg pixel size doesn't really give you the same scene as the jpeg either.
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Cropping the sensor for DNG saving
« Reply #23 on: 15 / June / 2014, 22:34:39 »
How about a config setting to control the crop size in the DNG file?
Options could be:
- JPEG crop (default)
- Active Area
- Full sensor
We could, not sure if it's worth it. If it is, maybe we should let you go the whole hog and specify the rectangle yourself.

For "Full sensor" we would have to change the active area too, because crop > active is invalid. I'm not sure how much use this would have. Anyone who wanted to analyze the masked pixels would probably just want to extract the data.

The three options would be a fairly simple change, and we could ensure the resulting DNG was valid. You can use exiftool to modify the values; but as you said, you have to ensure you modify both crop and active area in some cases.

Allowing the full sensor to be easily visible in any editor might let people help define the correct active area without having to upload DNG files.

Not sure I see a use case for setting an arbitrary crop though; but open to ideas.

Quote
As I noted in http://chdk.setepontos.com/index.php?topic=8085.msg113463#msg113463 using the jpeg pixel size doesn't really give you the same scene as the jpeg either.

I haven't come across any cases where our DNG crop (centered in the active area) is significantly different to the camera JPEG (other than distortion correction).

Do you have any examples? It might just be a matter of adjusting the active area slightly.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


*

Offline reyalp

  • ******
  • 14118
Re: Cropping the sensor for DNG saving
« Reply #24 on: 16 / June / 2014, 01:20:14 »
Allowing the full sensor to be easily visible in any editor might let people help define the correct active area without having to upload DNG files.
I suppose that could help, but explaining what to do and how to measure might be more complicated than just getting the dng. If they are actually working on the port, they can just set it in code.
Quote
Not sure I see a use case for setting an arbitrary crop though; but open to ideas.
The active area often contains some questionable border pixels. So if you want all the pixels that are "normal" levels, it's probably somewhere between the default crop and the full active area.
Quote
I haven't come across any cases where our DNG crop (centered in the active area) is significantly different to the camera JPEG (other than distortion correction).

Do you have any examples? It might just be a matter of adjusting the active area slightly.
I don't have specific example in mind, the point was that it easily could be off, since we just put it in the center with no regard to what the camera does.

The distortion correction makes this pretty irrelevant in many cases though, e.g. elph130
camera jpeg: https://app.box.com/s/dwlbfqiyjcb72kwv4jwi
default crop: https://app.box.com/s/ceqpq4o01mbcsr9onfyv
 :haha

Don't forget what the H stands for.

*

Offline RaduP

  • *****
  • 926
Re: Cropping the sensor for DNG saving
« Reply #25 on: 17 / June / 2014, 10:00:33 »
Great, I tested it and it works, and both UFRaw and Raw Therapee show the whole usable area, sans the bad borders.

IMHO, I think the default crop should be the usable area, not the JPG size. It also helps if one is doing his own lens distortion correction, since that will shrink the picture anyway, so any extra pixels will help.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Cropping the sensor for DNG saving
« Reply #26 on: 18 / June / 2014, 09:18:34 »
I haven't come across any cases where our DNG crop (centered in the active area) is significantly different to the camera JPEG (other than distortion correction).

Do you have any examples? It might just be a matter of adjusting the active area slightly.
I don't have specific example in mind, the point was that it easily could be off, since we just put it in the center with no regard to what the camera does.

Took a closer look at this.

On the G12 and G1X if I reset the crop to the camera JPEG size, then the DNG files are off by two pixels horizontally.
For the G12 our origin X = 18, camera = 20.
For the G1X our origin X = 26, camera = 28.

In both cases the camera value is a multiple of 4, while ours is not.

On the SX40 & IXUS310, our DNG's match the camera JPEG - in both cases our calculated X origin is a multiple of 4.

Not sure if the X origin being a multiple of 4 is just coincidence, or a general rule.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal