X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemiaCore%2FKMeans.fs;h=dfd2593b132bc7ca82762733581095d34ad712e9;hp=6e529476c496309d6c1778024210b10749038798;hb=b87b35b922551f122228df1fd9c530bbb807935a;hpb=2e3cd07dd099944059ef5e7a7f5ef57ffe3d677b diff --git a/Parasitemia/ParasitemiaCore/KMeans.fs b/Parasitemia/ParasitemiaCore/KMeans.fs index 6e52947..dfd2593 100644 --- a/Parasitemia/ParasitemiaCore/KMeans.fs +++ b/Parasitemia/ParasitemiaCore/KMeans.fs @@ -6,13 +6,15 @@ open System.Drawing open Emgu.CV open Emgu.CV.Structure -type Result = { - fg: Image - mean_bg: float32 - mean_fg: float32 - d_fg: Image } // Euclidean distances of the foreground to mean_fg. - -let kmeans (img: Image) : Result = +type Result = + { + fg : Image + mean_bg : float32 + mean_fg : float32 + d_fg : Image // Euclidean distances of the foreground to mean_fg. + } + +let kmeans (img : Image) : Result = let nbIteration = 4 let w = img.Width let h = img.Height @@ -56,8 +58,7 @@ let kmeans (img: Image) : Result = for i = 0 to h - 1 do for j = 0 to w - 1 do - if fgData.[i, j, 0] > 0uy - then + if fgData.[i, j, 0] > 0uy then fg_total <- fg_total + imgData.[i, j, 0] fg_nb <- fg_nb + 1 else