View Full Version : Retinex
FranceBB
13th September 2021, 10:21
Avisynth-retinex
https://github.com/Asd-g/AviSynth-Retinex
Not bad, considering it's doing everything automatically...
Here's a test with a v210 losslessly captured tape:
AVISource("Q:\00_INGEST_MAM\A.R.C.A\00_FILE_DA_ENCODARE\CALCIO SERIE A 1999 2000 TORINO VS ROMA SUPERSLOMO 991024 7769614.avi")
Bob()
ConvertBits(16)
ConvertToPlanarRGB()
original=Subtitle("Original")
filtered=MSRCR(sigma=250, lower_thr=0.001, upper_thr=0.001, fulls=true, fulld=true, restore=125.0).Subtitle("MSRCR")
StackHorizontal(original, filtered)
https://i.imgur.com/E71SRGR.png
https://i.imgur.com/DGwwxfB.png
https://i.imgur.com/ubGLX9J.png
Emulgator
14th September 2021, 07:35
FranceBB, did you swap pictures by any chance ?
FranceBB
14th September 2021, 09:02
FranceBB, did you swap pictures by any chance ?
This is what happens when I have a break at work, go to doom9, find something interesting and then people interrupt me halfway through 'cause they call me at my phone xD
The text doesn't match the picture in the script I wrote, so now I don't know which one is which. Dang it.
Selur
14th September 2021, 10:19
Usually the brighter one is the Retrinex output,...
Using Retinex in Vapoursynth with "clip = core.retinex.MSRCP(input=clip, sigma=[25,80,250], fulls=True, fulld=True)"
gives for example:
https://i.ibb.co/wpRdwjT/retinex-1.png (https://ibb.co/gt3rPhG)
https://i.ibb.co/Yd6gV8z/retinex-2.png (https://ibb.co/Yd6gV8z)
So I think the labeling is correct and the right side (like in my screenshots) is the filtered side.
Cu Selur
FranceBB
14th September 2021, 12:53
I think the labeling is correct and the right side (like in my screenshots) is the filtered side.
Good! :)
https://i.ibb.co/Yd6gV8z/retinex-2.png (https://ibb.co/Yd6gV8z)
Ah, that's funny, it's a Sky Deutschland feed eheheheh
:cool:
StainlessS
14th September 2021, 14:26
So, it's supposed to make them look too bright ?
wonkey_monkey
14th September 2021, 16:00
So, it's supposed to make them look too bright ?
Seems to be a left-right gradient on them (FranceBB's) too.
Edit: it seems like we've polluted the "New Plugins and Utilities" thread quite a bit here, by the way...
kedautinh12
14th September 2021, 16:14
I think it's same HDR
Selur
14th September 2021, 16:25
Can't really say what it should do, since I only used it to brighten up some way to dark indoor captures, where it really helped.
Looks like it's main effect is to brighten up dark areas and even out the general brightness of an image, so it might not be that suited for movies but more for single to dark scenes.
Here's another example (also using the default settings):
https://i.ibb.co/bFT0RKT/retinex-3.png (https://ibb.co/3v23YC2)
Edit: it seems like we've polluted the "New Plugins and Utilities" thread quite a bit here, by the way...
Argh, may be a mod could split the retinex discussion into a different thread,...
I think it's same HDR
Hmm, to me it seems more like the complete opposite to high dynamic range,...
Cu Selur
FranceBB
15th September 2021, 12:54
Hmm, to me it seems more like the complete opposite to high dynamic range...
It's pretty much the same as "fake HDR" when in mobile phones you choose "HDR" and you bump the slide to the maximum so it exasperates the shadows ehehehehe
Anyway, yes, it makes everything brighter.
wonkey_monkey
15th September 2021, 13:34
The rocks in Selur's example have got darker.
Selur
15th September 2021, 19:53
It's pretty much the same as "fake HDR" when in mobile phones you choose "HDR" and you bump the slide to the maximum so it exasperates the shadows ehehehehe
I mainly use my phone for navigation and checking mail, never really used it for anything video related. :)
Anyway, yes, it makes everything brighter.
I agree with wonkey_monkey, that does not seem to be the case.
For the fun of it I tool your first screenshot cropped by 720 on the right and then applied Retinex (Vapoursynth):
https://i.ibb.co/W2v34WV/retinex-4.png (https://ibb.co/6W0Z7RX)
Cu Selur
wonkey_monkey
15th September 2021, 20:00
Is that gradient due to the NAB bars on the sides?
Selur
15th September 2021, 20:13
This is what it looks like if I crop all the black bars (CropRel(clip=clip, left=12, right=732, top=0, bottom=2)) and then apply Retinex:
https://i.ibb.co/n60hTsd/retinex-5.png (https://ibb.co/rFtngG8)
so I would say: Yes
-> when using Retinex one should crop first. :)
Cu Selur
Sharc
15th September 2021, 20:32
For black, unfiltered (noisy) VHS frames I am getting this ugly patchwork out of retinex. Happens for example with fade-in/fade out.
https://i.postimg.cc/nzMMMyZF/Retinex-000127.png (https://postimages.org/)
wonkey_monkey
15th September 2021, 20:53
This is what it looks like if I crop all the black bars
so I would say: Yes
Hmm. Can't help thinking it's indicative of a bug, even if it goes away when cropped. The bars are fairly equal, so why does the left get bright but the right doesn't? Odd.
tormento
6th October 2021, 16:28
I am trying to use Retinex to remove color cast from a old film movie, unfortunately it has the tendency to brighten too much the dark photograms and cast sort of halo around objects.
Is there a way to limit it?
My script
SetMemoryMax()
SetFilterMTMode("DEFAULT_MT_MODE", 2)
LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("F:\In\1_48 Fantozzi\fantozzi.dgi",ct=24,cb=24,cl=0,cr=0)
ConvertBits(16)
SMDegrain (tr=6, thSAD=600, refinemotion=true, contrasharp=false, PreFilter=4, plane=4, chroma=true)
ConvertToPlanarRGB()
MSRCR(sigma=250, lower_thr=0.001, upper_thr=0.001, fulls=true, fulld=true, restore=125.0)
ConvertToYUV420()
fmtc_bitdepth (bits=8,dmode=8)
Prefetch(6)
Results:
https://i2.lensdump.com/i/gCTtBe.md.jpg (https://lensdump.com/i/gCTtBe)https://i3.lensdump.com/i/gCTIpM.md.jpg (https://lensdump.com/i/gCTIpM)
https://i.lensdump.com/i/gCTZFQ.md.jpg (https://lensdump.com/i/gCTZFQ)https://i1.lensdump.com/i/gCTr0a.md.jpg (https://lensdump.com/i/gCTr0a)
kedautinh12
6th October 2021, 16:33
If your old film movie have black bars, just cut before use retinex and add border again
tormento
6th October 2021, 16:34
If your old film movie have black bars, just cut before use retinex and add border again
I always crop black bars.
StvG
6th October 2021, 17:20
I am trying to use Retinex to remove color cast from a old film movie, unfortunately it has the tendency to brighten too much the dark photograms and cast sort of halo around objects.
Is there a way to limit it?
Try with very high sigma. For example sigma=2500.
tormento
7th October 2021, 09:23
Try with very high sigma. For example sigma=2500.
I had much better results but there is always a strong pink/red/purple dominance in all the images.
Look at dress, background and skin.
https://i3.lensdump.com/i/gC9CfC.md.jpg (https://lensdump.com/i/gC9CfC)https://i.lensdump.com/i/gC9Qj5.md.jpg (https://lensdump.com/i/gC9Qj5)
https://i1.lensdump.com/i/gC9Vqz.md.jpg (https://lensdump.com/i/gC9Vqz)https://i2.lensdump.com/i/gC99YT.md.jpg (https://lensdump.com/i/gC99YT)
Any hint?
kedautinh12
7th October 2021, 10:23
You can try report to developer
https://github.com/Asd-g/AviSynth-Retinex/issues
StvG
7th October 2021, 16:45
Any hint?
...
ConvertToPlanarRGB()
a=MSRCR(sigma=2500, lower_thr=0.001, upper_thr=0.001, fulls=true, fulld=true, restore=125.0)
Merge(a)
...
Or you can use more appropriate filters. The purpose of this filter is different than what you want.
An example ( https://github.com/crabshank/Avisynth-filters ):
ConvertToRGB64()
Auto_Gamma(b=1.5)
Manual_WP(x=0.3, y=0.3) # Manual_WP(auto_wp=true)
gispos
7th October 2021, 17:04
I've also tried to replace HDRAGC with retinex. But the result is only good for some scenes. As StvG has already written, a merge with a low 'weigth' value is usually necessary.
It would be nice if retinex got a little bit more fine-tuned.
retinex = MSRCR(sigma=250, lower_thr=0.001, upper_thr=0.001, fulls=true, fulld=true, restore=125.0)
merge(retinex, weight=0.4)
tormento
7th October 2021, 18:04
[code]ConvertToRGB64()
Auto_Gamma(b=1.5)
Manual_WP(x=0.3, y=0.3) # Manual_WP(auto_wp=true)[/code
This one works really nicely but I am losing all the blacks that became washed out, sort of very dark grey. I have looked into the wiki and there are no parameters to fix that. I tried LimitedRange=true too.
StvG
7th October 2021, 18:36
This one works really nicely but I am losing all the blacks that became washed out, sort of very dark grey. I have looked into the wiki and there are no parameters to fix that. I tried LimitedRange=true too.
Auto_Gamma(b=1.5) # Tune the value. Lower value - more brighter blacks.
Manual_WP(x=0.3, y=0.3) # Tune both values if not happy with colors.
gispos
7th October 2021, 18:42
I also like to use ContrastMask for lightening dark areas.
I have the function I think here in the forum found.
function ContrastMask(clip v, float "gblur", float "enhance")
{
enhance = default (enhance, 5.0)
gblur = default (gblur, 20.0)
enhance = (enhance>=0.0 && enhance<=10.0) ? float(enhance*0.1) : 1.0
v2=v.Tweak(sat=0)
v2=v2.invert()
v2=v2.gaussianblur(50.0,50.0+gblur)
photoshop_overlay=mt_lutxy(v,v2,"x 127.5 > y 255 x - 127.5 / * x 255 x - - + y x 127.5 / * ? ")
merged=overlay(v,photoshop_overlay,opacity=enhance)
return merged
}
tormento
7th October 2021, 20:02
I also like to use ContrastMask for lightening dark areas.
My problem is the exact opposite, it's the blacks to go for goods.
videoh
7th October 2021, 21:35
@tormento
You can try windowed histogram equalization to address the contrast extremes. Pick a strength and mix it with your source. Doubtful that Retinex is the right tool for your color cast.
Did you post a clip? We could have a go at it.
gispos
7th October 2021, 22:33
My problem is the exact opposite, it's the blacks to go for goods.
Then why retinex? It makes dark lighter.
Rizzoli Film: For me, the dark is too dark (no details) and the white balance is not correct.
tormento
8th October 2021, 11:39
Did you post a clip? We could have a go at it.
Here (https://send.cm/d/5Cz5) is a uncompressed, undenoised yellow tinted scene. You can see some "whiteish" titles too to have an idea of the wrong hue.
Here (https://send.cm/d/5Cz7)is a uncompressed, undenoised cyan tinted scene.
Here (https://send.cm/d/5Cz6)are some compressed and denoised scenes from various parts.
tormento
11th October 2021, 09:50
bump :)
StvG
11th October 2021, 12:31
Btw did you try tuning Auto_Gamma(b=x) ?
tormento
11th October 2021, 13:45
Btw did you try tuning Auto_Gamma(b=x) ?
Yep and it did not give good results as every component aged differently.
Selur
11th October 2021, 15:21
@tormento: did you try "AutoAdjust(auto_balance=true)" ? (no clue what would happen if one would apply retinex after that, but the general color adjustment looks good to me)
tormento
12th October 2021, 11:41
Guys, I upoloaded some samples here (https://forum.doom9.org/showthread.php?p=1954267#post1954267).
Please try some solutions, as my trials are all failing.
tormento
14th October 2021, 10:24
@tormento: did you try "AutoAdjust(auto_balance=true)" ? (no clue what would happen if one would apply retinex after that, but the general color adjustment looks good to me)
I have tried the following script
SetMemoryMax(4096)
SetFilterMTMode("DEFAULT_MT_MODE", 2)
LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("F:\In\1_48 Fantozzi\fantozzi.dgi",ct=24,cb=24,cl=0,cr=0)
ConvertBits(16)
SMDegrain (tr=6, thSAD=600, refinemotion=true, contrasharp=false, PreFilter=4, plane=4, chroma=true)
AutoAdjust(gain_mode=1,auto_gain=true,auto_balance=true,chroma_limit=2,gamma_limit=10,chroma_process=200,use_dither=false,high_quality=false)
fmtc_bitdepth (bits=8,dmode=8)
Prefetch(6)
and two problems arose.
The first one is that the colors, i.e. gamma have not changed at all, even maximizing all the ranges.
The second is that I have a strange split screen output
https://i.lensdump.com/i/gVikm3.md.jpg (https://lensdump.com/i/gVikm3)https://i1.lensdump.com/i/gVi6u0.md.jpg (https://lensdump.com/i/gVi6u0)
that goes away if I remove ConvertBits(16).
Any hint?
Boulder
14th October 2021, 10:46
AutoAdjust supports HBD only in the legacy stacked mode.
tormento
14th October 2021, 14:00
AutoAdjust supports HBD only in the legacy stacked mode.
Ok, that is for the half screen issue.
Any idea about why it doesn't change gamma or color balance at all?
I tried it in pure 8 bit space too.
StainlessS
14th October 2021, 14:23
Because the Luma ain't 8 bit either.
Its seeing near real 8 bit values in the Most Significant bytes, and almost random stuff in the least Significant bytes [which it also thinks is 8 bit luma].
Probably its histograms are flat, and does not give it much room to do anything, who knows???.
[I'm kinda surprised it looks as good as it does].
I tried it in 8 bit too.
And it looks the same [excluding half screen] ? Maybe post a sample for the guys to play with.
You could comment out some lines and start from there.
#SetMemoryMax(4096)
#SetFilterMTMode("DEFAULT_MT_MODE", 2)
LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("F:\In\1_48 Fantozzi\fantozzi.dgi",ct=24,cb=24,cl=0,cr=0)
ConvertBits(16)
#SMDegrain (tr=6, thSAD=600, refinemotion=true, contrasharp=false, PreFilter=4, plane=4, chroma=true)
AutoAdjust(gain_mode=1,auto_gain=true,auto_balance=true,chroma_limit=2,gamma_limit=10,chroma_process=200,use_dither=false,high_quality=false)
#fmtc_bitdepth (bits=8,dmode=8)
#Prefetch(6)
EDIT: And it will not get fixed or HBD added, no source available. [unless he comes back again].
Boulder
14th October 2021, 15:38
EDIT: And it will not get fixed or HBD added, no source available. [unless he comes back again].
That's mostly a minor annoyance as you can use ConvertToStacked() and ConvertFromStacked() as a workaround.
tormento
14th October 2021, 15:40
You could comment out some lines and start from there.
It does work, deleting ConvertBits(16) too ;)
Perhaps it's a problem of MT mode or memory.
StainlessS
14th October 2021, 15:46
minor annoyance
Yes, I suppose so.
Perhaps it's a problem of MT mode or memory.
why not try uncomment one at a time, see what happens.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.