Back Forum Reply New

New filters: PixelInfo / PsetRGB

Hello everyone,

here are two little filers:

Pixelinfo_0.1.zip

PixelInfo() is a GUI-based filter. It lets you pick a pixel and gives you color-information. It works only with YUY2 and RGB32.

PSetRGB(x,y,r,g,b) Draws a pixel on the given position with the given color. (RGB32 only)

How should i implement a YUY2 or even YV12 version of the Pset-filter? Any ideas or wishes? I will upload the source as well in a couple of days. Have to clean up first.

hanfrunz

Hi,

You can add a quot;modequot; parameter wich selects averaging, replacing or left untouched chroma values for the pixel pointed. Then you can choose the influence with co-located pixels.

I'd like to try this out, but I don't know how!  I made a simple test avs,

Code:
colorbars(720,480)
pixelinfo()
and load it with virtualdub, and the GUI shows up with all blank spaces, and clicking buttons doesn't do anything.  I don't see how it's possible for virtualdub to send mouse click to an avs script, so I'm missing something totally basic here.

Update: the script must be playing.  Improvements would be: passing the start position as arguments, passing the colorvalue to the script, and drawing a cursor to know where you're at.

It does save a lot of time compared to pasting the frame into a paint program, if it would accept coordinates, otherwise it takes too long to set them.


Originally Posted by jmac698Update: the script must be playing.  Improvements would be: passing the start position as arguments, passing the colorvalue to the script, and drawing a cursor to know where you're at.

It does save a lot of time compared to pasting the frame into a paint program, if it would accept coordinates, otherwise it takes too long to set them.

Yes the script must be playing, because the crosshair must be painted new in every frame. What do you mean with quot;cursorquot; there is one, is it to small? I plan a videowindow as part of the GUI, so you can just click on any pixel you wish, but i have to find out how to do it first

@AVIL: okay i try to implement these methods, and also a mode where you have to set four values quot;y1, U, y2 and Vquot;. YV12 is more tricky...

hanfrunz

I see a cursor/crosshair now, but it is not moving for me.  I change the numbers, but it doesn't move.  Sometimes when I stop and play again it has moved.  Does it always work for you?


Originally Posted by jmac698I see a cursor/crosshair now, but it is not moving for me.  I change the numbers, but it doesn't move.  Sometimes when I stop and play again it has moved.  Does it always work for you?

can you please post your script. Maybe a problem with caching. Try SetMemoryMax(0) in your script.

sweet!  i'm going to implement a mandelbrot generator when i get time now   maybe frames = iterations would be an interesting way to do it?

[edit]

would it be possible to have a non-gui pixelinfo that returns pixel info for an x,y coord like pixelinfo does?  it'd be the basis of script-based pixel manipulation if you could also check pixel values without having to select them.  that way you could make a primitive temporal smoother by checking if the pixel has changed by a threshold, and if not, keep the current pixel.  might be good for proof-of-concept filters, but it'd probably be dog slow for anything else

[edit 2]

oops, just realised i'd need width*height calls of pset... i'm not up for that just yet


Originally Posted by Mug Funkywould it be possible to have a non-gui pixelinfo that returns pixel info for an x,y coord like pixelinfo does?

This is the next thing i plan to do, but i think it is not possible to do something like:Code:
r=pget(x,y,quot;rquot;)
g=pget(x,y,quot;gquot;)
b=pget(x,y,quot;bquot;)
i could write the value to a file and read it with conditionalfilter but thats not very user friendly... Can some of the main-developer confirm this?

You can use Avisynth variable:
env-gt;SetVar(quot;pixelRquot;,Rvalue)


Originally Posted by FizickYou can use Avisynth variable:
env-gt;SetVar(quot;pixelRquot;,Rvalue)

this is not working  I think the variables are set once per filter. If i change it in filter one, there's is no change in filter two. I think i could use Invoke() somehow, but i don't know how...

hanfrunz

May be use GlobalVar?


Originally Posted by FizickMay be use GlobalVar?

i tried this too... same thing

Did you try this?

Code:
static AVSValue __cdecl GetSystemEnv(AVSValue args, void* /* userDataP */, IScriptEnvironment* envP)
{   const char* varName = args[0].AsString();   const char* val = getenv(varName);   return (val == NULL) ? AVSValue()             : AVSValue(envP-gt;SaveString(val, strlen(val)));
}Not sure I quite understand what you want to do here. Put you source up and I will have a look.

Hints:-

Constructor code runs exactly once as the script compiles.

GetFrame code runs once per frame being generated.

The cache can stop GetFrame being run a second time for the same frame number.

He needs something in the GetFrame category.  He wants to read a pixel each frame and return it in a scripting variable as integers.  What line of code would that be for him to try?

To write a conditional filter plugin look at src\filters\conditional\conditional_functions.cpp for examples.

To set a variable
Code:
int n = 42;
env-gt;SetVar(quot;namequot;, (AVSalue)n);
To get it back
Code:
AVSValue v = env-gt;GetVar(quot;namequot;);
int n = v.AsInt();
Originally Posted by IanBTo write a conditional filter plugin look at src\filters\conditional\conditional_functions.cpp for examples.

To set a variable
Code:
int n = 42;
env-gt;SetVar(quot;namequot;, (AVSalue)n);
To get it back
Code:
AVSValue v = env-gt;GetVar(quot;namequot;);
int n = v.AsInt();that works fine in one filter, but if have a script like that:Code:
xxxsource(whatever)
x=0
filterA
filterB
and filterA sets x=7, then if you debug filterB the value for x is 0!

Hi Hanfrunz,

I notice the colours in your avatar do not scale past 204 colour (except for the colour white which scales up to all three 255) levels: -

I took the liberty of making another version that scales up to all three 255 levels: -

Cheers

mmh but it is a 100/0/75/0 colorbar  But i don't know if the levels are correct...


Code:
xxxsource(whatever)
x=0
filterA
filterBAh a trickey one. The execution order will be something like this
Code:
x=0 # constructor time
...
World-gt;GetFrame(n) filterB-gt;GetFrame(n)   GetVar(x)       # returns 0   filterA-gt;GetFrame(n)     xxxsource-gt;GetFrame(n)       make a video frame       return     SetVar(x, 42)     return   GetVar(x)      # returns 42   return return
It is easiest to step down the GetFrame call chain with the debugger to see what is happening.

Perhaps if you explain exactly what you want to happen I can say exactly how to do it. At the moment I am second guessing what you want and offering generic answers which may have hidden gotcha's for your case
¥
Back Forum Reply New