Log in

View Full Version : Color, RGB levels, & gamma adjustment via matched frames


Mark Regalo
6th September 2011, 05:58
I have 2 different frames of the same frame. One frame has accurate colors, RGB levels, and gamma v.s. the actual video that is severely messed up.

Is there a filter or method via photoshop that I can use to find adjustment values that will match one frame with the mentioned metrics of another?

In my situation I have a bluray source of a movie that is very pale, sickly, and green looking while the posters of some of the same exact frames from the movie look pristine in terms of colors, RGB levels and gamma and I want to computationally measure the difference and apply it via AviSynth somehow.

The only problem I can see in this approach is some cropping and resolution differences between both frames but I think that since a part of the frame is exactly the same (if resized 1:1) then it should be ok to match?

jmac698
6th September 2011, 08:53
I've made a script for this exact problem. It's called findtweak. It's listed in the Development forum. It finds brightness and contrast values which would match two sources. Despite being beta it does work; it's only corner cases which will confuse it. You can do even better though, using histogram matching. This is implemented in the colorlike plugin. It works frame by frame though, but there's probably a way to apply the same adjustment from one frame to the entire movie. If not, then this is a good reason to update my script to adjust colors and gamma as well :)

I've tried this on different sources and there's some problems; differences in geometry (but you say you've photoshopped them 1:1 - that can be automated btw), differences in color (and the adjustment can create banding), differences in sharpness, differences in noise.

But in your case, the colors should be able to be fixed though you might need some debanding. You can also try to adjust it by hand, the users sliders feature in avsmod would help adjust a tweak command. I've also seen DVDs that had the wrong colorspace; greenish might mean rec601 values were being displayed as rec709.

Mark Regalo
7th September 2011, 00:34
@jmac698

It is actually a bluray disc and I just so happened to come across a couple of movie posters from the same movie on Google Images that shows some of the same frames. I'm not sure if it is allowed to upload a small m2ts cut from the bd which includes some of those scenes. I personally think working on a script that can automatically analyze the color, RGB levels, brightness, contrast and gamma differences between two frames of the same scene can turn out to be very useful for a wide span of situations. I'm eager to work on something like this and I also have some basic AviSynth programming which may be of assistance to you, if needed. Thanks!

jmac698
7th September 2011, 00:59
You are right, it's very useful. I wrote it to help someone match a dvd to a laserdisc version, where the laser version showed more of the picture. However, even matching them well, the DVD version was so much sharper you could see the transition. Even blurring the borderline wouldn't help; it would still be out of focus in some areas. Anyhow my script is at http://forum.doom9.org/showthread.php?t=161960.
You can help if you can if you can think of an algorithm. Ideallly we'd compare the exact pixels at different brightness, and with about 3 different values I think you can find gamma, contrast, and brightness. But in real life we can't do that, unless we can correspond two pixels spatially. Hence I was planning to use mvtools to find the zoom and translation between the two pictures. But even then, if they differ by sharpness, you certainly can't rely on individual pixels, certainly not if there's been zooming! So we need either patches of constant color in the picture, or to rely on histograms. So how to compare two histograms, and find a formula to match them closely, based on the possibilities of brightness, contrast, and gamma? And also to get a fitness measurement, so you know that this model is working well for these pictures. Then there is the problem of clipping in either picture, and getting the maximum accuracy. If (25-60)->(10,45) that's a brightness of -10 so you can't use those comparisons. There is one more possibility, that a log scale was used, for example for a film effect. That's something I especially want to do, for example I have a film frame of a scene shot locallly, and a picture of the same scene, I want to derive the film look used.
Anyhow just a few thoughts off my head, think about it for a while.

Revgen
11th September 2011, 07:41
^There's a thread over at OT where a guy posts an intriguing whitepaper and some MATLAB code. I have abosolutely no idea how to use Matlab and the whitepaper is greek to me. Maybe you can figure it out. He's says that it's better than Colourlike.

http://originaltrilogy.com/forum/topic.cfm/Colour-matching-for-fan-edits/topic/7257/

Yellow_
11th September 2011, 10:45
Would either of these approachs / plugins fix a source where every so many frames the exposure slowly drops and back up again? It was caused by a camera firmware problem that the exposure would just drop a little, this has nothing to do with auto exposure, the camera is fully manual.

I'll try to find a short clip to illustrate.

jmac698
12th September 2011, 14:49
There's already plugins for that, but under a different guise.
http://home.arcor.de/kassandro/ReduceFlicker/ReduceFlicker.htm
antiflicker
etc.
Search under old film restoration.

And thanks for that paper, I'll check it out.

Ok I think I've read that one before, will have to implement someday :)

I've been working on some aspects of clip matching, I can see that that board would get a lot of interest in my techniques.

And I just realized that antiflicker techniques are actually similar to histogram matching, they can actually be considered as a recoloring to a different brightness.

Mark Regalo
15th September 2011, 21:57
Any luck jmac698?