View Full Version : What is correct difference between clips?
george84
15th September 2017, 06:38
import vapoursynth as vs
core = vs.get_core()
clipsRGB = core.imwrif.Read("C:/Users/Walter/Documents/SMIL/BSG23/testsuite/OLED/vapoursynth/colorcheckerchart4k.tif", firstnum=0, mismatch=False, alpha=False)
clipsRGB = clipsRGB.text.ClipInfo()
clipRec2020 = core.imwrif.Read("C:/Users/Walter/Documents/SMIL/BSG23/testsuite/OLED/vapoursynth/colorcheckerchart4k.tif", firstnum=0, mismatch=False, alpha=False)
clipsRGB = core.resize.Bicubic(clipsRGB, format=vs.RGBS)
clipRec2020 = core.resize.Bicubic(clipRec2020, format=vs.RGBS)
d = core.std.MakeDiff(clipsRGB, clipRec2020)
d.set_output()
This code makes difference between identical clips.
Expected output is black, and that's what I get.
Now replace format with format=vs.YUV420P10, matrix_s="709")
What do you get? Grey!
Why? Is this correct?
poisondeathray
15th September 2017, 15:58
Where did you replace it? Post the full script
You should at least get chroma subsampling differences when using bicubic and YUV420P10
Myrsloik
15th September 2017, 17:42
This code makes difference between identical clips.
Expected output is black, and that's what I get.
Now replace format with
What do you get? Grey!
Why? Is this correct?
It's simple. Since integer formats can only store a limited range difference +-half the makediff output is biased around the middle value. Gray.
Float formats can represent any difference so no offset is added => black.
george84
16th September 2017, 14:43
It's simple. Since integer formats can only store a limited range difference +-half the makediff output is biased around the middle value. Gray.
Thank you for comment. After further study I find the best explanation in avisynth doku
mt_makediff subtracts two clips; equivalent to mt_lutxy("x y - 128 +"), but faster.
No need to explain it with limited integer range. As a side effect I learned the meaning of "lut".
So to visually represent differences between almost identical clips, the makediff should probably be followed by a Levels as in thread " What is wrong with this YUV => RGB => YUV roundtrip ? ".
poisondeathray
16th September 2017, 15:57
So to visually represent differences between almost identical clips, the makediff should probably be followed by a Levels as in thread " What is wrong with this YUV => RGB => YUV roundtrip ? ".
Yes. Sometimes there are "microscopic" differences that you can't see very well
Adding levels or other manipulations to enhance contrast makes it "easier" to see. da="amplified difference" in that example. There are other ways like increasing gamma - that's how it's typically done in other programs (except they typically don't use the offset like masktools by default). Since that was a 10bit example, "middle grey" was centered at 512 on a 0-1023 scale .
da = core.std.Levels(d, min_in=511, max_in=513, gamma=1, min_out=0, max_out=1023, planes=[0,1,2])
george84
17th September 2017, 07:29
After further tests I find the vapoursynth implementation of MakeDiff quite strange.
Strange implementation of MakeDiff
If a clip has a floating format representation then difference between same colors is black.
If a clip has an integer format representation then difference between same colors is grey.
I see no reason for this. It only confuses users. Why doesn't it conform to original specs as used in avisynth.
I mean the difference between vs.RGBS clip and a vs.RGB24 clip is only its internal representation, but in one case the difference between identical reds is black in other case it is grey.
Documentation makes even no mention of this and one has to check the source code.
Myrsloik
17th September 2017, 20:54
A difference is not a colorspace. Basically that's the answer. It's a big pile of mathematical nonsense you're showing there. The bias is added so it will make a tiny bit more sense when viewed.
It's not a strange implementation at all. It is identical to mt_makediff for integer formats and mt_makediff didn't even support float in avisynth when this was implemented.
george84
17th September 2017, 21:38
The bias is added ... more sense
So why is there no bias for float?
Myrsloik
17th September 2017, 21:39
So why is there no bias for float?
It isn't needed
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.