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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th March 2006, 12:21   #1  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 540
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
hanfrunz is offline   Reply With Quote
Old 13th March 2006, 20:57   #2  |  Link
AVIL
Registered User
 
Join Date: Nov 2004
Location: Spain
Posts: 408
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.
AVIL is offline   Reply With Quote
Old 13th March 2006, 21:23   #3  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
how to use it?

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.

Last edited by jmac698; 13th March 2006 at 22:05.
jmac698 is offline   Reply With Quote
Old 13th March 2006, 22:43   #4  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 540
Quote:
Originally Posted by jmac698
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
hanfrunz is offline   Reply With Quote
Old 13th March 2006, 23:30   #5  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
pixelinfo

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?
jmac698 is offline   Reply With Quote
Old 14th March 2006, 16:56   #6  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 540
Quote:
Originally Posted by jmac698
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.
hanfrunz is offline   Reply With Quote
Old 15th March 2006, 00:56   #7  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
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
__________________
sucking the life out of your videos since 2004

Last edited by Mug Funky; 15th March 2006 at 01:08.
Mug Funky is offline   Reply With Quote
Old 15th March 2006, 11:40   #8  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 540
Quote:
Originally Posted by Mug Funky
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:

Code:
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?
hanfrunz is offline   Reply With Quote
Old 16th March 2006, 22:19   #9  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
You can use Avisynth variable:
env->SetVar("pixelR",Rvalue)
Fizick is offline   Reply With Quote
Old 20th March 2006, 11:23   #10  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 540
Quote:
Originally Posted by Fizick
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
hanfrunz is offline   Reply With Quote
Old 20th March 2006, 18:18   #11  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
May be use GlobalVar?
Fizick is offline   Reply With Quote
Old 20th March 2006, 19:49   #12  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 540
Quote:
Originally Posted by Fizick
May be use GlobalVar?
i tried this too... same thing
hanfrunz is offline   Reply With Quote
Old 21st March 2006, 04:33   #13  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
set var

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->SaveString(val, strlen(val)));
}
jmac698 is offline   Reply With Quote
Old 22nd March 2006, 09:40   #14  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
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.
IanB is offline   Reply With Quote
Old 22nd March 2006, 15:46   #15  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
getframe

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?
jmac698 is offline   Reply With Quote
Old 23rd March 2006, 08:52   #16  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
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->SetVar("name", (AVSalue)n);
To get it back
Code:
AVSValue v = env->GetVar("name");
int n = v.AsInt();

Last edited by IanB; 23rd March 2006 at 08:55.
IanB is offline   Reply With Quote
Old 23rd March 2006, 12:25   #17  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 540
Quote:
Originally Posted by IanB
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->SetVar("name", (AVSalue)n);
To get it back
Code:
AVSValue v = env->GetVar("name");
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!
hanfrunz is offline   Reply With Quote
Old 23rd March 2006, 16:02   #18  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
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
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |

Last edited by SeeMoreDigital; 23rd March 2006 at 19:04.
SeeMoreDigital is online now   Reply With Quote
Old 23rd March 2006, 18:40   #19  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 540
mmh but it is a 100/0/75/0 colorbar But i don't know if the levels are correct...
hanfrunz is offline   Reply With Quote
Old 24th March 2006, 00:37   #20  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Quote:
Code:
xxxsource(whatever)
x=0
filterA
filterB
Ah a trickey one. The execution order will be something like this
Code:
x=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
  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
IanB 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 10:46.


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