Posts: 5
Threads: 1
Joined: 2018 Mar
Thanks: 1
Given 3 thank(s) in 2 post(s)
Country:
2018-04-05, 04:54 AM
(This post was last modified: 2018-04-11, 06:31 PM by MWilson.)
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)).
Posts: 2,290
Threads: 39
Joined: 2015 Jan
Thanks: 177
Given 187 thank(s) in 133 post(s)
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?
Posts: 5
Threads: 1
Joined: 2018 Mar
Thanks: 1
Given 3 thank(s) in 2 post(s)
Country:
2018-04-11, 10:56 AM
(This post was last modified: 2018-04-11, 10:58 AM by MWilson.
Edit Reason: Can't edit first post
)
(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.
Posts: 7,153
Threads: 601
Joined: 2015 Jan
Thanks: 1081
Given 1466 thank(s) in 963 post(s)
Country:
(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.
Just redo the comparisons, and replace the old ones with the new ones!
Posts: 5
Threads: 1
Joined: 2018 Mar
Thanks: 1
Given 3 thank(s) in 2 post(s)
Country:
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
}
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.
Posts: 7,153
Threads: 601
Joined: 2015 Jan
Thanks: 1081
Given 1466 thank(s) in 963 post(s)
Country:
That's strange... there should be an "Edit" button on bottom of the post...
Well, the deblur results are too... deblurred!
May you post one setting (and related screenshots) where the deblurred version is as close as possible to the untouched version? Thanks!
Posts: 5
Threads: 1
Joined: 2018 Mar
Thanks: 1
Given 3 thank(s) in 2 post(s)
Country:
2018-04-11, 02:51 PM
(This post was last modified: 2018-04-11, 06:23 PM by MWilson.
Edit Reason: Added an option to script
)
(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!
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.
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
}
|