camera2 pixel values not linear to sensor exposure time

226 views Asked by At

I tried to approximate raw sensor output with camera2 API using YUV_420_888 image format (raw not supported on my Sony XA1). I put everything to manual and deactivated every correction procedure I could find:

            mBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_OFF);
            mBuilder.set(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_OFF);
            mBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_OFF);
            mBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CameraMetadata.CONTROL_AWB_MODE_OFF);
            mBuilder.set(CaptureRequest.TONEMAP_MODE, CameraMetadata.TONEMAP_MODE_CONTRAST_CURVE);
            mBuilder.set(CaptureRequest.TONEMAP_CURVE,
                    new TonemapCurve(
                            new float[]{0.0f,0.0f,1.0f,1.0f},
                            new float[]{0.0f,0.0f,1.0f,1.0f},
                            new float[]{0.0f,0.0f,1.0f,1.0f}
                    ));
            mBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CameraMetadata.COLOR_CORRECTION_MODE_TRANSFORM_MATRIX);
            mBuilder.set(CaptureRequest.COLOR_CORRECTION_TRANSFORM, new ColorSpaceTransform(new int[]{
                    1, 1, 0, 1, 0, 1,
                    0, 1, 1, 1, 0, 1,
                    0, 1, 0, 1, 1, 1
            }));
            mBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, new RggbChannelVector(1.0f,1.0f,1.0f,1.0f));
            mBuilder.set(CaptureRequest.SHADING_MODE, CameraMetadata.SHADING_MODE_OFF);
            mBuilder.set(CaptureRequest.STATISTICS_LENS_SHADING_MAP_MODE, CameraMetadata.STATISTICS_LENS_SHADING_MAP_MODE_OFF);
            mBuilder.set(CaptureRequest.COLOR_CORRECTION_ABERRATION_MODE, CameraMetadata.COLOR_CORRECTION_ABERRATION_MODE_OFF);
            mBuilder.set(CaptureRequest.CONTROL_AE_ANTIBANDING_MODE, CameraMetadata.CONTROL_AE_ANTIBANDING_MODE_OFF);
            mBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, CameraMetadata.CONTROL_EFFECT_MODE_OFF);
            mBuilder.set(CaptureRequest.CONTROL_ENABLE_ZSL, false);
            mBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CameraMetadata.CONTROL_SCENE_MODE_DISABLED);
            mBuilder.set(CaptureRequest.EDGE_MODE, CameraMetadata.EDGE_MODE_OFF);
            mBuilder.set(CaptureRequest.HOT_PIXEL_MODE, CameraMetadata.HOT_PIXEL_MODE_OFF);
            mBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE, CameraMetadata.NOISE_REDUCTION_MODE_OFF);

After that i took a burst of 10 photos with a linear increase in exposure time and an ISO of 40. I analyzed the values of the Y-layer (luma component) and found them to be linear only up to 203 (8-bit full range = 255). The transition at 203 is very sharp, unlike a gamma corrected curve.

Questions: Is this a physical sensor effect ie pixel saturation? Have i forgotten some non-linear correction in the pipeline? Does camera2 API use a full range linear transformation for YUV_420_888?

thanks for any help!

1

There are 1 answers

0
hirnpilot On

Tested different ISO values (100,400) and the non-linearity still persisted. This excludes a physical saturation of the sensor.

But then I tested the RGB values and those are linear. The problematic Y-values >203 transform to outside the RGB [0,255] range. Problem solved, but it takes a lot of time to transform.