View Full Version : Region-based structure line detection for cartoons (Cartoons mask)
Blankmedia
14th December 2021, 04:45
Does anyone knows if there's an implementation of this mask in avisynth or if it's possible :
https://link.springer.com/content/pdf/10.1007/s41095-015-0007-3.pdf
I'm looking for a good cartoon mask, and I don't ever seem to find exacly what I'm looking for.
Classic edge detection will create two "line mask" for every thick cartoon line, which is logical.
I've tried mt_edge("cartoon") with different threshold and cleaned them with mt_hysteresis like in Hystoria, but there's always something. Like the eyes or black hair of a character will only get edge detected upon a certain distance so the interior of the eyes or hair will not get masked.
Then if you apply a dehalo in can create a weird gradiant in the black.
SaurusX
14th December 2021, 15:53
One option is to combine the edge mask with a luma mask set to detect the darkest parts of the image, the animation lines. The dark parts of the image are generally those that need the least filtering in any case, so excluding them is only rarely a problem.
VoodooFX
14th December 2021, 16:18
Examples in that paper looks nice, maybe someone can implement a plugin based on this paper.
Blankmedia
15th December 2021, 05:01
One option is to combine the edge mask with a luma mask set to detect the darkest parts of the image, the animation lines. The dark parts of the image are generally those that need the least filtering in any case, so excluding them is only rarely a problem.
Thanks for this, I tougth about something like that but didn't know how to phrase it. Your comment made me narrow my search and I stumbled upon lumamask by dogway. It helped a lot.
Here's some example if someone stumble upon this thread https://forum.videohelp.com/threads/388747-Avisynth-mask-to-target-plain-colors
I'm not familiar with avisynth expressions so I can't really fine tune mask by myself. One time I managed to create a not so bad mask. But it was really ressource intensive.
clip_source = last
clip_s = clip_source
clip_Y =clip_source.converttoy().minideen().vsTTempSmooth()
clip_T = clip_s.TEMmod(threshY=2, threshC=20, type=1, link=2, chroma=1, preblur=True).Converttoy(matrix="Rec709").RemoveGrain(mode=11, planar=false).mt_inpand_multi(mode="ellipse",sw=1,sh=1).aWarpSharp2(Blur=4,Type=1,Depth=9,Chroma=2).mt_deflate()
#~ .mt_expand_multi(mode="ellipse",sw=2,sh=2).mt_inpand_multi(mode="ellipse",sw=4,sh=4).aWarpSharp2(Blur=4,Type=1,Depth=9,Chroma=2).mt_inflate().
a = mt_edge(clip_Y,"cartoon",thY1=1.5,thy2=1.75).Removegrain(27)
b = mt_edge(clip_Y, "cartoon",thY1=1.1,thy2=30).Removegrain(27)
c=mt_hysteresis(a, b).Removegrain(27)
#~ mt_hysteresis(c, clip_t).Removegrain(27)
d = mt_hysteresis(clip_T, c).Removegrain(27)#.mt_inpand_multi(mode="ellipse",sw=0,sh=0)
e = mt_hysteresis(d, clip_T).mt_inpand_multi(mode="ellipse",sw=1,sh=1)
masque = mt_hysteresis(e,c).mt_deflate()
masque = merge(masque.Blur(1), clip_T).mt_inpand_multi(mode="ellipse",sw=1,sh=1)
denoised_clip = clip_source.MCTemporalDenoise(settings="very low", radius=2, Chroma=False, edgeclean=true, ecrad=6, stabilize=true, maxr=2, AA=True, useEEDI2=True, maxd =24, protect=True)
denoised_clip = denoised_clip.SMDegrain(TR=3,ThSAD=600,ContraSharp=True,RefineMotion=True,Plane=0,PreFilter=2,Chroma=False, DCT=5, pel=2)
denoised_clip = denoised_clip.MiniDeen(radiusY=2, radiusUV=2, thrY=6, thrUV=7, y=3, u=3, v=3)
clip_dark = clip_s.Blur(1).Blur(1).drk(100).LSFmod(defaults="slow", strength=300,soft=-2, ss_x=1.5, edgemode=1, preblur="FFT3Dfilter(sigma=4,plane=0)")
denoised = mt_merge(denoised_clip,clip_dark , masque)
I'm shooting blind and hope to hit.
Blankmedia
15th December 2021, 07:53
Examples in that paper looks nice, maybe someone can implement a plugin based on this paper.
Yeah, me too!
Blankmedia
18th December 2021, 07:29
I tried to create good reliable edgemask for multiple sources (Simpsons dvd and magic school bus old rip.
Y played, with lumask, fltmask, mt_edge (cartoon, Robert, min/max.) Tcanny,
Vstedsge
Still not* sure I'm understanding all .
I also tried to create a polynomial function (expression and mtlut) that would keep high luma, and would pull down black pixel so they would be easier to detect, but it didn't work.
I think I'm gonna need help.
This is the source file, if it's detecting the edge of the bus on frame 45 it would be nice.
https://mega.nz/file/R1pwHLRS#hU-kS8aJ6IbcR3XzdwHw-W4jV-z7BUeeF-PeFICo6dI
Edited: for clarity, missing word etc.
Blankmedia
20th December 2021, 06:16
Am I not getting responses :
A) because my question is unclear;
B) there's still good information somewhere on the web that you guys think I should have been able to figure it out;
C) I might be literally slow brained these past week and not taking the problem correctly.
I know you are nice people, I see it in threads. It's been a while since I've been here so I lost touch with the community.
So I assume I'm the one in the wrong here .
I was out for a pack of smokes, took me couple years to get back kids.
Thanks to you all.
I leave you a sweet spiritual prayer.
May your Ram be big, may your cpu be fast, may the cost storage fall down.
Merry Christmas
Envoyé de mon Pixel 6 en utilisant Tapatalk
anton_foy
20th December 2021, 15:29
Well to simplify it and I may be wrong but wouldn't it be a good idea to filter the lines out first just using coloyuv(autogain=true) and the levels or mt_binarize to threshold down to isolate the black lines as much as possible? Then after this step do the edge detection thingy or what else is needed.
I dont know because Im not into cartoons like that but logically this is the approach I would use.
Dogway
20th December 2021, 16:13
Normally I would run a FastLineDarkenMOD to darken the edges and then run an edge mask. The problem is that as you might know edge masks creates double lines so something smarter has to be done.
Luckily I managed to implement a ridge detector into FlatMask(), if you wait a day or so you can find it in my repo.
VoodooFX
20th December 2021, 19:14
Am I not getting responses :
I miss examples of what you get with the filters you've tried, what you expect, ect..
Blankmedia
20th December 2021, 20:51
I miss examples of what you get with the filters you've tried, what you expect, ect..
Sorry about that and thank you for having a look at it.
Here are some example that I tried :
FFMS2(path)
RoboCrop(LeftAdd=2, TopAdd=2, RightAdd=2, BotAdd =2, align=True)
w = Width()
h = Height()
neo_minideen(2)
vsTTempSmooth(7)
source=last
#~ TemporalDegrain2(degrainTR=2, grainLevel=2, postFFT=3, postTR=1, postSigma=1.0, postDither=-1, postMix=0, extraSharp=False, fftThreads=1, debug=false)
Spline64Resize(w*3, h*3, src_left=0.0, src_top=0.0, src_width=0.0, src_height=0.0)
/*
masq1 = ex_edge("FDoG", 30, 80, invert=False, UV=128) #30-80
masq2 = ex_edge("cartoon", 0, 5, invert=False, UV=128) #30-80
masq2 = masq2.RemoveGrain(26)
ex_logic(masq1, masq2, "or")
*/
ColorYUV(autowhite=False, autogain=True)
blanc = BlankClip(last, color=$000000).Extracty()
masq1 = GibbsNoiseBlock(mode_RG=26).neo_minideen(3).lumamask(b=20,w=200,UV=128).Turnleft().maa2().TurnRight().Extracty().mt_expand_multi(mode="ellipse",sw=2,sh=2).mt_inpand_multi(mode="ellipse",sw=2,sh=2).ex_deflate(UV=128).ex_invert(UV=128)
#~ masq1 = ex_edge("FDoG", 40, 50, invert=False, UV=128).Extracty() #30-80
masq2 = FlatMask(rad=1, hyst=1).mt_inpand_multi(mode="ellipse",sw=1,sh=1).ex_inflate(UV=128) #.mt_expand_multi(mode="ellipse",sw=3,sh=3).mt_inpand_multi(mode="ellipse",sw=4,sh=4)
masq3 = ex_edge("cartoon", 1, 4, invert=False, UV=128).Removegrain(21).neo_minideen(3).Extracty().ex_inflate(UV=128) #30-80
masq4 = ex_logic(masq1, masq2, "or").Removegrain(1).Extracty().ex_inflate(UV=128)
masq5 = ex_logic(masq3, masq4, "or").Removegrain(4).ex_inflate(UV=128)#.ex_invert(UV=128)
masq6= ex_logic(masq3, masq2, "or").Removegrain(4).Extracty().maa2().ex_inflate(UV=128)
#~ masq6= ex_logic(masq6, masq5, "or").Removegrain(1).Extracty().mt_inpand_multi(mode="ellipse",sw=2,sh=2).ex_binarize(20,UV=128).ex_blur(radius=2, radiusV=2, UV=128).ex_inflate(UV=128)
noisymask = mt_edge(thy1=4,thy2=4,mode="cartoon")
cleanmask = mt_edge(thy1=15,thy2=15,mode="cartoon")
masq7 = mt_hysteresis(cleanmask,noisymask).Extracty().Removegrain(4).mt_inflate().ex_blur(radius=2, radiusV=2, UV=128)
masq8 = ex_logic(masq4, masq7, "or").Removegrain(26).Extracty().ex_inflate(UV=128).mt_inpand_multi(mode="ellipse",sw=2,sh=2)
ligne1 = StackHorizontal(masq1.Spline64Resize(720,540).Subtitle("mask1").Converttoyv12(),masq2.Spline64Resize(720,540).Subtitle("mask2").Converttoyv12(), masq3.Spline64Resize(720,540).Subtitle("mask3").Converttoyv12())
ligne2 = StackHorizontal(masq4.Spline64Resize(720,540).Subtitle("mask4").Converttoyv12(),masq5.Spline64Resize(720,540).Subtitle("mask5").Converttoyv12(),masq6.Spline64Resize(720,540).Subtitle("mask6").Converttoyv12())
ligne3 = StackHorizontal(masq7.Spline64Resize(720,540).Subtitle("mask7").Converttoyv12(),masq8.Spline64Resize(720,540).Subtitle("masq8").Converttoyv12(), Source.Spline64Resize(720,540).Subtitle("Source").Converttoyv12())
Stackvertical(ligne1, ligne2, ligne3)
Here are some examples :
https://i.postimg.cc/XpX5PSd9/New-File000044.png (https://postimg.cc/XpX5PSd9)
https://i.postimg.cc/tnJs8WZ9/New-File004087.png (https://postimg.cc/tnJs8WZ9)
https://i.postimg.cc/v1w6D4jv/New-File015211.png (https://postimg.cc/v1w6D4jv)
https://i.postimg.cc/CdxnZTv9/New-File016667.png (https://postimg.cc/CdxnZTv9)
https://i.postimg.cc/wt5RN6YY/New-File024553.png (https://postimg.cc/wt5RN6YY)
https://i.postimg.cc/5YxYqZfY/New-File028242.png (https://postimg.cc/5YxYqZfY)
masq8 is somewhat decent. But I still miss some edges, from the bus on frame 44 for example. The one I drawed on. There's noise between the edges of the bus windows and around the flagpole, so when I try to avoid those I have trouble gettind all the edges of the bus or other edges correcly. I tried finedehalo2 dwith default (since I don't know anything about convultions.
Maybe I'm to intense.
Blankmedia
20th December 2021, 20:58
Well to simplify it and I may be wrong but wouldn't it be a good idea to filter the lines out first just using coloyuv(autogain=true) and the levels or mt_binarize to threshold down to isolate the black lines as much as possible? Then after this step do the edge detection thingy or what else is needed.
I dont know because Im not into cartoons like that but logically this is the approach I would use.
Yes, these are good ideas, but I' not very good playing with levels at least in this case.
It doesn't seem to work because other area of the image seem to fall in the same threshold.
Cartoon edges are tricky, because you need your mask to cover the whole edge vs the 2 edges of the dark line. Else when you filter you can get an empty line.
There migth be something to do with a sequence of logical merge to isolate properly only the edges and real dark areas (like kids air, space, etc).
Blankmedia
20th December 2021, 21:19
Normally I would run a FastLineDarkenMOD to darken the edges and then run an edge mask. The problem is that as you might know edge masks creates double lines so something smarter has to be done.
Luckily I managed to implement a ridge detector into FlatMask(), if you wait a day or so you can find it in my repo.
I'm eager to see it, you make great stuff!
Here are some try I made so far:
https://i.postimg.cc/XpX5PSd9/New-File000044.png (https://postimg.cc/XpX5PSd9)
https://i.postimg.cc/tnJs8WZ9/New-File004087.png (https://postimg.cc/tnJs8WZ9)
https://i.postimg.cc/v1w6D4jv/New-File015211.png (https://postimg.cc/v1w6D4jv)
https://i.postimg.cc/CdxnZTv9/New-File016667.png (https://postimg.cc/CdxnZTv9)
https://i.postimg.cc/wt5RN6YY/New-File024553.png (https://postimg.cc/wt5RN6YY)
https://i.postimg.cc/5YxYqZfY/New-File028242.png (https://postimg.cc/5YxYqZfY)
StainlessS
20th December 2021, 21:36
I have no idea if this is of any use [and dont know much about it], but VcMahon, has below plugin,
its an old plugin, but VC was a gas/oil pipeline guy who I think worked with satellite [maybe RADAR/SONAR etc] and other imagery
to try segment/partition and extract detail from them, those techniques might be applicable to cartoon stuff.
Anyways, might be worth a gander at least.
Image enhancement using watershed technique:- https://forum.doom9.org/showthread.php?t=117710
I have recently authored two plugins using Segmentation by watershed algorithm.
SegmentedAmp plugin smooths image within the basin boundaries and also accentuates the boundaries. By preprocessing the image to reduce over_segmentation, image can be enhanced.
ReTouch plugin in addition to segmentation uses flood fill technique to stretch image values within the basin boundaries or shifts or replaces by the lowest or highest value within each basin.
I have used an image which appeared in one of the threads and didee wove a magic spell around it. http://forum.doom9.org/showthread.php?t=115181
The result from using segmentedAmp are :
http://img307.imageshack.us/img307/3528/segmentedamp0df5.th.jpg (http://img307.imageshack.us/my.php?image=segmentedamp0df5.jpg)
Top row are inputs with various preprocessing plugins.
Result with ReTouch is :
http://img415.imageshack.us/img415/7310/retouch0gh0.th.jpg (http://img415.imageshack.us/my.php?image=retouch0gh0.jpg)
On right is processed using retouch and other plugins.
Only spatial processing has been done.
More details are at my plugin page.
EDIT: The images have disappeared from the thread.
Sonar Imagery:- https://www.google.co.uk/search?q=sonar+imagry&ei=t-vAYfy1H4eM8gKv9Y2IBg&ved=0ahUKEwi87YPmn_P0AhUHhlwKHa96A2EQ4dUDCA0&uact=5&oq=sonar+imagry&gs_lcp=Cgdnd3Mtd2l6EAMyBAgAEA0yBAgAEA0yBggAEA0QHjIGCAAQDRAeMgYIABANEB4yBggAEA0QHjIGCAAQDRAeMggIABANEAUQHjIICAAQDRAFEB4yCAgAEA0QBRAeOgcIABBHELADOgoIABBHELADEMkDSgQIQRgASgQIRhgAUKMdWIEgYNwjaAFwAXgAgAGPAYgB5gKSAQMxLjKYAQCgAQHIAQjAAQE&sclient=gws-wiz
Radar Imagery:- https://www.google.co.uk/search?q=radar+imagry&source=hp&ei=gevAYbHhBcGP8gLHsqrwBQ&iflsig=ALs-wAMAAAAAYcD5kUjZhUbUMArm9TCG8hFpXwGndxgb&ved=0ahUKEwjxpYrMn_P0AhXBh1wKHUeZCl4Q4dUDCAg&uact=5&oq=radar+imagry&gs_lcp=Cgdnd3Mtd2l6EAMyBAgAEA0yBAgAEA0yBAgAEA0yBAgAEA0yBAgAEA0yBwgAEMkDEA0yBggAEA0QHjIGCAAQDRAeMgYIABANEB4yBggAEA0QHjoOCC4QgAQQsQMQxwEQ0QM6CwgAEIAEELEDEIMBOggIABCABBCxAzoLCC4QgAQQsQMQgwE6EQguEIAEELEDEIMBEMcBEKMCOgUIABCABDoLCC4QgAQQxwEQowI6DgguEIAEELEDEMcBEKMCOggIABCxAxCDAToFCC4QgAQ6CwguEIAEEMcBEK8BOgoILhCxAxCDARAKOgsILhCABBDHARDRA1AAWJIaYIMcaABwAHgAgAHiAYgBsQySAQYwLjExLjGYAQCgAQE&sclient=gws-wiz
satellite imagery:- https://www.google.co.uk/search?q=satelite+imagery&ei=KezAYcymC4mCgAagoIXwBQ&ved=0ahUKEwiM352coPP0AhUJAcAKHSBQAV4Q4dUDCA0&uact=5&oq=satelite+imagery&gs_lcp=Cgdnd3Mtd2l6EAMyBAgAEAoyCAgAEAcQChAeMggIABAHEAoQHjIECAAQCjIECAAQCjIECAAQCjIECAAQCjIECAAQCjIECAAQCjIECAAQCjoECAAQRzoGCAAQBxAeSgQIQRgASgQIRhgAUJ4YWN8kYOAmaABwAngAgAGbAYgBgAiSAQMwLjiYAQCgAQHIAQjAAQE&sclient=gws-wiz
EDIT: VC, still visits the forum quite regularly.
Blankmedia
21st December 2021, 03:52
I have no idea if this is of any use [and dont know much about it], but VcMahon, has below plugin,
its an old plugin, but VC was a gas/oil pipeline guy who I think worked with satellite [maybe RADAR/SONAR etc] and other imagery
to try segment/partition and extract detail from them, those techniques might be applicable to cartoon stuff.
Anyways, might be worth a gander at least.
Image enhancement using watershed technique:- https://forum.doom9.org/showthread.php?t=117710
EDIT: The images have disappeared from the thread.
Sonar Imagery:- https://www.google.co.uk/search?q=sonar+imagry&ei=t-vAYfy1H4eM8gKv9Y2IBg&ved=0ahUKEwi87YPmn_P0AhUHhlwKHa96A2EQ4dUDCA0&uact=5&oq=sonar+imagry&gs_lcp=Cgdnd3Mtd2l6EAMyBAgAEA0yBAgAEA0yBggAEA0QHjIGCAAQDRAeMgYIABANEB4yBggAEA0QHjIGCAAQDRAeMggIABANEAUQHjIICAAQDRAFEB4yCAgAEA0QBRAeOgcIABBHELADOgoIABBHELADEMkDSgQIQRgASgQIRhgAUKMdWIEgYNwjaAFwAXgAgAGPAYgB5gKSAQMxLjKYAQCgAQHIAQjAAQE&sclient=gws-wiz
Radar Imagery:- https://www.google.co.uk/search?q=radar+imagry&source=hp&ei=gevAYbHhBcGP8gLHsqrwBQ&iflsig=ALs-wAMAAAAAYcD5kUjZhUbUMArm9TCG8hFpXwGndxgb&ved=0ahUKEwjxpYrMn_P0AhXBh1wKHUeZCl4Q4dUDCAg&uact=5&oq=radar+imagry&gs_lcp=Cgdnd3Mtd2l6EAMyBAgAEA0yBAgAEA0yBAgAEA0yBAgAEA0yBAgAEA0yBwgAEMkDEA0yBggAEA0QHjIGCAAQDRAeMgYIABANEB4yBggAEA0QHjoOCC4QgAQQsQMQxwEQ0QM6CwgAEIAEELEDEIMBOggIABCABBCxAzoLCC4QgAQQsQMQgwE6EQguEIAEELEDEIMBEMcBEKMCOgUIABCABDoLCC4QgAQQxwEQowI6DgguEIAEELEDEMcBEKMCOggIABCxAxCDAToFCC4QgAQ6CwguEIAEEMcBEK8BOgoILhCxAxCDARAKOgsILhCABBDHARDRA1AAWJIaYIMcaABwAHgAgAHiAYgBsQySAQYwLjExLjGYAQCgAQE&sclient=gws-wiz
satellite imagery:- https://www.google.co.uk/search?q=satelite+imagery&ei=KezAYcymC4mCgAagoIXwBQ&ved=0ahUKEwiM352coPP0AhUJAcAKHSBQAV4Q4dUDCA0&uact=5&oq=satelite+imagery&gs_lcp=Cgdnd3Mtd2l6EAMyBAgAEAoyCAgAEAcQChAeMggIABAHEAoQHjIECAAQCjIECAAQCjIECAAQCjIECAAQCjIECAAQCjIECAAQCjIECAAQCjoECAAQRzoGCAAQBxAeSgQIQRgASgQIRhgAUJ4YWN8kYOAmaABwAngAgAGbAYgBgAiSAQMwLjiYAQCgAQHIAQjAAQE&sclient=gws-wiz
EDIT: VC, still visits the forum quite regularly.
Neat, I'll look up that thread
Blankmedia
21st December 2021, 07:10
Hot damn, I have to go to sleep, I'm not sure what did the trick. It's not final but some undetectable edges are now visible and the mask is manageable.
But before I used V. C. Mohan plugin now called ManyPlus (http://avisynth.nl/index.php/ManyPlus), I remembered NonLinUSM (http://avisynth.nl/index.php/NonlinUSM). It sure did help by enhancing the edges a bit. I also stack a couple of low fastlinedarkenmod ans motion compensated sharpening.
I also got better with levels.
I'm not sure it's worth it, but so far it's not that bad fps wise, and there's clearly to much stuff here. I might not need that TemporalDegrain2 call.
FPS (min | max | average): 1.796 | 4.623 | 2.053
FFMS2(chemin)
RoboCrop(LeftAdd=2, TopAdd=2, RightAdd=2, BotAdd =2, align=True)
ColorYUV(autogain=True)
source=last
dn = frfun7(lambda=1.1, T=6.0, Tuv=2.0, p=1).FastLineDarkenMOD4(strength=255, prot=40, luma_cap=250, threshold=4, thinning=5).FastLineDarkenMOD4(strength=255, prot=40, luma_cap=250, threshold=4, thinning=5)
dn = dn.FastLineDarkenMOD4(strength=255, prot=40, luma_cap=250, threshold=4, thinning=5).FastLineDarkenMOD4(strength=255, prot=40, luma_cap=250, threshold=4, thinning=5).TemporalDegrain2(degrainTR=2, grainLevel=2, postFFT=3, postTR=1, postSigma=1.0, postDither=-1, postMix=0, extraSharp=False, fftThreads=1, debug=false)
#~ gb = ex_GaussianBlur(source, sigma=1.0, pad=true, mblur=false).FastLineDarkenMOD4(strength=255, prot=40, luma_cap=250, threshold=4, thinning=5)
gb = dn
sharp0 = gb.NonlinUSM(z=3, pow=4.0, str=1.5, rad=9.0).FastLineDarkenMOD4(strength=255, prot=0, luma_cap=255, threshold=4, thinning=5).mergechroma(source)
sup1 = gb.MSuper(pel=2,sharp=2)
sup2 = sharp0.MSuper(pel=2,sharp=2,levels=1)
bv1 = sup1.MAnalyse(isb=true, delta=1)
fv1 = sup1.MAnalyse(isb=false,delta=1)
bv2 = sup1.MAnalyse(isb=true, delta=2)
fv2 = sup1.MAnalyse(isb=false,delta=2)
gb = gb.MDegrain2(sup2,bv1,fv1,bv2,fv2)
gb = ex_blur(1.5,mode="gaussian",UV=3).FastLineDarkenMOD4(strength=255, prot=40, luma_cap=250, threshold=4, thinning=5).NonlinUSM(pow=4)
sh2=manyPlus_SegAmp(source, useclip = false, sh =-6,sm =6)
sh1=manyPlus_SegAmp(dn, useclip = false, sh = -2, sm = 10 , smu = 10, smv = 10)
sh0 =manyPlus_SegAmp(gb.drk(), useclip = False, sh = -1, sm = 3, smu = 5, smv = 5,sclip=sh1 )
#~ return sh1
s1 = stackhorizontal(source,gb,dn)
s2 = stackhorizontal(sh2,sh0, sh1)
#~ return stackvertical(s1,s2)
#~ manyPlus_SegAmp(dn, useclip = false, sh = 0, sm = 2, smu=2,smv=2,c4=True)
#~ frfun7(lambda=1.1, T=6.0, Tuv=2.0, p=1)
#~ lumamask(b=0,w=250,UV=128).Turnleft().maa2().TurnRight()
#~ Finedehalo2().HaloBuster(h=16, thr=1, elast=3)#.hqdn3d(ls=4.0, cs=3.0, lt=6.0, ct=4.5, restart=7, u=2, v=2)#.hqderingmod(mthr =140,minp = 1, mrad=4, nrmode = 3, show =False)
#~ Spline64Resize(1440,1080)
source=sh0
#~ TemporalDegrain2(degrainTR=2, grainLevel=2, postFFT=3, postTR=1, postSigma=1.0, postDither=-1, postMix=0, extraSharp=False, fftThreads=1, debug=false)
w = Width()
h = Height()
source.Spline64Resize(w*3, h*3, src_left=0.0, src_top=0.0, src_width=0.0, src_height=0.0)
/*
masq1 = ex_edge("FDoG", 30, 80, invert=False, UV=128) #30-80
masq2 = ex_edge("cartoon", 0, 5, invert=False, UV=128) #30-80
masq2 = masq2.RemoveGrain(26)
ex_logic(masq1, masq2, "or")
*/
#~ FineDehalo2().HQderingmod(mrad=3)
ColorYUV(autowhite=False, autogain=True)
Levels(20, 0.50, 200, 0, 255, coring=true)
sourcelevel = last
blanc = BlankClip(last, color=$000000).Extracty()
masq1 = GibbsNoiseBlock(mode_RG=26).neo_minideen(3).lumamask(b=20,w=200,UV=128).Turnleft().maa2().TurnRight().Extracty().mt_expand_multi(mode="ellipse",sw=2,sh=2).mt_inpand_multi(mode="ellipse",sw=2,sh=2).ex_deflate(UV=128).ex_invert(UV=128)
#~ masq1 = ex_edge("FDoG", 40, 50, invert=False, UV=128).Extracty() #30-80
masq2 = Flatmask(rad=1, hyst=1).mt_inpand_multi(mode="ellipse",sw=1,sh=1).ex_inflate(UV=128) #.mt_expand_multi(mode="ellipse",sw=3,sh=3).mt_inpand_multi(mode="ellipse",sw=4,sh=4)
masq3 = ex_edge("cartoon", 1, 3, invert=False, UV=128).Removegrain(4).neo_minideen(3).Extracty().ex_inflate(UV=128) #30-80
masq4 = ex_logic(masq1, masq2, "or").Removegrain(1).Extracty().ex_inflate(UV=128)
masq5 = ex_logic(masq3, masq4, "or").Removegrain(4).ex_inflate(UV=128)#.ex_invert(UV=128)
masq6= ex_logic(masq3, masq2, "or").Removegrain(4).Extracty().maa2().ex_inflate(UV=128)
#~ masq6= ex_logic(masq6, masq5, "or").Removegrain(1).Extracty().mt_inpand_multi(mode="ellipse",sw=2,sh=2).ex_binarize(20,UV=128).ex_blur(radius=2, radiusV=2, UV=128).ex_inflate(UV=128)
noisymasq = mt_edge(thy1=2.,thy2=2.,mode="cartoon")
cleanmasq = mt_edge(thy1=6,thy2=6,mode="cartoon")
masq7 = mt_hysteresis(cleanmasq,noisymasq).Extracty().Removegrain(4).mt_inflate().ex_blur(radius=2, radiusV=2, UV=128).maa2().ex_inpand(1).ex_binarize()
masq8 = ex_logic(masq4, masq7, "or").Removegrain(26).Extracty().ex_inflate(UV=128).mt_inpand_multi(mode="ellipse",sw=2,sh=2)
masq9 = mt_edge(thy1=20,thy2=20,mode="cartoon",chroma="-128").Extracty().ex_inpand(1)
masq10 = mt_hysteresis(masq9,masq7).Extracty().Removegrain(4).maa2()
#~ return StackHorizontal(masq10, masq9, masq7)
ligne1 = StackHorizontal(masq1.Spline64Resize(720,540).Subtitle("masq1").Converttoyv12(),masq2.Spline64Resize(720,540).Subtitle("masq2").Converttoyv12(), masq3.Spline64Resize(720,540).Subtitle("masq3").Converttoyv12())
ligne2 = StackHorizontal(masq4.Spline64Resize(720,540).Subtitle("masq4").Converttoyv12(),masq5.Spline64Resize(720,540).Subtitle("masq5").Converttoyv12(),masq6.Spline64Resize(720,540).Subtitle("masq6").Converttoyv12())
ligne3 = StackHorizontal(masq7.Spline64Resize(720,540).Subtitle("masq7").Converttoyv12(),masq8.Spline64Resize(720,540).Subtitle("masq8").Converttoyv12(), Source.Spline64Resize(720,540).Subtitle("Source").ShowFrameNumber( x= 640, y = 24, text_color=$ff0000).Converttoyv12())
ligne4 = StackHorizontal(masq9.Spline64Resize(720,540).Subtitle("masq9").Converttoyv12(),masq10.Spline64Resize(720,540).Subtitle("masq10").Converttoyv12(), sourcelevel.Spline64Resize(720,540).Subtitle("sourcelevel").ShowFrameNumber( x= 640, y = 24, text_color=$ff0000).Converttoyv12())
stack = Stackvertical(ligne1, ligne2, ligne3, ligne4)
return stack
It's on the right path.
https://i.postimg.cc/Fkb4cxhp/New-File-15-000044.png (https://postimg.cc/Fkb4cxhp)
Dogway
21st December 2021, 10:56
I finished the refactor of FlatMask() with a proper ridge descriptor. I didn't follow the equations to the letter but got the grasp of it and it works.
I focused on the double line topic of the original post. To make the faint edge of the bus visible, in the edge mask you have to really pump up the values and hence will catch a lot of false positives because actually it isn't a line anymore but a slight shade.
http://i.imgur.com/uBL4i1Km.png (https://i.imgur.com/uBL4i1K.png)
The source is dirty (dot crawl, halos...) so I added some prefiltering before flatmask.
a=last
# Prefilter (Custom for this source)
ex_boxblur(0,1,mode="mean")
turnright()
ex_median("verticalS")
turnleft()
ex_median("IQM")
# Valley Mask
FlatMask(1)
# Add regular edge mask
a=a.ex_edge("qprewitt")
ex_lutxy(a,"x dup * 0.1 * y + 0.5 *")
# Clean up
ex_smooth(2,sharp=true)
SaurusX
21st December 2021, 16:21
I finished the refactor of FlatMask() with a proper ridge descriptor. I didn't follow the equations to the letter but got the grasp of it and it works.
I focused on the double line topic of the original post. To make the faint edge of the bus visible, in the edge mask you have to really pump up the values and hence will catch a lot of false positives because actually it isn't a line anymore but a slight shade.
http://i.imgur.com/uBL4i1Km.png (https://i.imgur.com/uBL4i1K.png)
The source is dirty (dot crawl, halos...) so I added some prefiltering before flatmask.
a=last
# Prefilter (Custom for this source)
ex_boxblur(0,1,mode="mean")
turnright()
ex_median("verticalS")
turnleft()
ex_median("IQM")
# Valley Mask
FlatMask(1)
# Add regular edge mask
a=a.ex_edge("qprewitt")
ex_lutxy(a,"x dup * 0.1 * y + 0.5 *")
# Clean up
ex_smooth(2,sharp=true)
Very impressive!
Blankmedia
22nd December 2021, 04:34
Thanks Dogway I used your code and it's amazing!
Also I added a bit of a luma mask (thanks again) and a debanding call after your cleanup. I made 2 Hqderingmod call to reduce some parallel lines, but I'm not sure yet if I' gonna keep it.
It seems to give consistent result :
src = FFMS2()
src.HQderingmod(mrad=2,minp = 2 , nrmode =0, sharp = 0, show=False).HQderingmod(mrad=2,minp = 2 , nrmode =3, sharp = 0, show=False)
a = last
ex_boxblur(0,1,mode="mean")
turnright()
ex_median("verticalS")
turnleft()
ex_median("IQM")
neo_f3kdb(5,preset="very high",grainy=0, grainc=0, blur_first=true, sample_mode=4)
# Add lumamask to get dark haris and shoes and stuff, also limit texture degradation in dark area
lumen = lumamask(b=00,w=50, invert=True,uv=128).Santiag().ex_inflate(1,uv=128).Converttoy()
lumen = lumen.Levels(40,0.7,240,0,255)
# Valley Mask
dana = FlatMask(1)
# Add regular edge mask
a=a.ex_edge("qprewitt").Converttoy()
emask = dana.ex_lutxy(a,"x dup * 0.1 * y + 0.5 *")
#~ emask = ex_logic(emask, lumen, "or") ## create artefact
emask = emask.ex_lutxy(lumen,"y x > y x ?")
# Clean up
emask.ex_smooth(2,sharp=true)
This is my whole script so far, but it needs tuning a bit. I went way over board with a lot of things.
FFMS2(chemin)
RoboCrop(LeftAdd=2, TopAdd=2, RightAdd=2, BotAdd =2, align=True)
fmtc_bitdepth(bits=32)
fmtc_resample(css="444", fulls=False, fulld=True)
fmtc_matrix(mats="601", matd="709", fulls=True, fulld=True)
fmtc_matrix(mat="709", fulls=True, fulld=False, col_fam="YUV")
fmtc_resample (css="420")
src16 = fmtc_bitdepth(bits=16, dmode=8)
fmtc_bitdepth(bits=8, dmode=8)
src = last
HQderingmod(mrad=2,minp = 2 , nrmode =0, sharp = 0, show=False).HQderingmod(mrad=2,minp = 2 , nrmode =3, sharp = 0, show=False)
ex_boxblur(0,1,mode="mean")
turnright()
ex_median("verticalS")
turnleft()
ex_median("IQM")
neo_f3kdb(5,preset="very high",grainy=0, grainc=0, blur_first=true, sample_mode=4)
# Add lumamask to get dark haris and shoes and stuff, also limit texture degradation in dark area
lumen = lumamask(b=00,w=50, invert=True,uv=128).Santiag().ex_inflate(1,uv=128).Converttoy()
lumen = lumen.Levels(40,0.7,240,0,255)
# Valley Mask
dana = FlatMask(1)
# Add regular edge mask
a=src.ex_edge("qprewitt").Converttoy()
emask = dana.ex_lutxy(a,"x dup * 0.1 * y + 0.5 *")
emask = emask.ex_lutxy(lumen,"y x > y x ?")
# Clean up
emask = emask.ex_smooth(2,sharp=true)
emask16 = emask.fmtc_bitdepth(bits=16)
src16= src16.GibbsNoiseBlock(mode_RG=26)
sharp0 = src16.NonlinUSM(z=3, pow=1.1, str=0.25, rad=9).mergechroma(src16)
sup1 = src16.MSuper(pel=2,sharp=2)
sup2 = sharp0.MSuper(pel=2,sharp=2,levels=1)
bv1 = sup1.MAnalyse(isb=true, delta=1)
fv1 = sup1.MAnalyse(isb=false,delta=1)
bv2 = sup1.MAnalyse(isb=true, delta=2)
fv2 = sup1.MAnalyse(isb=false,delta=2)
sharpy = src16.MDegrain2(sup2,bv1,fv1,bv2,fv2)
denoised = src16.GibbsNoiseBlock(mode_RG=26).minideen(radius=1).Halobuster(h=12)
denoised = denoised.TemporalDegrain2(degrainTR=1, grainLevel=1, postFFT=0, postTR=1, postSigma=1.0, postDither=-1, postMix=0, extraSharp=True, fftThreads=1, debug=false)
ex_merge(denoised, sharpy, emask16,true).maa2()
DFMDeRainbow(maskthresh=12)
EDI_RPow2(4,CShift="Spline64Resize",FWidth=960,FHeight=720, nsize=0, nns=3, qual=2, etype=1, taps=4)
emask16 = emask16.spline64resize(960,720)
source = last
sharp0 = source.mt_adddiff(mt_makediff(source,source.removegrain(4)),U=2,V=2) # "median sharpen" (won't create halos on its own, IF the source is halo-free)
sup1 = source.MSuper(pel=2,sharp=2)
sup2 = sharp0.MSuper(pel=2,sharp=2,levels=1)
bv1 = sup1.MAnalyse(isb=true, delta=1)
fv1 = sup1.MAnalyse(isb=false,delta=1)
bc1 = source.MCompensate(sup2,bv1,thSAD=500) # using the super clip from the median-sharpener, to provide
fc1 = source.MCompensate(sup2,fv1,thSAD=500) # more headroom for the limiting process
max = mt_logic(bc1,fc1,"max").mt_logic(source,"max")
min = mt_logic(bc1,fc1,"min").mt_logic(source,"min")
sharp1 = source.LSFmod(preset="slow", strength=200, smode=5, edgemode=1).CAS(0.5).mergechroma(last) # chroma sharpen usually is unadvantageous
sharpy2 = sharp1.mt_clamp(max,min,0,0,U=2,V=2).FastLineDarkenMOD4(strength=75, prot=60, luma_cap=190, threshold=4, thinning=1).FastLineDarkenMOD4(strength=75, prot=60, luma_cap=190, threshold=4, thinning=1)
#~ shapy2
ex_merge(source, sharpy2, emask16,true).maa2()
emask16 = emask16.ex_inpand(1,"plus",thres=128)
deh = source.FineDehalo(rx=2.5, ry=2.5, thmi=80, thma=128, thlimi=50, thlima=100, darkstr=0.3, brightstr=1.0, showmask=0, contra=0.3, excl=true)
ex_merge(deh, last, emask16,true)
w=656
h=480
fr=44
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne1 = Stackhorizontal(a1, a3, a2)
fr=77
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne2 = Stackhorizontal(a1, a3, a2)
fr=5000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne3 = Stackhorizontal(a1, a3, a2)
fr=10000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne4 = Stackhorizontal(a1, a3, a2)
fr=15000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne5 = Stackhorizontal(a1, a3, a2)
fr=20000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne6 = Stackhorizontal(a1, a3, a2)
fr=25000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne7 = Stackhorizontal(a1, a3, a2)
fr=30000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne8 = Stackhorizontal(a1, a3, a2)
stack = Stackvertical(ligne1, ligne2, ligne3, ligne4, ligne5, ligne6, ligne7, ligne8)
return stack
#~ ConvertToStacked().Dither_out()
Prefetch(threads=1)
https://i.postimg.cc/f3Q0H4yz/Le-Bus-Magique-S01-E01-V5-clean000000.png (https://postimg.cc/f3Q0H4yz)
Zoom in
https://i.postimg.cc/t15ChJcj/Le-Bus-Magique-S01-E01-V5-clean000000-enhanced.png (https://postimg.cc/t15ChJcj)
Thanks to everyone again.
Blankmedia
22nd December 2021, 07:13
Im happy as a phoque right now, I'fhink tomorrow I'll reverse de projec to protect the eyes and the stars.
I'm encoding a little sample for you all. I should be available now but I must sleep.
Envoyé de mon Pixel 6 en utilisant Tapatalk
Dogway
22nd December 2021, 10:26
The results looks good!
I didn't know it was all for Gibbs noise, in that case you don't want to touch edges but just right outside them. Normally edge masks will have their center at the gradient change, that means half the edge mask will occupy the edge itself. FlatMask() is very robust so what you can do is subtract the edge mask with FlatMask's ridge mask.
Example:
a=ex_edge("qprewitt")#~ .ex_expand()
b=flatmask()
ex_makediff(a,b,dif=false)
I updated the filter with new args so now you can tune the mask gain (to convert from ridge to a proper flat mask) and low cutoff. It's also faster since I changed the derivatives to custom ones and changed defaults.
Blankmedia
22nd December 2021, 14:49
I didn't know it was all for Gibbs noise, in that case you don't want to touch edges but just right outside them.
Nice, I'll try that snippet and your new flatmask!
It wasn't all about Gibbs Noise, but the mask at first picked up a bit to much of it, so it was protecting it. (if I understand correctly, i.e the thin parallel line).
Here's a sample, it encoded at 1.2fps with that command :
avs4x26x64 --x26x-binary x265 --preset veryslow --profile main10 --merange 44 --no-rect --no-am --no-sao --aq-mode 1 --aq-strength 1.0 --rd 4 --psy-rd 1.6 --psy-rdoq 5.0 --rdoq-level 1 --qcomp 0.75 --rdpenalty 1 --tu-inter-depth 2 --tu-intra-depth 2 --ctu 32 --max-tu-size 16 --input-depth 16 --dither --crf 22 --pools 4 --colormatrix "bt709" --colorprim "bt709" --transfer "bt709" --videoformat 2 --sar 1:1 -o "output.265" "input.avs"
https://mega.nz/file/hl4mlLDS#hPe987-lJLInGs1IZubJNUQ-LhlidqHUZYZD44mqtDI
madey83
22nd June 2022, 07:20
Thanks Dogway I used your code and it's amazing!
Also I added a bit of a luma mask (thanks again) and a debanding call after your cleanup. I made 2 Hqderingmod call to reduce some parallel lines, but I'm not sure yet if I' gonna keep it.
It seems to give consistent result :
src = FFMS2()
src.HQderingmod(mrad=2,minp = 2 , nrmode =0, sharp = 0, show=False).HQderingmod(mrad=2,minp = 2 , nrmode =3, sharp = 0, show=False)
a = last
ex_boxblur(0,1,mode="mean")
turnright()
ex_median("verticalS")
turnleft()
ex_median("IQM")
neo_f3kdb(5,preset="very high",grainy=0, grainc=0, blur_first=true, sample_mode=4)
# Add lumamask to get dark haris and shoes and stuff, also limit texture degradation in dark area
lumen = lumamask(b=00,w=50, invert=True,uv=128).Santiag().ex_inflate(1,uv=128).Converttoy()
lumen = lumen.Levels(40,0.7,240,0,255)
# Valley Mask
dana = FlatMask(1)
# Add regular edge mask
a=a.ex_edge("qprewitt").Converttoy()
emask = dana.ex_lutxy(a,"x dup * 0.1 * y + 0.5 *")
#~ emask = ex_logic(emask, lumen, "or") ## create artefact
emask = emask.ex_lutxy(lumen,"y x > y x ?")
# Clean up
emask.ex_smooth(2,sharp=true)
This is my whole script so far, but it needs tuning a bit. I went way over board with a lot of things.
FFMS2(chemin)
RoboCrop(LeftAdd=2, TopAdd=2, RightAdd=2, BotAdd =2, align=True)
fmtc_bitdepth(bits=32)
fmtc_resample(css="444", fulls=False, fulld=True)
fmtc_matrix(mats="601", matd="709", fulls=True, fulld=True)
fmtc_matrix(mat="709", fulls=True, fulld=False, col_fam="YUV")
fmtc_resample (css="420")
src16 = fmtc_bitdepth(bits=16, dmode=8)
fmtc_bitdepth(bits=8, dmode=8)
src = last
HQderingmod(mrad=2,minp = 2 , nrmode =0, sharp = 0, show=False).HQderingmod(mrad=2,minp = 2 , nrmode =3, sharp = 0, show=False)
ex_boxblur(0,1,mode="mean")
turnright()
ex_median("verticalS")
turnleft()
ex_median("IQM")
neo_f3kdb(5,preset="very high",grainy=0, grainc=0, blur_first=true, sample_mode=4)
# Add lumamask to get dark haris and shoes and stuff, also limit texture degradation in dark area
lumen = lumamask(b=00,w=50, invert=True,uv=128).Santiag().ex_inflate(1,uv=128).Converttoy()
lumen = lumen.Levels(40,0.7,240,0,255)
# Valley Mask
dana = FlatMask(1)
# Add regular edge mask
a=src.ex_edge("qprewitt").Converttoy()
emask = dana.ex_lutxy(a,"x dup * 0.1 * y + 0.5 *")
emask = emask.ex_lutxy(lumen,"y x > y x ?")
# Clean up
emask = emask.ex_smooth(2,sharp=true)
emask16 = emask.fmtc_bitdepth(bits=16)
src16= src16.GibbsNoiseBlock(mode_RG=26)
sharp0 = src16.NonlinUSM(z=3, pow=1.1, str=0.25, rad=9).mergechroma(src16)
sup1 = src16.MSuper(pel=2,sharp=2)
sup2 = sharp0.MSuper(pel=2,sharp=2,levels=1)
bv1 = sup1.MAnalyse(isb=true, delta=1)
fv1 = sup1.MAnalyse(isb=false,delta=1)
bv2 = sup1.MAnalyse(isb=true, delta=2)
fv2 = sup1.MAnalyse(isb=false,delta=2)
sharpy = src16.MDegrain2(sup2,bv1,fv1,bv2,fv2)
denoised = src16.GibbsNoiseBlock(mode_RG=26).minideen(radius=1).Halobuster(h=12)
denoised = denoised.TemporalDegrain2(degrainTR=1, grainLevel=1, postFFT=0, postTR=1, postSigma=1.0, postDither=-1, postMix=0, extraSharp=True, fftThreads=1, debug=false)
ex_merge(denoised, sharpy, emask16,true).maa2()
DFMDeRainbow(maskthresh=12)
EDI_RPow2(4,CShift="Spline64Resize",FWidth=960,FHeight=720, nsize=0, nns=3, qual=2, etype=1, taps=4)
emask16 = emask16.spline64resize(960,720)
source = last
sharp0 = source.mt_adddiff(mt_makediff(source,source.removegrain(4)),U=2,V=2) # "median sharpen" (won't create halos on its own, IF the source is halo-free)
sup1 = source.MSuper(pel=2,sharp=2)
sup2 = sharp0.MSuper(pel=2,sharp=2,levels=1)
bv1 = sup1.MAnalyse(isb=true, delta=1)
fv1 = sup1.MAnalyse(isb=false,delta=1)
bc1 = source.MCompensate(sup2,bv1,thSAD=500) # using the super clip from the median-sharpener, to provide
fc1 = source.MCompensate(sup2,fv1,thSAD=500) # more headroom for the limiting process
max = mt_logic(bc1,fc1,"max").mt_logic(source,"max")
min = mt_logic(bc1,fc1,"min").mt_logic(source,"min")
sharp1 = source.LSFmod(preset="slow", strength=200, smode=5, edgemode=1).CAS(0.5).mergechroma(last) # chroma sharpen usually is unadvantageous
sharpy2 = sharp1.mt_clamp(max,min,0,0,U=2,V=2).FastLineDarkenMOD4(strength=75, prot=60, luma_cap=190, threshold=4, thinning=1).FastLineDarkenMOD4(strength=75, prot=60, luma_cap=190, threshold=4, thinning=1)
#~ shapy2
ex_merge(source, sharpy2, emask16,true).maa2()
emask16 = emask16.ex_inpand(1,"plus",thres=128)
deh = source.FineDehalo(rx=2.5, ry=2.5, thmi=80, thma=128, thlimi=50, thlima=100, darkstr=0.3, brightstr=1.0, showmask=0, contra=0.3, excl=true)
ex_merge(deh, last, emask16,true)
w=656
h=480
fr=44
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne1 = Stackhorizontal(a1, a3, a2)
fr=77
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne2 = Stackhorizontal(a1, a3, a2)
fr=5000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne3 = Stackhorizontal(a1, a3, a2)
fr=10000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne4 = Stackhorizontal(a1, a3, a2)
fr=15000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne5 = Stackhorizontal(a1, a3, a2)
fr=20000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne6 = Stackhorizontal(a1, a3, a2)
fr=25000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne7 = Stackhorizontal(a1, a3, a2)
fr=30000
a1 = src16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Source frame" + String(fr))
a2 = emask16.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Mask frame" + String(fr)).ConvertToYUV420()
a3 = last.Trim(fr, fr).Spline64Resize(w,h).Subtitle("Result frame" + String(fr))
ligne8 = Stackhorizontal(a1, a3, a2)
stack = Stackvertical(ligne1, ligne2, ligne3, ligne4, ligne5, ligne6, ligne7, ligne8)
return stack
#~ ConvertToStacked().Dither_out()
Prefetch(threads=1)
https://i.postimg.cc/f3Q0H4yz/Le-Bus-Magique-S01-E01-V5-clean000000.png (https://postimg.cc/f3Q0H4yz)
Zoom in
https://i.postimg.cc/t15ChJcj/Le-Bus-Magique-S01-E01-V5-clean000000-enhanced.png (https://postimg.cc/t15ChJcj)
Thanks to everyone again.
Hello @Blankmedia
it looks very impressive.
Could you advice how to use your script in StaxRip app?
Blankmedia
23rd June 2022, 02:34
Hello @Blankmedia
it looks very impressive.
Could you advice how to use your script in StaxRip app?
I wish I could help you but I've nerver used StaxRip.
But can't you just use avisynth and x264 or x265?
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.