Replace "for [..] in [..]" by "for [..] to [..]" for consistency.
[master-thesis.git] / Parasitemia / ParasitemiaCore / ImgTools / Morpho.fs
index b3a2e75..588622e 100644 (file)
@@ -16,13 +16,13 @@ open Types
 let suppressMAdjacency (img: Matrix<byte>) =
     let w = img.Width
     let h = img.Height
-    for i in 1 .. h - 2 do
-        for j in 1 .. w - 2 do
+    for i = 1 to h - 2 do
+        for j = 1 to w - 2 do
             if img.[i, j] > 0uy && img.Data.[i + 1, j] > 0uy && (img.Data.[i, j - 1] > 0uy && img.Data.[i - 1, j + 1] = 0uy || img.Data.[i, j + 1] > 0uy && img.Data.[i - 1, j - 1] = 0uy)
             then
                 img.[i, j] <- 0uy
-    for i in 1 .. h - 2 do
-        for j in 1 .. w - 2 do
+    for i = 1 to h - 2 do
+        for j = 1 to w - 2 do
             if img.[i, j] > 0uy && img.Data.[i - 1, j] > 0uy && (img.Data.[i, j - 1] > 0uy && img.Data.[i + 1, j + 1] = 0uy || img.Data.[i, j + 1] > 0uy && img.Data.[i + 1, j - 1] = 0uy)
             then
                 img.[i, j] <- 0uy
@@ -86,8 +86,8 @@ let findExtremum (img: Image<Gray, 'TDepth>) (extremumType: ExtremumType) : IEnu
                     result'.Add(current)
         result'
 
-    for i in 0 .. h - 1 do
-        for j in 0 .. w - 1 do
+    for i = 0 to h - 1 do
+        for j = 0 to w - 1 do
             let maxima = flood (Point(j, i))
             if maxima.Count > 0
             then
@@ -240,7 +240,7 @@ let private areaOperation (img: Image<Gray, byte>) (area: int) (op: AreaOperatio
                     queue.Add (imgData.[ni, nj, 0]) p'
 
     // Reverse order is quicker.
-    for i in areas.Count - 1 .. -1 .. 0 do
+    for i = areas.Count - 1 downto 0 do
         let m = areas.[i]
         if m.Elements.Count <= area && m.State <> AreaState.Removed
         then
@@ -360,8 +360,8 @@ let areaOpen2 (img: Image<Gray, byte>) (area: int) =
     let se = [| -1, 0; 0, -1; 1, 0; 0, 1 |]
 
     let histogram = Array.zeroCreate 256
-    for i in 0 .. h - 1 do
-        for j in 0 .. w - 1 do
+    for i = 0 to h - 1 do
+        for j = 0 to w - 1 do
             let v = imgData.[i, j, 0] |> int
             histogram.[v] <- histogram.[v] + 1
 
@@ -370,12 +370,12 @@ let areaOpen2 (img: Image<Gray, byte>) (area: int) =
     let pointsChecked = HashSet<Point>()
     let pointsToCheck = Stack<Point>()
 
-    for level in 255 .. -1 .. 0 do
+    for level = 255 downto 0 do
         let mutable n = histogram.[level]
         if n > 0
         then
-            for i in 0 .. h - 1 do
-                for j in 0 .. w - 1 do
+            for i = 0 to h - 1 do
+                for j = 0 to w - 1 do
                     if not flooded.[i, j] && imgData.[i, j, 0] = byte level
                     then
                         let mutable maxNeighborValue = 0uy
@@ -507,8 +507,8 @@ let private areaOperationF (img: Image<Gray, float32>) (areas: (int * 'a) list)
 
         let mutable diff = 0.f
 
-        for i in 0 .. h - 1 do
-            for j in 0 .. w - 1 do
+        for i = 0 to h - 1 do
+            for j = 0 to w - 1 do
                 match ownership.[i, j] with
                 | null -> ()
                 | island ->
@@ -562,8 +562,8 @@ let thin (mat: Matrix<byte>) =
 
     while pixelChanged do
         pixelChanged <- false
-        for i in 0..h-1 do
-            for j in 0..w-1 do
+        for i = 0 to h - 1 do
+            for j = 0 to w - 1 do
                 if data1.[i, j] = 1uy
                 then
                     let p2 = if i = 0 then 0uy else data1.[i-1, j]
@@ -622,8 +622,8 @@ let removeArea (mat: Matrix<byte>) (areaSize: int) =
     let data = mat.Data
     let data' = mat'.Data
 
-    for i in 0..h-1 do
-        for j in 0..w-1 do
+    for i = 0 to h - 1 do
+        for j = 0 to w - 1 do
             if data'.[i, j] = 1uy
             then
                 let neighborhood = List<Point>()
@@ -658,8 +658,8 @@ let connectedComponents (img: Image<Gray, byte>) (startPoints: List<Point>) : Po
     while pointToCheck.Count > 0 do
         let next = pointToCheck.Pop()
         pointChecked.Add(next) |> ignore
-        for ny in -1 .. 1 do
-            for nx in -1 .. 1 do
+        for ny = -1 to 1 do
+            for nx = -1 to 1 do
                 if ny <> 0 && nx <> 0
                 then
                     let p = Point(next.X + nx, next.Y + ny)