hans1967
24th May 2011, 18:08
Hi Community,
I have a Sequence of Frames. Frames are completely black except for exactly one white Pixel in each Frame. The white Pixels are at different Locations in different Frames.
Do you know a Software, Plugin or Script (Virtualdub, Avisynth, IrfanView-Batchmode or other) which will output the X-Y-Coordinates of the white Pixels in each Frame?
Thank you for your Efforts.
Best Regards,
hans1967
cretindesalpes
24th May 2011, 20:00
# Fake input clip, for testing
a = BlankClip ()
b = BlankClip (width=1, height=1, color=$FFFFFF)
a.Animate (0, a.FrameCount () - 1, "Overlay", b, 53, 12, b, 635, 429)
# Actual script. Requires Masktools v2 alpha 48.
ConvertToYV12 ()
mt_binarize ()
x_lsb = mt_logic (mt_lutspa (mode="absolute", expr="x 255 &u"), mode="and")
x_msb = mt_logic (mt_lutspa (mode="absolute", expr="x 8 >>u"), mode="and")
y_lsb = mt_logic (mt_lutspa (mode="absolute", expr="y 255 &u"), mode="and")
y_msb = mt_logic (mt_lutspa (mode="absolute", expr="y 8 >>u"), mode="and")
ScriptClip ("""
x = x_msb.YPlaneMax () * 256 + x_lsb.YPlaneMax ()
y = y_msb.YPlaneMax () * 256 + y_lsb.YPlaneMax ()
sep = ", "
WriteFile ("coordinates.txt", "x", "sep", "y")
""")
hans1967
24th May 2011, 20:56
@ cretindesalpes
Thank you very much!
Avisynth is a huge Tool with infinite Possibilities. But not easy to survey for Non-Experts. Therefore this Forum is great useful!
I will tryout your script soon.
Thank you for your Efforts.
Best Regards.
hans1967
StainlessS
3rd September 2013, 16:23
Just came across this thread whilst searching, here an alternative script
# Fake input clip, for testing
a = BlankClip ()
b = BlankClip (width=1, height=1, color=$FFFFFF)
a.Animate (0, a.FrameCount () - 1, "Overlay", b, 53, 12, b, 635, 429)
# Actual script. Requires RT_Stats()
#ConvertToYV12 ()
OBJECT_SIZE = 1 # Object to find, size in pixels, smallest of W and H
AREA_X = 0 # Area of frame to search (0,0,0,0=full frame {As Crop})
AREA_Y = 0
AREA_W = 0
AREA_H = 0
LUMA_MIN = 235 # Luma minimum of object to find
LUMA_MAX = 255
NOTFOUND="NOT FOUND"
sep = ", "
ScriptClip ("""
Bingo=RT_YInRangeLocate(Baffle=OBJECT_SIZE,x=AREA_X,y=AREA_Y,w=AREA_W,h=AREA_H,Lo=LUMA_MIN,hi=LUMA_MAX)
(Bingo) ? WriteFile ("coordinates.txt", "YIRL_X", "sep", "YIRL_Y") : WriteFile ("coordinates.txt", "NOTFOUND")
""")
EDITED to make more flexible
EDIT:
RGB clips converted to Luma_Y
Will also find objects bigger than OBJECT_SIZE.
Will find eg 'hollow Wire Frame Rectangle' where frame widths are at least OBJECT_SIZE thick and between LUMA_MIN and LUMA_MAX.
Will find Disc (hollow or not) so long as top, bottom, left, and right, extremities are at least OBJECT_SIZE thick and contain at least
1 pixel in range LUMA_MIN to LUMA_MAX per scanline (h or v).
RT_YInRangeLocate() tests scanlines from outer most scanlines (h and v), towards inner most, stops where it find Baffle consecutive scanlines
that contain at least 1 pixel in range LUMA_MIN to LUMA_MAX. Object interiors are not tested and so could be hollow.
Would also give +ve result for a disjoint shape like this
--
| |
--
RT_YInRangeLocate(), developed for PlanetCrop script supplied with RT_Stats.
EDIT:
Added RT_RgbInRangeLocate() to RT_Stats v1.23
RED =$AA # Object Color to look for
GREEN =$CC
BLUE =$FF
OBJECT_W = 10 # Object Width
OBJECT_H = 10 # Object Height
AREA_X = 0 # Area of frame to search (0,0,0,0=full frame, As Crop)
AREA_Y = 0
AREA_W = -0
AREA_H = -0
R_MIN = RED R_MAX = RED
G_MIN = GREEN G_MAX = GREEN
B_MIN = BLUE B_MAX = BLUE
# Overlay Converts RGB->YUV->RGB (can set wrong color). Use Layer Instead, MUST set ALPHA
RGBA=((255 * 256 + RED)*256+GREEN)*256+BLUE
COORDINATES="coordinates.txt"
# Fake input clip, for testing
a = BlankClip(length=480,width=480,height=480)
b = a.BlankClip(width=OBJECT_W, height=OBJECT_H, color=RGBA)
a.Animate (0, a.FrameCount () - 1, "Layer", b,"add",257, 0, 0, b,"add",257, 479, 479)
NOTFOUND="NOT FOUND"
sep = ", "
Bra = "] "
RT_FileDelete(COORDINATES) # Delete coordinates file
ScriptClip ("""
Bingo=RT_RgbInRangeLocate(x=AREA_X,y=AREA_Y,w=AREA_W,h=AREA_H,
\ RLo=R_MIN,Rhi=R_MAX,GLo=G_MIN,Ghi=G_MAX,BLo=B_MIN,Bhi=B_MAX,Baffle_W=OBJECT_W,Baffle_H=OBJECT_H)
(Bingo) ? WriteFile (COORDINATES,"current_frame", "Bra", "RGBIRL_X", "sep", "RGBIRL_Y")
\ : WriteFile (COORDINATES,"current_frame", "Bra", "NOTFOUND")
""")
EDIT: Note, RT_RgbInRangeLocate() RGB32 and RGB24, however above demo RGB32 Only as Layer only for RGB32.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.