View Single Post
Old 23rd June 2005, 17:23   #1  |  Link
mg262
Clouded
 
mg262's Avatar
 
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
Filter: ColourLike

This was mentioned in a recent thread -- thanks to @communist + everyone else who fed me with ideas, pointers & encouragement.
___________________________________________

ColourLike

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

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

Full description:

WriteHistogram(clip, string outputFile, int every = 1) - computes histograms for each channel of the YV12 clip and stores the results in outputFile. If e.g. every=3 is specified, only every 3rd frame of clip is sampled.

ColourLike(clip source, string sourceHistogramFile, string referenceHistogramFile) - takes a YV12 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.

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 adjust the DVD to look as much like the VHS as possible
dvd.colourlike("dvd hist.txt", "vhs hist.txt")

Here are some screenshot showing the results of both of the above, in the following format:



i.e. the top two pictures are original and the bottom two have been passed through the filter; bottom left is the DVD passed through a curve chosen to make it look as much like the VHS as possible, etc.

YUV colour space


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.
mg262 is offline   Reply With Quote