public static void rotate(Mat image,double angle){
  double radians=Math.toRadians(angle);
  double sin=Math.abs(Math.sin(radians));
  double cos=Math.abs(Math.cos(radians));
  int newWidth=(int)(image.width() * cos + image.height() * sin);
  int newHeight=(int)(image.width() * sin + image.height() * cos);
  Point center=new Point(newWidth / 2,newHeight / 2);
  Mat rotMatrix=Imgproc.getRotationMatrix2D(center,angle,1.0);
  Size size=new Size(newWidth,newHeight);
  Imgproc.warpAffine(image,image,rotMatrix,image.size());
}

public static void rotate ( Mat image , double angle ) { double radians = Math . toRadians ( angle ) ; double sin = Math . abs ( Math . sin ( radians ) ) ; double cos = Math . abs ( Math . cos ( radians ) ) ; int newWidth = ( int ) ( image . width ( ) * cos + image . height ( ) * sin ) ; int newHeight = ( int ) ( image . width ( ) * sin + image . height ( ) * cos ) ; Point center = new Point ( newWidth / 2 , newHeight / 2 ) ; Mat rotMatrix = Imgproc . getRotationMatrix2D ( center , angle , 1.0 ) ; Size size = new Size ( newWidth , newHeight ) ; Imgproc . warpAffine ( image , image , rotMatrix , image . size ( ) ) ; }
rotate an image by an angle ( counterclockwise )
