Confusion about obtaining linear RGB images. #1334
-
|
Hi, im working on a color analysis project using Picamera2, and im trying to capture and work with linear RGB images. I read in the documentation that:
Im currently using create_still_configuration() and camera.capture_array() to capture still images, and with this i think i understand that im obtaining sRGB photos. If this is the case, how would you recommend to me to convert them to linearized RGB? Is there a configuration, maybe, to take RGB photos from the start? Sorry, i think im going in circles and that this question have been solved multiple times already, but im recently learning color science fundamentals and when it combines with cameras configurations it can get tricky, for me at least. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Hi, thanks for the question. Just to understand, are you wanting RGB images without any transfer function applied (therefore linear pixel data), or RGB images with the standard sRGB transfer function? In the latter case (RGB with the standard sRGB transfer function), just change the output format that you ask for to In the former case (genuinely linear values), it would probably be best to edit the camera tuning file. You would need to look for the Note that 8-bit output is often a bit narrow for linear pixel data, as you'll find banding might appear if you apply a transfer function later. On a Pi 5 you can get 16-bit outputs, although folks who want to work with linear pixel values often prefer to start with the raw image direct from the sensor. Please do post back with more information on the Pi, camera mode and use case if you would like more advice. |
Beta Was this translation helpful? Give feedback.
-
|
Tuning files will be in Tip: before changing the tuning file, just type some garbage characters at the very top and check that the camera system doesn't start. This proves you've got the right tuning file and can save significant amounts of head-scratching later! As I said previously, 8 bit output may not be very good with linear data, but you'll have to judge what works for your application. But do note that there's lots of other processing that happens to the output image - lens shading, colour correction, white balance, colour matrices, denoising etc. which is why I mention that folks making more "scientific" measurements often use the raw image from the sensor. |
Beta Was this translation helpful? Give feedback.
Tuning files will be in
/usr/share/libcamera/ipa/rpi/pisp(Pi 5) or/usr/share/libcamera/ipa/rpi/vc4(earlier Pis). You need to locate the file for your sensor (e.g.imx708.jsonfor the regular Camera Module 3, orimx477.jsonfor the HQ camera). If you've built libcamera from source, they'll be in/usr/local/share/.... What camera do you have?Tip: before changing the tuning file, just type some garbage characters at the very top and check that the camera system doesn't start. This proves you've got the right tuning file and can save significant amounts of head-scratching later!
As I said previously, 8 bit output may not be very good with linear data, but you'll have to judge what works f…