View Single Post
Old 6th August 2012, 10:28   #21  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
Like I said, you can use the call plugin to run a batch script or whatever, but it's only run once before the script starts.

Here's how to read and plot pixels:
Code:
Function GetPixel(clip clip, int x, int y) {
    #Return luma of a pixel
    current_frame=0
    clip
    IsYUY2 ? ConvertToYV12 : clip#AverageLuma only works on planar.  YV12 is planar.
    pointresize(6,6,x,y,1,1)#Blow up the pixel at x,y by 6 times (minimum possible with resize)
    int(AverageLuma)
}

Function PutPixel(clip clip, int x, int y, int luma) {
    #Plot a pixel
    clip
    ClipIsYV12=IsYV12
    ClipIsYV12 ? ConvertToYUY2 : last
    pointresize(width*2, height)
    u=128
    v=128
    pixel=blankclip(last, color_yuv=luma*65536+u*256+v, width=2, height=1)
    layer(last, pixel, "add", 256, x*2, y)#Layer only works with YUY2
    pointresize(width/2, height)
    ClipIsYV12 ? ConvertToYV12 : last
}
I have to tell you, I'm using an undocumented trick here. You can read a pixel once at the start on a specific frame, by setting current_frame. This lets you use the runtime variables, like AverageLuma. Remove the "current_frame=" line to use it as a runtime function. With the runtime way; averageluma has to appear inside scriptclip or one of the others.

The array implementation in avslib is quite slow. I have the same thoughts of a meta-data per-frame with another clip; but it could be added at the bottom. The garbage in the last few lines can be be cropped out.

You can extend this to RGB with showred.converttoyv12 for example. You could also make a kind of array in a clip by plotting pixels and reading them.

My slicer and addcode plugins can also read and plot int's on a line of video.
http://forum.doom9.org/showthread.ph...74#post1582574

for myself: keywords pset, plot, plot a pixel, plot(x,y), pset(x,y)

edit: thank you me! I swear, this is the 5th time I've searched for this post.

Last edited by jmac698; 1st March 2015 at 12:30.
jmac698 is offline   Reply With Quote