This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[HELP] Fragments disappear in hand-drawn animation
#18
Quote:Is there anything we can do about it?
Okay, the baiscally try to Mask the content.

To use it in Hybrid with Avisynth one could write the whole stuff in a custom section.
So if you want to test it.
  • set "Filtering->Support" to "Avisynth"
  • enable a "Filtering->Avisynth->Custom" and enter:
    LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\mvtools2.dll")
    LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\masktools2.dll")
    LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\MedianBlur2.dll")
    LoadPlugin("I:\Hybrid\64bit\Avisynth\AVISYN~1\RgTools.dll")
    Import("I:\Hybrid\64bit\Avisynth\avisynthPlugins\SpotLess.avs")
      
    /*
        SpotTest(),
        Purpose:
            Spotless produces frame global changes [most pixels are changed], here we want to try alter only real spots where there is significant change in spotless Y [by YTh8]
            and also that are near grey in source [by CTh8], these targeted pixels are then overlayed from Spotless result onto original src.

        Src,       Pre-Spotless source
        Filtered,  Spotless result
        YTh8,      threshold for Y in 8 bit range.
        CTh8,      threshold for Chroma in 8 bit range.
        YNoiseTh8, ?????
        Show,      Show Masks.Mask is the final mask made from MaskY and MaskC
    */
    Function SpotTest(clip Src,clip Filtered,int "YTh8",int "Cth8",int "YNoiseTh8",Bool "Show") { # 8 -> 16 bit YUV444 only
        YTh8      = Min(Max(Default(YTh8,12),0),255)
        CTh8      = Min(Max(Default(CTh8,12),0),255)
        YNoiseTh8 = Min(Max(Default(YNoiseTh8,8),0),255)
        Show = Default(Show,False)
        try {bpc = Src.BitsPerComponent} catch(msg) {bpc=8}
        try {Y444=Src.IsYV24||Src.Is444} catch(msg) {Y444=false}
        Assert(Y444,"SpotTest: Must be YV24/YUV444")
        YTh      = BitLShift(YTh8,bpc-8).String
        CTh      = BitLShift(CTh8,bpc-8).String
        YNoiseTh = BitLShift(YNoiseTh8,bpc-8).String
        SY  = Src.ExtractY
        FY  = Filtered.ExtractY
        PSY = SY.SelectEvery(1,-1)
        NSY = SY.SelectEvery(1, 1)
        MaskN   = Mt_Lutxyz(PSY,SY,NSY,"x "+ YNoiseTh + " - y <= y z "+ YNoiseTh + " + <= & z "+ YNoiseTh + " - y <= y x "+ YNoiseTh + " + <= & | 0 range_max ?")
                                                                                           # ( ((x-YNoiseTh <= y) & (y <= z+YNoiseTh)) | ((z-YNoiseTh <= y) & (y <= x+YNoiseTh)) )  ? 0 : 255 ## Infix @ 8 bit
                                                                                           # ((YPrv-YNoiseTh <= YCur <= YNxt+YNoiseTh) || (YNxt-YNoiseTh <= YCur <= YPrv+YNoiseTh)) ? 0 : 255

        MaskY   = Mt_Lutxy(SY,FY,"x y - abs " + YTh + " > range_max 0 ?")                  # "(abs(x-y) > YTh) ? 255 : 0"
        MU      = Mt_Lut(Src.ExtractU,"x range_half - abs")                                # "abs(x - 128)"
        MV      = Mt_Lut(Src.ExtractV,"x range_half - abs")                                # "abs(x - 128)"
        MaskC   = Mt_Lutxy(MU,MV,"x 2 ^ y 2 ^ + .5 ^ round " + CTh + " <= range_max 0 ?")  # "(round(((x^2)+(y^2))^0.5) <= CTh) ? 255 : 0"    # 2D chroma distance from grey (by Pythagoras)
        MaskN = MaskN.mt_Expand
        MaskY = MaskY.mt_Expand
        MaskC = MaskC.mt_Expand
        MaskAnd = MaskC.Mt_Logic(MaskY,"and")
        MaskAnd = MaskAnd.Mt_Logic(MaskN,"and")
        MaskSelect = MaskAnd.mt_Expand.Blur(1.0)

        Overlay(Src,Filtered,Mask=MaskSelect,Opacity=1.0)
        CGREY = MaskSelect.Mt_lut("range_half")
        SEP=$FF0000
        HBAR=Src.BlankClip(length=1,Height=4,color=SEP)
        LFT=StackVertical(Src.Subtitle("Src"),HBAR,Filtered.Subtitle("Filt"),HBAR,Last.Subtitle("Result"))
        MID=StackVertical(YtoUV(CGrey,CGrey,MaskN).Subtitle("MaskN"),HBAR,YtoUV(CGrey,CGrey,MaskY).Subtitle("MaskY {abs(SrcY-FiltY) > YTh}"),HBAR,YtoUV(CGrey,CGrey,MaskSelect).Subtitle("MaskSelect=MaskAnd.mt_Expand.Blur(1.0) {Blk=Src used : Wht=Filt used}"))
        RGT=StackVertical(YtoUV(CGrey,CGrey,MaskC).Subtitle("MaskC {Src Chroma distance from Grey <= Cth8"),HBAR,YtoUV(CGrey,CGrey,MaskAnd).Subtitle("MaskAnd {MaskN & MaskC & MaskY}"),HBAR,YtoUV(CGrey,CGrey,CGrey))
        VBAR=LFT.BlankClip(length=1,width=4,color=SEP)
        STK = StackHorizontal(LFT,VBAR,MID,VBAR,RGT)
        (Show) ? STK : Last
    }

    ConvertToYV24()
    Src=Last
    Filtered=SpotLess(RadT=1)
    YTH8     = 8
    CTH8     = 12
    YNOISETH8 = 2
    SHOW = False
    SpotTest(Src,Filtered,YTH8,CTH8,YNOISETH8,SHOW)
    Return Last.ConvertToRGB32

    ConvertToRGB32()
    # colorformat RGB32
    (fixed #colorspace RGB32 -> # colorformat RGB32)
    in it. Make sure to adjust the paths in the Import- and the LoadPlugin-lines.
    If you set "SHOW = True" also add
    # width 4320
    # height 3240
    and expext the whole thing to get terrible instable unless you disable multithreading (Filtering->Avisynth->Misc->Script->Miscellaneous->Disable MT)

    Side note at least with these values it doesn't really remove much, but also doesn't wreak the image totally, still ad least some problems are still there.
    [Image: spotless-with-spottest.png]

    -> unless someone spends time on porting this to Vapoursynth I will at least not add direct support for this.
    If someone can show me that this actually can do more it might reconsider and even try to port this myself.

    Cu Selur

    Ps.: Note that the SpotLess version also notes: "NOT FOR cartoon/anime, live video only, sorry." So it's kind of to be expected that both the mask and the normal SpotLess have problems with your content.
Reply


Messages In This Thread
RE: Fragments disappear in hand-drawn animation - by Selur - 19.02.2022, 20:15

Forum Jump:


Users browsing this thread: 3 Guest(s)