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)