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 5th January 2013, 05:57   #1  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,368
Brightness and/or Gamma difference calculation

I ran into this after a scare concerning the North American Blu-ray release of K-ON!! The actual scare ended up being for naught, since I pretty much whittled it down to my TV's noise reduction settings somehow having gone out of whack, but in trying to find an answer for it I stumbled upon this blog post:
http://konfan.blogspot.com/2012/06/k-on-season-2-blu-ray-us-vs-jp-review.html

Toward the bottom, it compares the quality of the Japanese and North American discs (and seeing it there is what reassured me that there wasn't some horrible Warpsharping that'd been done to it). The screenshots illustrate that the North American release is brighter, for instance in this example:
http://img546.imageshack.us/img546/6882/jpscreen05.png
http://img225.imageshack.us/img225/9672/usscreen05.png



So hypothetically, if one wanted to adjust the brightness back down to match what you find in the screenshot from the Japanese release, how would you go about calculating the difference, and is there any specially-targeted filter for AviSynth that can do this or is it just using the Levels or Tweak filter and plugging in the right adjustment values (which goes back to somehow calculating the difference)?

It's not that I can't just play it by eye when messing with those filters, but I'd prefer being able to do it a bit more programmatically.
qyot27 is offline   Reply With Quote
Old 5th January 2013, 09:46   #2  |  Link
Mounir
Registered User
 
Join Date: Nov 2006
Posts: 761
yes ylevels can (work on luma only) ex: ylevels(0,1.000,255,0,255)

Try(0,0.850,255,0,255) but i haven't checked

more infos:
http://avisynth.org/mediawiki/Ylevels
Mounir is offline   Reply With Quote
Old 5th January 2013, 12:38   #3  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,368
Quote:
Originally Posted by Mounir View Post
yes ylevels can (work on luma only) ex: ylevels(0,1.000,255,0,255)

Try(0,0.850,255,0,255) but i haven't checked

more infos:
http://avisynth.org/mediawiki/Ylevels
0.900 actually comes a lot closer than 0.850, but that doesn't answer the question I was really asking.

Is there a tool that could take those two example screenshots, compute the difference between them, plot them on a scale between true black and true white (or whatever makes sense in the context of the luma or chroma), and then return either the plot results or the subtracted value between the two clips' plot positions?

In limited tests, it appears that Histogram() can kind of get there: it can display a plot, and what I'm hoping to do is calculate the value by which clip B (the US screenshot) was moved and/or compressed in comparison to clip A (the Japanese screenshot). See below.

The histogram for the original:


For the US:





While I found that 0.900 gets really really close to the original level of brightness (and the resultant histogram also looks very similar to the original, albeit obviously not exact), my point was that I wanted to be able to get a figure without having to assess the filtered results visually, at least not at first. A method that can be applied to any arbitrary video where I have comparison screenshots. Doing it this way also potentially means more fine-grained values that are more absolute instead of rounded ones that are easier for ballpark estimates (and human error).

Last edited by qyot27; 5th January 2013 at 12:48.
qyot27 is offline   Reply With Quote
Old 5th January 2013, 14:32   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,436
ColorLike() might be worth a look
http://forum.doom9.org/showthread.ph...ight=colorlike
__________________
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 5th January 2013, 16:11   #5  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,393
An exact match is somewhat unlikely anyway. You don't know the processing chain in which the difference was caused. If the difference stems from a processing chain in RGB or HSV, then you can do YUV-processing 'til you get blue in the face, but the matching will never be exact.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 5th January 2013, 16:28   #6  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,368
Quote:
Originally Posted by StainlessS View Post
It does seem to match what I'm looking for, but my attempts at getting it to write a histogram file are resulting in "Avisynth: stack overflow" errors. Maybe because I'm using 2.6? I tried with both the 25Aug05 build and neuron2's build.

Quote:
Originally Posted by Didée
An exact match is somewhat unlikely anyway. You don't know the processing chain in which the difference was caused. If the difference stems from a processing chain in RGB or HSV, then you can do YUV-processing 'til you get blue in the face, but the matching will never be exact.
I was afraid it might come down to something like this in how any prior processing might've messed with it. I'm comfortable with sacrificing exactness so long as it can get reasonably close, though.




Now, whether what I describe is at all close to a 'proper' way of doing this, I don't know. But taking those histograms I posted earlier, I took the position of one of the features in the original - the long line - close to the center, and got its x pixel value (it makes it nice that Histogram() outputs a chart that's 256 pixels wide), and since the position of that same feature in the US screenshot is almost dead-center, I just divided the original's position by 128 to get the value of its percentage from center. 0.90625. As I mentioned earlier, turning the US screenshot's value down to 0.900 got it really really close to the original, so that process seems to make sense in how to go about ascertaining a value to shoot for when doing a correction like this.

Last edited by qyot27; 5th January 2013 at 16:45.
qyot27 is offline   Reply With Quote
Old 5th January 2013, 17:16   #7  |  Link
zee944
Registered User
 
Join Date: Apr 2007
Posts: 240
I know exactly what do you want. That's what I wanted a few years back

For the closest match, you should apply a customized luma curve (an .amp file) to your video with GiCoCu(). The problematic part is to find out how the optimal luma curve should look like. You'd have to do pixel to pixel comparsion of the frames for that. Which of course never works, because the geometry never matches. You'd have to this smartly, with threshhold, throwing away the statistically extreme values, averaging etc. I don't know any plugin which can do that. A simpler way is to calculate out by comparing histograms, which is less accurate, but might work, and there's a HistogramAdjust plugin for that too - I've never used it.

You should read this:
http://forum.doom9.org/showthread.php?t=153196

The easiest way is to measure the average luma of both frames (with the runtime functions like LumaDifference, AverageLuma etc.) and tweak the video accordingly, but it's way simpler than what you wanted. However, your two sources seem quite close to each other, like they have a close common print they were both originated from. If a simple Tweak() or Levels() gives you a 95% match and it is consistent throughout the whole video, it really doesn't worth to think about the more complicated methods. They're imperfect too, because of what Didée was saying: you can't reverse the result of a processing chain in one step. And if you'd be willing to do more steps, you don't know what they were...
zee944 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 17:57.


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