Alan_Hook
Posts: 1
Joined: Sat Nov 30, 2019 8:04 am

Cfx Colour Fix

Sun Dec 01, 2019 8:40 am

I am working with the Stereo Pi Board, and I am trying to build a project which filters colour. I want to create a video feed which can see all colours BUT red hue. When I’ve built this in other systems (unity etc) I use a LUT jpeg to shift the colour spectrum.

I’m new to using Raspberry Pi, but it looks like the -cfx could set a range. The only real information on -cfx I can find is setting to 128:128 for B&W and 100:150 for sepia. I am presuming that the first value is the U of YUV and the second value is the V.

I think, I want to cut diagonally across the U:V colour space keeping a yellow-blue range.

On first testing all I can get is a monochromic colour overlay.

Where can I find more information on how -cfx effects colour? I want to understand how it effects the YUV.

Is there a simpler way to approach this, maybe using a custom white balance, dropping the red/magenta in a tint?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7527
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Cfx Colour Fix

Mon Dec 02, 2019 9:51 am

Yes, -cfx just sets the U & V to the specified values - it's a pure memset (although as part of the image processing, not a separate operation).

AWB would normally meter against each channel, whilst manual AWB drops all control onto the user. If you have a controlled scene then you could set manual wb gains as red=0, blue=something sensible, and you would probably get the response you're expecting. The colour conversions may mess with that later in the processing though. "-awb=off -awbg=0.0,1.8" or around there. Run with -set first and it'll print out the red and blue gains that AWB has chosen.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
Realizator
Posts: 33
Joined: Thu Jul 14, 2016 12:53 pm
Contact: Website Twitter

Re: Cfx Colour Fix

Tue Dec 03, 2019 8:23 am

6by9 wrote:
Mon Dec 02, 2019 9:51 am
Yes, -cfx just sets the U & V to the specified values - it's a pure memset (although as part of the image processing, not a separate operation).
If it is possible to set not exact values (like 128:128), but a range (like 0-255:0-128)?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7527
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Cfx Colour Fix

Tue Dec 03, 2019 10:06 am

Realizator wrote:
Tue Dec 03, 2019 8:23 am
If it is possible to set not exact values (like 128:128), but a range (like 0-255:0-128)?
That would be a mathematical scaling, not a memset.
The only functionality exposed is setting a fixed value for each of U & V.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
Realizator
Posts: 33
Joined: Thu Jul 14, 2016 12:53 pm
Contact: Website Twitter

Re: Cfx Colour Fix

Tue Dec 03, 2019 11:09 am

6by9 thank you for your U and V settings clarification!

I tried to play with AWB settings, and looks like it is a right way.
Am I right understand, that GREEN component suggested to 1.0 all the time? Or it can vary according to light conditions?

Here are my results on playing with WB settings:

Auto white balance (raspistill -o awb-auto.jpg)
Image

White balance 1.0,1.0 (raspistill -awb off -awbg 1.0,1.0 -o wb-manual-1_0-1_0.jpg)
Image

White balance 0.1,1.0 (raspistill -awb off -awbg 0.1,1.0 -o wb_manual-0_1-1_0.jpg)

Image

On the last image RED component is unnoticeable, but we can see blue elements on the photo. If I try to set values lower 0.1 for Red, I get a dark image.
Also I found that both numbers are limited by 8.0, and if you set a bigger value you get "Invalid command line option (-awbg)" message.

Alan_Hook, is this approach works for your experiment?
Last edited by Realizator on Tue Dec 03, 2019 4:02 pm, edited 1 time in total.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7527
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Cfx Colour Fix

Tue Dec 03, 2019 11:41 am

Yes green is always at x1.0.
The three colour channels don't have the same sensitivities, hence the variation.
Processing does change between several colourspaces, so there are conversion matrices which a full AWB algorithm will also vary.

It seems to work for me with red at x0.05, but yes below that it results start going weird. AE has no knowledge that red is going to be dropped, so it's expecting the contribution from it in the output frame. AWB taking that out is likely to be giving odd results.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”