Hello guest, if you like this forum, why don't you register? https://fanrestore.com/member.php?action=register (December 14, 2021) x


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AviSynth Deblur (A Simple Sharpening Script)
#1
DEBLUR
Quick and dirty sharpening.
REQUIREMENTS
fft3dfilter
arearesize
-------------------------------

I wanted to write something that could "fix" blurry encodes. It works fairly well, as long as your source isn't fubar to begin with.

I just posted a few images that should show what can be done with the default settings followed by a bit of denoising (fft3dfilter(sigma=8) for these).

Anyways hope you enjoy the script!

----------------------------------

Code:
function deblur2(clip v,float "blend",bool "clean",int "bsize", bool "show")
{
blend=Default(blend,.75)
clean=default(clean,true)
show=default(show,false)
bsize=default(bsize,4)
osize=bsize/2
v=v.converttoyv12()
v
fft3dfilter(16,bw=bsize,bh=bsize,ow=osize,oh=osize)
Subtract(last,v)
Subtract(v,last)
a=last
a.arearesize(width(v)/2,height(v)/2)
fft3dfilter(16,bw=bsize,bh=bsize,ow=osize,oh=osize)
gaussresize(width(a),height(a),p=1)
Subtract(last,a)
Subtract(a,last)
b=last
b
fft3dfilter(16,bw=bsize,bh=bsize,ow=osize,oh=osize)
Subtract(last,b)
Subtract(b,last)
fft3dfilter(sharpen=4)
(clean==true) ? last.fft3dfilter(16,bw=32,bh=32,ow=16,oh=16) : last
merge(v,last,blend)
x=last
(show==true) ? StackHorizontal(v,x) : x
return last
}

And here are a few images. Left is original, center is blurred, right is the result at the default strength with a block size of 48 (deblur2(bsize=48)).

[Image: 0J8QYZe.png]
[Image: pilb4xO.png]
Reply
Thanks given by: spoRv , Colek
#2
Wow! That's impressive. Those "post" pictures look like they came from a higher resolution source, instead of being "recovered" from the low-res source.

How well would this work with VHS captures?
Reply
Thanks given by:
#3
(2018-04-11, 04:32 AM)jerryshadoe Wrote: Wow! That's impressive. Those "post" pictures look like they came from a higher resolution source, instead of being "recovered" from the low-res source.

I'm not impressed with myself here. What's happened is I've put the denoiser after that stackhorizontal. I'd like to remove the images, and I apologize for them. Sad
Reply
Thanks given by:
#4
(2018-04-11, 10:56 AM)MWilson Wrote: I'm not impressed with myself here. What's happened is I've put the denoiser after that stackhorizontal. I'd like to remove the images, and I apologize for them. Sad

Just redo the comparisons, and replace the old ones with the new ones!
Reply
Thanks given by: MWilson
#5
spoRv, I can't seem to edit the post.

Code:
function deblur1(clip v,float "blend",bool "clean", bool "show")
{
blend=Default(blend,.75)
clean=default(clean,true)
show=default(show,false)
v=v.converttoyv12()
v
fft3dfilter(16)
Subtract(last,v)
Subtract(v,last)
a=last
a.arearesize(width(v)/2,height(v)/2)
fft3dfilter(16)
gaussresize(width(a),height(a),p=1)
Subtract(last,a)
Subtract(a,last)
b=last
b
fft3dfilter(16)
Subtract(last,b)
Subtract(b,last)
fft3dfilter(sharpen=4)
(clean==true) ? last.fft3dfilter(48) : last
merge(v,last,blend)
x=last
(show==true) ? StackHorizontal(v,x) : x
return last
}


[Image: ei5Zl7Z.png]
[Image: jawTMR7.png]

These are actual comparisons. On the left is the untouched image, center has been blurred, right is the result of the above script called as deblur1(1) on the blurred (center) image.
Reply
Thanks given by:
#6
That's strange... there should be an "Edit" button on bottom of the post...

Well, the deblur results are too... deblurred! Big Grin

May you post one setting (and related screenshots) where the deblurred version is as close as possible to the untouched version? Thanks!
Reply
Thanks given by:
#7
(2018-04-11, 02:20 PM)spoRv Wrote: That's strange... there should be an "Edit" button on bottom of the post...

Well, the deblur results are too... deblurred! Big Grin

May you post one setting (and related screenshots) where the deblurred version is as close as possible to the untouched version? Thanks!

No problem! I ran these through a gaussianblur(3) call (center) and then ran this script as deblur1(.75) (so defaults).
The only change made to the script was reducing the amount of denoising on the clean line.


[Image: pilb4xO.png]
[Image: 0J8QYZe.png]

Code:
function deblur1(clip v,float "blend",bool "clean", bool "show")
{
blend=Default(blend,.75)
clean=default(clean,true)
show=default(show,false)
v=v.converttoyv12()
v
fft3dfilter(16)
Subtract(last,v)
Subtract(v,last)
a=last
a.arearesize(width(v)/2,height(v)/2)
fft3dfilter(16)
gaussresize(width(a),height(a),p=1)
Subtract(last,a)
Subtract(a,last)
b=last
b
fft3dfilter(16)
Subtract(last,b)
Subtract(b,last)
fft3dfilter(sharpen=4)
(clean==true) ? last.fft3dfilter(16,bw=32,bh=32,ow=16,oh=16) : last
merge(v,last,blend)
x=last
(show==true) ? StackHorizontal(v,x) : x
return last
}
Edit: here's a version where you can set the block size. I've set the default to 4 (the original was 48). Other than that it's exactly the same as above.
Code:
function deblur2(clip v,float "blend",bool "clean",int "bsize", bool "show")
{
blend=Default(blend,.75)
clean=default(clean,true)
show=default(show,false)
bsize=default(bsize,4)
osize=bsize/2
v=v.converttoyv12()
v
fft3dfilter(16,bw=bsize,bh=bsize,ow=osize,oh=osize)
Subtract(last,v)
Subtract(v,last)
a=last
a.arearesize(width(v)/2,height(v)/2)
fft3dfilter(16,bw=bsize,bh=bsize,ow=osize,oh=osize)
gaussresize(width(a),height(a),p=1)
Subtract(last,a)
Subtract(a,last)
b=last
b
fft3dfilter(16,bw=bsize,bh=bsize,ow=osize,oh=osize)
Subtract(last,b)
Subtract(b,last)
fft3dfilter(sharpen=4)
(clean==true) ? last.fft3dfilter(16,bw=32,bh=32,ow=16,oh=16) : last
merge(v,last,blend)
x=last
(show==true) ? StackHorizontal(v,x) : x
return last
}
Reply
Thanks given by: spoRv


Possibly Related Threads…
Thread Author Replies Views Last Post
  Script to make MKVs importable in Premiere deleted user 1 2,014 2021-10-23, 07:36 PM
Last Post: alleycat
  Thumbnail script with scene detection deleted user 1 2,975 2020-01-04, 04:40 PM
Last Post: deleted user
  AviSynth Rigby Reardon's Mondo Sync Script for TGtBatU Chewtobacca 0 2,751 2016-11-13, 01:27 AM
Last Post: Chewtobacca
  Script snippets subforum Feallan 3 6,317 2016-11-13, 12:32 AM
Last Post: Feallan

Forum Jump:


Users browsing this thread: 2 Guest(s)