Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

beginning the implementation of the Hough transform

  • Loading branch information...
commit e4636d0b68575225940d04e4cedc2c0b4d5cf659 1 parent a1b651e
dezyal authored
Showing with 27 additions and 1 deletion.
  1. +26 −0 OCR/Rotation.ml
  2. +1 −1  OCR/main.ml
View
26 OCR/Rotation.ml
@@ -1,4 +1,30 @@
(*
+ [Fonction de détection d'angle]
+ Détection de l'inclinaison à l'aide
+ de la transformé de Hough
+*)
+let px_vote acc acc_w acc_h x y w h rho_max =
+ let ox = x-w/2 and oy = y-h/2 in
+ for i=0 to acc_w do
+ let theta = (float)i/.(float)acc_w*.3.14159265 in
+ let rho = (float)ox*.cos(theta) +. (float)oy*.sin(theta) in
+ let i_rho = int_of_float(
+ 0.5 +. (rho/.rho_max +. 0.5)*.(float)acc_h) in
+ acc.(i).(i_rho) <- acc.(i).(i_rho) + 1
+ done
+
+let hough_skew_detection mtx w h =
+ let rho_max = sqrt((float)(w*w +h*h)) in
+ let theta_w = 360 and rho_h = int_of_float(1.+.rho_max) in
+ let acc = Array.make_matrix theta_w rho_h 0 in
+ for x = 0 to w-1 do
+ for y = 0 to h-1 do
+ px_vote acc theta_w rho_h x y w h rho_max;
+ (* To be continued... *)
+ done
+ done
+
+(*
[Fonction Rotate]
Effectue la rotation d'une image à partir
d'un angle en degré
View
2  OCR/main.ml
@@ -14,7 +14,7 @@ let main () =
[|2;5;2;5;20;5;2;5;2|] (1./.48.) in
let mtx3 = Pretreatment.new_binarisation
(Pretreatment.pre_bin mtx2 w h) w h in
- let mtx3 = Rotation.rotate mtx3 w h (-2.) in
+ let mtx3 = Rotation.rotate mtx3 w h (0.5) in
OSdl.display (Pretreatment.mtx2su mtx3 w h pfi) w h;
OSdl.wait ();
exit 0
Please sign in to comment.
Something went wrong with that request. Please try again.