X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FParasitesMarker.fs;h=9adf1850513f69aee3ea5ce96c1985b5109e6961;hb=10afa9a402eb88c8e073fe8b0d607faa25230eef;hp=fde0afe4601110e061f98f8b4f4aa32636a5920a;hpb=06bd63d8c01100c28873dfafd59b5efccbfb67e4;p=master-thesis.git diff --git a/Parasitemia/Parasitemia/ParasitesMarker.fs b/Parasitemia/Parasitemia/ParasitesMarker.fs index fde0afe..9adf185 100644 --- a/Parasitemia/Parasitemia/ParasitesMarker.fs +++ b/Parasitemia/Parasitemia/ParasitesMarker.fs @@ -10,6 +10,10 @@ type Result = { stain: Image infection: Image } +// Create three binary markers : +// * 'Dark stain' corresponds to the colored pixel, it's independent of the size of the areas. +// * 'Stain' corresponds to the stain around the parasites. +// * 'Infection' corresponds to the parasite. It shouldn't contain thrombocytes. let find (green: Image) (filteredGreen: Image) (kmediansResult: KMedians.Result) (config: Config.Config) : Result = // We use the filtered image to find the dark stain. @@ -17,23 +21,22 @@ let find (green: Image) (filteredGreen: Image) (km let darkStain = d_fg.Cmp(median_bg * config.darkStainLevel, CvEnum.CmpType.GreaterThan) darkStain._And(filteredGreen.Cmp(median_fg, CvEnum.CmpType.LessThan)) darkStain._And(fg) - + let fgFloat = (fg / 255.0).Convert() - let greenWithoutBg = green.Copy() + use greenWithoutBg = ImgTools.gaussianFilter green 1.0 greenWithoutBg.SetValue(Gray(0.0), fg.Not()) - let findSmears (sigma: float) (level: float) : Image = - let greenWithoutBgSmoothed = ImgTools.gaussianFilter greenWithoutBg sigma - let fgSmoothed = ImgTools.gaussianFilter fgFloat sigma - + let findSmears (sigma: float) (level: float) : Image = + use greenWithoutBgSmoothed = ImgTools.gaussianFilter greenWithoutBg sigma + use fgSmoothed = ImgTools.gaussianFilter fgFloat sigma let smears = (greenWithoutBg.Mul(fgSmoothed)).Cmp(greenWithoutBgSmoothed.Mul(level), CvEnum.CmpType.LessThan) smears._And(fg) - smears + smears { darkStain = darkStain; stain = findSmears config.stainSigma config.stainLevel infection = findSmears config.infectionSigma config.infectionLevel } - +