Log in

View Full Version : Need to upscale a video


Jenyok
3rd September 2012, 15:02
Didee
.
Need your help.
This is a video clip.
.
http://sektorgaza.net/video/1991/a/jawa.mpg
Width=192
Height=144
.
I need to enlarge video clip (content), see upper, up to 4 times with very good quality (the bestest quality).
new Width=768
new Height=576
.
May be, enlargement is on 2 steps, 1 step is to enlarge source video clip up to 2 times, 2 step is to enlarge video clip from 1 step up to 2 times more.
.
Please, describe algorythm, which filters and in which case I could use those filters.
.
Thanks.

Didée
3rd September 2012, 15:21
For doing an upscale, first you need to have a picture. Your clip is only 20% picture, but 80% artifacts.

{source}
BicubicResize(64,48).BicubicResize(768,576,1,0)

Aahh, how clean it is now.

Jenyok
3rd September 2012, 16:04
Didee
.
And what is more ?

Jenyok
4th September 2012, 11:29
Didee
.
What could I do more ?

Jenyok
4th September 2012, 11:49
Archimedes
.
Could We see your script: NNEDI2 + SuperSlowSharpen + dfttest ?
.
Au...

Jenyok
5th September 2012, 11:14
Various SSSharp functions...
.

#
# Various Sharpen functions ...
#
# Sharp.avsi
#
#



LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\VARIABLEBLUR_25_DLL_20050524\variableblur.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DCTFUN4B_25_DLL_20060205\dctfun4b.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DEGRAINMEDIAN_20061008\degrainmedian.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MASKTOOLS-V2_0A48\mt_masktools-25.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAIN-1_0\removegrain.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAINHD_20071126\removegrainhd.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SHARPFUNCTION_ASHARP_25_DLL_20030118\asharp.dll")

LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SHARPFUNCTION_WARPSHARP_20080325\warpsharp.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SHARPFUNCTION_AWARPSHARP_25_DLL_20030203\awarpsharp.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SHARPFUNCTION_AWARPSHARP_20090619\awarpsharp.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SHARPFUNCTION_UNSHARPHQ_V04\unsharphq_v04.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DCTFILTER_25_DLL_20030221\dctfilter.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\FFT3DFILTER_20070220\fft3dfilter.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\TTEMPSMOOTH_25_DLL_20051117\ttempsmooth.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\VAGUEDENOISER_25_DLL_20050926\vaguedenoiser.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\HQDN3D_25_DLL_20050125\hqdn3d.dll")

LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_11_3\mvtools2.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAIN-1_0\repair.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\NNEDI2\nnedi2.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MASKTOOLS-V1_5_8\masktools.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DEEN_25_DLL_20050705\deen.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SANGNOM_25_DLL_20040118\sangnom.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\GRADFUN2DB-V1_0\gradfun2db.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\ADDGRAINC_25_DLL_20060610\addgrainc.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\AVERAGE_V11\average.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DFTTESTV_1_6\dfttest.dll")

Import("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MINBLUR\minblur.avsi")
Import("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\GRADFUN2DBMOD_V1_5\gradfun2dbmod_v1_5.avsi")
Import("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\HQDERING\hqdering.avsi")
Import("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DEHALO_ALPHA\dehalo_alpha.avsi")
Import("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\SEESAW\seesaw.avsi")


#
# SSSharp() function ...
#
# http://forum.doom9.org/showthread.php?t=132330
#
function SSSharp(clip c, float "rad", bool "ssw", float "strength", int "iter", bool "ss", int "denoise")
{
rad = Default(rad, 0.25)
ssw = Default(ssw, true)
strength = Default(strength, 4.0)
iter = Default(iter, 1)
ss = Default(ss, true)
denoise = Default(denoise, iter)

c
w = width(c)
h = height(c)

sswc = ssw ? c.ssw() : c

ush = unsharp(vary=rad, varc=1, strength=strength)

(iter >= 1) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >=c1) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 2) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >=c2) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 3) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >=c3) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 4) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >=c4) ? degrainmedian(mode=3).dctfun4b(2, 2) : last

return (last)
}

#
# SSSharp2() function ...
#
# http://forum.doom9.org/showthread.php?t=132330
# http://forum.doom9.org/showthread.php?t=132330&page=3
#
# replace SSW() function with SSW2() function ...
#
function SSSharp2(clip c, float "rad", bool "ssw", float "strength", int "iter", bool "ss", int "denoise")
{
rad = Default(rad, 0.25)
ssw = Default(ssw, true)
strength = Default(strength, 4.0)
iter = Default(iter, 1)
ss = Default(ss, true)
denoise = Default(denoise, iter)

c
w = width(c)
h = height(c)

sswc = ssw ? c.ssw2() : c

ush = unsharp(vary=rad, varc=1, strength=strength)

(iter >= 1) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 1) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 2) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 2) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 3) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 3) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 4) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 4) ? degrainmedian(mode=3).dctfun4b(2, 2) : last

return (last)
}


#
# SSSharpHQ() function ...
#
# http://forum.doom9.org/showthread.php?t=132330
#
# replace unSharp() function with unSarpHQ() function ...
#
function SSSharpHQ(clip c, float "rad", bool "ssw", float "strength", int "iter", bool "ss", int "denoise")
{
rad = Default(rad, 0.25)
ssw = Default(ssw, true)
strength = Default(strength, 4.0)
iter = Default(iter, 1)
ss = Default(ss, true)
denoise = Default(denoise, iter)

c
w = width(c)
h = height(c)

sswc = ssw ? c.ssw() : c

## unsharpHQ(float STR = 5.0)
# ush = unsharpHQ(rad * 10.0)
ush = unsharpHQ(strength)

(iter >= 1) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 1) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 2) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 2) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 3) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 3) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 4) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 4) ? degrainmedian(mode=3).dctfun4b(2, 2) : last

return (last)
}

#
# SSSharpHQ2() function ...
#
# http://forum.doom9.org/showthread.php?t=132330
# http://forum.doom9.org/showthread.php?t=132330&page=3
#
# replace unSharp() function with unSharpHQ() function ...
# replace SSW() function with SSW2() function ...
#
function SSSharpHQ2(clip c, float "rad", bool "ssw", float "strength", int "iter", bool "ss", int "denoise")
{
rad = Default(rad, 0.25)
ssw = Default(ssw, true)
strength = Default(strength, 4.0)
iter = Default(iter, 1)
ss = Default(ss, true)
denoise = Default(denoise, iter)

c
w = width(c)
h = height(c)

sswc = ssw ? c.ssw2() : c

## unsharpHQ(float STR = 5.0)
# ush = unsharpHQ(rad * 10.0)
ush = unsharpHQ(strength)

(iter >= 1) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 1) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 2) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 2) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 3) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 3) ? degrainmedian(mode=3).dctfun4b(2, 2) : last
(iter >= 4) ? MT_Merge(ush, sswc, spline64resize((ss ? w * 4 : w), (ss ? h * 4 : h)).halomaskM(hbias=-128, hthr=256, \
agmrad=(ss ? round(rad * 4) : round(rad))).spline64resize(w, h)) : last
(denoise >= 4) ? degrainmedian(mode=3).dctfun4b(2, 2) : last

return (last)
}

#
# Supported functions() and so on...
# for SSSharp(), SSSharp2(), SSSharpHQ(), SSSharpHQ2() functions ...
#
# http://forum.doom9.org/showthread.php?t=132330
#
# version 0.1, optimizations by Didee
#
function halomaskMR(clip c, int "hthr", int "hbias")
{
hthr = Default(hthr, 256)
hbias = Default(hbias, -128)

s = c
Ablur = s.removegrain(4)
Gblur = s.gaussianblur(vary=1, varc=0)
mask3 = mt_lutxy(Ablur, Gblur, "y x - abs " + string(hthr) + " * " + string(hbias) + " +", U=1, V=1)

return (mask3)
}


#
# Supported functions() and so on...
# for SSSharp(), SSSharp2(), SSSharpHQ(), SSSharpHQ2() functions ...
#
# http://forum.doom9.org/showthread.php?t=132330
#
# version 0.1, optimizations by Didee
#
function SSW(clip c)
{
c#.unsharp()
w = width(c)
h = height(c)

spline64resize(w * 3, h * 3)

awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99)
awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99)
awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99)
awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99)
awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99)

awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99)
awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99)
awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99)
awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99)
awarpsharp(cm=0, depth=3, blurlevel=1, thresh=0.99)

Spline64Resize(w, h)

return (last)
}



#
# Supported functions() and so on...
# for SSSharp(), SSSharp2(), SSSharpHQ(), SSSharpHQ2() functions ...
#
# http://forum.doom9.org/showthread.php?t=132330
#
# version 0.1, optimizations by Didee
#
function SSW2(clip c)
{
c#.unsharp()
w = width(c)
h = height(c)

spline64resize(w * 3, h * 3)

awarpsharp2(chroma=2, depth=2, blur=1, thresh=253)
awarpsharp2(chroma=2, depth=2, blur=1, thresh=253)
awarpsharp2(chroma=2, depth=2, blur=1, thresh=253)
awarpsharp2(chroma=2, depth=2, blur=1, thresh=253)
awarpsharp2(chroma=2, depth=2, blur=1, thresh=253)

awarpsharp2(chroma=2, depth=2, blur=1, thresh=253)
awarpsharp2(chroma=2, depth=2, blur=1, thresh=253)
awarpsharp2(chroma=2, depth=2, blur=1, thresh=253)
awarpsharp2(chroma=2, depth=2, blur=1, thresh=253)
awarpsharp2(chroma=2, depth=2, blur=1, thresh=253)

Spline64Resize(w, h)

return (last)
}

Jenyok
7th September 2012, 05:09
May be so ?!
.

AVISource("a_mpeg3a.avi") # 192 x 144 pix

ConvertToYV12()


#
# Upsize
#
NNEDI3_rpow2(rfactor=2, cshift="spline64resize", fwidth=384, fheight=288, qual=2, nsize=2, nns=2)


#
# Deblocking
#
Deblock_QED()


#
# Denosing
#
dfttestMC(sigma=1.5, mcradius=3, mdg=true, pp=2)

FFT3DFilter(sigma=0.3, sigma2=0.3, sigma3=1, sigma4=10, plane=0, wintype=1, bt=1, bw=16, bh=16, ow=8, oh=8, ncpu=4)


#
# Sharpen
#
SSSharpHQ2(iter=4, strength=25, rad=1)

ConvertToYUY2()

Guest
7th September 2012, 13:56
[bump after breakout from the NNEDI thread]

Jenyok
7th September 2012, 14:34
neuron2
.
And what could we do ?

Guest
7th September 2012, 14:57
Your last script references a sample that you have not given us. Is it as bad as the first one? Where are you getting these crappy 192x144 clips? Cheap cell phone video? No, can't be that as it is too professionally composed and edited. So what is it, rule 6 material? Put it in context for us.

You're asking how to do a x4 upsample with good quality, starting with a horrible quality source! And you seriously expect there to be some magic script to do that?

Didée said it all: first you need to have a picture.

Jenyok
10th September 2012, 08:54
neuron2
.
And how will you do upscale this video ?
What is your strategy ?

pbristow
10th September 2012, 10:32
Jenyok: You need to try answering other people's questions if you want your own to be answered. :)

Myself I'd start by running the clip through NNEDI3 to double the size, since nothing less is going to have any hope of reconstructing the broken lines... but I wouldn't expect miracles: Things looks so bad that NNEDI3 could just be confused into joining up all the wrong things. Don't waste time with two passes of NNEDI3 : By the second pass, all it can do is exagerate whatever artifacts were introduced by the first pass. So for the second 2x step, use something simple and not too sharpening, such as a soft bicubic or even good old bilinear. That should help blur some of the artifacts and leave you with a soft-looking but watchable picture... ...ish. :\

Really, though, with such a tiny starting resolution you've nothing to lose by just trying each of the available resizers in turn (either in single passes, or in combination with the various EEDIs & NNEDIs) and see which one *you* like the look of best. Don't bother with ResampleHQ: The lack-of-detail issues here completely dwarf any tiny areas of non-linearity.