X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemiaCore%2FEllipse.fs;h=cf55a8eb2f68ddee0372dd435e597ae66cb599c9;hp=db23ece8976d2e82a53c42533f26d787a74936a5;hb=bb642da712542095d8c5ead2d0d036470eb040b9;hpb=04d4504e7b248a82ddfc1a41d325e59d24146590 diff --git a/Parasitemia/ParasitemiaCore/Ellipse.fs b/Parasitemia/ParasitemiaCore/Ellipse.fs index db23ece..cf55a8e 100644 --- a/Parasitemia/ParasitemiaCore/Ellipse.fs +++ b/Parasitemia/ParasitemiaCore/Ellipse.fs @@ -131,7 +131,9 @@ let find (edges: Matrix) // We choose a window size for which the biggest ellipse can always be fitted in. let windowSize = roundInt (2.f * r2) - let factorNbPick = config.Parameters.factorNbPick + let factorNbValidPick = config.Parameters.factorNbValidPick + let factorNbMaxPick = config.Parameters.factorNbMaxPick + let nbPickElementsMin = config.Parameters.nbPickElementsMin let increment = windowSize / (int incrementWindowDivisor) @@ -180,8 +182,9 @@ let find (edges: Matrix) if currentElements.Count >= 10 then - let mutable nbOfPicks = (float currentElements.Count) * factorNbPick |> int - while nbOfPicks > 0 do + let mutable nbOfPicks = (float currentElements.Count) * factorNbMaxPick |> int + let mutable nbOfValidPicks = (float currentElements.Count) * factorNbValidPick |> int + while nbOfPicks > 0 && nbOfValidPicks > 0 do let p1 = currentElements.[rng.Next(currentElements.Count)] let p2 = currentElements.[rng.Next(currentElements.Count)] let p3 = currentElements.[rng.Next(currentElements.Count)] @@ -200,7 +203,8 @@ let find (edges: Matrix) match ellipse p1xf p1yf (float m1) p2xf p2yf (float m2) p3xf p3yf with | Some e when e.Cx > 0.f && e.Cx < w_f - 1.f && e.Cy > 0.f && e.Cy < h_f - 1.f && e.A >= r1 - radiusTolerance && e.A <= r2 + radiusTolerance && e.B >= r1 - radiusTolerance && e.B <= r2 + radiusTolerance -> - ellipses.Add e + nbOfValidPicks <- nbOfValidPicks - 1 + ellipses.Add e | _ -> () | _ -> ()