Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se |
|
|
#1 | Link |
|
Registered User
Join Date: Mar 2002
Posts: 130
|
General-purpose masking filters?
It seems like we have a lot of neat filters that calculate a mask for the video clip and then process things that fall under / don't fall under that mask.
For example, we have MSmooth / MSharpen which detect edges, BlockBuster which detects areas most likely to be afflicted with DCT blocks, etc. My question: would it be simple to convert these masking algorithms into filters that just apply the masks and return the relavant clips? For example, it would make something like this possible: clip = MPEG2Source("test.d2v") #split into edges and not edges clip_edges = clip.EdgeMask(strength=5) clip_notedges = clip.EdgeMask(inverse=true,strength=5) #process edges ... #process parts of the clip which aren't edges clip_notedges_block1 = clip_notedges.DCTBlockMask(block_size=4,detail_min=1,detail_max=20) clip_notedges_block2 = clip_notedges.DCTBlockMask(block_size=4,detail_min=20,detail_max=100) #more processing here ... #splice the clips back together clip_notedges_final = Layer(clip_noedges_block1,clip_notedges_block2) clip_final = Layer(clip_edges,clip_notedges) return clip_final --- It seems to me that these masking functions could be more useful than they already are if they are broken out of their respective filters so we can play with them more. -p
__________________
xvid + vorbis + ogm = dance all night |
|
|
|
|
|
#2 | Link |
|
developer wannabe
Join Date: Nov 2001
Location: Brooklyn, NY
Posts: 1,211
|
This is already possible. I know MSharpen, for instance, has a parameter along the lines of "showmask=true" that can then be fed to Mask/Layer -- I've done it myself. You can also use GeneralConvolution to simulate edge masks via Sobel matrices; there's an example of this somewhere on avisynth.org.
|
|
|
|
|
|
#3 | Link | |
|
Registered User
Join Date: Mar 2002
Posts: 130
|
Quote:
__________________
xvid + vorbis + ogm = dance all night |
|
|
|
|
|
|
#5 | Link |
|
Registered User
Join Date: Mar 2002
Posts: 130
|
Here's the problem I think needs to be addressed here: too many filters duplicate concerns that would better served by having a single function that all the functions can call.
For example, take MSmooth and MSharpen. They both use an edge masking algorithm to apply a Blur or a Sharpen filter to specific parts of the image. From a high level, this approach has several faults: - A change to the edge masking algorithm must be manually applied to both filters. Faults can crop up here. - Assuming that the code for blurring and sharpening in MSmooth and MSharpen is reimplemented within those filters rather than called from the Avisynth core, bugfixes and speed improvements for Avisynth's internal routines do not carry over to the filter. - It is conceviable that someone would want to apply a filter such as Con3d to a clip which has been edge-masked. As it is right now, this is not possible unless that filter's author reimplements Con3d's routines and adds another argument to his filter: "con3d=[true|false]". But what if a user wants to run Con3d on the edge-masked clip, and then say WarpSharp? As it is right now, this is not possible. My point in brief: Avisynth is a piece of software that supports complex and robust scripting. In this way, it is philosophically a very UNIX-like piece of software. This point is supported by the internal filters present in Avisynth: each of the internal filters does one thing, and does it well. Many user-coded plugins, on the other hand, are monolithic, like Windows applications tend to be. Rather than each plugin doing one thing and doing it well, many plugins in some way reimplement each other at some level. This is not optimal from a software engineering standpoint, and the end-user has less power using monolithic filters than he would have if he were able to use atomic filters (as justified above). -p *edit* word choice
__________________
xvid + vorbis + ogm = dance all night Last edited by primitive; 4th February 2003 at 23:18. |
|
|
|
|
|
#7 | Link | |
|
Registered User
Join Date: Mar 2002
Posts: 130
|
Quote:
Open source development is characterized by groups of developers that band together to scratch a collective itch. I believe that more atomic plugins will increase Avisynth's power as an editing tool. I'm a Linux guy, so I appreciate the power of having a collection of atomic tools that are easily bound together by a robust scripting language. Avisynth provides this robust scripting environment, so why not use it to its fullest? -p
__________________
xvid + vorbis + ogm = dance all night |
|
|
|
|
|
|
#9 | Link |
|
Guest
Join Date: Jan 2002
Posts: 21,901
|
I wanna cut some boards. I better pull out my generic motor and my generic blade and my generic power supply and my generic handle assembly and spend hours assembling them together. Of course, having a separate motor in all my power tools and my vacuum cleaner, etc., is really ugly and suboptimal, so I wouldn't even consider it. Of course, since I have to have a common motor I can't specialize the tools, so they'll all have to sacrifice power and functionality to use the common motor, but hey, I'm Unix-like!
And by the way, MSharpen and MSmooth cannot easily use a common atomic edge mask algorithm. Performance is probably the most important criterion for video work. Atomicity works against that. I already deleted my ill-chosen words before your response. Remember you cannot be robbed of something you never had. Last edited by Guest; 4th February 2003 at 23:20. |
|
|
|
|
|
#10 | Link | ||
|
Registered User
Join Date: Mar 2002
Posts: 130
|
Quote:
- An improvement to any one part of the generic setup should improve whatever you combine the generic components to make. If most operations are atomic, small optimizations in one component can make big gains across the board. - Software is not a material good. Though it may take you a while to piece together a script function for the first time, it's not like everyone who ever uses that function has to make that kind of time investment, and the function itself can be distributed for free. Quote:
Also, is there something about the Avisynth architecture that would make clip.EdgeMask(inverse=true,strength=5).Convolution3d(preset="AnimeHQ") slower than clip.MSmooth(strength=5,Con3d=true,preset="AnimeHQ") assuming that Con3d was integrated into MSmooth? -p
__________________
xvid + vorbis + ogm = dance all night |
||
|
|
|
|
|
#11 | Link | |
|
Guest
Join Date: Jan 2002
Posts: 21,901
|
Quote:
I don't know why you chose me to rag on. MSharpen and MSmooth already have options to output their edge masks. Are you ragging on me because I didn't code them to read other (nonexistent) ones, or because I had the audacity to want an integrated application? Tell me exactly what you are saying I should do with respect to these filters that you singled out, presumably as paradigmatic of your case. Thank you. Extra copying will often be required to make things atomic. There will also be an additional load on the Avisynth frame cache. Last edited by Guest; 4th February 2003 at 23:54. |
|
|
|
|
|
|
#12 | Link | |||
|
Registered User
Join Date: Mar 2002
Posts: 130
|
Quote:
Quote:
- I'd have to manually update my MSmooth/Con3d hybrid every time a new version of either filter is released. That'd be a pain in the ass, and I'd probably find a strange and obscure way to introduce faults. - I'd have to add more arguments to MSmooth to make it work with the Con3d smoothing method, including a modality trigger (mode="3x3" or mode="Con3d"). This type of tying-together of functionality is called "logical cohesion" and is highly undesirable. Reference: http://www.it.lut.fi/opetus/99-00/01.../lecture7.html The other option is to break the edge-masking functionality into its own plugin and then let the user specify the smoothing method. This seems attractive because the MSmooth documentation implies that MSmooth's smoothing method is similar to Avisynth's internal Blur(). This also avoids the cohesion problem referred to earlier by requiring neither a modality switch nor separately compiled versions of what is essentially the same filter. Quote:
-p
__________________
xvid + vorbis + ogm = dance all night Last edited by primitive; 5th February 2003 at 01:38. |
|||
|
|
|
|
|
#13 | Link |
|
Guest
Join Date: Jan 2002
Posts: 21,901
|
Specifically, what are you asking me to do with MSmooth and MSharpen? As I said, I already output the edge map and if someone else wants to write a different back end filter that reads the edge map, there's nothing to stop them.
I'm really not interested in general tools versus applications discussions or academic arguments about software "purity". If you don't have any specific requests for me I will bow out. Last edited by Guest; 5th February 2003 at 02:03. |
|
|
|
|
|
#14 | Link |
|
developer wannabe
Join Date: Nov 2001
Location: Brooklyn, NY
Posts: 1,211
|
I like what you're saying, primitive, but am as mystified as neuron2 WRT what the Avisynth core team should do (in your opinion). Are you proposing any backend changes, or can your ideas be implemented adequately in the current system?
|
|
|
|
|
|
#15 | Link | |
|
Registered User
Join Date: Mar 2002
Posts: 130
|
Quote:
- Right now, it looks like it's possible to extract a mask using MSmooth in conjunction with ColorKeyMask(). You should be able invert that mask as well with creative use of Subtract(). However, using this method hurts, and using it to get an inverted mask really hurts (because you have to mask the MSmooth-generated frame, then use that masked frame again as a mask against that same frame in its unprocessed form). Rather than go through this runaround, it'd be cleaner (and faster) for the filter to output masked pixels directly; this would eliminate the need to call any of the Mask() functions altogether. (primitive)
__________________
xvid + vorbis + ogm = dance all night |
|
|
|
|
|
|
#17 | Link |
|
Vlad, the Buffy slayer
Join Date: Oct 2001
Location: France
Posts: 445
|
Hi,
I have to admit I mainly agree with Primitive (Althought I'm not a linux guy). I sometimes dreamed of an internal integrated tool box in addition to env->BitBlt for example : Env->EdgeMask (Method=[Fast|Slow|...] Env->MotionMask (...) etc Because the same method are used in many filters. I know that if wanted to use an edgemask. My first action would be to ask Donald his permission to use his edge detection algo to make primary test and then if the results are good I'll try to find a better one or to optimize Donald's one. That would be cool to have an integrated tool box. But by reading Primitive post, it's true that it would be even better to allow the end user to use the same trick. I have not thought about it long enought to say wether it's possible or not. I'll have to think about it.
__________________
Vlad59 Convolution3D for avisynth 2.0X : http://www.hellninjacommando.com/con3d Convolution3D for avisynth 2.5 : http://www.hellninjacommando.com/con3d/beta |
|
|
|
|
|
#19 | Link | |
|
Vlad, the Buffy slayer
Join Date: Oct 2001
Location: France
Posts: 445
|
Quote:
My mother always said me to ask even if I knew the answer will be yes .
__________________
Vlad59 Convolution3D for avisynth 2.0X : http://www.hellninjacommando.com/con3d Convolution3D for avisynth 2.5 : http://www.hellninjacommando.com/con3d/beta |
|
|
|
|
![]() |
|
|