Perhaps your code got corrupted with copy-and-paste, with a lot of missing underscores and stars. This is my first attempt at a first clean-up:
(*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*)
Still, I can't figure out how you are going to use these functions. In rotate
you seem to assume that InImage
is a vector, because you make numerical computations with its first and second element. In Rotier
you take the ImageDimensions
of InImage
, which assumes that InImage
is an image, which has no first and second element.
A general advice: inside the code it is better to avoid variable names that start with a capital letter, to avoid conflit with built-in functions. For example, Offset
, with capitalized initial, is a built-in function.