This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[HELP] AviSynth 32 bit - ColorMatrix filter not working for video?
#22
Yeah, this is really a headache.

So again, the reason I'm using ColorMatrix 709->601 is because I process a DVD source with another program that shifts the color matrix to 709, so the colors look off. I take the result (which is an image stream) and when processing through Hybrid for final scaling/sharpening/etc., I use the ColorMatrix 709->601 to shift the color matrix back, so that the colors match the source DVD.

In Hybrid 2020.11.03.1 (and 2020.10.28.1), the ColorMatrix filter doesn't do anything, so the colors don't get shifted back.

HOWEVER, what I think is probably what I SHOULD be doing instead of using (probably mis-using Tongue ) the ColorMatrix filter, is simply opening the image stream like this:

[Image: naiaa0v.png]

Now, the Avisynth script has convert lines like ConvertToYV12(matrix="Rec601").

This appears to get the colors to match the source DVD MUCH MORE precisely than ColorMatrix. And it WORKS in Hybrid 2020.11.03.1. Tongue

The test image I was using above is not a good test image. It's just for an example, and is not even from a video source... it's an Adobe test image that shipped with Photoshop 3.0 in the mid 1990's! Tongue

Here's a GIF! The first frame is taken direct from the DVD, and is upscaled in IrfanView (Lanczos). The second frame is after it's been processed with Topaz Video Enhance AI, which upscales it using machine learning. Looks good! But, the colors are shifted, as you can see:

[Image: 3RNfcSf.gif]

It took me a while to figure out what was going on. At first I assumed it's just the way the "machine learning" works and is trying to do some kind of color correction. But after trial-and-error investigation, I found that what actually appears to be going on is that the color matrix is getting converted from Rec.601 to Rec.709. Sometimes it can actually look a bit better. But sometimes it doesn't look good. In either case, it's not correct to the source DVD. Topaz VEAI has been like this for quite some time, and it happens when it outputs RGB24 PNG image streams.

So before, I was trying to fix this by using ColorMatrix.

But, if just simply open the image stream with bt470bg selected for color matrix (instead of bt709 which is what I was doing before), I get this script:

ClearAutoloadDirs()
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ImageSeq.dll")
# loading source: E:/USER/fin/Kaiji/wip/Episode 01/032370.png
#  color sampling RGB24@8, matrix: bt470, scantyp: progressive, luminance scale: limited
ImageReader(file="E:\USER\fin\Kaiji\wip\EPB7DA~1\032370.png", end=100, fps=23.976, use_DeviL=true, pixel_type="RGB24")
# current resolution: 1440x960
# filtering
# color modifications
Levels(0,1.02,255,0,255)
# adjust color to YV12 (color matrix: Rec601)
ConvertToYV12(matrix="Rec601")
PreFetch(4)
# setting output fps to 23.976fps
AssumeFPS(24000,1001)
#  output: color sampling YV12@8, matrix: bt470, scantyp: progressive, luminance scale: limited
return last

(Side note: Topaz VEAI slightly lowers the gamma; that's why I've bumped it up to 1.02 in Levels. In the above GIF, I bumped the gamma up on the Topaz VEAI result to only show the color matrix shift.)

So now, with ConvertToYV12(matrix="Rec601") in the script (instead of ConvertToYUY2(interlaced=false, matrix="Rec709") and ColorMatrix(mode="Rec.709->Rec.601")), the output much better matches the source DVD:

[Image: HPkzY3z.gif]

I'm not sure if ColorMatrix is supposed to give results like the above. I would think, intuitively, that it should. But maybe I'm misusing it... I'm not sure if it's really designed to go from Rec.709->Rec.601, even though it can be set like that. It does nothing in Hybrid 2020.10.28.1 and 2020.11.03.1, and I don't think that's correct behavior; it should probably be fixed at some point. I probably won't be using ColorMatrix anymore, so that means no more giant posts from me about it, which I'm sure is a relief. Big Grin




By the way, in case you (or anyone) finds it useful, here's the DVD source frame, and the Topaz VEAI frame (gamma bumped up to 1.02) shown above.

[attachment=1124]
Reply


Messages In This Thread
RE: AviSynth 32 bit - ColorMatrix filter not working for video? - by The_Tinkerer - 03.11.2020, 14:05

Forum Jump:


Users browsing this thread: 3 Guest(s)