mat.CopyTo(img)
saveImg img filepath
-
type Histogram = { data: int[]; total: int; sum: int; min: float32; max: float32 }
let histogramImg (img: Image<Gray, float32>) (nbSamples: int) : Histogram =
toFloat level, toFloat mean1, toFloat mean2
-
let suppressMConnections (img: Matrix<byte>) =
let w = img.Width
let h = img.Height
then
img.[i, j] <- 0uy
-
let findEdges (img: Image<Gray, float32>) : Matrix<byte> * Image<Gray, float32> * Image<Gray, float32> =
let w = img.Width
let h = img.Height
edges, xGradient, yGradient
-
let gaussianFilter (img : Image<'TColor, 'TDepth>) (standardDeviation : float) : Image<'TColor, 'TDepth> =
let size = 2 * int (ceil (4.0 * standardDeviation)) + 1
img.SmoothGaussian(size, size, standardDeviation, standardDeviation)
-
type Points = HashSet<Point>
let drawPoints (img: Image<Gray, 'TDepth>) (points: Points) (intensity: 'TDepth) =
result.Select(fun l -> Points(l))
-
let findMaxima (img: Image<Gray, 'TDepth>) : IEnumerable<Points> =
findExtremum img ExtremumType.Maxima
-
let findMinima (img: Image<Gray, 'TDepth>) : IEnumerable<Points> =
findExtremum img ExtremumType.Minima
-
type PriorityQueue () =
let size = 256
let q: Points[] = Array.init size (fun i -> Points())
highest <- -1
lowest <- size
-
type private AreaState =
| Removed = 1
| Unprocessed = 2
| _ -> ()
()
-
let areaOpen (img: Image<Gray, byte>) (area: int) =
areaOperation img area AreaOperation.Opening
member val Level = 0.f with get, set
member val Surface = 0 with get, set
-
let private areaOperationF (img: Image<Gray, float32>) (areas: (int * 'a) list) (f: ('a -> float32 -> unit) option) (op: AreaOperation) =
let w = img.Width
let h = img.Height
| _ -> ()
()
-
let areaOpenF (img: Image<Gray, float32>) (area: int) =
areaOperationF img [ area, () ] None AreaOperation.Opening
for p in pointsChecked do
imgData.[p.Y, p.X, 0] <- maxNeighborValue
-
// Zhang and Suen algorithm.
// Modify 'mat' in place.
let thin (mat: Matrix<byte>) =
data1 <- data2
data2 <- tmp
-
// Remove all 8-connected pixels with an area equal or greater than 'areaSize'.
// Modify 'mat' in place.
let removeArea (mat: Matrix<byte>) (areaSize: int) =
List<Point>(pointChecked)
-
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);
-
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);
-
let drawEllipse (img: Image<'TColor, 'TDepth>) (e: Types.Ellipse) (color: 'TColor) (alpha: float) =
-
if alpha >= 1.0
then
img.Draw(Ellipse(PointF(float32 e.Cx, float32 e.Cy), 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: Types.Ellipse list) (color: 'TColor) (alpha: float) =
List.iter (fun e -> drawEllipse img e color alpha) ellipses
-
let rngCell = System.Random()
let drawCell (img: Image<Bgr, byte>) (drawCellContent: bool) (c: Types.Cell) =
if drawCellContent