Some further insights into the new picamera2/libcamera-approach. The guys developing this do all kinds of fancy stuff - which might be nice for the average user, but troublesome for our purposes. However, as the new approach is more open-minded, you have more influence about the outcome of the whole process.
Let me give you an example. The new libcamera-stack includes something which is called (alsc). This is the short for “Automatic Lens Shading Correction”. These algorithms can be user-tuned with an own tuning file, but by default a tuning file is used which is shipped with the libcamera installation for various sensors.
Now, lens shading is usually used to compensate for deficiancies with a certain lens/sensor combination. Most interestingly, the tuning file for the HQ camera, which is not delivered with specific lens, includes a alsc-section as well! I have no idea what lens was used here during calibration, but certainly it is not the lens I am using in my scanner setup.
Any indeed, if I look closely at a capture of the empty film gate (I have reduced the q-parameter of the image to utilize banding to show better the issue),
you see that the image center is darker than the image egdes. Also noticable is an annoying pink cast, especially in the right image corners.
Continuing our little experiment, I disabled the alsc in the tuning file - which is simple enough, you only need to change the original rpi.alsc
on line 207 of the original tuning file to x.rpi.alsc
, like shown in the following screen shot:
After this little surgery I get a much improved flat response:
EDIT (28/06/22): originally, I gave below an example that the colors of an image changed drastically when switching off the ALSC. I am not so sure any longer that this was the real reason. It seems that the new libcamera-stack behaves somewhat arbitrary when you set the red and blue gains - the AWB-algorithm than spits out a somewhat arbitrary color temperature which is in turn used for selecting the ccm-matrices which take you from camera RGB to sRGB. This might be the main effect for the change in color appearance reported below.
I’ll leave the original post below, just in italics.
The bad thing about this is that the color boost observed between the old picamera/Broadcom combination and the picamera2/libcamera compo is gone as well. Here’s a quick example of a scan with the alsc
and one with the alsc turned off:
That looks very similar to results obtained with the old picamera/Broadcom combo. So it seems that the adaptive lens shading is doing more than lens shading correction only. Oh well…
Clearly, it would be perfect if one could come up with an optimized tuning file for film scanning. Theoretically, one could do such a calibration; there is tuning software available. However, this tuning software requires you to take a series of images, flat and with specific color-checkers imaged. At the moment, I have no idea how to do this (specifically: getting the color-checker into the small Super-8 frame for imaging). Any ideas are welcome!