View Full Version : Retinex
mawen1250
19th October 2014, 15:30
Source & Readme (https://github.com/HomeOfVapourSynthEvolution/VapourSynth-Retinex)
r3 Binary: GitHub (https://github.com/HomeOfVapourSynthEvolution/VapourSynth-Retinex/releases) | NMM (http://nmm.me/zs)
Retinex is a very powerful filter in dynamic range compression, contrast enhancement, color constancy, de-fog, etc.
Filter examples
Source
retinex.MSRCP()
retinex.MSRCR()
http://thumbnails111.imagebam.com/36300/d19a77362990894.jpg (http://www.imagebam.com/image/d19a77362990894) http://thumbnails110.imagebam.com/36300/68a4da362990901.jpg (http://www.imagebam.com/image/68a4da362990901) http://thumbnails112.imagebam.com/36300/5082b1362990909.jpg (http://www.imagebam.com/image/5082b1362990909)
http://thumbnails111.imagebam.com/36300/30c624362990915.jpg (http://www.imagebam.com/image/30c624362990915) http://thumbnails109.imagebam.com/36300/07d385362990923.jpg (http://www.imagebam.com/image/07d385362990923) http://thumbnails111.imagebam.com/36300/ed624e362990929.jpg (http://www.imagebam.com/image/ed624e362990929)
http://thumbnails110.imagebam.com/36300/418e55362990933.jpg (http://www.imagebam.com/image/418e55362990933) http://thumbnails112.imagebam.com/36300/0c73c8362990938.jpg (http://www.imagebam.com/image/0c73c8362990938) http://thumbnails110.imagebam.com/36300/e465f1362990946.jpg (http://www.imagebam.com/image/e465f1362990946)
MeteorRain
19th October 2014, 19:01
That's an awesome example :cool:
Mystery Keeper
20th October 2014, 01:16
http://s017.radikal.ru/i423/1410/30/0b5821d450d3.png
Looks very very wrong.
mawen1250
20th October 2014, 07:09
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.
Mystery Keeper
20th October 2014, 09:33
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.
mawen1250
21st October 2014, 15:08
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.
Mystery Keeper
21st October 2014, 17:38
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.
mawen1250
8th November 2014, 06:58
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%.
Jindadil007
18th July 2017, 04:21
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.
blaze077
18th July 2017, 07:18
Remove all the data types from the call. Should look like this:
video = core.retinex.MSRCR(video, sigma=[25,80,250], lower_thr=0.001, upper_thr=0.001, fulls=True, fulld=True, restore=125)
Jindadil007
18th July 2017, 07:35
Remove all the data types from the call. Should look like this:
video = core.retinex.MSRCR(video, sigma=[25,80,250], lower_thr=0.001, upper_thr=0.001, fulls=True, fulld=True, restore=125)
:thanks:...It worked like a charm
Selur
11th April 2018, 06:37
Is it intended that the image might get distorted depending on the source.
Using:
# 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 (https://forum.selur.net/attachment.php?aid=277) 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
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.