X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FParasitesMarker.fs;h=671755c24b4f0c6eaf9fca54516cb8301d387c87;hb=81d1b86719a1ebaf649c1de4c1364603155a53e1;hp=720488d8bcc61e9322f061e651d6f20a539d90cb;hpb=6b550c3faf4dea77738fa5c27cd9af277f45549c;p=master-thesis.git diff --git a/Parasitemia/Parasitemia/ParasitesMarker.fs b/Parasitemia/Parasitemia/ParasitesMarker.fs index 720488d..671755c 100644 --- a/Parasitemia/Parasitemia/ParasitesMarker.fs +++ b/Parasitemia/Parasitemia/ParasitesMarker.fs @@ -12,7 +12,6 @@ type Result = { infection: Image stain: 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. @@ -44,24 +43,23 @@ let findMa (green: Image) (filteredGreen: Image) ( tmp, tmp - // 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 (filteredGreen: Image) (config: Config.Config) : Result * Image = use filteredGreenWithoutInfection = filteredGreen.Copy() - ImgTools.areaCloseF filteredGreenWithoutInfection (int config.InfectionArea) + ImgTools.areaCloseF filteredGreenWithoutInfection (int config.RBCRadius.InfectionArea) let filteredGreenWithoutStain = filteredGreenWithoutInfection.Copy() - ImgTools.areaCloseF filteredGreenWithoutStain (int config.StainArea) + ImgTools.areaCloseF filteredGreenWithoutStain (int config.RBCRadius.StainArea) - // We use the filtered image to find the dark stain. - let _, mean_fg, mean_bg = - let hist = ImgTools.histogramImg filteredGreenWithoutInfection 300 - ImgTools.otsu hist - - let darkStain = filteredGreenWithoutInfection.Cmp(-(float mean_bg) * config.Parameters.darkStainLevel + (float mean_fg), CvEnum.CmpType.LessThan) + let darkStain = + // We use the filtered image to find the dark stain. + let _, mean_fg, mean_bg = + let hist = ImgTools.histogramImg filteredGreenWithoutInfection 300 + ImgTools.otsu hist + filteredGreenWithoutInfection.Cmp(-(float mean_bg) * config.Parameters.darkStainLevel + (float mean_fg), CvEnum.CmpType.LessThan) let marker (img: Image) (closed: Image) (level: float) : Image = let diff = img.Copy() @@ -70,8 +68,15 @@ let find (filteredGreen: Image) (config: Config.Config) : Result diff._ThresholdBinary(Gray(0.0), Gray(255.)) diff.Convert() - let infectionMarker = marker filteredGreen filteredGreenWithoutInfection config.Parameters.infectionLevel - let stainMarker = marker filteredGreenWithoutInfection filteredGreenWithoutStain config.Parameters.stainLevel + let infectionMarker = marker filteredGreen filteredGreenWithoutInfection (1. / config.Parameters.infectionSensitivity) + let stainMarker = marker filteredGreenWithoutInfection filteredGreenWithoutStain (1. / config.Parameters.stainSensitivity) + + // TODO: comprendre pourquoi des valeurs sont negatives!?!? + (* + let blackTopHat = filteredGreen.CopyBlank() + CvInvoke.Subtract(filteredGreenWithoutInfection, filteredGreen, blackTopHat) + ImgTools.saveImg (ImgTools.normalizeAndConvert blackTopHat) "BottomHat.png" + *) { darkStain = darkStain infection = infectionMarker