-// 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 findMa (green: Image<Gray, float32>) (filteredGreen: Image<Gray, float32>) (config: Config.Config) : Result * Image<Gray, byte> * Image<Gray, byte> =
- // We use the filtered image to find the dark stain.
- let kmediansResults = KMedians.kmedians filteredGreen
- let { KMedians.fg = fg; KMedians.median_bg = median_bg; KMedians.median_fg = median_fg; KMedians.d_fg = d_fg } = kmediansResults
- let darkStain = d_fg.Cmp(median_bg * float config.Parameters.darkStainLevel, CvEnum.CmpType.GreaterThan)
- darkStain._And(filteredGreen.Cmp(median_fg, CvEnum.CmpType.LessThan))
- darkStain._And(fg)
-
- let fgFloat = (fg / 255.0).Convert<Gray, float32>()
- use greenWithoutBg = ImgTools.gaussianFilter green 1.0
- greenWithoutBg.SetValue(Gray(0.0), fg.Not())
-
- let findSmears (sigma: float) (level: float) : Image<Gray, byte> =
- 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
-
- let tmp = filteredGreen.Convert<Gray, byte>()
-
- { darkStain = darkStain;
- stain = findSmears 10. 0.9
- infection = findSmears 2.2 0.87 },
- 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.