From: Greg Burri Date: Fri, 19 Feb 2016 18:36:51 +0000 (+0100) Subject: Replace "for [..] in [..]" by "for [..] to [..]" for consistency. X-Git-Tag: 1.0.11~13 X-Git-Url: http://git.euphorik.ch/?a=commitdiff_plain;h=1b8e45987bde692ab5602c281f878707f70459b7;p=master-thesis.git Replace "for [..] in [..]" by "for [..] to [..]" for consistency. --- diff --git a/Parasitemia/ParasitemiaCore/AssemblyInfo.fs b/Parasitemia/ParasitemiaCore/AssemblyInfo.fs index f473726..cfda389 100644 --- a/Parasitemia/ParasitemiaCore/AssemblyInfo.fs +++ b/Parasitemia/ParasitemiaCore/AssemblyInfo.fs @@ -34,8 +34,8 @@ open System.Runtime.InteropServices // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [] -[] -[] +[] +[] do () \ No newline at end of file diff --git a/Parasitemia/ParasitemiaCore/Classifier.fs b/Parasitemia/ParasitemiaCore/Classifier.fs index 5a6dcbe..1db8b03 100644 --- a/Parasitemia/ParasitemiaCore/Classifier.fs +++ b/Parasitemia/ParasitemiaCore/Classifier.fs @@ -145,8 +145,8 @@ let findCells (ellipses: Ellipse list) (parasites: ParasitesMarker.Result) (widt let minX, minY, maxX, maxY = ellipseWindow e let mutable area = 0 - for y in (if minY < 0 then 0 else minY) .. (if maxY >= height then height - 1 else maxY) do - for x in (if minX < 0 then 0 else minX) .. (if maxX >= width then width - 1 else maxX) do + for y = (if minY < 0 then 0 else minY) to (if maxY >= height then height - 1 else maxY) do + for x = (if minX < 0 then 0 else minX) to (if maxX >= width then width - 1 else maxX) do let p = PointF(float32 x, float32 y) if pixelOwnedByE p e neighbors then @@ -167,8 +167,8 @@ let findCells (ellipses: Ellipse list) (parasites: ParasitesMarker.Result) (widt let mutable darkStainPixels = 0 let mutable nbElement = 0 let minX, minY, maxX, maxY = ellipseWindow e - for y in minY .. maxY do - for x in minX .. maxX do + for y = minY to maxY do + for x = minX to maxX do let p = PointF(float32 x, float32 y) if pixelOwnedByE p e neighbors then @@ -204,8 +204,8 @@ let findCells (ellipses: Ellipse list) (parasites: ParasitesMarker.Result) (widt let mutable nbElement = 0 let elements = new Matrix(maxY - minY + 1, maxX - minX + 1) - for y in minY .. maxY do - for x in minX .. maxX do + for y = minY to maxY do + for x = minX to maxX do let p = PointF(float32 x, float32 y) if pixelOwnedByE p e neighbors then diff --git a/Parasitemia/ParasitemiaCore/EEOver.fs b/Parasitemia/ParasitemiaCore/EEOver.fs index 6862dc5..9a77f48 100644 --- a/Parasitemia/ParasitemiaCore/EEOver.fs +++ b/Parasitemia/ParasitemiaCore/EEOver.fs @@ -184,7 +184,7 @@ let private twointpts (x: float[]) (y: float[]) (a1: float) (b1: float) (phi_1: let private threeintpts (xint: float[]) (yint: float[]) (a1: float) (b1: float) (phi_1: float) (a2: float) (b2: float) (h2_tr: float) (k2_tr: float) (phi_2: float) (aa: float) (bb: float) (cc: float) (dd: float) (ee: float) (ff: float) : float = let mutable tanpts = 0 let mutable tanindex = 0 - for i in 0..2 do + for i = 0 to 2 do if istanpt xint.[i] yint.[i] a1 b2 aa bb cc dd ee ff = TANGENT_POINT then tanpts <- tanpts + 1 @@ -216,18 +216,18 @@ let private fourintpts (xint: float[]) (yint: float[]) (a1: float) (b1: float) ( let theta = Array.zeroCreate 4 - for i in 0 .. 3 do + for i = 0 to 3 do if abs xint.[i] > a1 then xint.[i] <- if xint.[i] < 0.0 then -a1 else a1 theta.[i] <- if yint.[i] < 0.0 then 2.0 * Math.PI - acos (xint.[i] / a1) else acos (xint.[i] / a1) #if DEBUG_LOG - for k in 0..3 do + for k = 0 to 3 do printf "k=%d: Theta = %f, xint=%f, yint=%f\n" k theta.[k] xint.[k] yint.[k] #endif - for j in 1 .. 3 do + for j = 1 to 3 do let tmp0 = theta.[j] let tmp1 = xint.[j] let tmp2 = yint.[j] @@ -253,7 +253,7 @@ let private fourintpts (xint: float[]) (yint: float[]) (a1: float) (b1: float) ( #if DEBUG_LOG printf "AFTER sorting\n" - for k in 0..3 do + for k = 0 to 3 do printf "k=%d: Theta = %f, xint=%f, yint=%f\n" k theta.[k] xint.[k] yint.[k] #endif @@ -266,7 +266,7 @@ let private fourintpts (xint: float[]) (yint: float[]) (a1: float) (b1: float) ( let xint_tr = Array.zeroCreate 4 let yint_tr = Array.zeroCreate 4 - for i in 0..3 do + for i = 0 to 3 do xint_tr.[i] <- (xint.[i] - h2_tr) * cosphi + (yint.[i] - k2_tr) * -sinphi yint_tr.[i] <- (xint.[i] - h2_tr) * sinphi + (yint.[i] - k2_tr) * cosphi @@ -358,7 +358,7 @@ let private quadroots (p: float[]) (r: float[,]) = let private cubicroots (p: float[]) (r: float[,]) = if p.[0] <> 1.0 then - for k in 1..3 do + for k = 1 to 3 do p.[k] <- p.[k] / p.[0] p.[0] <- 1.0 let s = p.[1] / 3.0 @@ -423,13 +423,13 @@ let private cubicroots (p: float[]) (r: float[,]) = t <- d r.[1, 1] <- t - for k in 1..3 do + for k = 1 to 3 do r.[2, k] <- 0.0 let private biquadroots (p: float[]) (r: float[,]) = if p.[0] <> 1.0 then - for k in 1..4 do + for k = 1 to 4 do p.[k] <- p.[k] / p.[0] p.[0] <- 1.0 let e = 0.25 * p.[1] @@ -447,13 +447,13 @@ let private biquadroots (p: float[]) (r: float[,]) = then p.[2] <- c / b quadroots p r - for k in 1..2 do - for j in 1..2 do + for k = 1 to 2 do + for j = 1 to 2 do r.[j, k+2] <- r.[j, k] p.[1] <- -p.[1] p.[2] <- b quadroots p r - for k in 1..4 do + for k = 1 to 4 do r.[1,k] <- r.[1,k] - e quadExecuted <- true @@ -502,7 +502,7 @@ let private biquadroots (p: float[]) (r: float[,]) = then p.[1] <- 0.0 else - for k in 1..4 do + for k = 1 to 4 do r.[1, k] <- -e r.[2, k] <- 0.0 quadExecuted <- true @@ -559,7 +559,7 @@ let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float32 * float32[] |] #if DEBUG_LOG - for i in 0..4 do + for i = 0 to 4 do printf "cy[%d]=%f\n" i cy.[i] #endif @@ -569,11 +569,11 @@ let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float32 * float32[] let nroots = if abs cy.[4] > EPS then - for i in 0 .. 3 do + for i = 0 to 3 do py.[4-i] <- cy.[i] / cy.[4] py.[0] <- 1.0 #if DEBUG_LOG - for i in 0..4 do + for i to 0 to 4 do printf "py[%d]=%f\n" i py.[i] #endif biquadroots py r @@ -581,7 +581,7 @@ let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float32 * float32[] elif abs cy.[3] > EPS then - for i in 0..2 do + for i = 0 to 2 do py.[3 - i] <- cy.[i] / cy.[3] py.[0] <- 1.0 cubicroots py r @@ -589,7 +589,7 @@ let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float32 * float32[] elif abs cy.[2] > EPS then - for i in 0..1 do + for i = 0 to 1 do py.[2-i] <- cy.[i] / cy.[2] py.[0] <- 1.0 quadroots py r @@ -610,7 +610,7 @@ let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float32 * float32[] let ychk = Array.init nroots (fun _ -> Double.MaxValue) let mutable nychk = 0 - for i in 1 .. nroots do + for i = 1 to nroots do if abs r.[2, i] < EPS then ychk.[nychk] <- r.[1, i] * b1 @@ -622,7 +622,7 @@ let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float32 * float32[] #if DEBUG_LOG printf "nychk=%d\n" ychk.Length - for j in 0 .. ychk.Length - 1 do + for j = 0 to ychk.Length - 1 do printf "\t j=%d, ychk=%f\n" j ychk.[j] #endif diff --git a/Parasitemia/ParasitemiaCore/Ellipse.fs b/Parasitemia/ParasitemiaCore/Ellipse.fs index 01e1bec..b39ab4d 100644 --- a/Parasitemia/ParasitemiaCore/Ellipse.fs +++ b/Parasitemia/ParasitemiaCore/Ellipse.fs @@ -179,8 +179,8 @@ let find (edges: Matrix) // Add the new elements. let newElemsBegin_j = window_j + windowSize - increment let newElemsEnd_j = window_j + windowSize - 1 - for j in (if newElemsBegin_j < 0 then 0 else newElemsBegin_j) .. (if newElemsEnd_j >= w then w - 1 else newElemsEnd_j) do - for i in window_i_begin .. window_i_end do + for j = (if newElemsBegin_j < 0 then 0 else newElemsBegin_j) to (if newElemsEnd_j >= w then w - 1 else newElemsEnd_j) do + for i = window_i_begin to window_i_end do if edgesData.[i, j] = 1uy then currentElements.Add(Point(j, i)) diff --git a/Parasitemia/ParasitemiaCore/Granulometry.fs b/Parasitemia/ParasitemiaCore/Granulometry.fs index 877df99..004a25e 100644 --- a/Parasitemia/ParasitemiaCore/Granulometry.fs +++ b/Parasitemia/ParasitemiaCore/Granulometry.fs @@ -29,8 +29,8 @@ let findRadiusByClosing (img: Image) (range: int * int) (scale: f if s % 2 = 0 then failwith "s must be odd" let m = new Matrix(Array2D.create s s 1uy) let r = (float s) / (Math.Sqrt 2. + 2.) |> roundInt - for i in 0 .. r - 1 do - for j in 0 .. r - 1 do + for i = 0 to r - 1 do + for j = 0 to r - 1 do if i + j < r then m.[i, j] <- 0uy @@ -40,7 +40,7 @@ let findRadiusByClosing (img: Image) (range: int * int) (scale: f m let mutable previous_n = Double.NaN - for r in r1' .. r2' do + for r = r1' to r2' do let se = if useOctagon then (octagon (2 * r - 1)).Mat // It doesn't speed up the process. else CvInvoke.GetStructuringElement(CvEnum.ElementShape.Ellipse, Size(2 * r, 2 * r), Point(-1, -1)) diff --git a/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs b/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs index 363acda..edf4cd2 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs @@ -51,8 +51,8 @@ let drawCell (img: Image) (drawCellContent: bool) (c: Cell) = let colorG = rngCell.Next(20, 70) let colorR = rngCell.Next(20, 70) - for y in 0 .. c.elements.Height - 1 do - for x in 0 .. c.elements.Width - 1 do + for y = 0 to c.elements.Height - 1 do + for x = 0 to c.elements.Width - 1 do if c.elements.[y, x] > 0uy then let dx, dy = c.center.X - c.elements.Width / 2, c.center.Y - c.elements.Height / 2 diff --git a/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs b/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs index 3980120..df5858d 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs @@ -51,8 +51,8 @@ let find (img: Image) : Matrix * Matrix * Matrix 0.f || vy <> 0.f @@ -92,8 +92,8 @@ let find (img: Image) : Matrix * Matrix * Matrix() - 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 nmsData.[i, j] = 1uy && magnitudesData.[i, j] >= thresholdHigh then nmsData.[i, j] <- 0uy @@ -101,8 +101,8 @@ let find (img: Image) : Matrix * Matrix * Matrix 0 do let p = toVisit.Pop() edgesData.[p.Y, p.X] <- 1uy - for i' in -1 .. 1 do - for j' in -1 .. 1 do + for i' = -1 to 1 do + for j' = -1 to 1 do if i' <> 0 || j' <> 0 then let ni = p.Y + i' diff --git a/Parasitemia/ParasitemiaCore/ImgTools/Histogram.fs b/Parasitemia/ParasitemiaCore/ImgTools/Histogram.fs index 92b73f6..e3a9950 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/Histogram.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/Histogram.fs @@ -30,8 +30,8 @@ let histogramImg (img: Image) (nbSamples: int) : Histogram = let data = Array.zeroCreate nbSamples - for i in 0 .. img.Height - 1 do - for j in 0 .. img.Width - 1 do + for i = 0 to img.Height - 1 do + for j = 0 to img.Width - 1 do let p = bin imgData.[i, j, 0] data.[p] <- data.[p] + 1 @@ -54,8 +54,8 @@ let histogramMat (mat: Matrix) (nbSamples: int) : Histogram = let data = Array.zeroCreate nbSamples - for i in 0 .. mat.Height - 1 do - for j in 0 .. mat.Width - 1 do + for i = 0 to mat.Height - 1 do + for j = 0 to mat.Width - 1 do let p = bin matData.[i, j] data.[p] <- data.[p] + 1 diff --git a/Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs b/Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs index 0949713..ae542ce 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs @@ -41,8 +41,8 @@ let mergeChannelsWithProjection (img: Image) (v1r: float32, v1g: f let project (r: float32) (g: float32) (b: float32) = ((r - v1r) * vr + (g - v1g) * vg + (b - v1b) * vb) / vMagnitude let result = new Image(img.Size) // TODO: Essayer en bindant Data pour gagner du temps - for i in 0 .. img.Height - 1 do - for j in 0 .. img.Width - 1 do + for i = 0 to img.Height - 1 do + for j = 0 to img.Width - 1 do result.Data.[i, j, 0] <- project img.Data.[i, j, 2] img.Data.[i, j, 1] img.Data.[i, j, 0] normalize result upperLimit diff --git a/Parasitemia/ParasitemiaCore/ImgTools/Morpho.fs b/Parasitemia/ParasitemiaCore/ImgTools/Morpho.fs index b3a2e75..588622e 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/Morpho.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/Morpho.fs @@ -16,13 +16,13 @@ open Types let suppressMAdjacency (img: Matrix) = 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) (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) (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) (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) (area: int) = let pointsChecked = HashSet() let pointsToCheck = Stack() - 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) (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) = 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) (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() @@ -658,8 +658,8 @@ let connectedComponents (img: Image) (startPoints: List) : 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) diff --git a/Parasitemia/ParasitemiaCore/ImgTools/Otsu.fs b/Parasitemia/ParasitemiaCore/ImgTools/Otsu.fs index 6b8ee53..82dfde4 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/Otsu.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/Otsu.fs @@ -9,7 +9,7 @@ let otsu (hist: Histogram) : float32 * float32 * float32 = let mutable level = 0 let sum = hist.data |> Array.mapi (fun i v -> i * v |> float) |> Array.sum - for i in 0 .. hist.data.Length - 1 do + for i = 0 to hist.data.Length - 1 do wB <- wB + hist.data.[i] if wB <> 0 then @@ -28,7 +28,7 @@ let otsu (hist: Histogram) : float32 * float32 * float32 = let mean1 = let mutable sum = 0 let mutable nb = 0 - for i in 0 .. level - 1 do + for i = 0 to level - 1 do sum <- sum + i * hist.data.[i] nb <- nb + hist.data.[i] (sum + level * hist.data.[level] / 2) / (nb + hist.data.[level] / 2) @@ -36,7 +36,7 @@ let otsu (hist: Histogram) : float32 * float32 * float32 = let mean2 = let mutable sum = 0 let mutable nb = 0 - for i in level + 1 .. hist.data.Length - 1 do + for i = level + 1 to hist.data.Length - 1 do sum <- sum + i * hist.data.[i] nb <- nb + hist.data.[i] (sum + level * hist.data.[level] / 2) / (nb + hist.data.[level] / 2) diff --git a/Parasitemia/ParasitemiaCore/KMeans.fs b/Parasitemia/ParasitemiaCore/KMeans.fs index 86f1e3b..6e52947 100644 --- a/Parasitemia/ParasitemiaCore/KMeans.fs +++ b/Parasitemia/ParasitemiaCore/KMeans.fs @@ -35,7 +35,7 @@ let kmeans (img: Image) : Result = 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 -> () | _ -> @@ -54,8 +54,8 @@ let kmeans (img: Image) : Result = 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 + 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] diff --git a/Parasitemia/ParasitemiaCore/KMedians.fs b/Parasitemia/ParasitemiaCore/KMedians.fs index 5819a66..504172a 100644 --- a/Parasitemia/ParasitemiaCore/KMedians.fs +++ b/Parasitemia/ParasitemiaCore/KMedians.fs @@ -29,7 +29,7 @@ let kmedians (img: Image) : Result = let mutable d_fg = new Image(img.Size) let mutable fg = new Image(img.Size) - for i in 1 .. nbIteration do + for i = 1 to nbIteration do d_bg <- img.AbsDiff(Gray(median_bg)) d_fg <- img.AbsDiff(Gray(median_fg)) @@ -38,8 +38,8 @@ let kmedians (img: Image) : Result = let bg_values = List() let fg_values = List() - 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 fg.Data.[i, j, 0] > 0uy then fg_values.Add(float img.Data.[i, j, 0]) else bg_values.Add(float img.Data.[i, j, 0]) diff --git a/Parasitemia/ParasitemiaUI/AssemblyInfo.fs b/Parasitemia/ParasitemiaUI/AssemblyInfo.fs index 49cbbb3..a4b44e1 100644 --- a/Parasitemia/ParasitemiaUI/AssemblyInfo.fs +++ b/Parasitemia/ParasitemiaUI/AssemblyInfo.fs @@ -34,8 +34,8 @@ open System.Runtime.InteropServices // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [] -[] -[] +[] +[] do () \ No newline at end of file