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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th December 2007, 00:48   #1  |  Link
Hadien
Infected Mushroom Fan
 
Hadien's Avatar
 
Join Date: Dec 2007
Location: Atlanta,GA
Posts: 17
PaintBucket/fill script

I did a search and found an old thread that mentioned using a color key Mask. However, I was looking for a script capable of filling a "contiguous" area from a certain point on a frame. I mean more specifically that it fills only the pixels confined by the other colors from a point... For example, its a lot like the paintbucket effect in Aftereffects or the color fill tool in Microsoft Paint(but with a tolerance option)

I'm thinking of making this a component of a larger function I'm trying to develop... though I'm still a bit new to the AVISynth language itself...

I first wanted to see if such a function existed, and If one didn't, how I would go about to creating one...
Hadien is offline   Reply With Quote
Old 19th December 2007, 03:53   #2  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
You could try doing something like a mask where you selectively choose colors that fall within a tolerance range, and then set those pixels to a color and replace the old pixels with the color you want it to be.

How you would go about this though, I have absolutely no idea, but I can at least give you an idea of how it (in my eyes) might be done.
Sagekilla is offline   Reply With Quote
Old 19th December 2007, 07:58   #3  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,436
Flood fill algorithms are easy to find, for instance. Heck, the simplest method might even be to pull the relevant code out of GIMP or Inkscape and plop it into SimpleSample or your favorite open-source filter.

It'd be possible but probably impractical to build one with existing filters, unless you used CelForeground somehow.
__________________
There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order.
foxyshadis is offline   Reply With Quote
Old 19th December 2007, 18:59   #4  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,335
Try MaskHS in AviSynth 2.6.
Wilbert is offline   Reply With Quote
Old 19th December 2007, 23:11   #5  |  Link
Hadien
Infected Mushroom Fan
 
Hadien's Avatar
 
Join Date: Dec 2007
Location: Atlanta,GA
Posts: 17
2.6 eh...
heh, Looks like I'll have to update... thanks for the heads up.

@Foxshadis
Finding the algorithm for a paint fill isn't the real problem. Its how you would implement it through AVISynth... I mean how to work on a frame pixel by pixel... The closest thing I found to evaluating a frame by pixel were the "colorspace"LUT filters. but even those filters I can't quite understand. I tried following their examples but I can't seem to get any results. I guess I'm just misinterpreting what the filters are used for. Not even sure I need them...

Thanks for the link, that scanline fill sounds more promising (though I'm still in the same boat on how to construct it)

And I'll try the MaskHS and see how it would help.
Update:Oh 2.6 is a pre-Alpha... Guess I should be careful...

Last edited by Hadien; 20th December 2007 at 00:35. Reason: Updating
Hadien is offline   Reply With Quote
Old 20th December 2007, 22:36   #6  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,335
Quote:
And I'll try the MaskHS and see how it would help.
Update:Oh 2.6 is a pre-Alpha... Guess I should be careful...
Yes, you should be I can always make a separate plugin (for v2.5) from it when it's worthwhile.
Wilbert is offline   Reply With Quote
Old 21st December 2007, 10:39   #7  |  Link
Hadien
Infected Mushroom Fan
 
Hadien's Avatar
 
Join Date: Dec 2007
Location: Atlanta,GA
Posts: 17
I'm looking at the documentation for MaskHS... And though I do see many uses I can get out of it, I don't see how it can offer me a contiguous area for a selected color from a given point.

Is there any way you can call up the value of a certain pixel location and change it,per frame? like pixel[x][y] for Frame z (or all frames) or something? (and yes, I'm sure it wouldn't be an array since arrays are not native to AVISynth, but bear with me)
for example:

...
#assuming the colorspace is RGB and the clip is 720X480
#this will change the center pixel to the color red
pixel[360][240] =$FF0000
...

If thats not possible then is there any way to make a function to handle this? and upon further thinking if the current version can't support it do you think its possible for it to show up in a later version? Being able to do this would surely help in me writing out a fill script. Or am I just underestimating MaskHS?

Edit: As for that CelForeground... All I can find on that is a dll... I don't even know what arguments or functions it has or how it exactly works. the closest documentation I came to it was where Foxyshadis was recommending it to someone else in another thread...and looking from the pics posted using CelForground, it doesn't look like what I'm looking for...

Last edited by Hadien; 21st December 2007 at 10:56.
Hadien is offline   Reply With Quote
Old 21st December 2007, 11:15   #8  |  Link
squid_80
Registered User
 
Join Date: Dec 2004
Location: Melbourne, AU
Posts: 1,963
Quote:
Originally Posted by Wilbert View Post
Yes, you should be I can always make a separate plugin (for v2.5) from it when it's worthwhile.
I already did that a while ago since I needed it. Returns a YV12 clip with blank chroma planes instead of a Y8 clip. Also requires VS2005 SP1 runtime libraries.

Edit: Link removed. See below for new link.

Last edited by squid_80; 22nd December 2007 at 06:56.
squid_80 is offline   Reply With Quote
Old 21st December 2007, 12:47   #9  |  Link
Leak
ffdshow/AviSynth wrangler
 
Leak's Avatar
 
Join Date: Feb 2003
Location: Austria
Posts: 2,441
My 0.02 EYPO:

Implementing a fill algorithm in an AviSynth script would be dog slow, and moreover AviSynth scripts lack a useful loop construct and aren't meant to be run on a per-frame basis.

So your best bet would be to write a filling plugin in C/C++ (like suggested earlier) and call that from your script.

np: Yello - How How (Papa-Who-Ma-Mix) (Eccentrix Remixes)
__________________
now playing: [artist] - [track] ([album])
Leak is offline   Reply With Quote
Old 21st December 2007, 23:07   #10  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,335
@Hadien

Quote:
However, I was looking for a script capable of filling a "contiguous" area from a certain point on a frame.
Could you explain what you mean by a "contiguous" area?

This zip-file contains documentation of CelForeground:

http://www.geocities.com/wilbertdijk...nd_08Sep05.zip

and also this thread:

http://forum.doom9.org/showthread.php?t=99778

but i never used it, so i don't know its possibilities.

@squid_80,

Thanks! Could you also include the source?
Wilbert is offline   Reply With Quote
Old 22nd December 2007, 03:00   #11  |  Link
Hadien
Infected Mushroom Fan
 
Hadien's Avatar
 
Join Date: Dec 2007
Location: Atlanta,GA
Posts: 17
@Leak
Quote:
Originally Posted by Leak
your best bet would be to write a filling plugin in C/C++ (like suggested earlier) and call that from your script.
I guess so... I'm not exactly sure how to make it interact...Do I simply make the function into some dll then simply import (LoadPackage) it into my script and call it? or is there something more to that... guess it wouldn't hurt for me to just play around a bit...

@Wilbert

imagine you're using Paint and you just have a blank screen. you then make a simple box shape in the center. the color inside the box and the color outside the box are both the same color (white) while the box line is black. If you only want to turn the color inside the box to another color (lets say red) you would use the paintbucket tool paint has. you would select the color you want to change to in the palette then fill in the box with a red color.
notice it only fills in the white pixels inside the box, not all the white pixels on the canvas. Thats what I mean by contiguous... it doesn't change all the pixels that have the color on the frame. just the white pixels that are adjacent to other white pixels to which down the line is adjacent to the pixel location you define... (it sounds to me that I'm over complicating the definition)... if you were to select a position outside the box instead, then the white outside the box would be red while the inside would remain white.



of course if there were some way to use MaskHS (or ColorKeyMask, or something similar) to find all the colors you plan to change then subtract all the areas that wouldn't have the target location. It would end up with the similar (if not, exact) result I'm looking for...
Hadien is offline   Reply With Quote
Old 22nd December 2007, 04:20   #12  |  Link
vcmohan
Registered User
 
Join Date: Jul 2003
Location: India
Posts: 735
In my Colorit plugin the mask creation functions and color fill functions are available. May be tried.
__________________
mohan
my plugins are now hosted here
vcmohan is offline   Reply With Quote
Old 22nd December 2007, 07:00   #13  |  Link
squid_80
Registered User
 
Join Date: Dec 2004
Location: Melbourne, AU
Posts: 1,963
Quote:
Originally Posted by Wilbert View Post
Thanks! Could you also include the source?
www.digitalfoundry.org/andrew/MaskHS_src.zip
Includes both source and a compiled dll. (It's called avisynthplugin because that's what my skeleton filter project is called and I never changed it.)

edit mod: link: http://www.geocities.com/wilbertdijkhof/MaskHS_src.zip (dll included; docs: see v2.60 documentation).

Last edited by squid_80; 11th December 2008 at 21:19.
squid_80 is offline   Reply With Quote
Old 22nd December 2007, 08:00   #14  |  Link
Hadien
Infected Mushroom Fan
 
Hadien's Avatar
 
Join Date: Dec 2007
Location: Atlanta,GA
Posts: 17
Quote:
Originally Posted by vcmohan View Post
In my Colorit plugin the mask creation functions and color fill functions are available. May be tried.
THANKS!!! your Colordrops function did the trick for me and with it I was able to use it to finish my other function (a simple auto-rotoscoping function). theres is also a number of other functions in your colorit.dll I could use as components.

the reason I needed such a fill function was because I was challenged in making a vid just using AVISynth and so using applications like Premiere Pro and Aftereffects (or your favorite editing and compositing program)were prohibited. the point of the challenge was to show off what AVISynth could do... and while using something like a fill script (or a simple rotoscoping script) isn't what AVISynth is meant to do, I just wanted to show that AVISynth is capable of being abused and do these things.

and although my Rotoscoping function is extremely slow by AVISynth terms, it'll definitely be much faster than doing it manually through AE. so much that it'll likely be integrated into my workflo from now on.

Thanks to everyone for the help!!
Hadien is offline   Reply With Quote
Old 23rd December 2007, 21:56   #15  |  Link
BlueCup
Registered User
 
Join Date: Jan 2003
Posts: 66
Have any samples of your work that you can post here?
BlueCup is offline   Reply With Quote
Old 24th December 2007, 06:42   #16  |  Link
Hadien
Infected Mushroom Fan
 
Hadien's Avatar
 
Join Date: Dec 2007
Location: Atlanta,GA
Posts: 17
here:


Running from top left to right to bottom right:

1. The first one is the original source.
2.The second is the area I want the function to rotoscope.
3.Third is the original after going through my DefineLine function (clip orig, int "power", float "thickness", bool "denoise", int "radius", int "Luma_t", int "Chroma_t")
using spatial softening, convolution Kernel, then Binarize
4.Fourth is having the second mask the output of the third
5.Fifth is the result of a number of functions (including the ColorDrops Function) within AutoRoto()
6.the final shows the completed version in RGB32 (with the black background already transparent)

My function AutoRoto() has different modes so it can return one of the last four if given the first two. I'm also planning to add extra modes so that if you already have one of the other masks you can add it in as the second clip argument and call a different mode depending on which you input. the function currently has both feathering and mask expansion. (this example is using an expansion of -3 and a feathering of 10)
Hadien is offline   Reply With Quote
Old 28th December 2007, 10:54   #17  |  Link
peter100m
Registered User
 
Join Date: Mar 2005
Posts: 36
Hadien: wow. nice work! Is AutoRoto something you consider making public? It would be a great addition to Avisynth!
peter100m is offline   Reply With Quote
Old 28th December 2007, 13:28   #18  |  Link
Hadien
Infected Mushroom Fan
 
Hadien's Avatar
 
Join Date: Dec 2007
Location: Atlanta,GA
Posts: 17
I hope to...I would love to contribute to the community but I will say up front that I wouldn't have gotten so far without vcmohan's ColorIt plugin, I wouldn't feel right if I didn't say I was helped.

But I feel its nowhere near ready for public use. I've only performed one test case (initially, I only planned on using it once in the project) and theres a lot of hard code, so I don't know exactly how much of that hard code actually needs to be dynamic. Plus I'm not yet fixed on how much functionality I want it to have...

currently, the way I have the function set up you can only fill one area, while the ColorDrops() allows for multiple fill locations. The way I plan to get around this is allow Autoroto() to return the masked lines clip (#4 in my example) to where the user manually ColorDrops all the areas (just so You know, I choose the areas you want to be transparent;first argument is a white blankclip, and the color to fill with is anything but that white... any color not close to white anyway) then call it back into the function using a new mode, or simply do the rest it manually
Hadien is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:35.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.