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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th April 2024, 00:21   #1  |  Link
simple_simon
Registered User
 
Join Date: Feb 2003
Posts: 106
Fix distorted aliasing from bad upscales

Is there any way to reverse this?: https://ibb.co/G5kXwBz
It looks like the video was badly upsized from 480p to 1080p without correcting the existing line aliasing so now the aliasing is stretched and impossible to fix with normal dealiasing filters. I came up with this filter chain:

Code:
propSet("_FieldBased",0).deep_resize(720,240,grain=0,qual=2,gpuid=-1,show=false)
maa2()
deep_resize(720,480,grain=0,qual=2,gpuid=-1,show=false)
maa2()
lsfplus(strength=40,preset="slow",preblur="neo_fft3d(sigma=4,u=2,v=2)")
deep_resize(960,720,grain=0,qual=2,gpuid=-1,show=false)
which works decently but figured I'd crowdsource and see if there a better solution I'm unaware of.
simple_simon is offline   Reply With Quote
Old 17th April 2024, 02:08   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Downscale, perhaps using an inverse kernel / desampler, then use 1x_AnimeUndeint_Compact_130k_net_g, then upscale. Adjust to taste.

I fiddled a bit with a height below 480 which seemed helped better with some aliasing artifacts, you can play with that and other kernels as well. FMTC has inverse kernels too

https://imgsli.com/MjU2Mjcx

Code:
ImageSource("snapshot-02-39-411.png")
propSet("_FieldBased",0)
DeBicubicResizeMT(720,400, accuracy=2)
ConvertToPlanarRGB()
z_convertformat(pixel_type="RGBPS", use_props=0)
mlrt_ncnn(network_path="PATH\1x_AnimeUndeint_Compact_130k_net_g.onnx", builtin=false)
mlrt_ncnn(network_path="PATH\2X_DigitalFilmV5_Lite.onnx", builtin=false)
z_convertformat(width=1440, height=1080, use_props=0)
The pavement is slightly less red from one of the models. When you convert it back to YUV, smoothtweak(hue2=1) will make it more like the original
poisondeathray is offline   Reply With Quote
Old 17th April 2024, 03:52   #3  |  Link
simple_simon
Registered User
 
Join Date: Feb 2003
Posts: 106
Those are a bunch of tools I'm not familiar with so it'll take me some time to play around with that (I don't even have a need to convert colorspace enough to know offhand how to convert back to YUV). But the results are damn impressive. Thanks for the suggestions.
simple_simon is offline   Reply With Quote
Old 17th April 2024, 20:21   #4  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,545
Wow PDR, that is impressive.
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."
Emulgator is offline   Reply With Quote
Old 17th April 2024, 21:02   #5  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by simple_simon View Post
Those are a bunch of tools I'm not familiar with so it'll take me some time to play around with that (I don't even have a need to convert colorspace enough to know offhand how to convert back to YUV). But the results are damn impressive. Thanks for the suggestions.


What I mean is the models work in 32bit RGB float (the mlrt_ncnn steps). But usually people encode to 8 or 10bit 4:2:0 YUV (but some people use 4:4:4 when models are used because some of them sharpen the chroma significantly)

The output of the script as-is before the last line is 1440x800 because the downscale was 720x400, then a 2x model was applied

The last line resamples to 1440x1080 (to compare to same as input dimensions) . If you wanted 8bit 4:2:0 , you can add pixel_type="YV12" or whatever format you're encoding to .

Models are slow - you you could use deep_resize instead like you did before instead of 2X_DigitalFilmV5_Lite - whatever you feel like . Most of the problem fixing for the aliasing is from 1x_AnimeUndeint_Compact_130k_net_g on a downscaled input . It's really good model for anime or cartoon type aliasing issues

Before commiting to the Smoothtweak adjustment, I would examine other frames with other colors as well. Look at histogram("levels") and compare the U,V channels

Code:
z_convertformat(width=1440, height=1080, pixel_type="YV12", use_props=0)
Smoothtweak(hue2=1)

If you're stuck and can't find the answers just ask and someone will help out
poisondeathray is offline   Reply With Quote
Old 17th April 2024, 23:04   #6  |  Link
lollo2
Registered User
 
lollo2's Avatar
 
Join Date: Aug 2017
Location: Italy
Posts: 115
Quote:
Originally Posted by poisondeathray View Post
Downscale, perhaps using an inverse kernel / desampler, then use 1x_AnimeUndeint_Compact_130k_net_g, then upscale. Adjust to taste.

I fiddled a bit with a height below 480 which seemed helped better with some aliasing artifacts, you can play with that and other kernels as well. FMTC has inverse kernels too

https://imgsli.com/MjU2Mjcx
Excellent result, master!
__________________
A channel on S-VHS / VHS capture and AviSynth restoration https://www.youtube.com/channel/UCMs...h1MmNAs7I8nu4g
lollo2 is offline   Reply With Quote
Old Yesterday, 10:24   #7  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,580
Quote:
Originally Posted by poisondeathray View Post
ImageSource("snapshot-02-39-411.png")
propSet("_FieldBased",0)
DeBicubicResizeMT(720,400, accuracy=2)
ConvertToPlanarRGB()
z_convertformat(pixel_type="RGBPS", use_props=0)
mlrt_ncnn(network_path="PATH\1x_AnimeUndeint_Compact_130k_net_g.onnx", builtin=false)
mlrt_ncnn(network_path="PATH\2X_DigitalFilmV5_Lite.onnx", builtin=false)
z_convertformat(width=1440, height=1080, use_props=0)
Can AVSLibPlacebo or FMTC replace the 2 z_convertformat instructions?
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old Yesterday, 12:17   #8  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 1,070
You can even try internal and eveready ConvertBits(32) to go into 32bits float RGB.
DTL is offline   Reply With Quote
Old Yesterday, 13:14   #9  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,580
Quote:
Originally Posted by dtl View Post
you can even try internal and eveready convertbits(32) to go into 32bits float rgb.
rgb=rgbps?
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old Yesterday, 14:48   #10  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 1,070
RGB with 32bit (float) per sample is RGBPS. AVS do not support integer 32bit samples so ConvertBits(32) can only convert to float.

So you first convert to Planar RGB and next convert any sample format to float32. Typically RGB float32 is the only common format accepted by 'neural-networks' libraries as most fail safe and most dynamic range capable. It is not optimized for performance but easy to implement by current very poor residuals of opensource developers.

The last z_convertformat(width=1440, height=1080, use_props=0) do not change sample format and only resize so you again can use any internal resize (or any other installed).

To go back to some usable by encoders you anyway need to add something like ConvertToYV12() or if it can not make direct convert from float32 - ConvertBits(8).ConvertToYV12()

See example how to feed that NN-plugins with RGBPS format with internal conversions and back - https://forum.doom9.org/showthread.p...55#post1983255

Last edited by DTL; Yesterday at 14:55.
DTL is offline   Reply With Quote
Reply


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 07:41.


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