2

I use rawpy module in python to post-process raw images, however, no matter how I set the Params, the output is different from the default RGB in camera ISP, so anyone know how to operate on this please?

I have tried the following ways:

Default:

output = raw.postprocess()

Use Camera White balance:

output = raw.postprocess(use_camera_wb=True)

No auto bright:

output = raw.postprocess(use_camera_wb=True, no_auto_bright=True)

None of these could recover the RGB image as the camera ISP output.

Warcupine
  • 4,460
  • 3
  • 15
  • 24
rainyfly
  • 21
  • 2
  • What type of raw file do you have -- Canon, Nikon, Sony, DNG? Some vendors have better detail in their raw files than others, and some raw formats have been reverse-engineered better than others. – Tomi Aarnio Oct 22 '19 at 07:32

1 Answers1

0

The dcraw/libraw/rawpy stack is based on publicly available (reverse-engineered) documentation of the various raw formats, i.e., it's not using any proprietary libraries provided by the camera vendors. As such, it can only make an educated guess at what the original camera ISP would do with any given image. Even if you have a supposedly vendor-neutral DNG file, chances are the camera is not exporting everything there in full detail.

So, in general, you won't be able to get the same output.

Tomi Aarnio
  • 2,446
  • 1
  • 19
  • 14
  • Oh, I got it. Thanks. The raw file is with '.ARW' ext, by Sony. The amazing thing I found is that the JPG output by Camera ISP is not aligned with the RAW counterpart, with the effect like zooming out. I really got confused by the Camera ISP, the output using rawpy is just the demosaicing version, so it's aligned with the raw image, but the camara ISP may do something like zooming after demosaicing. – rainyfly Oct 23 '19 at 08:21
  • Sensors typically have a few "optical black" rows or columns at one of the edges that are physically blocked to eliminate all incoming light. The ISP uses those to estimate black level and noise. A few additional scanlines may contain metadata such as sensor parameters. Some vendors strip off the extra rows & columns from the ARW/CR2/NEF/DNG, others don't. – Tomi Aarnio Oct 23 '19 at 11:56
  • Really, even Adobe Lightroom using the "Camera Matching" preset doesn't come much close to the camera JPEGs from the ARW files. What you can do though, if you're adventurous, is to build a deep learning-based surrogate model trained on lots of raw-jpeg pairs. It should be relatively easy if you feed aligned images to the model (which can be done with dcraw). – ansgri Feb 11 '21 at 22:14