X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemiaCore%2FParasitesMarker.fs;h=263e35ef60a2724e646673c311235ee36366d722;hb=b87b35b922551f122228df1fd9c530bbb807935a;hp=6c25d043af0ea0f67ef2681e26c9a9cc649b1a5f;hpb=e3842630f4d36c5ea8c8a0c3d4762684e1c510f4;p=master-thesis.git diff --git a/Parasitemia/ParasitemiaCore/ParasitesMarker.fs b/Parasitemia/ParasitemiaCore/ParasitesMarker.fs index 6c25d04..263e35e 100644 --- a/Parasitemia/ParasitemiaCore/ParasitesMarker.fs +++ b/Parasitemia/ParasitemiaCore/ParasitesMarker.fs @@ -7,14 +7,19 @@ open Emgu.CV open Emgu.CV.Structure open Utils +open Histogram +open Otsu +open Morpho open ImgTools -type Result = { - darkStain: Image // Colored pixel, it's independent of the size of the areas. It corresponds to white cells, schizontes, gametocytes, throphozoites. - nucleus: Image // Parasite nucleus. It may contain some debris. It shouldn't contain thrombocytes or larger elements. - parasite: Image } // The whole parasites. +type Result = + { + darkStain : Image // Colored pixel, it's independent of the size of the areas. It corresponds to white cells, schizontes, gametocytes, throphozoites. + nucleus : Image // Parasite nucleus. It may contain some debris. It shouldn't contain thrombocytes or larger elements. + parasite : Image // The whole parasites. + } -let find (img: Image) (config: Config.Config) : Result * Image * Image = +let find (img : Image) (config : Config.Config) : Result * Image * Image = let imgWithoutNucleus = img.Copy() areaCloseF imgWithoutNucleus (roundInt config.RBCRadius.NucleusArea) @@ -24,24 +29,25 @@ let find (img: Image) (config: Config.Config) : Result * Image) (closed: Image) (level: float) : Image = + let marker (img : Image) (closed : Image) (level : float) : Image = let diff = img.Copy() diff._Mul(level) CvInvoke.Subtract(closed, diff, diff) diff._ThresholdBinary(Gray(0.0), Gray(255.)) diff.Convert() + // Nucleus. let nucleusMarker = marker img imgWithoutNucleus (1. / config.Parameters.infectionSensitivity) + // Cytoplasm. let imgWithoutParasite = img.CopyBlank() let kernelSize = - let size = roundInt (config.RBCRadius.Pixel / 5.f) + let size = roundInt config.RBCRadius.CytoplasmSize if size % 2 = 0 then size + 1 else size use kernel = - if kernelSize <= 3 - then + if kernelSize <= 3 then CvInvoke.GetStructuringElement(CvEnum.ElementShape.Rectangle, Size(3, 3), Point(-1, -1)) else CvInvoke.GetStructuringElement(CvEnum.ElementShape.Ellipse, Size(kernelSize, kernelSize), Point(-1, -1)) @@ -49,9 +55,11 @@ let find (img: Image) (config: Config.Config) : Result * Image