CAM_ACTIVE_AREA for SD4000 (RAW/DNG) - General Discussion and Assistance - CHDK Forum supplierdeeply

CAM_ACTIVE_AREA for SD4000 (RAW/DNG)

  • 22 Replies
  • 8346 Views
*

Offline pixeldoc2000

  • ****
  • 356
  • IXUS900Ti 1.00C, IXUS300HS 1.00D
    • pixel::doc homebase
CAM_ACTIVE_AREA for SD4000 (RAW/DNG)
« on: 14 / February / 2011, 18:43:31 »
Advertisements
I tinkered around how to find CAM_ACTIVE_AREA values for my SD4000.

I've startet to capture DNG on camera with following settings:
  • Dark Frame Substraction: off
  • Bad pixel removal: disabled
  • Image size: L (default, not widescreen)

and this code:
Code: [Select]
   #define CAM_RAW_ROWPIX              3816     // ROM:FFB28EEC
    #define CAM_RAW_ROWS                2784     // ROM:FFB28EF4

    // use exiftool -activearea="22 120 2763 3784" to change values till DNG fit
    // or dng4ps2 ([url=http://chdk.setepontos.com/index.php/topic,3410.msg31974.html#msg31974]The SX1 IS Porting Thread[/url])
    #define CAM_ACTIVE_AREA_X1          0
    #define CAM_ACTIVE_AREA_Y1          0
    #define CAM_ACTIVE_AREA_X2          3850     // use value greater than CAM_RAW_ROWPIX
    #define CAM_ACTIVE_AREA_Y2          2850     // use value greater than CAM_RAW_ROWS
We get a DNG where we can see the "full" raw buffer content.

Now edit ACTIVE AREA values in DNG file with exiftool till values fit and DNG shows only "valid" pixel (messure how much pixel to croop with Image Viewer like XnView on Windows).
Code: [Select]
exiftool -activearea="22 120 2763 3784" CRW_0001.DNG
So we end up with something like this:
Code: [Select]
   #define CAM_ACTIVE_AREA_X1          120      // x offset (right)
    #define CAM_ACTIVE_AREA_Y1          22      // y offset (down)
    #define CAM_ACTIVE_AREA_X2          3784
    #define CAM_ACTIVE_AREA_Y2          2763

Final DNG is 3664 x 2741 pixel.

Look attached figure.

Please correct me if i'm wrong or you have any suggestion.
I'm want to put it into wiki too.
« Last Edit: 05 / March / 2011, 14:47:38 by pixeldoc2000 »

*

Offline reyalp

  • ******
  • 13792
Re: CAM_ACTIVE_AREA
« Reply #1 on: 14 / February / 2011, 21:27:10 »
Quote
Now edit ACTIVE AREA values in DNG file with exiftool till values fit and DNG shows only "valid" pixel (messure how much pixel to croop with Photoshop / Gimp).
I used CHDK raw, convert with rawconvert, inspect in imaging program.

On many cameras, it's not clear exactly what the 'active area' should include. There is frequently a border of pixels that still contain image data but are not at the same level as the main image. I tend to include those, but not everyone agrees.
Don't forget what the H stands for.

Re: CAM_ACTIVE_AREA
« Reply #2 on: 15 / February / 2011, 04:47:26 »
not at the same level as the main image.

What does that mean ?

*

Offline na01

  • *
  • 17
Re: CAM_ACTIVE_AREA
« Reply #3 on: 15 / February / 2011, 14:58:35 »
I suppose that he is referring to the dark borders that you can see here
http://dl.dropbox.com/u/20628274/CRW_0426.DNG


*

Offline Lebeau

  • ***
  • 187
Re: CAM_ACTIVE_AREA
« Reply #4 on: 15 / February / 2011, 15:49:31 »
Bonjour Pixeldoc2000,

Your sd4000 has maximum resolution of 3648 x 2736 and your ROM values are 3816 x 2784, therefore you have a non-exposed area equivalent to 168 x 48.

I would give a try to something like the following as your coordinate areas:
 - sensor : (0, 0) ... ( 3816, 2784)
 - active area : (116, 14) ... (3788, 2766)
resulting with a crop (3648 x 2736) positionned at
 - crop area (120, 3784) ... (22, 2763)

Important note: These numbers shall always be even since the sensor use 2x2 CFA sensor :)

Re: CAM_ACTIVE_AREA
« Reply #5 on: 15 / February / 2011, 17:10:42 »
I suppose that he is referring to the dark borders that you can see here


Thanks, he is referring to 'brightness level'.

*

Offline pixeldoc2000

  • ****
  • 356
  • IXUS900Ti 1.00C, IXUS300HS 1.00D
    • pixel::doc homebase
Re: CAM_ACTIVE_AREA
« Reply #6 on: 18 / February / 2011, 16:32:23 »
IDA Disassemble where i found RAW Pixel values for SD4000 1.00D:

In function Getcaptureinfodata it's at the first brache:

Code: [Select]
ROM:FFB28F14 Getcaptureinfodata                      ; DATA XREF: ROM:FFC2B46C
ROM:FFB28F14
ROM:FFB28F14 var_10          = -0x10
ROM:FFB28F14 var_C           = -0xC
ROM:FFB28F14
ROM:FFB28F14                 STMFD   SP!, {R0-R4,LR}
ROM:FFB28F18                 LDR     R0, [R0]
ROM:FFB28F1C                 MOV     R1, SP
ROM:FFB28F20                 ADR     R3, aShd_capture_info ; "SHD_CAPTURE_INFO"
ROM:FFB28F24                 BL      sub_FFB28EAC        ; <--------------------------------
ROM:FFB28F28                 TST     R0, #1
ROM:FFB28F2C                 BNE     loc_FFB28F68
ROM:FFB28F30                 MOV     R2, #0x10
ROM:FFB28F34                 MOV     R1, SP
ROM:FFB28F38                 MOV     R0, R3
ROM:FFB28F3C                 BL      sub_FF8679E8
ROM:FFB28F40                 TST     R0, #1
ROM:FFB28F44                 BNE     loc_FFB28F68
ROM:FFB28F48                 LDMFD   SP, {R1,R2}
ROM:FFB28F4C                 ADR     R0, aCapturesize04l ; "CaptureSize    : ( %04ld, %04ld )\r"
ROM:FFB28F50                 BL      sub_FF93CE94
ROM:FFB28F54                 LDR     R1, [SP,#8]
ROM:FFB28F58                 LDR     R2, [SP,#0xC]
ROM:FFB28F5C                 ADR     R0, aAngeloutputsiz ; "AngelOutputSize : ( %04ld, %04ld )\r"
ROM:FFB28F60                 BL      sub_FF93CE94
ROM:FFB28F64                 MOV     R0, #0
ROM:FFB28F68
ROM:FFB28F68 loc_FFB28F68                            ; CODE XREF: Getcaptureinfodata
ROM:FFB28F68                                         ; Getcaptureinfodata
ROM:FFB28F68                 ADD     SP, SP, #0x10
ROM:FFB28F6C                 LDMFD   SP!, {R4,PC}

Code: [Select]
ROM:FFB28EAC sub_FFB28EAC                            ; CODE XREF: Getcaptureinfodata
ROM:FFB28EAC                 CMP     R1, #0
ROM:FFB28EB0                 MOVEQ   R0, #0x11
ROM:FFB28EB4                 BXEQ    LR
ROM:FFB28EB8                 CMP     R0, #0
ROM:FFB28EBC                 BEQ     loc_FFB28EEC
ROM:FFB28EC0                 CMP     R0, #1
ROM:FFB28EC4                 MOVNE   R0, #3
ROM:FFB28EC8                 BXNE    LR
ROM:FFB28ECC                 MOV     R0, #1904
ROM:FFB28ED0                 STR     R0, [R1]
ROM:FFB28ED4                 LDR     R0, =1390
ROM:FFB28ED8                 STR     R0, [R1,#4]
ROM:FFB28EDC                 MOV     R0, #1824
ROM:FFB28EE0                 STR     R0, [R1,#8]
ROM:FFB28EE4                 SUB     R0, R0, #0x1C8
ROM:FFB28EE8                 B       loc_FFB28F08
ROM:FFB28EEC ; ---------------------------------------------------------------------------
ROM:FFB28EEC
ROM:FFB28EEC loc_FFB28EEC                            ; CODE XREF: sub_FFB28EAC
ROM:FFB28EEC                 LDR     R0, =3816       ; RAW H Pixel
ROM:FFB28EF0                 STR     R0, [R1]
ROM:FFB28EF4                 MOV     R0, #2784       ; RAW V Pixel
ROM:FFB28EF8                 STR     R0, [R1,#4]
ROM:FFB28EFC                 MOV     R0, #3648       ; JPEG H Pixel
ROM:FFB28F00                 STR     R0, [R1,#8]
ROM:FFB28F04                 MOV     R0, #2736       ; JPEG V Pixel
ROM:FFB28F08
ROM:FFB28F08 loc_FFB28F08                            ; CODE XREF: sub_FFB28EAC
ROM:FFB28F08                 STR     R0, [R1,#0xC]
ROM:FFB28F0C                 MOV     R0, #0
ROM:FFB28F10                 BX      LR

Reference to Getcaptureinfodata function:
Code: [Select]
ROM:FFC2B464                 DCD GetUnpackCrwIntegralMultiValueForShadin ; StartRedirectUART
ROM:FFC2B468                 DCD aGetcaptureinfodata ; "GetCaptureInfoData"
ROM:FFC2B46C                 DCD Getcaptureinfodata      ; <----------------- Points to function
ROM:FFC2B470                 DCD aReloaddefectadjustmentdata ; "ReloadDefectAdjustmentData"
ROM:FFC2B474                 DCD Reloaddefectadjustmentdata
ROM:FFC2B478                 DCD aReloadshadingadjustmentdata ; "ReloadShadingAdjustmentData"
« Last Edit: 18 / February / 2011, 17:54:48 by pixeldoc2000 »

*

Offline pixeldoc2000

  • ****
  • 356
  • IXUS900Ti 1.00C, IXUS300HS 1.00D
    • pixel::doc homebase
Re: CAM_ACTIVE_AREA
« Reply #7 on: 18 / February / 2011, 16:36:59 »
Your sd4000 has maximum resolution of 3648 x 2736 and your ROM values are 3816 x 2784, therefore you have a non-exposed area equivalent to 168 x 48.

I would give a try to something like the following as your coordinate areas:
 - sensor : (0, 0) ... ( 3816, 2784)
 - active area : (116, 14) ... (3788, 2766)
resulting with a crop (3648 x 2736) positionned at
 - crop area (120, 3784) ... (22, 2763)
This value don't crope/hide the "dark frame".

Important note: These numbers shall always be even since the sensor use 2x2 CFA sensor
I understand why to use even numbers, but please explain what exacly you mean with "2x2 CFA".

Any comment about chdk_cam_active_area_v1.png ?
« Last Edit: 18 / February / 2011, 20:22:01 by pixeldoc2000 »


*

Offline pixeldoc2000

  • ****
  • 356
  • IXUS900Ti 1.00C, IXUS300HS 1.00D
    • pixel::doc homebase
Re: CAM_ACTIVE_AREA
« Reply #8 on: 18 / February / 2011, 17:40:08 »
This how SD4000 DNG looks like with (too large) test values:

Code: [Select]
   #define CAM_ACTIVE_AREA_X1          0
    #define CAM_ACTIVE_AREA_Y1          0
    #define CAM_ACTIVE_AREA_X2          3850     // use value greater than CAM_RAW_ROWPIX
    #define CAM_ACTIVE_AREA_Y2          2850     // use value greater than CAM_RAW_ROWS

The green border mark the actual "good" pixel without the darker pixel (Dark Frame) around the "active" area.
AFAIK badpixel generation also use CAM_ACTIVE_AREA.
« Last Edit: 18 / February / 2011, 17:48:07 by pixeldoc2000 »

*

Offline pixeldoc2000

  • ****
  • 356
  • IXUS900Ti 1.00C, IXUS300HS 1.00D
    • pixel::doc homebase
Re: CAM_ACTIVE_AREA
« Reply #9 on: 18 / February / 2011, 17:51:07 »
On many cameras, it's not clear exactly what the 'active area' should include. There is frequently a border of pixels that still contain image data but are not at the same level as the main image. I tend to include those, but not everyone agrees.
I would tend to crop away dark frame in dng like sd4000_cam_active_area_v1.jpg . Looks like SD4000 RAW always have Dark Frame.
« Last Edit: 18 / February / 2011, 17:55:50 by pixeldoc2000 »

 

Related Topics