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 > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th July 2016, 09:23   #21  |  Link
Bloax
The speed of stupid
 
Bloax's Avatar
 
Join Date: Sep 2011
Posts: 317

Doing some adjustment bullshit in Photoshop (primarily curves with a little Color Balance cheating) certainly reveals that you can do much more.


But it's good to see people making interesting things, even if I have no use for them myself being the young'un I am.
Bloax is offline   Reply With Quote
Old 19th July 2016, 11:49   #22  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Terneuzen, Zeeland, the Netherlands, Europe, Earth, Milky Way,Universe
Posts: 689
Quote:
Originally Posted by Bloax View Post
But it's good to see people making interesting things, even if I have no use for them myself being the young'un I am.
But perhaps there are some old family films hidden somewhere at your uncles or grandfathers house, you never know

Fred.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Old 19th July 2016, 15:12   #23  |  Link
udobroemme
Registered User
 
Join Date: Oct 2012
Posts: 12
Thank you very much for this great filter. I did a few tests with some faded prints and the results are very impressing.
udobroemme is offline   Reply With Quote
Old 19th July 2016, 15:17   #24  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Ok it might be not correct but it works as you can see on my examples.
I did try in GamMaC to set levels using both individual min,max for each channel, and also chanmin=min(minR,minG,minB), chanmax=max(maxR,maxG,maxB),
and results were not terribly encouraging. Looking at AutoLevels source, I find that it converts R,G & B to Luma Y to get min, max and mean (together
with the ignore args). So, AutoLevels currently uses neither RGB min,max method mentioned. Dont know whether this change was done since the previous
IanB quote or whether always as is.
Anyway, we really dont need to be re-inventing that wheel and I am now happy to completely abandon any idea to do same in purely RGB.

Fred can you verify that you did not use any of the gamma args in AutoLevels in your tests [they are unused by default and I did not pass on gamma
related args in the AutoLevelsGamMac() stub]. EDIT: better still can you post the script for eg the Lollipop Lady [GamMac000001.jpg].

EDIT: @ Bloax, you could have gotten LockChan 2 Lenna without the metrics setting Show=false, and perhaps better
results in PhotoShop due to missing white text. (guess you just downloaded the pic and not GamMac).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 19th July 2016 at 15:48.
StainlessS is offline   Reply With Quote
Old 19th July 2016, 18:43   #25  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Fred, I cocked up previous trials at the RGB prelevel thing (such is the lot of a nincompoop),
I had another go and this time a bit better.

Here v1.03Beta for you to have a play with, because I'm going t' pub.
LINK REMOVED

and the puppy pic



args added
Code:
    Th, Default 0.0(off)        0.0 -> 10.0(perhaps limited to ~2.0 in non Beta). Default for MinTh and MaxTh. Suggest about 0.2(percent).
    MinTh, Default Th.          0.0 -> ??? as for Ignore_low in AutoLevels, or threshold in YPlaneMin.
    MaxTh, Default Th.          0.0 -> ??? as for Ignore_high in AutoLevels, or threshold in YPlaneMax.
    MinMaxLock, Default True.   If true, input_low and input_high set identical eg min(rmin,gmin,bmin) for R,G,B. Else set individually.
Can use instead of AutoLevels if required.

EDIT: If you (or anyone) would like to knock up a little documentation, that would be glorious [me hates dat]
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 15th June 2018 at 14:28.
StainlessS is offline   Reply With Quote
Old 20th July 2016, 00:04   #26  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Terneuzen, Zeeland, the Netherlands, Europe, Earth, Milky Way,Universe
Posts: 689
Quote:
Originally Posted by StainlessS View Post
Fred can you verify that you did not use any of the gamma args in AutoLevels in your tests [they are unused by default and I did not pass on gamma
related args in the AutoLevelsGamMac() stub]. EDIT: better still can you post the script for eg the Lollipop Lady [GamMac000001.jpg].
Yes, I can confirm I have not used any gamma args in AutoLevels(). Do you still need my script? Because I have seen your update in the next post.

Fred.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Old 20th July 2016, 00:07   #27  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Terneuzen, Zeeland, the Netherlands, Europe, Earth, Milky Way,Universe
Posts: 689
Quote:
Originally Posted by StainlessS View Post
Here v1.03Beta for you to have a play with, because I'm going t' pub.
Thank you! Have a Belgian beer on my account
Will test it asap...

Quote:
EDIT: If you (or anyone) would like to knock up a little documentation, that would be glorious [me hates dat]
I can do this, but first we must be sure to have the final version.

Fred.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Old 20th July 2016, 00:31   #28  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
I can do this, but first we must be sure to have the final version.
Fantastic, however, you also have to pick names (mine usually start out as temp or fred (not in honour of you, [but you can tell people that it is, I will not deny it])
Need full docs, way more sensible than wot I wud wryt.
Take your time, be careful, and good. May the lord be with you, and also with you. (no idea wot that means).

EDIT: Pick, suggest whatever arg names you want, I pretty much guarantee your suggestions are acceptable and concrete.
EDIT:
Lost my other Vape stick again, today is a very sad day, again. Sick 0' losin my Vape sticks, the world is such a dangerous place.

Stella, beer, pretty damn good. Also your Trappist, brewed by drunken clerics (very well recommended).
Belgians are the most prolific of Beer makers (high up there on drinkers too) in the world.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 20th July 2016 at 10:56.
StainlessS is offline   Reply With Quote
Old 20th July 2016, 14:21   #29  |  Link
Motenai Yoda
Registered User
 
Motenai Yoda's Avatar
 
Join Date: Jan 2010
Posts: 709
Quote:
I did try in GamMaC to set levels using both individual min,max for each channel, and also chanmin=min(minR,minG,minB), chanmax=max(maxR,maxG,maxB),
and results were not terribly encouraging.
Just to be sure, did you recalculate the avg values with the scale formula before guess gamma?
my suggestion was about to match a reference channel range coz other tools yet did increase global contrast using something like min(minR,minG,minB)/max(maxR,maxG,maxB), also autolevels roughly do the same but it stretch all of them to 0/255 - 16/235 not maintaining the source frame's dynamic range

also IanB was talking about don't change RGB ratios as AutoLevels is to increase global contrast without change colors or dominances.
GamMac will change those ratios anyway.

ps as gamma function is more effective on the lower part of the range than on the upper one, maybe will be better to use a different, more balanced, curve?
__________________
powered by Google Translator

Last edited by Motenai Yoda; 20th July 2016 at 14:31.
Motenai Yoda is offline   Reply With Quote
Old 20th July 2016, 15:51   #30  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Not terribly encouraging
Basically I forgot that the thresholds were in percent, and so forgot to divide by 100.0, so results were garbage

Quote:
did you recalculate the avg values with the scale formula before guess gamma?
No.
Yoda, discuss what is required with Fred, so far as I'm concerned it is his baby and he's the gaffer.

Source is included in the zip below (I shall not try to convert the original script to be similar to current version).

Code:
GamMac(), [Gamma Machine] An extraordinary Idea by VideoFred (the gent from Gent). Coded by StainlessS.

    Home Thread:- http://forum.doom9.org/showthread.php?p=1774281#post1774281
    Idea:-        http://forum.doom9.org/showthread.php?t=173683

RGB Only.

    Useful to correct color cast on old 8mm films.
    Alters channel pixel average to match LockChan using Gamma correction. (By default alters Red and Blue channels to match Green).
    Additional tweaking via RedMul, GrnMul and BluMul.

GamMac(clip c,int "LockChan"=1,Float "LockVal"=128,
      \ Float "RedMul"=1.0,Float "GrnMul"=1.0, Float "BluMul"=1.0,
      \ Float "MinLim"=32.0,Float "MaxLim"=255.0-32.0,float "GamLo"=0.25,Float "GamHi"=4.0,
      \ Bool "Show"=false,int "Verbosity"=1
      \ Float "Th"= -1.0,Float "loTh"=Th,Float "hiTh"=Th,Bool "loHiLock"=True
      \ )

    LockChan Default 1.         Chan for lock to Ave. (0)LockVal=RedAve, (1)LockVal=GreenAve, (2)LockVal=BlueAve
                                -1 = Use explicit LockVal below.
                                -2 = LockVal=(RedAve+GrnAve+BluAve)/3.0.
                                -3 = LockVal=Median(RedAve,GrnAve,BluAve)
    LockVal, default 128.0.     Ignored if LockChan != -1.0. 0.0 < LockVal < 255.0
    RedMul, default 1.0.        0.1 <= RedMul <= 10.0.  Red channel adjustment.
    GrnMul, default 1.0.        0.1 <= GrnMul <= 10.0.  Green channel adjustment.
    BluMul, default 1.0.        0.1 <= BluMul <= 10.0.  Blue channel adjustment.
                                   Above Multipliers only shown in metrics when at least one is != 1.0.
    MinLim, default 32.0.       0.0 < MinLim < 255.0    If any channel average smaller than this, then no effect on channel.
    MaxLim, default 255.0-32.0. MinLim < MaxLim < 255.0 If any channel average greater than this, then no effect on channel.
    GamLo, default 0.25.        0.1 <= GamLo <= 10.0.  Lower value for guess gamma (starting guess range and limit)
    GamHi, default 4.0.         GamLo < GamHi <= 10.0. Upper value for guess gamma (starting guess range and limit)
    Show, default false.        True, show info.
    Verbosity, default 1.       0=Only Upper metrics, 1(default)=Upper + important ones. 2=Full metrics.

    Th, Default -1.0(off)      -1.0, or 0.0 -> 2.0. Sets Default for loTh and hiTh. Suggest about 0.0, or 0.1(percent).
    loTh, Default Th.          -1.0, or 0.0 -> 2.0. as for Ignore_low in AutoLevels, or Threshold in YPlaneMin.
    hiTh, Default Th.          -1.0, or 0.0 -> 2.0. as for Ignore_high in AutoLevels, or Threshold in YPlaneMax.
                               Percent, amount of extreme pixels (eg noise) to ignore when finding minimum and maximum R, G or B channel values.
                               -1.0 is OFF, input channel minimum is set to 0 and maximum set to 255.0, as in levels(0,gamma,255, ... ).
                               If loTh set to eg 0.0, then will scan frame looking for minimum accumulated channel values that have more than 0.0%
                               of pixels, and set input_min for that channel to that value. (Accumulated:- including values that were lower but not
                               of great enough number to break the threshold).
                               If hiTh set to eg 0.0, then will scan frame looking for maximum accumulated channel values that have more than 0.0%
                               of pixels, and set input_max for that channel to that value.
                               loTh and hiTh, only shown in metrics if greater or equal to 0.0 ie switched ON.

    loHiLock, Default True.    If (loHiLock==true) then input_lowR  = min(rmin,gmin,bmin) ELSE input_lowR  = rmin
                               If (loHiLock==true) then input_highR = max(rmax,gmax,bmax) ELSE input_highR = rmax
                               Where for Red, sort of equivalent to outR=LevelsR(input_lowR,gamma,input_highR, 0,255)
                               Same for other channels.
Code:
Imagesource("GreenChurch.png",end=0)
#Imagesource("Puppy.png",end=0)
#Imagesource("lennaRed.png",end=0)

#Avisource("1937 Lund Utah 16mm Film [Low, 360p].mp4.avi")
#Avisource("1941 Flint Michigan Parade [Low, 360p].mp4.AVI")

ConvertToRGB24
ORG=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)
LockVal  = 128          # Only valid if LockChan == -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.
Show     = true         # Subtitles

A=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,Show=Show,Verbosity=0)

thB     = 0.0
BluMulB = 0.95
B=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMulB,Show=Show,Verbosity=1,th=thB)

thC     = 0.0
BluMulC = 0.95
LoHiLockC=False
C=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMulC,Show=Show,Verbosity=2,th=thC,LoHiLock=LoHiLockC)

TOP=StackHorizontal(ORG,A)
BOT=StackHorizontal(B,C)
StackVertical(TOP,BOT)
return Last
Produces this


Here v1.04, incl GreenChurch, Puppy, and red Lenna pings(990KB):- LINK REMOVED

Fred, I'm leaving totally up to you to say what your orders are, including any arg name changes or whatever,
awaiting instruction.

I can do what Yoda suggests if required (or make optional via arg if required).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 15th June 2018 at 14:29.
StainlessS is offline   Reply With Quote
Old 20th July 2016, 21:03   #31  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
OK, have tried to implement what Yoda was talking about.

update to DOC
Code:
GamMac(clip c,int "LockChan"=1,Float "LockVal"=128,
      \ Float "RedMul"=1.0,Float "GrnMul"=1.0, Float "BluMul"=1.0,
      \ Float "MinLim"=32.0,Float "MaxLim"=255.0-32.0,float "GamLo"=0.25,Float "GamHi"=4.0,
      \ Bool "Show"=false,int "Verbosity"=1
      \ Float "Th"= -1.0,Float "loTh"=Th,Float "hiTh"=Th,Bool "loHiLock"=True
      \ bool "Scale"=true
      \ )

...


    Scale, default False.      if Scale (and loTh and/or hiTh >= 0.0)  then scales input channel averages
                                 eg, in_scale = (Scale) ? 255.0 / (in_max - in_min) : 1.0;
                                 where in_min = min(minR,minG,minB) and in_max = max(maxR,maxG,maxB)
Script
Code:
#Imagesource("GreenChurch.png",end=0)
Imagesource("Puppy.png",end=0)
#Imagesource("lennaRed.png",end=0)

#Avisource("1937 Lund Utah 16mm Film [Low, 360p].mp4.avi")
#Avisource("1941 Flint Michigan Parade [Low, 360p].mp4.AVI")

ConvertToRGB24
ORG=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)
LockVal  = 128          # Only valid if LockChan == -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.
Show     = true         # Subtitles
th		 = 0.0

A=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,Show=Show,Verbosity=1,Th=Th)

B=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,Show=Show,Verbosity=1,th=Th,SCALE=True)

LoHiLockC=False
C=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,Show=Show,Verbosity=1,th=th,LoHiLock=LoHiLockC,SCALE=True)

TOP=StackHorizontal(ORG,A)
BOT=StackHorizontal(B,C)
StackVertical(TOP,BOT)
return Last
EDIT: Below images have full precision metrics, forgot to switch that off.



Here:- LINK REMOVED

Can both Fred and Yoda check it out [not sure if its worth the bother].

here main changes

Code:
PVideoFrame __stdcall GamMac::GetFrame(int n, IScriptEnvironment* env) {
    n = (n<0) ? 0 : (n>= vi.num_frames) ? vi.num_frames - 1 : n;
    CountRGB(n,cntR,cntG,cntB,env);
    int in_minR = (loTh>=0.0) ? ChanMin(cntR,loTh)                  : 0;
    int in_minG = (loTh>=0.0) ? ChanMin(cntG,loTh)                  : 0;
    int in_minB = (loTh>=0.0) ? ChanMin(cntB,loTh)                  : 0;

    int in_maxR = (hiTh>=0.0) ? ChanMax(cntR,hiTh)                  : 255;
    int in_maxG = (hiTh>=0.0) ? ChanMax(cntG,hiTh)                  : 255;
    int in_maxB = (hiTh>=0.0) ? ChanMax(cntB,hiTh)                  : 255;

    int in_min  = (loTh>=0.0) ? min(min(in_minR,in_minG),in_minB)   : 0;
    int in_max  = (hiTh>=0.0) ? max(max(in_maxR,in_maxG),in_maxB)   : 255;

    if(loTh>=0.0 && loHiLock) in_minR=in_minG=in_minB=in_min;
    if(hiTh>=0.0 && loHiLock) in_maxR=in_maxG=in_maxB=in_max;

    double inR=ChanAve(cntR);
    double inG=ChanAve(cntG);
    double inB=ChanAve(cntB);

    double in_scale = (Scale) ? 255.0 / (in_max - in_min) : 1.0;

    double scaleR = inR * in_scale;
    double scaleG = inG * in_scale;
    double scaleB = inB * in_scale;

    double lockval;

    if(LockChan==0)         {lockval=scaleR;}
    else if(LockChan==1)    {lockval=scaleG;}
    else if(LockChan==2)    {lockval=scaleB;}
    else if(LockChan==-2)   {lockval=((scaleR+scaleG+scaleB)/3.0);}
    else if(LockChan==-3)   {
        double mx=max(max(scaleR,scaleG),scaleB);
        double mn=min(min(scaleR,scaleG),scaleB);
        lockval=scaleR+scaleG+scaleB-mx-mn;
    } else {
        lockval =LockVal;
    }

    bool skipR=(inR<MinLim || inR>MaxLim);
    bool skipG=(inG<MinLim || inG>MaxLim);
    bool skipB=(inB<MinLim || inB>MaxLim);
    bool guessR=(in_minR!=0 || in_maxR!=255 || fabs(scaleR-lockval*RedMul)>=0.00001);
    bool guessG=(in_minG!=0 || in_maxG!=255 || fabs(scaleG-lockval*GrnMul)>=0.00001);
    bool guessB=(in_minB!=0 || in_maxB!=255 || fabs(scaleB-lockval*BluMul)>=0.00001);
    double gammaR=(skipR || !guessR)?1.0:GuessGamma(in_minR,in_maxR,cntR,lockval*RedMul);
    double gammaG=(skipG || !guessG)?1.0:GuessGamma(in_minG,in_maxG,cntG,lockval*GrnMul);
    double gammaB=(skipB || !guessB)?1.0:GuessGamma(in_minB,in_maxB,cntB,lockval*BluMul);
    SetGammaLut(in_minR,in_maxR, gammaR,lutR);
    SetGammaLut(in_minG,in_maxG, gammaG,lutG);
    SetGammaLut(in_minB,in_maxB, gammaB,lutB);

...
EDIT: Or instead of
Code:
   double in_scale = (Scale) ? 255.0 / (in_max - in_min) : 1.0;

    double scaleR = inR * in_scale;
    double scaleG = inG * in_scale;
    double scaleB = inB * in_scale;
should it be
Code:
    double in_scale = (Scale) ? 255.0 / (in_max - in_min) : 1.0;

    double scaleR = (inR - in_min) * in_scale;
    double scaleG = (inG - in_min) * in_scale;
    double scaleB = (inB - in_min) * in_scale;
with above mod


Without metrics


Think that last mod was correct, updating soon. EDIT: Damn that bottom RHS one is good (Nice one Yoda ).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 15th June 2018 at 14:31.
StainlessS is offline   Reply With Quote
Old 20th July 2016, 22:27   #32  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
Nice Job, S, beautiful work! Makes faded images look brand new.

p.s. Lena is here
https://www.cs.cmu.edu/~chuck/lennapg/lenna.shtml

There is a full scan of the original, yes it was reddish and the scarf looks to be blue.

Last edited by jmac698; 20th July 2016 at 22:33.
jmac698 is offline   Reply With Quote
Old 20th July 2016, 23:02   #33  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Thanx very much JMac, but, me gots dem all 12/53 (Marilyn) up till bout 08.

GamMac() v1.04Beta3:- LINK REMOVED

Check it out.















EDIT: Non of the above have had any of the xxxMul settings applied.
All setting same as in first image metrics.

Waiting for orders Fred, change anything ? (then beta lifted)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 15th June 2018 at 14:32.
StainlessS is offline   Reply With Quote
Old 21st July 2016, 01:38   #34  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
GamMac() v1.04Beta4:- LINK REMOVED

Scale changed from Bool to Int.
Code:
GamMac(), [Gamma Machine] An extraordinary Idea by VideoFred (the gent from Gent). Coded by StainlessS.

    Home Thread:- http://forum.doom9.org/showthread.php?p=1774281#post1774281
    Idea:-        http://forum.doom9.org/showthread.php?t=173683

RGB Only.

    Useful to correct color cast on old 8mm films.
    Alters channel pixel average to match LockChan using Gamma correction. (By default alters Red and Blue channels to match Green).
    Additional tweaking via RedMul, GrnMul and BluMul.

GamMac(clip c,int "LockChan"=1,Float "LockVal"=128,
      \ Float "RedMul"=1.0,Float "GrnMul"=1.0, Float "BluMul"=1.0,
      \ Float "MinLim"=32.0,Float "MaxLim"=255.0-32.0,float "GamLo"=0.25,Float "GamHi"=4.0,
      \ Bool "Show"=false,int "Verbosity"=1
      \ Float "Th"= -1.0,Float "loTh"=Th,Float "hiTh"=Th,Bool "loHiLock"=True,
      \ int "Scale"=0
      \ )

    LockChan Default 1.         Chan for lock to Ave. (0)LockVal=RedAve, (1)LockVal=GreenAve, (2)LockVal=BlueAve
                                -1 = Use explicit LockVal below.
                                -2 = LockVal=(RedAve+GrnAve+BluAve)/3.0.
                                -3 = LockVal=Median(RedAve,GrnAve,BluAve)
    LockVal, default 128.0.     Ignored if LockChan != -1.0. 0.0 < LockVal < 255.0
    RedMul, default 1.0.        0.1 <= RedMul <= 10.0.  Red channel adjustment.
    GrnMul, default 1.0.        0.1 <= GrnMul <= 10.0.  Green channel adjustment.
    BluMul, default 1.0.        0.1 <= BluMul <= 10.0.  Blue channel adjustment.
                                   Above Multipliers only shown in metrics when at least one is != 1.0.
    MinLim, default 32.0.       0.0 < MinLim < 255.0    If any channel average smaller than this, then no effect on channel.
    MaxLim, default 255.0-32.0. MinLim < MaxLim < 255.0 If any channel average greater than this, then no effect on channel.
    GamLo, default 0.25.        0.1 <= GamLo <= 10.0.  Lower value for guess gamma (starting guess range and limit)
    GamHi, default 4.0.         GamLo < GamHi <= 10.0. Upper value for guess gamma (starting guess range and limit)
    Show, default false.        True, show info.
    Verbosity, default 1.       0=Only Upper metrics, 1(default)=Upper + important ones. 2=Full metrics.

    Th, Default -1.0(off)      -1.0, or 0.0 -> 2.0. Sets Default for loTh and hiTh. Suggest about 0.0, or 0.1(percent).
    loTh, Default Th.          -1.0, or 0.0 -> 2.0. as for Ignore_low in AutoLevels, or Threshold in YPlaneMin.
    hiTh, Default Th.          -1.0, or 0.0 -> 2.0. as for Ignore_high in AutoLevels, or Threshold in YPlaneMax.
                               Percent, amount of extreme pixels (eg noise) to ignore when finding minimum and maximum R, G or B channel values.
                               -1.0 is OFF, input channel minimum is set to 0 and maximum set to 255.0, as in levels(0,gamma,255, ... ).
                               If loTh set to eg 0.0, then will scan frame looking for minimum accumulated channel values that have more than 0.0%
                               of pixels, and set input_min for that channel to that value. (Accumulated:- including values that were lower but not
                               of great enough number to break the threshold).
                               If hiTh set to eg 0.0, then will scan frame looking for maximum accumulated channel values that have more than 0.0%
                               of pixels, and set input_max for that channel to that value.
                               loTh and hiTh, only shown in metrics if greater or equal to 0.0 ie switched ON.

    loHiLock, Default True.    If (loHiLock==true) then input_lowR  = min(rmin,gmin,bmin) ELSE input_lowR  = rmin
                               If (loHiLock==true) then input_highR = max(rmax,gmax,bmax) ELSE input_highR = rmax
                               Where for Red, sort of equivalent to outR=LevelsR(input_lowR,gamma,input_highR, 0,255)
                               Same for other channels.

    Scale, default 0.          Range 0 -> 2. No Effect unless Scale > 0 and loTh and/or hiTh >= 0.0.
                                   0) No Effect.
                                   1) Scales input channel average maximum dynamic range of R,G,B, 0.0 -> 255.0
                                      where,
                                         in_min = min(minR,minG,minB) and in_max = max(maxR,maxG,maxB)
                                         inR = R channel Average, inG = G channel Average, inB = B channel Average.
                                      in_scale = 255.0 / (in_max - in_min)
                                      scaleR   = min(max((inR - in_min) * in_scale,0.0),255.0)
                                      scaleG   = min(max((inG - in_min) * in_scale,0.0),255.0)
                                      scaleB   = min(max((inB - in_min) * in_scale,0.0),255.0)
                                   2) Scales input channel average dynamic range of R and G and B, Individually, 0.0 -> 255.0
                                      in_scaleR = 255.0 / (in_maxR - in_minR)
                                      in_scaleG = 255.0 / (in_maxG - in_minG)
                                      in_scaleB = 255.0 / (in_maxB - in_minB)
                                      scaleR = min(max((inR - in_minR) * in_scaleR,0.0),255.0)
                                      scaleG = min(max((inG - in_minG) * in_scaleG,0.0),255.0)
                                      scaleB = min(max((inB - in_minB) * in_scaleB,0.0),255.0)
test
Code:
#Imagesource("GreenChurch.png",end=0)
Imagesource("Puppy.png",end=0)
#Imagesource("lennaRed.png",end=0)
#Imagesource("G1.BMP",end=0) crop(0,0,0,-48) Spline36Resize(480,360)

ConvertToRGB24
ORG=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)
LockVal  = 128          # Only valid if LockChan == -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.
Show     = true         # Subtitles
th		 = 0.0

LoHiLockC=True Scale=0
A=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,Show=Show,Verbosity=1,Th=Th,SCALE=SCALE)

LoHiLockC=False Scale=1
B=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,Show=Show,Verbosity=1,th=th,LoHiLock=LoHiLockC,SCALE=Scale)

LoHiLockC=False Scale=2
C=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,Show=Show,Verbosity=1,th=th,LoHiLock=LoHiLockC,SCALE=Scale)

TOP=StackHorizontal(ORG,A)
BOT=StackHorizontal(B,C)
StackVertical(TOP,BOT)
return Last


Show=False



Bot RHS is new Scale=2 (prev Bot RHS puppy now on BOT LHS).

EDIT: I can probably move LoHiLock functionality into Scale, once I figure out how they 'interfere/interact' with each other.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 15th June 2018 at 14:34.
StainlessS is offline   Reply With Quote
Old 21st July 2016, 11:20   #35  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,565
I have some underwater diving photo, with red channel almost dead.

Is there any way to apply the script to images?
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 21st July 2016, 13:53   #36  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Not being magic, I do not know.

Have you tried it ?

EDIT:
Dont know much about the underwater thing, but think much of the red part of spectrum is absorbed by the water,
and weird things happen due to distance, the further away things would be further affected by red absorption
of the water between observer and the viewed object. There probably is no magic bullet due to the distance
from viewer thing, I guess all you can really do is try to correct for the object of main concern.

Here, just a quick knock up
Code:
Imagesource("Fish.BMP",end=0) Spline36Resize(480,360)
ConvertToRGB24
ORG=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)
LockVal  = 128          # Only valid if LockChan == -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.
Show     = false         # Subtitles
th		 = 0.0

LoHiLock=True Scale=0
A=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,Show=Show,Verbosity=1,Th=Th,LoHiLock=LoHiLock,SCALE=SCALE)
RedMul   = 0.87
LoHiLock=false
Scale=1
B=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,Show=Show,Verbosity=1,th=th,LoHiLock=LoHiLock,SCALE=Scale)
Scale=2
C=GamMac(LockChan=LockChan,LockVal=LockVal,RedMul=RedMul,GrnMul=GrnMul,BluMul=BluMul,Show=Show,Verbosity=1,th=th,LoHiLock=LoHiLock,SCALE=Scale)
TOP=StackHorizontal(ORG,A)
BOT=StackHorizontal(B,C)
StackVertical(TOP,BOT)
return Last




Also does not help if you got no idea what something is supposed to look like.

Here, same pic modded via something else:- http://forum.doom9.org/showthread.ph...98#post1726798

EDIT: Some more stuff here:- http://forum.doom9.org/showthread.php?t=156774

EDIT: On above pic, LoHiLock would have no effect dues to all min being 0, and all max being 255.
Also, scale 2 and 3 should produce same I think (for same reason, bottom two pics are therefore probably identical,
maybe try adjust eg bluMul a little for one of them).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 15th June 2018 at 14:35.
StainlessS is offline   Reply With Quote
Old 21st July 2016, 15:55   #37  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
I made "6-axis color" for underwater thing. Not sure if it is useful with avisynth environment.
https://gfycat.com/PaleShorttermBelugawhale
__________________
VirtualDub2
shekh is offline   Reply With Quote
Old 21st July 2016, 23:00   #38  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Shekh, that dont look anything like any beluga whale to me (dont they normally look like a dolphin wearing a crash helmet ?)
https://www.google.com/search?q=belu...QiR4IiAE&dpr=1
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 21st July 2016, 23:52   #39  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
tormento,

It is possible that MinLim, or MaxLim is preventing any changes on a channel.
Try something like
Code:
MinLim=0.01
MaxLim=254.99
to disable them. Is intended to prevent attempts to modify eg black or white frames.

I'll see if I can implement some kind of indicator when channel mods are disabled due to MinLim/MaxLim.
If channel mods are disabled, then will probably see Gamma=1.0 for that channel.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 22nd July 2016, 09:20   #40  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Terneuzen, Zeeland, the Netherlands, Europe, Earth, Milky Way,Universe
Posts: 689
Quote:
Originally Posted by StainlessS View Post
Waiting for orders Fred, change anything ? (then beta lifted)
Sorry for the delay, I was away for a few days. Tomorrow I have time to do some testing!

Fred.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Reply

Tags
color cast, correction, fade, gamma

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 22:42.


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