// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [<assembly: AssemblyVersion("1.0.*")>]
-[<assembly: AssemblyVersion("1.0.0.6")>]
-[<assembly: AssemblyFileVersion("1.0.0.6")>]
+[<assembly: AssemblyVersion("1.0.0.7")>]
+[<assembly: AssemblyFileVersion("1.0.0.7")>]
do
()
\ No newline at end of file
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
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
let mutable nbElement = 0
let elements = new Matrix<byte>(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
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
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]
#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
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
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
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]
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
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
|]
#if DEBUG_LOG
- for i in 0..4 do
+ for i = 0 to 4 do
printf "cy[%d]=%f\n" i cy.[i]
#endif
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
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
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
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
#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
// 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))
if s % 2 = 0 then failwith "s must be odd"
let m = new Matrix<byte>(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
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))
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
let xGradientData = xGradient.Data
let yGradientData = yGradient.Data
- 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
let vx = xGradientData.[i, j]
let vy = yGradientData.[i, j]
if vx <> 0.f || vy <> 0.f
// Hysteresis thresholding.
let toVisit = Stack<Point>()
- 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
while toVisit.Count > 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'
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
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
let project (r: float32) (g: float32) (b: float32) = ((r - v1r) * vr + (g - v1g) * vg + (b - v1b) * vb) / vMagnitude
let result = new Image<Gray, float32>(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
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
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
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
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
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
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 ->
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]
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>()
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)
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
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)
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)
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
+ 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]
let mutable d_fg = new Image<Gray, float32>(img.Size)
let mutable fg = new Image<Gray, byte>(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))
let bg_values = List<float>()
let fg_values = List<float>()
- 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])
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [<assembly: AssemblyVersion("1.0.*")>]
-[<assembly: AssemblyVersion("1.0.0.6")>]
-[<assembly: AssemblyFileVersion("1.0.0.6")>]
+[<assembly: AssemblyVersion("1.0.0.7")>]
+[<assembly: AssemblyFileVersion("1.0.0.7")>]
do
()
\ No newline at end of file