public static Bitmap Orient_Step2(Bitmap blob)
{
int width = blob.Width;
int height = blob.Height;
int area = width * height;
Image<Bgra, Byte> blobb = new Image<Bgra, byte>(blob);
Rectangle crop = GetCropZone(blobb);
System.Drawing.Point trPoint = new System.Drawing.Point(crop.Right, crop.Top);
System.Drawing.Point blPoint = new System.Drawing.Point(crop.Right, crop.Bottom);
double slope = Utility.SlopeFromPoints(trPoint, blPoint);
double angle = Math.Atan(slope);
float angleToRotate = (float)(90.0 - angle);
Bitmap rotated = RotateImg(blobb.ToBitmap(), angleToRotate, Color.Transparent);
if (rotated.Height < rotated.Width)
{
return RotateImg(blobb.ToBitmap(), angleToRotate + 90, Color.Transparent);
}
return rotated;
}