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 11th June 2023, 00:49   #2641  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
Quote:
Originally Posted by tormento View Post
Please, explain me the script with crop+dilation.
The script posted above.

Quote:
Originally Posted by tormento View Post
Isn't inverse kernel supposed to get rid of the upscaling artifacts?
It's a scaling+sharpening convolution so it depends on source artifacts, in this case ringing in borders, and if you sharpen too much ringing around edges as you see. You might want to play with different b and c settings.


EDIT: I tried the FillingBorders() method and still prefer padding. So follow along.

For the ringing you can try two things, apply a milder kernel:
Code:
Crop(2,2,-2,-2)
PadBorders(16,16,16,16,mode="dilate")
fmtc_resample (1280+20, 720+20, kernel="bicubic", a1=0.5, a2=0.0, invks=True)
PadResize(1280,720)
or if it's still too soft, I cobbled up this filter chain to remove the ringing and then some post-sharpening.
Code:
# Crop garbage
Crop(2,2,-2,-2)
# Pad
PadBorders(16,16,16,16,mode="dilate")
a=fmtc_resample (1280+20, 720+20, kernel="bicubic", a1=-0.5, a2=0.25, invks=false)
  fmtc_resample (1280+20, 720+20, kernel="bicubic", a1= 0.5, a2=0.0,  invks=True) # 0.5 for less ringing

# Remove ringing
ex_luts(last,a,mode="clamp",pixels=ex_shape(1),UV=3)
# Final Sharpening
ex_unsharp(0.5,Fc=1920,safe=true)

# Crop Padding
PadResize(1280,720)
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 11th June 2023 at 10:18.
Dogway is offline   Reply With Quote
Old 11th June 2023, 10:57   #2642  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,503
Quote:
Originally Posted by Dogway View Post
The script posted above
Thank you.

I have played a bit and what I called ghosting is indeed ringing.

However, even if you added a deringing part, I still can see it along lines.

I thought it could appear upscaling only but as a matter of fact, it's appearing when downscaling too. Why?

Another question: I thought that I should respect the same parameters of bicubic when downscaling. Isn't it true?


P.S: Could you sort out a way to find native resolution beside using getnative?
__________________
@turment on Telegram

Last edited by tormento; 11th June 2023 at 11:08.
tormento is offline   Reply With Quote
Old 11th June 2023, 17:41   #2643  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,503
P.S: I am having strange issues with nnedi3resize(1920,qual=2), as a very simple

PHP Code:
LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("N:\In\AnoHana\01.dgi")
fmtc_resample (1280720kernel="bicubic"a1=1a2=0invks=True)
nnedi3resize(1920,qual=2
throws me



but a simple propShow() before nnedi3resize shows



So, why is it complaining? Strangely, if I add a propSet("_FieldBased", -1) in the scripts, it works ok.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 12th June 2023, 00:54   #2644  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
Quote:
Originally Posted by tormento View Post
However, even if you added a deringing part, I still can see it along lines.

I thought it could appear upscaling only but as a matter of fact, it's appearing when downscaling too. Why?

Another question: I thought that I should respect the same parameters of bicubic when downscaling. Isn't it true?

P.S: Could you sort out a way to find native resolution beside using getnative?
You mean the script I posted above with the deringing and ex_unsharp(). Sure, any kind of "sharpening" is going to create ringing because the real effect it causes is "acutance". The example was a balanced compromise between sharpness and ringing. If you want absolute zero ringing you should use invks=false, because what that is doing is a deconvolution (reverse convolution), like turning b=1,c=0 into b=0,c=1. At that point you are better off downscaling with no sharpening, but also no blurring, aka "Zopti720" that is b=-1.00,c=0.16.

I started making a sort of getnative function in AviSynth, but dropped it as I'm already in bonus, not up for these kind of mindf* filters like SceneStats and else XD. Just maintenance from now on.
You can make a function though that downscales and also upscales back at the same time with deepresize such as "deepresize(n).deepresize(1/n)" turn "n" into a slider and examine visually.

Quote:
Originally Posted by tormento View Post
P.S: I am having strange issues with nnedi3resize(1920,qual=2), as a very simple

PHP Code:
LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("N:\In\AnoHana\01.dgi")
fmtc_resample (1280720kernel="bicubic"a1=1a2=0invks=True)
nnedi3resize(1920,qual=2
Sorry I didn't know you also wanted to upscale back. Yes that line should work. As you pointed out it's failing because it's somehow labeled as interlaced/telecined ("_FieldBased=1") turn that into 0 and you're fine.

EDIT: New script with nnedi3resize():
Code:
Crop(2,2,-2,-2)
PadBorders(16,16,16,16,mode="fill")
fmtc_resample (1280+20, 720+20, kernel="bicubic", a1=-1.0, a2=0.16, invks=false)
nnedi3resize(1920+32,1080+30,qual=2,sharpness=50)
PadResize(1920,1080)
Increase "c" if you want more sharpness/acutance, until ringing bothers you.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 12th June 2023 at 01:34.
Dogway is offline   Reply With Quote
Old 12th June 2023, 21:30   #2645  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,503
A fix for DGDecodeNV.dll about FieldBased is coming. That will fix the issue with needi3resize.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 13th June 2023, 13:34   #2646  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 702
@Dogway
Really like the unsharpmask_HBD, the threshold param is very useful to bypass sharpening of flat/non detailed areas. Can it be modified though to get rid of the halos/ringing a bit? Any suggestion of how to reduce it?

Edit: oh I just spotted this you posted above:

Quote:
# Remove ringing
ex_luts(last,a,mode="clamp",pixels=ex_shape(1),UV=3)
Maybe this works?

Edit2: no it did not reduce much sadly.

Last edited by anton_foy; 13th June 2023 at 17:10.
anton_foy is offline   Reply With Quote
Old 13th June 2023, 22:15   #2647  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
unsharpmask_HBD is a port of real.finder's UnsharpMask_avsi, so it could work on some functions, I haven't used it at all so I don't know, since then I made my new unsharp mask filer ex_unsharp(), it also has 'thres' and a new mode called 'safe' inspired from CTools to prevent ringing. Try using both.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 13th June 2023, 22:30   #2648  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 702
Quote:
Originally Posted by Dogway View Post
unsharpmask_HBD is a port of real.finder's UnsharpMask_avsi, so it could work on some functions, I haven't used it at all so I don't know, since then I made my new unsharp mask filer ex_unsharp(), it also has 'thres' and a new mode called 'safe' inspired from CTools to prevent ringing. Try using both.
Just lovely I will great! Thanks!

Edit: removed my idiotic question.

Last edited by anton_foy; 14th June 2023 at 09:56.
anton_foy is offline   Reply With Quote
Old 14th June 2023, 00:35   #2649  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,503
The DGIndexNV slipstream to correct the _FieldBased issue is out.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 18th June 2023, 13:28   #2650  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Dogway during my tests to find the sweet spots with mfilter=Expr() for denoising,
I've noticed that on many sources the last row of blocks and last line of blocks looks quite different and very often is completely red.

Here's a galery of some examples, I have many more:
https://abload.de/gallery.php?key=eRBeHu1y

I'm wondering if this is just a problem/bug with the mfilter implementation routine or if the last row and line of blocks really gets filtered differently and in some cases much weaker or not at all.

The first I don't care as I just use mfilter for testing my denoising settings but don't actually use it for filtering. The latter I certainly DO care and would worry me.

-It is not any of my filter settings, because, if it occurs, it occurs with the very default settings also. Like:
Code:
SMDegrain(mfilter=Expr("81","90","250",Scale_inputs="int"))
what I tried to rule out so far:
-It is not a problem of 8 or 16 bit workflow
-It is not a problem of resolution as it can appear on any mod(4) resolution. Tried mod(8) or mod(16) with not much of a difference.
-It is not a problem of improper cropping where there might be a dark line or row left. It can also be seen on modern CGI which fill out a 1080p res just perfectly

Last edited by LeXXuz; 18th June 2023 at 13:30.
LeXXuz is offline   Reply With Quote
Old 18th June 2023, 14:34   #2651  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 1,027
As a workaround it possible to AddBorders before processing and Crop after. I also sometime have completely buggy blocks (arranged in rows, but not complete row) at the last (bottom) rows with 1080 lines frame processing with DX12-ME at GTX1060 and not know where it is come from - simply add 72 samples padding to the bottom and crop after.

Also mvtools Mdegrain not process frame borders not covered with full blocks and simply copy (lines, columns) from source. So to process full active frame area it must be fully covered with blocks. Padding with MSuper not helps.

So may be you use too large block size and frame width/height can not be fully covered. mvtools not add blocks overlapping frame borders (into padded by MSuper area - it is mostly reserved for motion compensation when MV points to the block position outside real frame area and not too out of frame).

Last edited by DTL; 18th June 2023 at 14:37.
DTL is offline   Reply With Quote
Old 19th June 2023, 09:53   #2652  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Quote:
Originally Posted by DTL View Post
As a workaround it possible to AddBorders before processing and Crop after.
It's really an odd issue. Good idea with the extra padding though.

Take this clip for example. This is the uncropped 1080p source (1920x1080):


Looks like mvtools doesn't mind the small letterbox borders here.
But it has a problem with the 1920 width here, although it is perfectly divisible by 32,16,8,4,2 of course.
It does not mind that the default 1080p resolution is not divisible by 32 or 16. I process it with the default blocksize of 16 for HD.

Correctly cropping 22 lines of the image at the top and the bottom, resulting in a 1920x1036 resolution, it now DOES mind the source's hight is now additionaly not divisible by 8, showing a red block row at the bottom:


And now it gets really weird. By adding just 2 black lines at the bottom and 2 black rows at the right, creating an unusual resolution of 1922x1038, which now is only divisible by 2, shows only full red (or unprocessed) on the recently added areas while the source picture now seems to be processed correctly:


And of course after cropping out those extra 2 lines and rows, finally the picture looks as it should have been in the first place:


I don't get it. And it's nothing Dogway can do about with SMDegrain if it also happens by using mvtools directly, like you said.
Proofs once more mvtools needs some overhaul. Until then, I have to live with yet another workaround, I guess. Again, thanks for the padding tip DTL.

Last edited by LeXXuz; 19th June 2023 at 11:13.
LeXXuz is offline   Reply With Quote
Old 19th June 2023, 10:36   #2653  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 1,027
Also the edge of frame rows and columns of blocks are not completely processed with overlapping (up to blksize/2). For example in versions up to 2.7.45 top row have only horizontal overlap and half vertical (from next row below). In post-2.7.45 in 2x 'diagonal' overlap mode the top blocks row do not have even horizontal overlap at the upper half of block.
To fix it the more padding can be added (so that active frame area will be surrounded with at least 1/2 of blocksize) and all active frame area will be covered with overlapped blocks.

" it's nothing Dogway can do about with SMDegrain"

Required padding can be calculated in scripting from input frame size and block size and added in the library script and cropped after MDegrain. It will make processing somehow slower because of more blocks to process so may be optional function switch.

Last edited by DTL; 19th June 2023 at 10:42.
DTL is offline   Reply With Quote
Old 19th June 2023, 11:12   #2654  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Quote:
Originally Posted by DTL View Post
To fix it the more padding can be added (so that active frame area will be surrounded with at least 1/2 of blocksize) and all active frame area will be covered with overlapped blocks.
Yes, totally forgot about block overlapping. So best way to play it safe would be to first have a resolution divisible by blocksize and then add a padding 'frame' of 1/2 of blocksize around the image?

In which direction does the block overlapping actually occur?
Since I never noticed that problem with the very first line and row of blocks, only the very last ones, I imagined overlapping goes to the right and to the bottom. Which then would mean it'll be enough to pad just 1/2 of blocksize to the right and bottom of the clip.

Or does it go into all four directions (left, top, right, bottom)?
LeXXuz is offline   Reply With Quote
Old 19th June 2023, 11:47   #2655  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 1,027
"In which direction does the block overlapping actually occur?"

Second row of blocks is shifted to the right and bottom. Main blocks scan is from left to right and from top to bottom (the MAnalyse have zigzag/meander scan and some new MDegrain in post-2.7.45 too in attempt to reuse near cached data). Though the last (right most) block in shifted row may be skipped (?). Also last row from the bottom may be skipped - need to look in the sources and attempt to understand later.

" best way to play it safe would be to first have a resolution divisible by blocksize and then add a padding 'frame' of 1/2 of blocksize around the image?"

Yes - may be close to this.

"Or does it go into all four directions (left, top, right, bottom)?"

Overlapping _not_ cover (completely) _all_ edges of _covered_by_blocks frame area. So if not all frame area covered by blocks - the 'full' overlap is cover even less.

Overlapping weight function have special cases for 'internal frame blocks' (full overlap processing) and all edges and corners cases (left,top,right,bottom and all 4 corners). So to have all active frame area covered with 'full overlap' it is required to add padding to all 4 frame edges (at least to 1/2 block size if the overlap=blocksize/2 used - max overlap) and to have frame size divisible to block size. Or simply try to add 'big' padding like 2 block size to all edges - it may be also cause covering of active frame area with blocks and with full overlap and all special edge/corners cases will be moved to outside of active frame area zones.

Last edited by DTL; 19th June 2023 at 11:50.
DTL is offline   Reply With Quote
Old 19th June 2023, 12:30   #2656  |  Link
LeXXuz
21 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 716
Quote:
Originally Posted by DTL View Post
So to have all active frame area covered with 'full overlap' it is required to add padding to all 4 frame edges (at least to 1/2 block size if the overlap=blocksize/2 used - max overlap) and to have frame size divisible to block size.
Okay, sold. I'll just make sure the resolution is divisible by blocksize and add a border of 16 black pixels around the clip to play it extra safe. I don't care about additional processing time. Thx again.
LeXXuz is offline   Reply With Quote
Old 23rd June 2023, 14:21   #2657  |  Link
salvo00786
Registered User
 
Join Date: Feb 2022
Posts: 19
Hi Guys... A question for you. What is the difference between CAS ans CASm? What is better between these two?
salvo00786 is offline   Reply With Quote
Old 24th June 2023, 08:12   #2658  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
Quote:
Originally Posted by salvo00786 View Post
Hi Guys... A question for you. What is the difference between CAS ans CASm? What is better between these two?
Well the CASm description says it all. An "improvement" over CAS, whether you find an improvement or not you have to test.
CAS as you know is AMD's Contrast Adaptive Sharpening, and Asd-g ported it to a plugin. Then you have CAS+ also inside SharpenersPack, it's my port of CAS to a function, just a tiny bit slower than the plugin.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 24th June 2023, 10:14   #2659  |  Link
salvo00786
Registered User
 
Join Date: Feb 2022
Posts: 19
Hi... thanks for you reply, but where I can find the description for CASm? I tried to search for CASm before asking, but I haven't found anything?
salvo00786 is offline   Reply With Quote
Old 24th June 2023, 11:37   #2660  |  Link
FTLOY
Friend of a friend..
 
FTLOY's Avatar
 
Join Date: Feb 2023
Posts: 128
Quote:
Originally Posted by salvo00786 View Post
Hi... thanks for you reply, but where I can find the description for CASm? I tried to search for CASm before asking, but I haven't found anything?
https://github.com/Dogway/Avisynth-S...ack.avsi#L3064
FTLOY is offline   Reply With Quote
Reply

Tags
avisynth, dogway, filters, hbd, packs

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 09:20.


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