Skip to content
Browse files

Update OCR/Rotation.ml

  • Loading branch information...
1 parent fb869fb commit c3d52bf174e7c8d08614d0220ac149340f532a8c @dezyal dezyal committed
Showing with 24 additions and 2 deletions.
  1. +24 −2 OCR/Rotation.ml
View
26 OCR/Rotation.ml
@@ -39,16 +39,38 @@ let hough_skew_detection mtx w h =
[Fonction Rotate]
Effectue la rotation d'une image à partir
d'un angle en radian
+*)(*
+let rotate mtx w h a =
+ let new_mtx = Array.make_matrix w h 255 in
+ let cosA = cos(a) and
+ sinA = sin(a) in
+ let center_x = int_of_float((float)w/.2.) and
+ center_y = int_of_float((float)h/.2.) in
+ for x = 0 to w-1 do
+ for y = 0 to h-1 do
+ if (mtx.(x).(y) == 0) then
+ let new_x = int_of_float(
+ (float)(x-center_x)*.cosA +. (float)(y-center_y)*.sinA
+ +. (float)center_x) in
+ let new_y = int_of_float(
+ (float)(y-center_y)*.cosA -. (float)(x-center_x)*.sinA
+ +. (float)center_y) in
+ if (new_x > -1 && new_x < w-1 && new_y > -1 && new_y < h-1) then
+ new_mtx.(new_x).(new_y) <- 0
+ done
+ done;
+ new_mtx
*)
let rotate mtx w h a =
let new_mtx = Array.make_matrix w h 255 in
+ let cosA = cos(a) and sinA = sin(a) in
for x = 0 to w-1 do
for y = 0 to h-1 do
if (mtx.(x).(y) == 0) then
let new_x = int_of_float(
- (float)x*.cos(a) -. (float)y*.sin(a))
+ (float)x*.cosA -. (float)y*.sinA)
and new_y = int_of_float(
- (float)(x)*.sin(a) +. (float)y*.cos(a)) in
+ (float)(x)*.sinA +. (float)y*.cosA) in
if (new_x > -1 && new_x < w-1 && new_y > -1 && new_y < h-1) then
new_mtx.(new_x).(new_y) <- 0
done

0 comments on commit c3d52bf

Please sign in to comment.
Something went wrong with that request. Please try again.