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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th August 2005, 12:31   #21  |  Link
mg262
Clouded
 
mg262's Avatar
 
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
Quote:
This should in theory change the brightness, contrast, saturation, etc but not affect hue. I haven't found this to be very useful in practice.
And that would have something to do with the fact that I forgot to centre the polar colour space at (U=128, V=128) rather than (U=0, V=0)... . It now works:


ColourLike, 25 Aug 05



I've also added a saturation gamma function. The idea is this. A normal gamma operation can brighten or darken midtones while (approximately) leaving highlights and shadows alone. The saturation Gamma can increase or decrease the saturation of areas with medium saturation, while leaving greys and very saturated areas alone. I will some screenshots at a later date, but here is the syntax:

SaturationGamma(clip, float gamma, float fixed = 127.0)


The fixed parameter gives a "very saturated" saturation level [measured as a distance from (128,128)] that will be left alone by the function... but it will work fine if you leave this number at default. When I have a bit more time I will generate some screenshots that will make the use of the function clearer...but the results are (in my view) quite interesting, so do give it a go!

(Incidentally, I haven't forgotten that I promised to write something about Gamma, I'm just being rubbish and have taken on too much... I will get round to it.)

Edit, to recap:

dvd.polarcolourlike("dvd polar hist 1.txt", "vhs polar hist 1.txt", true, true)

The first true tells the filter to affect luma, and the second true tells it to affect saturation.
__________________
a.k.a. Clouded. Come and help by making sure your favourite AVISynth filters and scripts are listed.

Last edited by mg262; 25th August 2005 at 14:41.
mg262 is offline   Reply With Quote
Old 30th August 2005, 15:50   #22  |  Link
mgh
Registered User
 
Join Date: Oct 2004
Location: India
Posts: 321
Works well for both luma and chroma correction, but only with latest virtualdub.
I have some vcds with wrong color and either too dark or too bright. Have tried correction using a video file with visually OK color and luma balance .
Script
loadplugin("C:\Program Files\dgindex\\DGDecode.dll")
mpeg2source("C:\Program Files\vcds\video.d2v",cpu=6).lanczosresize(400,300)
FFT3DFilter(OH=16,OW=16,BH=48,BW=48,BT=3,Sigma=1,Sharpen=1)
vid=RemoveGrain(last,mode=12).autocrop(mode=0,wmultof=16,hmultof=16,samples=16,Aspect=0,threshold=50,samplestartframe=0,leftadd=0,rightadd=0,topadd=2,bottomadd=2).aSharp(0.4,0,0).aWarpsharp(3,1,bm=3,cm=0,thresh=0.99)
WriteHistogram(vid, "C:\Program Files\vcds\video.d2v.txt", 100)
vid1=avisource("D:\videos\good.avs")
WriteHistogram(vid1, "E:\capture\good.txt",100)
vid=vid.colourlike("C:\Program Files\vcds\video.d2v.txt", "E:\capture\good.txt", true, true,true)
return vid
Works very well with virtaualdub 1.6.10-a total mess with virtualdubmod 1.5.10 and avs2avi 139.
Do not know why. Have asked the question in virtualdub forum
http://forum.doom9.org/showthread.ph...594#post705594
which has samples.
__________________
A shut mouth gathers no foot
mgh is offline   Reply With Quote
Old 30th August 2005, 18:16   #23  |  Link
mg262
Clouded
 
mg262's Avatar
 
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
Sorry to hear about the problem; it's much more likely to be a problem at my end than in VDM -- but I use VirtualDubMod 1.5.10 all the time, so it's not a blanket incompatiiblity. When I am back at my own PC (some time from now) I will download the samples + investigate -- but in the meantime, if you can, please post a minimal problem-causing script, i.e. remove as many other filters as possible. Also, once the text files are wriiten once, you don't need to write them again -- so this sort of thing should do:

loadplugin("C:\Program Files\dgindex\\DGDecode.dll")
mpeg2source("C:\Program iles\vcds\video.d2v",cpu=6)
colourlike("C:\Program Files\vcds\video.d2v.txt", E:\capture\good.txt", true, true,true)


Edit: the AVI is YV12, yes?
__________________
a.k.a. Clouded. Come and help by making sure your favourite AVISynth filters and scripts are listed.

Last edited by mg262; 30th August 2005 at 18:18.
mg262 is offline   Reply With Quote
Old 30th August 2005, 20:17   #24  |  Link
mgh
Registered User
 
Join Date: Oct 2004
Location: India
Posts: 321
The avs is yv12.
From the virtualdub forum, it looks like the difference maybe because vdub 1.6.10 uses its own internal yv12 decoder. The problem does not occur with all videos. With the particular video, this script solved the problem
loadplugin("C:\Program Files\dgindex\\DGDecode.dll")
mpeg2source("C:\Program iles\vcds\video.d2v",cpu=6)
colourlike("C:\Program Files\vcds\video.d2v.txt", E:\capture\good.txt", false, true,true)
LumaYV12(lumoff=-10)
__________________
A shut mouth gathers no foot
mgh is offline   Reply With Quote
Old 30th August 2005, 20:23   #25  |  Link
mg262
Clouded
 
mg262's Avatar
 
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
Would you mind trying the following?

Take a video on which the problem occurs -- preferably a very short clip. Open up the video in the latest version of VirtualDub (so you get the correct results) and save the results to an AVI file using direct stream copy.

Now open up the resulting file in any of the programs that cause a problem. How does it look?
__________________
a.k.a. Clouded. Come and help by making sure your favourite AVISynth filters and scripts are listed.
mg262 is offline   Reply With Quote
Old 31st August 2005, 20:37   #26  |  Link
mgh
Registered User
 
Join Date: Oct 2004
Location: India
Posts: 321
Have been doing some trials. Problem occurs only with videos which contain large dark areas or large bright areas-a known problem for encoders;maybe also problem for some decoders sometimes.
Basically, I am trying it with VCDs and my initial attempts at TV captures with bad encoding/capture-to correct color balance and levels. With luma disabled, the color balance correction has worked with everything I have tried. With luma enabled it works with all vids except of the type I have mentioned.
DVDs do not have the problem-these days i just load in avi.NET and encode at default settings to get standalone compatible divx/xvid files or use DVDShrink to get the size down to fit single layer DVD-using error correction. Either way is totally painless.
Vcds tend to have blockiness and color/levels problem-blockiness because of limited bitrate and overbright or overdark to reduce bitrate requirement. DGIndex/DGDecode is excellent at deblocking and decoding. Your filter takes care of color problems with all and levels with most vids painlessly.
The problematic videos are best tackled to my eye by the LUMAYV12 filter built into DGIndex/DGDecode-the lumoff parameter is the most useful.

will try out your suggestion and let you know.
Thanx
__________________
A shut mouth gathers no foot
mgh is offline   Reply With Quote
Old 8th September 2005, 02:28   #27  |  Link
mg262
Clouded
 
mg262's Avatar
 
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
@mgh,

From the last post, I'm not sure whether you've given up on diagnosing the problem. There are some things I was going to say after you had run the tests I suggested... but I may as well say them now. The first is that if you start with a very dark or very bright video, you are effectively using a very low colour depth -- and applying any sort of per-pixel operation, as ColourLike does, will result in artefacts due to the low colour depth. That is not a bug in the filter. Simply applying levels would have resulted in similar problems.

In your case, because the material is compressed using a block by block method, the artefacts that show up most clearly are blocks. Applying a deblocking filter as you have done is the correct approach to this.

Second, the curious feature about this problem is that different decoders are producing different outputs. If I had produced the filter as a standalone program, I think there would be a fair chance that I had included some sort of bug in the output method which accounted for this -- but in this case, almost all the interface work is being done by AVISynth and so I'm more inclined to think that one of your decoders is doing something unexpected. This may simply be a matter of how it is configured -- for example, FFDshow has a built in deblocking filter that can be used on material as it is played back.

Third, it's not difficult to isolate the cause of the difference. The AVI file that you would obtain by using a direct stream copy should be identical to the frameserve output of the AVISynth script. So if you were to generate this file, and find that the difference persisted when opening it in different programs, it would be certain that it was the decoders that caused the difference. You could then try to understand why one of the decoders altered the output... and if I were in your place, I would certainly try to do this as it might be that one of your decoders was altering every file opened on your system (although generally in a way that was less obvious than in this case).
mg262 is offline   Reply With Quote
Old 13th September 2005, 14:53   #28  |  Link
mgh
Registered User
 
Join Date: Oct 2004
Location: India
Posts: 321
Sorry for delay in reply. Have been experimenting. Unable to reproduce problem with the same or other sources. May be some mixup on my part somewhere.
I am now using this as template.xls with dgindex

loadplugin("C:\Program Files\dgindex\DGDecode.dll")
Function correctcolor( clip clp, bool c) {
c==true ?writehistogram(clp,"histo.txt",100):NOP
c==false ?NOP:colourlike("histo.txt","C:\Program Files\dgindex\good.txt",false,true,true)
}
mpeg2source("__vid__",cpu=6)
aud="__aud__"
f=framerate()
f ==29.97 ?separatefields().doubleweave().pulldown(0,2):NOP
w=width()
w==352 ? lanczosresize(352,264):fielddeinterlace().lanczosresize(640,480)
RemoveGrain(mode=12).autocrop(mode=0,wmultof=16,hmultof=16,samples=16,Aspect=0,threshold=50,samplestartframe=0,leftadd=0,rightadd=0,topadd=0,bottomadd=0).aSharp(0.4,0,0).aWarpsharp(3,1,bm=3,cm=0,thresh=0.99)
w==352 ?correctcolor(true):NOP
FFT3DFilter(plane=0,OH=16,OW=16,BH=48,BW=48,BT=3,Sigma=1,Sharpen=1).FFT3DFilter(plane=1,OH=16,OW=16,BH=48,BW=48,BT=3,Sigma=1,Sharpen=1).FFT3DFilter(plane=2,OH=16,OW=16,BH=48,BW=48,BT=3,Sigma=1,Sharpen=1).removedirt()
a=rightstr(aud,3)
b=rightstr(aud,10)
c=leftstr(b,4)
d=value(c)
e=d/1000
a=="ac3" ?audiodub(last,nicac3source(aud,2)).delayaudio(e):NOP
a=="mpa" ?audiodub(last,nicmpasource(aud)).delayaudio(e):NOP
return last

Using it with virtualdub 1.6.10 for both mpgs from vcds and dvd rips.
Best color correction tool for my use especially mpgs from vcds.Generally disable the fft3d line for DVD rips.
Thanx
__________________
A shut mouth gathers no foot
mgh is offline   Reply With Quote
Old 13th September 2005, 16:49   #29  |  Link
mg262
Clouded
 
mg262's Avatar
 
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
As promised, screenshots (the middle column contains the original):



____________

Incidentally, every function in this filter should be compatible with @tsp's multithreading support in mode 1 (fastest mode). (But there's no point in multithreading the histogram writing functions as they do all their work at load time.)

Last edited by mg262; 14th September 2005 at 18:31.
mg262 is offline   Reply With Quote
Old 4th April 2007, 20:47   #30  |  Link
tranfa
Registered User
 
Join Date: Oct 2006
Posts: 68
Is this plugin still available/usable?
tranfa is offline   Reply With Quote
Old 5th April 2007, 17:17   #31  |  Link
ChiDragon
Registered User
 
ChiDragon's Avatar
 
Join Date: Sep 2005
Location: Vancouver
Posts: 600
Huh? The links still work fine...

BTW, I want to thank you for bumping this up, I never knew about it before.
ChiDragon is offline   Reply With Quote
Old 5th April 2007, 18:33   #32  |  Link
tranfa
Registered User
 
Join Date: Oct 2006
Posts: 68
Quote:
Originally Posted by ChiDragon View Post
Huh? The links still work fine...

BTW, I want to thank you for bumping this up, I never knew about it before.
...I get this message:

----------------------------------------------------
Forbidden
You don't have permission to access /mg262/posts/colour/ColourLike_230505.dll on this server.

--------------------------------------------------------------------------------

people.pwf.cam.ac.uk on PWF-HOME3

tranfa is offline   Reply With Quote
Old 5th April 2007, 20:33   #33  |  Link
tranfa
Registered User
 
Join Date: Oct 2006
Posts: 68
Quote:
Originally Posted by tranfa View Post
...I get this message:

----------------------------------------------------
Forbidden
You don't have permission to access /mg262/posts/colour/ColourLike_230505.dll on this server.

--------------------------------------------------------------------------------

people.pwf.cam.ac.uk on PWF-HOME3


Unresolved also downloading from Firefox.

Last edited by tranfa; 5th April 2007 at 20:58.
tranfa is offline   Reply With Quote
Old 5th April 2007, 21:00   #34  |  Link
Alain2
Registered User
 
Join Date: May 2005
Posts: 236
Quote:
Originally Posted by tranfa View Post
Unresolved also downloading from Firefox.
Same for me
Quote:
Forbidden
You don't have permission to access /mg262/posts/colour/ColourLike_25Aug05.dll on this server.

people.pwf.cam.ac.uk on PWF-HOME3
Alain2 is offline   Reply With Quote
Old 5th April 2007, 21:57   #35  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
http://forum.doom9.org/showthread.php?t=118430
Wilbert is offline   Reply With Quote
Old 5th April 2007, 22:27   #36  |  Link
tranfa
Registered User
 
Join Date: Oct 2006
Posts: 68
Quote:
Originally Posted by Wilbert View Post
Thank you Wilbert!!
tranfa is offline   Reply With Quote
Old 6th April 2007, 07:54   #37  |  Link
ChiDragon
Registered User
 
ChiDragon's Avatar
 
Join Date: Sep 2005
Location: Vancouver
Posts: 600
Oh weird, Save Target As saved the 403 error HTML as a .dll file. Thanks Wilbert.

Last edited by ChiDragon; 6th April 2007 at 08:00.
ChiDragon is offline   Reply With Quote
Old 15th July 2012, 21:18   #38  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Updated (some time ago) docs for Colorlike:

Code:
ColourLike:  http://forum.doom9.org/showthread.php?t=96308

by mg262,

Search keywords: colour, color, ColorLike, curve, gamma, levels, channel.

Brief description: Makes a clip look like a 'reference' clip by adjusting each colour channel.

Full description:

  YV12 and it now has RGB32 support.

  It also has a polar-YUV mode, which as its 3 channels has
      1) Y,
      2) Length of the UV-vector (saturation)
      3) Angle of the UV-vector. (hue)
    Currently the angle is not changed by the filter (ie does not change hue).

  Be careful to feed the filter with the right kind of histogram... YUV, RGB and Polar-YUV are three different kinds. 


  Functions:

  
    WriteHistogram(clip,string outputfile, int  "every"=1)
      YV12, RGB32
      Computes histograms for each channel of the clip and stores the results in outputFile.
      If e.g.  every=3 is specified, only every 3rd frame of clip is sampled.
      # Returns original clip (No Constructor)


    #CopyHistogram(string InputFilename, string OutputFilename) 
    #  Copy a histogram ie make duplicate file.
    #  Not Implemented (Implememted in source but commented out) 
    
    
    WritePolarHistogram(clip,string outputfile, int  "every"=1)
      YV12 Only, Emits a "Requires RGB32" message if NOT YV12 ???
      Computes polar histograms for each channel of the clip and stores the results in outputFile.
      If e.g.  every=3 is specified, only every 3rd frame of clip is sampled.
      # Returns original clip (No Constructor)
    
        
    CopyPolarHistogram(string InputFilename, string OutputFilename)
      Copy a Polar histogram ie make duplicate file.
      # Returns 0
    
    
    WriteColourLikeCurve(string OutputFilename, string sourceHistogramFile, string referenceHistogramFile)
      Writes YUV Equalising curves
      # Returns 0
    
    
    ColourLike(clip source,string sourceHistogramFile,string referenceHistogramFile, \
              bool "affectfirst"=true, bool "affectsecond"=true,bool "affectthird"=true)
      YV12, RGB32 
      Takes a clip source and histogram files for this clip and a reference clip, and applies curves to each channel
      chosen, to make source look as much like the reference as possible.
    
      
    PolarColourLike(clip source, string sourceHistogramFile,string referenceHistogramFile, \
           bool "affectfirst"=true, bool "affectsecond"=true,bool "affectthird")
      YV12 Only # RGB32, Not implemented for RGB32 depite error msg saying YV12 & RGB32 only
      Takes a clip source and histogram files for this clip and a reference clip, and applies curves to the clip,
      to make source look as much like the reference as possible.
      affectfirst, affects Y channel
      affectsecond, affects length of the UV-vector (ie SATURATION)
      affectthird, if supplied is IGNORED, (angle of the UV-vector) (ie Does not change HUE)   
      The first true tells the filter to affect luma, and the second true tells it to affect saturation.

  
    ApplyAMP(clip, string CurveFilename)
      YV12, RGB32
      Affects Y channel only for YV12


    SaturationGamma(clip, float gamma, float "fixed"=127.0)
      YV12
      Affects U & V channels Only (applies gamma to length of the UV-vector [SAT])
      Y channel untouched
        I've also added a saturation gamma function. The idea is this. A normal gamma operation can brighten or darken
        midtones while (approximately) leaving highlights and shadows alone. The saturation Gamma can increase or decrease
        the saturation of areas with medium saturation, while leaving greys and very saturated areas alone. 
        The fixed parameter gives a "very saturated" saturation level [measured as a distance from (128,128)] that will
        be left alone by the function... but it will work fine if you leave this number at default.
        The results are (in my view) quite interesting, so do give it a go!
        

----------------

Examples:

  Here are some examples from a case where the same clip is present in (unrelated) DVD and VHS sources.

  First generate the histograms:

  dvd.WriteHistogram("dvd hist 100.txt", 100)
  vhs.WriteHistogram("vhs hist 100.txt", 100)

  Then, say, adjust the VHS to look as much like the DVD as possible:
    vhs.colourlike("vhs hist.txt", "dvd hist.txt")
  or 
    vhs.colourlike("vhs hist.txt", "dvd hist.txt", true, false, false)
      which means: just process Y (respectively R) but ignore U and V (respectively G and B).

  Or adjust the DVD to look as much like the VHS as possible
  dvd.colourlike("dvd hist.txt", "vhs hist.txt")

  Polar:
    dvd
    WritePolarHistogram("dvd polar hist 1.txt", 1)
    vhs
    WritePolarHistogram("vhs polar hist 1.txt", 1)
    
    dvd.polarcolourlike("dvd polar hist 1.txt", "vhs polar hist 1.txt", true, true, true) #last 'true' is ignored

      The first true tells the filter to affect luma, and the second true tells it to affect saturation.
      This should in theory change the brightness, contrast, saturation, etc but not affect hue.
      I haven't found this to be very useful in practice.
      I think a variant which changed hue would be more useful, but this is ill-defined... or more precisely, 
      because hue is represented by a circle rather than a line, there is a whole family of 'hue-equalising' filters...

------------------------------------------------------------------------------------------------
Notes:
  Generating histograms runs at about 75fps on DVD source on my PC (and I think most of that time is MPEG decoding), but
  this still seems slow because the entire file needs to be scanned. As in the example, you can specify quite a large
  value of 'every' without affecting the results too much.

  You only need to generate the histograms once, so you probably want the WriteHistogram calls in a separate AVS to
  ColourLike.

  This filter can be used on completely unrelated clips (which I haven't tried yet); I don't actually think that is a
  particularly meaningful thing to do, so I'm pretty pessimistic about the results -- but if you do happen to try it,
  see what the results look like when you just use it on the Y channel, and also when you just use it on the U&V channels.
  (Use MergeLuma or MergeChroma with source and the output of this filter.)

  For the record, I'm not terribly happy with the results of the filter overall -- as I noted in that other thread, I
  think there is 'crosstalk' between the colour channels that this process does not account for. So I think a proper colour
  matching function will have to use something more sophisticated than channel-curves.

The 'other thread' mentioned is here:
http://forum.doom9.org/showthread.php?t=95574

------------------------------------------------------------------------------------------------------------------------
Above text, mostly words of author mg262, but edited from various posts on doom9 and had some text inserted to either
clarify or denote usage.

Edited by StainlessS, on doom9
Last available source/dll via Wilberts link above:
http://forum.doom9.org/showthread.php?t=118430
__________________
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 1st June 2013, 22:07   #39  |  Link
pila13
Registered User
 
pila13's Avatar
 
Join Date: Mar 2009
Location: Ukraine
Posts: 38
hello, i need help with this plugin, i try to move color setting form original source what in NTSC, in a LQ PAL, i found wathi filter, and at first i thoguht it's working, but.... I just notice this -



And i have no idead how do i fix this ><;, i hope some one can help me, or propose different filter, what do same job what colorlike, but don't have this problems... thank you ~
pila13 is offline   Reply With Quote
Old 1st June 2013, 23:27   #40  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Pila13,

You have only just posted your problem, be patient, there is no need whatever to PM me on the matter.
I dont claim to be any expert on ColorLike, I only gathered together the documentation (quite some time ago).
There are probably people who could give better advise on this.

EDIT: You might also want to consider creating your own thread in the Avisynth Usage section of the forum.
__________________
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; 1st June 2013 at 23:39.
StainlessS 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 15:39.


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