PDA

View Full Version : New filters: PixelInfo / PsetRGB


hanfrunz
13th March 2006, 12:21
Hello everyone,

here are two little filers:

Pixelinfo_0.1.zip (http://www.geocities.com/hanfrunz/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

AVIL
13th March 2006, 20:57
Hi,

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

jmac698
13th March 2006, 21:23
I'd like to try this out, but I don't know how! I made a simple test avs,
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.

hanfrunz
13th March 2006, 22:43
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.

Yes the script must be playing, because the crosshair must be painted new in every frame. What do you mean with "cursor" 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 "y1, U, y2 and V". YV12 is more tricky...

hanfrunz

jmac698
13th March 2006, 23:30
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?

hanfrunz
14th March 2006, 16:56
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?

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

Mug Funky
15th March 2006, 00:56
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 :)

hanfrunz
15th March 2006, 11:40
would 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:


r=pget(x,y,"r")
g=pget(x,y,"g")
b=pget(x,y,"b")


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?

Fizick
16th March 2006, 22:19
You can use Avisynth variable:
env->SetVar("pixelR",Rvalue)

hanfrunz
20th March 2006, 11:23
You can use Avisynth variable:
env->SetVar("pixelR",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

Fizick
20th March 2006, 18:18
May be use GlobalVar?

hanfrunz
20th March 2006, 19:49
May be use GlobalVar?

i tried this too... same thing :(

jmac698
21st March 2006, 04:33
Did you try this?
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->SaveString(val, strlen(val)));
}

IanB
22nd March 2006, 09:40
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.

jmac698
22nd March 2006, 15:46
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?

IanB
23rd March 2006, 08:52
To write a conditional filter plugin look at src\filters\conditional\conditional_functions.cpp for examples.

To set a variableint n = 42;
env->SetVar("name", (AVSalue)n);To get it backAVSValue v = env->GetVar("name");
int n = v.AsInt();

hanfrunz
23rd March 2006, 12:25
To write a conditional filter plugin look at src\filters\conditional\conditional_functions.cpp for examples.

To set a variableint n = 42;
env->SetVar("name", (AVSalue)n);To get it backAVSValue v = env->GetVar("name");
int n = v.AsInt();

that works fine in one filter, but if have a script like that:

xxxsource(whatever)
x=0
filterA
filterB

and filterA sets x=7, then if you debug filterB the value for x is 0!

SeeMoreDigital
23rd March 2006, 16:02
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: -

http://img122.imageshack.us/img122/3597/bars75extg3xj.png


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

http://img122.imageshack.us/img122/1517/bars75new8zv.png


Cheers

hanfrunz
23rd March 2006, 18:40
mmh but it is a 100/0/75/0 colorbar :) But i don't know if the levels are correct...

IanB
24th March 2006, 00:37
xxxsource(whatever)
x=0
filterA
filterBAh a trickey one. The execution order will be something like thisx=0 # constructor time
...
World->GetFrame(n)
filterB->GetFrame(n)
GetVar(x) # returns 0
filterA->GetFrame(n)
xxxsource->GetFrame(n)
make a video frame
return
SetVar(x, 42)
return
GetVar(x) # returns 42
return
returnIt 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 ;)

hanfrunz
24th March 2006, 11:47
we want that filter A (pget) reads the rgb values of a given pixel. These values should be stored in script-variables (r,g,b). Then other filters can use these values to do whatever you wish.

IanB
24th March 2006, 14:45
Probably you wantint n = 42;
env->SetGlobalVar("name", (AVSValue)n);PushContext/PopContext would have to be involved but I am not quite sure why in this case. Are you env->Invoke'ing a 2nd chain? A single GetFrame chain should all be in the same context.

You may have to debug trace your way thru the code chain from the child->GetFrame() call in filterB down thru to the Set(Global)Var call in filterA::GetFrame.

There be dragons in that there code :D

jmac698
2nd April 2006, 16:03
How is the plugin coming?

I noticed:
http://forum.doom9.org/showthread.php?p=674982#post674982
HighInBC: Is there a way for avisynth to return the color of a specific pixel into an int?

Someone wants to use it for a whitebalance script. It proves my point that this is a needed function, as there's people with great ideas that can only script and not write a full plugin.

hanfrunz
3rd April 2006, 10:54
How is the plugin coming?

I noticed:
http://forum.doom9.org/showthread.php?p=674982#post674982


Someone wants to use it for a whitebalance script. It proves my point that this is a needed function, as there's people with great ideas that can only script and not write a full plugin.

I still think, that it is not possible to for a filter to change a scriptvariable, but i will investigate if i have time. A new version with a preview-window will be uploaded the next days!

hanfrunz

jmac698
4th April 2006, 04:40
I don't understand the problem, but I asked IanB to give you a hand, has his suggestions not helped? If you can explain clearly I'm sure you can get help....
There's also the source code I left for you.

hanfrunz
4th April 2006, 11:01
I don't understand the problem, but I asked IanB to give you a hand, has his suggestions not helped? If you can explain clearly I'm sure you can get help....
There's also the source code I left for you.

The main problem is time, i hope i find some time the next days to analyse all that stuff...

Backwoods
7th August 2006, 09:39
Have you found any time to work on this filter hanfrunz?

hanfrunz
7th August 2006, 19:55
i worked a little bit on the pget() filter, but it's too buggy right now. I try to release a new version in a few days.

hanfrunz

windcool
8th August 2006, 16:04
I can't download this filter.
Please check the adress,.

hanfrunz
10th August 2006, 10:58
@windcool: please try again, works fine for me. Geocities is sometimes down...

yashar
24th September 2006, 06:07
are you still working on this filter hanfrunz?

hanfrunz
25th September 2006, 10:51
sometimes, i will release a new version soon.

Wilbert
17th September 2007, 00:05
@jmac698,

Something like this:


LoadPlugin("F:\CompilingPlugins\PixelValue\Release\PixelValue.dll")

w = ColorBars(pixel_type="RGB32")
#w = ScriptClip(w, """Subtitle(String(RGB(200, 40, "B")))""")
#w = ScriptClip(w, """Subtitle(String(RGB(500, 40, "BGR")))""")
w = ScriptClip(w, """Subtitle(String(RGB(500, 40, "R")))""")
return w

See readme for further information and examples.

http://www.geocities.com/wilbertdijkhof/PixelValue_v01.zip