Reputation: 1469
I'm trying to do a project here, which I want to implement the following:
I have a rotation matrix and translation matrix are estimated, now I have an image in a certain location and I want to multiply all the image pixel by the rotation matrix and add the results to the translation matrix.....
My issue is how to work with the pixels? I mean how to extract the pixel from the image in order to do the operation that I mentioned above?
it's ok to give me the suggestion in either opencv or c++
*I need to know how to do this operation new_p(x,y) = old_p(x,y)* rotation_matrix + translation_matrix. I'm defining the image like that IplImage(), 3 channel image. For now I need to do the geometrical transformation but I don't know how to use old_p(x,y) which mean old pixels*
Thank you.
Upvotes: 0
Views: 1521
Reputation: 17141
In Opencv, the functions you need are in the "Geometric Image transformations" section of the manual. In your case, as you already have the rotation matrix and the translation, warpAffine
is the function of choice (link to function documentation). First two columns of the transformation matrix that you pass are the rotation matrix, the third is the translation vector (in case you are not familiar with homogeneous coordinates).
Upvotes: 4
Reputation: 37777
The basic idea will be that you need a color value for every pixel in the final result image. So you need to find a function which maps a (rotated and translated) pixel onto every (x,y)
position of the final result image.
Given a matrix transforming the original image coordinates to target image coordinates, you'll probably end up inverting that transformation and applying that for every target image pixel, plus or minus a few optimizations.
Upvotes: 0