I have an image in YUV 420 semi-planar format where the bytes are stored in such manner:
[Y1 Y2 ... [U1 V1....
Yk Yk+1...] Uk' Uk'+1]
where size of the Y plane is twice that of UV plane and for every 2*2 matrix of Y values, there is 1 U and 1 V value.
I want to apply a homography matrix to this image without converting it to RGB. So, it's easy to do this for Y plane as Y values have a one-to-one mapping with the x-y pixel coordinate of image but how to do this for the UV plane as UV values don't have a direct mapping with the x-y pixel coordinates?
I did it by filling the UV-plane only for even x-y coordinates.
First, I found out the Y-coordinate in the original image for that pixel location by applying inverse homography. Then, I found the corresponding UV-coordinate for that Y-coordinate and used the value at that location to fill the UV-plane of my new image.