The rotation function itself works fine. I only got problems with my interpolation. Here is all of my Code.
So maybe you can see any mistakes here.
(rotate function)
rotate[inImage, rot,
Offset_] := {Offset[[1]] +
Sqrt[(inImage[[1]] - Offset[[1]])^2 + (inImage[[2]] -
Offset[[2]])^2]*
Cos[ArcTan[(inImage[[1]] - Offset[[1]]), (inImage[[2]] -
Offset[[2]])] - rot],
Offset[[2]] +
Sqrt[(inImage[[1]] - Offset[[1]])^2 + (inImage[[2]] -
Offset[[2]])^2]*
Sin[ArcTan[(inImage[[1]] - Offset[[1]]), (inImage[[2]] -
Offset[[2]])] - rot]};
(Nearest Neighbour Interpolation)
NearNeigh[NewPoints,
InImage] := {InImage[[Round[NewPoints[[1]]],
Round[NewPoints[[2]]]]]};
(Module to rotate an Image by a specific Angle, InterpMethod is unused atm)
Rotier[InImage, Rotatio, InterpMethod_] :=
Module[{OutImage, PunkteNeu, PunkteAlt, ImageHeight, ImageWidth,
Offset, Corners, MinX, MaxX, MinY, MaxY},
{ImageWidth, ImageHeight} = ImageDimensions[InImage];
(I want to rotate around middle for now)
Offset = {ImageWidth/2. + 0.5, ImageHeight/2. + 0.5};
(Here i check the Corners of the DestinationImage)
Corners = {{1, ImageWidth, 1, ImageWidth}, {1, 1, ImageHeight,
ImageHeight}};
Corners = rotate[Corners, Rotatio, Offset];
MinX = Floor[Min[Corners[[1, All]]]];
MaxX = Ceiling[Max[Corners[[1, All]]]];
MinY = Floor[Min[Corners[[2, All]]]];
MaxY = Ceiling[Max[Corners[[2, All]]]];
(Here i create a Matrix with the coordinates of the destination Image so i can inversewarp the image)
PunkteAlt = {Table[i, {i, MinX, MaxX}, {j, MinY, MaxY}],
Table[i, {j, MinX, MaxX}, {i, MinY, MaxY}]};
(I rotate every coordinate of the destination Image to get the coresponding souce image coordinates)
PunkteNeu = rotate[PunkteAlt, Rotatio, Offset];
(Because i get noninteger values i have to interpolate. but this doesn't work atm)
OutImage = NearNeigh[PunkteNeu, InImage];
Return[OutImage];
]; (End Module Rotier)