View Full Version : How cut a clip to MxN tiles clips
Terka
28th April 2010, 15:07
Hi, want to try apply a filter on small area only. (Dup filter)
so i want to cut the clips SPATIALLY to smaller clips, apply the DUP on each of them and join them together.
Is thera any fast way how to do it?
Gavino
28th April 2010, 16:01
Use Crop to cut the clip up and StackHorizontal/StackVertical to put it back together again. Both are relatively fast operations.
If you're looking to create a regular grid of tiles, you might find the GScript looping constructs useful for iterating over the different sections.
Terka
29th April 2010, 11:36
Gavino, Thank you, installed the gscript, but im not able to make the tiles.
Could you please help? If i want to split 720x576 source to 8x8 tiles, the crop method is tooo long.
Didée
29th April 2010, 12:55
Calling Dup on 8x8 tiles? Most probably, once you'll have a working script, you will find that there's quite some risk to get blocking artifacts. Problem is when amongst some neighboring blocks some blocks do trigger the threshold, and some blocks do not. You can imagine what happens.
It seems more safe to me to just Dup the whole frame at once, with a pretty small threshold (that usually would be "not safe" at all), then use RemoveDirt to postprocess the result. RemoveDirt has lots of useful mechanisms ... one of them is compairing the changes of neighboring blocks, in order to decide if the change of the actual block should be accepted or not.
Gavino
29th April 2010, 13:18
Gavino, Thank you, installed the gscript, but im not able to make the tiles.
Could you please help? If i want to split 720x576 source to 8x8 tiles, the crop method is tooo long.
Could you explain more clearly what you want to do, perhaps with an outline script?
You may want to revise your strategy anyway, in the light of Didée's remarks.
Terka
21st May 2010, 15:41
thank you both for reply.
want to try both methods. could you (both of you) show me the scripts?
Gavino
23rd May 2010, 10:52
I was hoping you might provide more details of your requirements and what you have already tried, but this script fragment shows the general approach to do this sort of thing with GScript.
It splits a clip 'c' into MxN tiles, does some processing on each tile, and puts the results back together in 'result'. For simplicity, it assumes the clip width and height are multiples of M and N respectively.
tw = c.width/M
th = c.height/N
GScript("""
for (j = 0, N-1) { # each row of tiles
for (i = 0, M-1) { # each column of tiles
tile = c.Crop(i*tw, j*th, tw, th)
newTile = DoSomething(tile) # possibly depending on i,j
row = (i==0 ? newTile : StackHorizontal(row, newTile))
}
result = (j==0 ? row : StackVertical(result, row))
}
""")
return result # or do further processing on it
Terka
24th May 2010, 16:32
Gavino, thank you. Is working, must test the results.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.