Log in

View Full Version : SelectLines filter?


shoopdabloop
23rd August 2009, 06:52
I was wondering how one would go about making a SelectLines function similar to the temporal filter SelectEvery, and using the same syntax?

SelectLines(clip clip, int step-size, int offset1 [, int offset2, ...])

Could someone help?
I'm not sure how to extract the lines properly.
If I did, I would provide basis for function.

The additional offsets are not required, but it would be nice to implement them.

Gavino
23rd August 2009, 09:30
Use Crop to select the lines and StackVertical to build the result.

shoopdabloop
23rd August 2009, 10:54
Crop can only use even numbers in YV12, is it possible to get single lines without colorspace conversion?
Perhaps with resizers, I will try that.

Gavino
23rd August 2009, 11:29
You can't really have a single line in YV12. Because each chroma line corresponds to 2 luma lines, it only makes sense to extract pairs of lines. Crop and the resizers enforce these restrictions.

Guest
23rd August 2009, 14:07
You could do it if you convert to RGB space.

Manao
23rd August 2009, 16:17
You can also up-pointresize by a factor 2 before cutting into the frame, then down-pointresize by a factor 2 the final result. If you just care about luma, you'll end up exactly with what you want, without any loss from yuv <-> rgb conversion. If you do care about chroma, you have to think carefully about what you are doing.

thewebchat
23rd August 2009, 16:51
Couldn't you convert to YUY2 instead of RGB? YV12->YUY2 conversion should just be a copy on the chroma channels, right?

Manao
23rd August 2009, 17:13
YV12 -> YUY2 -> YV12 modifies chroma pixels, while pointresize doesn't.

Gavino
23rd August 2009, 17:46
Apart from the colorspace issue, Manao's mention of PointResize has helped me see that the actual selection of the lines can be done better by PointResize, rather than Crop/StackVertical as I said earlier, ie use point downsize by a factor 1/stepsize.

If the clip height is not a multiple of stepsize, it would need to be padded or cropped (depending on offset) to make it so.

shoopdabloop
23rd August 2009, 22:09
So PointResize would not cause luma or chroma issues in YV12 space?
Sorry, if these questions sound noobish.

Gavino
23rd August 2009, 23:17
Even with PointResize, you still have the restriction that the output height must be a multiple of 2 for YV12.

I think you need to specify more clearly just what you want your function to do in the case of YV12 input, taking into account the luma/chroma issues and the height restrictions.