Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th October 2014, 15:30   #1  |  Link
mawen1250
Registered User
 
Join Date: Aug 2011
Posts: 103
Retinex

Source & Readme

r3 Binary: GitHub | NMM

Retinex is a very powerful filter in dynamic range compression, contrast enhancement, color constancy, de-fog, etc.

Filter examples

Source
retinex.MSRCP()
retinex.MSRCR()






Last edited by mawen1250; 8th November 2014 at 06:57. Reason: Update r3 and filter examples
mawen1250 is offline   Reply With Quote
Old 19th October 2014, 19:01   #2  |  Link
MeteorRain
結城有紀
 
Join Date: Dec 2003
Location: NJ; OR; Shanghai
Posts: 894
That's an awesome example
MeteorRain is offline   Reply With Quote
Old 20th October 2014, 01:16   #3  |  Link
Mystery Keeper
Beyond Kawaii
 
Mystery Keeper's Avatar
 
Join Date: Feb 2008
Location: Russia
Posts: 724

Looks very very wrong.
__________________
...desu!

Last edited by Mystery Keeper; 20th October 2014 at 01:37.
Mystery Keeper is offline   Reply With Quote
Old 20th October 2014, 07:09   #4  |  Link
mawen1250
Registered User
 
Join Date: Aug 2011
Posts: 103
Thanks for your report.
This is the correct result for MSRCP. It indicates that there's a bluish color cast in the original image, which is amplified after the Retinex with *chromaticity preservation*. Under this circumstance the color cast itself is unwanted chromatic information, so the plain MSRCP result is not suitable.

possible solutions:
1. Use MSRCR(MSR with color restoration) instead, which will eliminate color cast. Currently it's not implemented yet.
2. Do some modification to the MSRCP algorithm, such as adding a threshold to attenuate chroma adjustment for very dark area.
3. For now, this may be a good solution: use std.Lut to build a mask guided by luma, and apply std.MaskedMerge to blend the value of source and retinex for chroma planes.

Last edited by mawen1250; 20th October 2014 at 07:30.
mawen1250 is offline   Reply With Quote
Old 20th October 2014, 09:33   #5  |  Link
Mystery Keeper
Beyond Kawaii
 
Mystery Keeper's Avatar
 
Join Date: Feb 2008
Location: Russia
Posts: 724
I used ShufflePlanes to restore chroma the fastest way. Local contrast looks better in most of image, but worse at certain spots. Whole image looks desaturated. Experimented to see if it makes a good motion estimation clip for Analyse. Looks like it doesn't. Neighboring frames may differ in a way that actually messes up motion estimation.
__________________
...desu!

Last edited by Mystery Keeper; 20th October 2014 at 09:41.
Mystery Keeper is offline   Reply With Quote
Old 21st October 2014, 15:08   #6  |  Link
mawen1250
Registered User
 
Join Date: Aug 2011
Posts: 103
Update r2
MSRCP: Add option chroma_protect to attenuate chroma adjustment.
MSRCP: Intensity channel is calculated from average of R, G, B value
now, instead of weighted average.

@Mystery Keeper
Now you can try processing in RGB color space, and adjust chroma_protect when processing in YUV, to see if the result is better.
mawen1250 is offline   Reply With Quote
Old 21st October 2014, 17:38   #7  |  Link
Mystery Keeper
Beyond Kawaii
 
Mystery Keeper's Avatar
 
Join Date: Feb 2008
Location: Russia
Posts: 724
While the option decreases chroma corruption, it is still present. I'm still better off with ShufflePlanes. Still, your filter is great for local contrast enhancement. Thank you.
__________________
...desu!
Mystery Keeper is offline   Reply With Quote
Old 8th November 2014, 06:58   #8  |  Link
mawen1250
Registered User
 
Join Date: Aug 2011
Posts: 103
Update r3

Add new function retinex.MSRCR()----MSR with Color Restoration.
Fix incorrect result when lower_thr>0 or upper_thr>0.
Default parameters change: lower_thr=0.001, upper_thr=0.001.
Speed up about 15%.
mawen1250 is offline   Reply With Quote
Old 18th July 2017, 04:21   #9  |  Link
Jindadil007
Registered User
 
Join Date: Dec 2016
Posts: 71
Hi. I tried with updated r3 and getting Invalid Syntex error while using this.

video = core.retinex.MSRCR(video, sigma=[25,80,250], float lower_thr=0.001, float upper_thr=0.001, bool fulls=True, bool fulld=fulls, float restore=125)

Pl. suggest the changes to be made. Thanks.
Jindadil007 is offline   Reply With Quote
Old 18th July 2017, 07:18   #10  |  Link
blaze077
Registered User
 
Join Date: Jan 2016
Posts: 79
Remove all the data types from the call. Should look like this:
Code:
video = core.retinex.MSRCR(video, sigma=[25,80,250], lower_thr=0.001, upper_thr=0.001, fulls=True, fulld=True, restore=125)

Last edited by blaze077; 18th July 2017 at 07:21.
blaze077 is offline   Reply With Quote
Old 18th July 2017, 07:35   #11  |  Link
Jindadil007
Registered User
 
Join Date: Dec 2016
Posts: 71
Quote:
Originally Posted by blaze077 View Post
Remove all the data types from the call. Should look like this:
Code:
video = core.retinex.MSRCR(video, sigma=[25,80,250], lower_thr=0.001, upper_thr=0.001, fulls=True, fulld=True, restore=125)
...It worked like a charm
Jindadil007 is offline   Reply With Quote
Old 11th April 2018, 06:37   #12  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Is it intended that the image might get distorted depending on the source.
Using:
Code:
# Imports
import vapoursynth as vs
core = vs.get_core()
# Loading Plugins
core.std.LoadPlugin(path="G:/Hybrid/64bit/vsfilters/ColorFilter/Retinex/Retinex.dll")
core.std.LoadPlugin(path="G:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# Loading F:\TestClips&Co\files\5000frames.mp4 using LWLibavSource
clip = core.lsmas.LWLibavSource(source="F:/TESTCL~1/files/5000FR~1.MP4", format="YUV420P10", cache=0)
# making sure input color matrix is set as 470bg
clip = core.resize.Point(clip, matrix_in_s="470bg")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip, fpsnum=25, fpsden=1)
# Making sure input color range is set to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adjusting color space from YUV420P10 to YUV444P16
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16)
# color adjustment using Retinex
clip = core.retinex.MSRCP(input=clip, sigma=[25,80,250], fulls=True, fulld=True)
# adjusting output color from: YUV444P16 to YUV420P8 for x264Model (i420)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8)
# Output
clip.set_output()
and this source.
The first 100 frames are totally broken.

Cu Selur

Ps.: there is also another user who has issues with Retinex, see: https://forum.selur.net/showthread.php?tid=345
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 11th April 2018 at 06:55.
Selur is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:12.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.