I'm currently working on implementing an algorithm in EmguCV in C#, meaning that I don't want to use the build in rotate function that comes with EmguCV.
I've already found the algorithm that I want to implement, but I'm kinda stuck as how to implement it. The main problem is, that I don't know how the specify the X and Y values of my Matrix to be able to do the intended calculations.
Rotation Algorithm: https://i.stack.imgur.com/hQMxF.jpg
Right now my Code looks like this:
static void Main(string[] args) {
Mat image = CvInvoke.Imread("C:\\Users\\Leon\\Desktop\\a.jpg", LoadImageType.Grayscale);
int height = image.Height;
int width = image.Width;
//Convert to Matrix
Matrix<Byte> matrix = new Matrix<Byte>(image.Rows, image.Cols, image.NumberOfChannels);
image.CopyTo(matrix);
Matrix<Byte> newMatrix = new Matrix<Byte>(image.Rows, image.Cols, image.NumberOfChannels);
image.CopyTo(newMatrix);
for (int i = 0; i < matrix.Rows-1; i++)
{
for (int j = 0; j < matrix.Cols-1; j++)
{
}
}
CvInvoke.Imshow("abc", matrix);
CvInvoke.WaitKey(0);
}
But as I said, I'm in doubt of as how to implement the algorithm. My plan was to rotate the pixels in "matrix" and store them in "newMatrix" but I do not know how to specify the X and Y values of my matrix.
Maybe someone can help me out here.
EDIT: There has been suggested that this answer here: "How can I get and set pixel values of an EmguCV Mat image?" will be an answer to my question. But it is not. I know that I can do Math.Cos and Math.Sin but I do not know how to specify X and Y in my Matrix. I don't have problems accessing the Data in my Matrix.