![]() |
[HELP] AviSynth 32 bit - ColorMatrix filter not working for video? - Printable Version +- Selur's Little Message Board (https://forum.selur.net) +-- Forum: Hybrid - Support (https://forum.selur.net/forum-1.html) +--- Forum: Problems & Questions (https://forum.selur.net/forum-3.html) +--- Thread: [HELP] AviSynth 32 bit - ColorMatrix filter not working for video? (/thread-1569.html) |
RE: AviSynth 32 bit - ColorMatrix filter not working for video? - Selur - 03.11.2020 Okay, to many things to look at. I can't keep the overview. + don't have much time this week. So let's first stick to preview only, Vapoursynth and the current version. (Vapoursynth since, the code is a bit easier there.) First think I noticed when looking at the image: - It's not limited luma range! It's 28-255, so full range. - so using ColorMatrix while clamping the colors on input and output to 16-235 will cause color changes. So whatever created the video stream didn't properly flag the input and might have messed up the colors during the rgb->yuv444 conversion. Opening the image with Luma range PC and Color Matric bt709 and then opening the normal preview with FFvHuFF and Color space rgb select uses the following script for preview: # Imports enabling ColorMatrix with 'Rec.601/..' to 'Rec.709' and Clipping set to 'no clipping' uses: # Imports now using the FilterPreview: # Imports Send you a link to my latest version, which should fix the 'unnkown color format' problem. (btw. you can check the preview script in your temp folder while the Preview is open) Cu Selur RE: AviSynth 32 bit - ColorMatrix filter not working for video? - The_Tinkerer - 03.11.2020 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 ![]() ![]() 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. ![]() 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! ![]() 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: ![]() 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() (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: ![]() 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. ![]() 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] RE: AviSynth 32 bit - ColorMatrix filter not working for video? - Selur - 03.11.2020 There's a difference between a mislabed source and that ColorMatrix does when 709->601 is selected,... If your source is just mislabel simply using the right color matrix on import is the correct way to go. Also the Topaz output doesn't look impressive. That looks doesn't look better than "Waifu2x nvk" (Vapoursynth resizer) + aWarpSharp2 and some color change. Cu Selur |