open Emgu.CV
open Emgu.CV.Structure
-type Result = {
- fg: Image<Gray, byte>
- mean_bg: float32
- mean_fg: float32
- d_fg: Image<Gray, float32> } // Euclidean distances of the foreground to mean_fg.
-
-let kmeans (img: Image<Gray, float32>) : Result =
+type Result =
+ {
+ fg : Image<Gray, byte>
+ mean_bg : float32
+ mean_fg : float32
+ d_fg : Image<Gray, float32> // Euclidean distances of the foreground to mean_fg.
+ }
+
+let kmeans (img : Image<Gray, float32>) : Result =
let nbIteration = 4
let w = img.Width
let h = img.Height
let imgData = img.Data
let fgData = fg.Data
- for i in 1 .. nbIteration do
+ for i = 1 to nbIteration do
match d_bg with
| null -> ()
| _ ->
let mutable fg_total = 0.f
let mutable fg_nb = 0
- for i in 0 .. h - 1 do
- for j in 0 .. w - 1 do
- if fgData.[i, j, 0] > 0uy
- then
+ for i = 0 to h - 1 do
+ for j = 0 to w - 1 do
+ if fgData.[i, j, 0] > 0uy then
fg_total <- fg_total + imgData.[i, j, 0]
fg_nb <- fg_nb + 1
else