center: Point
elements: Matrix<byte> }
+type KdEllipse (e: Types.Ellipse) =
+ inherit Types.Ellipse (e.Cx, e.Cy, e.A, e.B, e.Alpha)
+
+ interface KdTree.I2DCoords with
+ member this.X = this.Cx
+ member this.Y = this.Cy
+
+
let findCells (ellipses: Types.Ellipse list) (parasites: ParasitesMarker.Result) (fg: Image<Gray, byte>) : Cell list =
- []
\ No newline at end of file
+ if ellipses.IsEmpty
+ then
+ []
+ else
+ let tree = KdTree.Tree.buildTree (ellipses |> List.map KdEllipse)
+ []
\ No newline at end of file
| 3 -> threeintpts xint yint a1 b1 phi_1 a2 b2 h2_tr k2_tr phi_2 aa bb cc dd ee ff
| 4 -> fourintpts xint yint a1 b1 phi_1 a2 b2 h2_tr k2_tr phi_2 aa bb cc dd ee ff
| _ -> -1.0
- Some (area, xint.[..nintpts-1], yint.[..nintpts-1])
\ No newline at end of file
+ if nintpts = 0
+ then Some (area, [||], [||])
+ else Some (area, xint.[..nintpts-1], yint.[..nintpts-1])
\ No newline at end of file
let windowSize = roundInt (1.6 * (snd radiusRange))
let factorNbPick = 1.5
let ellipses = logTime "Finding ellipses" (fun () ->
- Ellipse.find edges xEdges yEdges radiusRange windowSize factorNbPick)
+ Ellipse.find edges xEdges yEdges radiusRange windowSize factorNbPick) |> List.filter (fun e -> not (e.CutAVericalLine 0.0) &&
+ not (e.CutAVericalLine (float img.Width)) &&
+ not (e.CutAnHorizontalLine 0.0) &&
+ not (e.CutAnHorizontalLine (float img.Height)))
drawEllipses img ellipses (Bgr(0.0, 255.0, 255.0))
//saveImg img "ellipses.png"
other.Removed <- true
ellipses.RemoveAll(fun e -> e.Removed) |> ignore
- dprintfn "Number of ellipse: %A" ellipses.Count
-
List.ofSeq ellipses |> List.map (fun e -> e.Ellipse)
//use img = new Image<Bgr, byte>("../../../../src/Tests_hough/images/rbc_single_oblong_4.png")
//use img = new Image<Bgr, byte>("../../../../src/Tests_hough/images/strange_rbc_1.png")
//use img = new Image<Bgr, byte>("../../../../src/Tests_hough/images/rbc_single_blurred.png")
- //use img = new Image<Bgr, byte>("../../../../src/Tests_hough/images/lot.png")
+ use img = new Image<Bgr, byte>("../../../../src/Tests_hough/images/lot.png")
///// PARASITES /////
- use img = new Image<Bgr, byte>("../../../../src/Parasites/images/1.png")
+ //use img = new Image<Bgr, byte>("../../../../src/Parasites/images/1.png")
// KdTree.test3 ()
// Utils.dprintfn "area: %A" area
- let result = ImageAnalysis.doAnalysis img config
+ let result = Utils.logTime "Total" (fun () ->
+ ImageAnalysis.doAnalysis img config )
display mainWindow img
mainWindow.Root.Show()
// Does the ellipse contain the point (x, y)?.
member this.Contains x y =
- ((x - cx) * cos alpha + (y - cy) * sin alpha) ** 2.0 / a ** 2.0 + ((x - cx) * sin alpha - (y - cy) * cos alpha) ** 2.0 / b ** 2.0 <= 1.0
\ No newline at end of file
+ ((x - cx) * cos alpha + (y - cy) * sin alpha) ** 2.0 / a ** 2.0 + ((x - cx) * sin alpha - (y - cy) * cos alpha) ** 2.0 / b ** 2.0 <= 1.0
+
+ // A line is defined as : y = mx + l
+ member this.CutALine (m: float) (l: float) : bool =
+ -2.0 * l ** 2.0 + a ** 2.0 + m ** 2.0 * a ** 2.0 + b ** 2.0 + m ** 2.0 * b ** 2.0 -
+ 4.0 * m * l * cx - 2.0 * m ** 2.0 * cx ** 2.0 + 4.0 * l * cy + 4.0 * m * cx * cy -
+ 2.0 * cy ** 2.0 + (-1.0 + m ** 2.0) * (a ** 2.0 - b ** 2.0) * cos (2.0 * alpha) - 2.0 * m * (a ** 2.0 - b ** 2.0) * sin (2.0 * alpha) > 0.0
+
+ member this.CutAVericalLine (y: float) : bool =
+ a ** 2.0 + b ** 2.0 - 2.0 * y ** 2.0 + 4.0 * y * cx - 2.0 * cx ** 2.0 + a ** 2.0 * cos (2.0 * alpha) - b ** 2.0 * cos (2.0 * alpha) > 0.0
+
+ member this.CutAnHorizontalLine (x: float) : bool =
+ a ** 2.0 + b ** 2.0 - 2.0 * x ** 2.0 + 4.0 * x * cy - 2.0 * cy ** 2.0 - a ** 2.0 * cos (2.0 * alpha) + b ** 2.0 * cos (2.0 * alpha) > 0.0
\ No newline at end of file