Log in

View Full Version : newbie needs a AWB script for underwater capture


kisav
6th August 2021, 16:58
This was my first attempt to capture underwater video with action camera.
In the shallow water it looks ok, but with the increase of the depth the video has very pronounced green tint...
Can someone help me with working AWB avs script to address this problem...

P.S. So far I've tried RGBAdjust but didn't like the result too much...

DJI_0538-sample.mp4 (https://drive.google.com/file/d/171TVD-gusQ1waL3Xr50BWWK-bBQq8PVz/view?usp=sharing)

johnmeyer
6th August 2021, 17:12
Unless your video is only a few feet underwater, you will not be able to achieve real color balance because too much red has been filtered out. I don't think any automatic color correction will work. You can sometimes get a little better balance using the color corrector in your NLE, but you need to try to get something that pleases you rather than something that is truly "balanced."

Arx1meD
7th August 2021, 10:50
kisav,
Perhaps, in your case, AWB will not help you to correct the color. Try to open the video in VirtualDub and use filters: 6-axis color correction, ColorMill, Hue-Saturation-Intensity, RGB Equalizer (ACOWB probably). Adjust the filter or combination of filters as you see fit.

kisav
7th August 2021, 11:54
"...You can sometimes get a little better balance using the color corrector in your NLE..."

John,
I'm using avs+ AvsPmod only... for many reasons. Portability is one of them...

kisav
7th August 2021, 12:08
Arx1meD,
I'm getting better results (https://drive.google.com/file/d/1Edvkq9l7KZ3ifP9DBufaQR1RGsfZ8RJW/view?usp=sharing) with 6-axis vd plugin then RGBAdjust
but I can't properly 'port it' in avs script... I'm getting acid colors (https://drive.google.com/file/d/10FP0Do2iVDpkLYbwY3IDYpcdw8tqG09h/view?usp=sharing).


ConvertToRGB32()
LoadVirtualDubPlugin("D:\SOFTWARE\Video and Audio\Tools\VirtualDub2_44282\plugins64\sixaxis.vdf", "Sixaxis", preroll=0)
Trim(2380, 4100).Sixaxis(0,0.5,1, -0.173,0.122, 1, 0.5,1, 0.5,1, 0.5,1, 0.5,1, 0.5,1, 0.5,1)

P.S. all the numbers were taken from *.vdscript file

Arx1meD
7th August 2021, 15:47
but I can't properly 'port it' in avs script... I'm getting acid colors.

The problem with Sixaxis. In my opinion, it does not work well in AviSynth.

VirtualDub filters only work with RGB color. Some VirtualDub filters work with frame sizes in multiples of mode 16.
Therefore, it is better like this:
ConvertToRGB32()
AddBorders(#1,#2,0,0) #if the frame is not a multiple of mode 16
...
Crop(#1,#2,0,0) #if the frame is not a multiple of mode 16
ConvertToYV12()

kisav
7th August 2021, 18:36
Arx1meD,

unfortunately it didn't fix the problem.
My new corrected resolution is 960x544 now (https://drive.google.com/file/d/1r8ZJwk5xrJVrn-cBnEj5Ox-jLpYD0al9/view?usp=sharing)

ConvertToRGB32()
AddBorders(0,2,0,2) #if the frame is not a multiple of mode 16

johnmeyer
7th August 2021, 19:46
Correcting using my NLE (Vegas) produces the most natural results. I just picked three points in the clip and corrected the colors at those points, and then used the keyframing facility to create intermediate corrections, as the color changed. Here is the result:

Corrected via NLE (best result) (https://www.mediafire.com/file/rqfm5c1tmect1xg/Restored.mp4/file)

I then used GamMac to do the color correction "automatically". I have copied my script below. Here is the result:

GamMac Color Corrected (https://www.mediafire.com/file/6nr09hjon3x9e9d/Restored+(GamMac).mp4/file)

Someone who understands GamMac better than I do (the author perhaps?) could probably get much better results.

#GamMac color correction
O=Last
DC=Last
LockChan = -1 # Chan for lock to Ave, 0=R, 1=G, 2=B
# -1 = Use LockVal below.
# -2 = LockVal=(RedAve+GrnAve+BluAve)/3.0 for LockVal.
# -3 = LockVal=Median(RedAve,GrnAve,BluAve)
Scale=2

RedMul = 1.0 # Required Ave multiplier for Red Channel, applied when requesting GuessGamma(reqAve*RedMul), Even applied when LockChan=-1.
GrnMul = 1.0 # Same for Green channel. GrnMul even applies when LockChan is Green Channel, etc for chans.
BluMul = 0.7 # Same for Blue channel. Allows tinkering/fine tuning.

Th = 0.04
loTh = 0.04
hiTh = 0.04
LockVal = 160.0 # Only valid if LockChan == -1

RngLim = 11

GamMax = 10.0
Show = False # Metrics
Verb = 2 # Verbocity FULL
SHOWCOORDS= False # Show Original with Coords

x =20 # Coords (for dc Detection Clip)
y =20
w=-20
h=-20

omin=0 # Output channels minimum (footroom for manual editing).
omax=255 # Output channels maximum (headroom for manual editing).

source=AVISource("E:\fs.avi").KillAudio()

output=GamMac(source,LockChan=LockChan,SCALE=SCALE,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,
\ Th=Th,LockVal=LockVal,RngLim=RngLim,GamMax=GamMax,
\ dc=DC,loTh=loTh,hiTh=hiTh,
\ x=x,y=y,w=w,h=h,
\ omin=omin,omax=omax,
\ Show=Show,Verbosity=Verb)


return output

#Alternative output settings for debugging
#stackhorizontal(source,output)

/*
return Interleave(
\ source
\ , output
\ )
*/

Arx1meD
7th August 2021, 20:37
kisav,
Fix color in VirtualDub and encode video with high bitrate. Then process this video in AviSynth.

My new corrected resolution is 960x544
Your frame size in height and width is a multiple of 16. 960/16=60.0 and 544/16=34.0. You don't need to use AddBorders(0,2,0,2) ... Crop(0,2,0,2)

Arx1meD
7th August 2021, 21:01
kisav,
Read this threads: https://forum.doom9.org/showthread.php?t=175536 and https://forum.doom9.org/showthread.php?t=176091

johnmeyer
8th August 2021, 01:16
If you want to see how a professional underwater photographer color corrects underwater footage, look for posts by Nick Hope ("nhope (https://forum.doom9.org/member.php?u=5482)"), or go peruse his underwater stills and video page:

Bubblevision (http://www.bubblevision.com/)

Underwater photography is his business.

I think he may have posted here, or in his blog, or elsewhere, about how he does color correction for underwater footage. As you will see, much of his footage is lit by lights that he brings along. Once you get more than a few meters under the water, that is about all you can do.

kisav
15th August 2021, 17:40
johnmeyer, thank you
I got not so bad result using GamMac after some number tweaking...
DJI_0538-GamMac.mp4 (https://drive.google.com/file/d/1oZUw5fUr01ns-hRG5P55qaGgo2LYo5Er/view?usp=sharing)


It's not perfect, Maybe someone can tweak it further,
here is the 1080p version before applying GamMac
DJI_0538-CC_Unchanged_1080p.mp4 (https://drive.google.com/file/d/1syS-jKmlbWbpD5HxpwoA8txw0Q8QfxSn/view?usp=sharing)

P.S. here is my config:
#GamMac color correction
O=Last
DC=Last
LockChan = -1 # Chan for lock to Ave, 0=R, 1=G, 2=B
# -1 = Use LockVal below.
# -2 = LockVal=(RedAve+GrnAve+BluAve)/3.0 for LockVal.
# -3 = LockVal=Median(RedAve,GrnAve,BluAve)
Scale=1

RedMul = 1.0 # Required Ave multiplier for Red Channel, applied when requesting GuessGamma(reqAve*RedMul), Even applied when LockChan=-1.
GrnMul = 1.0 # Same for Green channel. GrnMul even applies when LockChan is Green Channel, etc for chans.
BluMul = 1.0 # Same for Blue channel. Allows tinkering/fine tuning.

Th = 0.00
loTh = -1.00
hiTh = -1.00
LockVal = 128.0 # Only valid if LockChan == -1

RngLim = 11

GamMax = 10.0
Show = False # Metrics
Verb = 2 # Verbocity FULL
SHOWCOORDS= False # Show Original with Coords

x =20 # Coords (for dc Detection Clip)
y =20
w=-20
h=-20

omin=0 # Output channels minimum (footroom for manual editing).
omax=255 # Output channels maximum (headroom for manual editing).

johnmeyer
15th August 2021, 20:59
Your GamMac results look pretty good to me. Nice job!