Log in

View Full Version : YV12ReduceBy2 Horizontal Only?


Lycaon
23rd March 2004, 02:25
I'm working on low bitrate encoding for PocketPC and have had exceptional results using the SelectEven filter to resize, smooth, IVTC via decimation, etc. I would like to experiment with the same technique applied to the horizontal axis.

I have no experience in writing filters, but I can guess at the theory:

A mod2 convolution filter with a 1x2 kernel, whose coordinate points would be {(0,0), (1,0)}. The 2 values of the kernel would be 1 and 0.
____
|1|0|

I would need to constrain the kernel to only move to positions where it fits entirely within the image.

Any suggestions or ideas?

Thanks,

Lycaon

scmccarthy
23rd March 2004, 16:35
Special case the beginning and end using a 1x1 filter.

Stephen

Lycaon
27th March 2004, 19:47
@scmccarthy, thanks for the reply. Could you give me some more info. I'm a bit confused by a 1x1 filter. I'm guessing that I would use it to translate only the parts of the image I wanted. I did a little more research and now have more questions lol :rolleyes:

At this point I'm trying to understand how to translate the math into script language.

I came across the Kronecker Delta, which is exactly what I'm describing in this filter.


The convolution would look like this:


I = Input Image
O = Output Image

Questions:
1. Will this sort of convolution work on YV12 since the chroma is shared in a 2x2 matrix? Does this matter?
2. How do you shift the kernel so it doesn't overlap nor go outside of the image?
3. How do you reconcile the difference in the output (i,j) address and the (i,j) address of the new image? Is there another step in the convolution or do you specify the dimensions of the new image and the new values are just plugged in sequentially regardless of the output (i,j) address?

Thank you for any help on all of this.

Lycaon

scmccarthy
27th March 2004, 21:19
How do you shift the kernel so it doesn't overlap nor go outside of the image? I only mean to reply to this past.

1) skip the first and last column as you suggest.
2) add a column at the beginning or end or both.
in order to process the first and last column
with the same filter.
3) modify the filter to work on one column only.

But I am thinking of the kernel processing the first and second columns, then the 2nd and 3rd columns. but if you just want to reduce the size, then you might not do that.

On the other hand, it is good to crop off the edges of the image anyway.

Stephen

Lycaon
29th March 2004, 05:03
Thanks scmccarthy, you got me heading in the right direction. I ended up using Tom Barry's YV12InterlacedReduceBy2. It does everything that I was trying to do piecemeal. Unfortunately, it doesn't solve the DVD horizontal issue of MOD16 as 720/2 = 360/16 = 22.5 :(

I'm assuming there is no way around this. I've tried cropping and adding borders, but that causes a change in aspect ratio at a width of 320.

And now that I see the aliasing that comes from point sampling, I'll have to keep experimenting to see what will resize the horizontal to smooth it best with out aliasing.

scmccarthy
30th March 2004, 07:03
I like to crop down to 696x360 and resize to 752x320. That is what I am doing now, but you must be doing something more restrictive.

Ususally cropping down to 704 is a good idea.

Stephen