I'm dealing with a predictive block-matching motion estimation algorithm. This means, the values of motion vectors are found using the previously found values and I am stuck with a really trivial thing.
I'm dealing with images divided into blocks, so I should have a motion vector for each block. I created a 2xN
matrix motion_vectors
, where N is the number of all blocks (blocks_in_the_first_row*blocks_in_the_first_column
). The first row is the x
coordinate and second row the y
coordinate of the motion vector.
I have 2 predictors to help to estimate the motion vector of the current block.
If my current block is at position (i,j)
then the positions of the predictors are (i, j-1)
(the block "on top)" and (i-1, j)
(the block on the left).
My problem is, that I can't figure out a way how to adress the predictor blocks (in for
loops) in motion_vectors
since the dimensions are different (one is a 2xN
matrix, the other blocks_in_row x blocks_in_column
). I also wouldn't like to change the dimensions of motion_vectors
, since then I would need a two-"layer" array. One for the x
coordinates and one for y
, but that doesn't fit to the further design.
I hope I made myself understandable, if not, please let me know.
Thanks for any clues!