X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemiaCore%2FImgTools%2FDrawing.fs;h=2882f4bb1920f10e78d9f215fdf4a410fd4242cb;hp=9662049ebc6c793f2c9f39b4a5173a1416fc6fc4;hb=2d712781def419c9acc98368f7102b19b064f16d;hpb=d715615d0b1da40fd10e9dbabbd4530cd5125a19 diff --git a/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs b/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs index 9662049..2882f4b 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs @@ -14,14 +14,14 @@ let drawPoints (img : Image) (points : Points) (intensity : 'TDep img.Data.[p.Y, p.X, 0] <- intensity let drawLine (img : Image<'TColor, 'TDepth>) (color : 'TColor) (x0 : int) (y0 : int) (x1 : int) (y1 : int) (thickness : int) = - img.Draw(LineSegment2D(Point(x0, y0), Point(x1, y1)), color, thickness); + img.Draw (LineSegment2D (Point (x0, y0), Point (x1, y1)), color, thickness); let drawLineF (img : Image<'TColor, 'TDepth>) (color : 'TColor) (x0 : float) (y0 : float) (x1 : float) (y1 : float) (thickness : int) = - img.Draw(LineSegment2DF(PointF(float32 x0, float32 y0), PointF(float32 x1, float32 y1)), color, thickness, CvEnum.LineType.AntiAlias); + img.Draw (LineSegment2DF (PointF (float32 x0, float32 y0), PointF (float32 x1, float32 y1)), color, thickness, CvEnum.LineType.AntiAlias); let drawEllipse (img : Image<'TColor, 'TDepth>) (e : Ellipse) (color : 'TColor) (alpha : float) = if alpha >= 1.0 then - img.Draw(Emgu.CV.Structure.Ellipse(PointF(e.Cx, e.Cy), SizeF(2.f * e.B, 2.f * e.A), e.Alpha / PI * 180.f), color, 1, CvEnum.LineType.AntiAlias) + img.Draw (Emgu.CV.Structure.Ellipse (PointF (e.Cx, e.Cy), SizeF (2.f * e.B, 2.f * e.A), e.Alpha / PI * 180.f), color, 1, CvEnum.LineType.AntiAlias) else let windowPosX = e.Cx - e.A - 5.f let gapX = windowPosX - (float32 (int windowPosX)) @@ -29,24 +29,24 @@ let drawEllipse (img : Image<'TColor, 'TDepth>) (e : Ellipse) (color : 'TColor) let windowPosY = e.Cy - e.A - 5.f let gapY = windowPosY - (float32 (int windowPosY)) - let roi = Rectangle(int windowPosX, int windowPosY, 2.f * (e.A + 5.f) |> int, 2.f * (e.A + 5.f) |> int) + let roi = Rectangle (int windowPosX, int windowPosY, 2.f * (e.A + 5.f) |> int, 2.f * (e.A + 5.f) |> int) img.ROI <- roi if roi = img.ROI then // We do not display ellipses touching the edges (FIXME) - use i = new Image<'TColor, 'TDepth>(img.ROI.Size) - i.Draw(Emgu.CV.Structure.Ellipse(PointF(e.A + 5.f + gapX, e.A + 5.f + gapY), SizeF(2.f * e.B, 2.f * e.A), e.Alpha / PI * 180.f), color, 1, CvEnum.LineType.AntiAlias) - CvInvoke.AddWeighted(img, 1.0, i, alpha, 0.0, img) + use i = new Image<'TColor, 'TDepth> (img.ROI.Size) + i.Draw (Emgu.CV.Structure.Ellipse(PointF(e.A + 5.f + gapX, e.A + 5.f + gapY), SizeF(2.f * e.B, 2.f * e.A), e.Alpha / PI * 180.f), color, 1, CvEnum.LineType.AntiAlias) + CvInvoke.AddWeighted (img, 1.0, i, alpha, 0.0, img) img.ROI <- Rectangle.Empty let drawEllipses (img : Image<'TColor, 'TDepth>) (ellipses : Ellipse list) (color : 'TColor) (alpha : float) = List.iter (fun e -> drawEllipse img e color alpha) ellipses -let rngCell = System.Random() +let rngCell = System.Random () let drawCell (img : Image) (drawCellContent : bool) (c : Cell) = if drawCellContent then - let colorB = rngCell.Next(20, 70) - let colorG = rngCell.Next(20, 70) - let colorR = rngCell.Next(20, 70) + let colorB = rngCell.Next (20, 70) + let colorG = rngCell.Next (20, 70) + let colorR = rngCell.Next (20, 70) for y = 0 to c.elements.Height - 1 do for x = 0 to c.elements.Width - 1 do @@ -61,9 +61,9 @@ let drawCell (img : Image) (drawCellContent : bool) (c : Cell) = let crossColor, crossColor2 = match c.cellClass with - | HealthyRBC -> Bgr(255., 0., 0.), Bgr(255., 255., 255.) - | InfectedRBC -> Bgr(0., 0., 255.), Bgr(120., 120., 255.) - | Peculiar -> Bgr(0., 0., 0.), Bgr(80., 80., 80.) + | HealthyRBC -> Bgr (255., 0., 0.), Bgr (255., 255., 255.) + | InfectedRBC -> Bgr (0., 0., 255.), Bgr (120., 120., 255.) + | Peculiar -> Bgr (0., 0., 0.), Bgr (80., 80., 80.) drawLine img crossColor2 (c.center.X - 3) c.center.Y (c.center.X + 3) c.center.Y 2 drawLine img crossColor2 c.center.X (c.center.Y - 3) c.center.X (c.center.Y + 3) 2