Hi all. I think I'm losing my Midas touch here big time. I used to have this really good script that allowed me to protect lines and details while filtering flat areas and well...no idea where it went. And I can't remember for the life of me how to create one. This was years ago- but I'll be more careful now. Anyway, this is the script I have (the color orange is just to see where the actual filter would be applied. It's for testing purposes)
And below is what it's producing. Again, I'm simply attempting to protect my lines and filter the rest. Can anyone lend a hand here? ThanksCode:MPEG2Source("blah") Assumetff() TFM() TDecimate(mode=1) a=Last b=blankclip(a, color=color_orange) mask1=mt_binarize() mask2=mt_edge("cartoon") Overlay(mask1, mask2)
+ Reply to Thread
Results 1 to 6 of 6
-
-
As usual, post a sample of the video.
One thing to note: mt_edge() and mt_binarize() have threshold values you can play with. Also, you can expand the mask with mt_expand() and inpand with mt_inpand(). It can be helpful to blur the mask too -- to soften the edge between process an unprocessed areas.Last edited by jagabo; 16th Jul 2021 at 23:22.
-
Code:
MPEG2Source("blah") Assumetff() TFM() TDecimate(mode=1) video=last Loadplugin("Plugins_JPSDR.dll") LevelLimit=(video.BitsPerComponent==8) ? 255 : 1023 IntensityMask=ConvertToY(video).Levels(0,2,LevelLimit,0,LevelLimit,coring=false) EdgeMask=aSobel(IntensityMask,chroma=0,thresh=255).invert.Levels(0,2,LevelLimit,0,LevelLimit,coring=false).Blur(1) FilteredVideo=invert(video) #USE YOUR OWN FILTERING HERE. INVERT IS JUST AN EXAMPLE! video=Overlay(video,FilteredVideo,mask=EdgeMask,opacity=1.0) return video -
Done.As usual, post a sample of the video.
Yes, it all sounds very nice. Can you please show me how that would look like on a script please? As I stated, I forgot how to do it.One thing to note: mt_edge() and mt_binarize() have threshold values you can play with. Also, you can expand the mask with mt_expand() and inpand with mt_inpand(). It can be helpful to blur the mask too -- to soften the edge between process an unprocessed areas.
Atak, I do appreciate your help but your script is not exactly what I'm trying to do here. And it doesn't even load. -
First, a note on your script in the first post:
You are creating two masks, mask1 and mask2. Then you overlay mask2 into mask1, thereby overwriting mask1 with mask2. The result of Overlay() is simply mask2.Code:mask1=mt_binarize() mask2=mt_edge("cartoon") Overlay(mask1, mask2)
Here's one way to animate the mask creation with mt_edge() so you can quickly determine what values you want to use:
That will show you the result of mt_edge() (for frame 22 only) over a range of 0 to 100 for thy1 and thy2. Try the different modes to see what the differences are (sobel, roberts, etc).Code:function anim_mask(clip c, int thresh) { mt_edge(c, "hprewitt", thy1=thresh, thy2=thresh) Subtitle(string(thresh)) # show threshold value } AviSource("bridge.avi") # RGB source? ConvertToYV12() Trim(22,0).Loop(100,0,0) # only frame 22, repeated 100 times emask = Animate(0,100, "anim_mask", last,0, last,100).GreyScale() return(emask)
http://avisynth.nl/index.php/MaskTools2/Mt_edge
mt_expand() can expand the mask to fill in small holes and cover areas near edges. You can soften the mask (to make the transition from masked to not masked areas less obvious:
Code:function anim_mask(clip c, int thresh) { mt_edge(c, "hprewitt", thy1=thresh, thy2=thresh) Subtitle(string(thresh)) # show threshold value } AviSource("bridge.avi") # RGB source? ConvertToYV12() Trim(22,0).Loop(100,0,0) # only frame 22, repeated 100 times emask = Animate(0,100, "anim_mask", last,0, last,100).mt_expand().Blur(1.0).GreyScale() return(emask)
[Attachment 59909 - Click to enlarge]
Conversely, you can use mt_inpand() to thin the mask and remove small dots.
Similar Threads
-
Divide each line of text into new subtitle line
By martanius in forum SubtitleReplies: 1Last Post: 11th Apr 2021, 17:21 -
Help with My Script Motion Mask for two videos
By Kuronoe in forum Newbie / General discussionsReplies: 5Last Post: 28th Jan 2021, 19:41 -
Help with My Scriot Motion Mask for two videos
By Kuronoe in forum Newbie / General discussionsReplies: 0Last Post: 28th Jan 2021, 10:46 -
Request for Youtube-dl command line assistance
By peteinoz in forum Video Streaming DownloadingReplies: 7Last Post: 20th Oct 2020, 11:55 -
Mask question
By Aludin in forum EditingReplies: 12Last Post: 12th Jan 2017, 00:31


Quote