1
$\begingroup$

I have a set of images of biological cells, which look like this:

enter image description here

How do I find the edge of these cells in a robust way (i.e. without having to manually tweak each one. I have three images here:

img1 = Import["https://i.stack.imgur.com/hZ5Vt.jpg"]
img2 = Import["https://i.stack.imgur.com/tQ5wd.jpg"]
img3 = Import["https://i.stack.imgur.com/wjfvW.jpg"]

and I'm looking for ways to deliminate the outer edge. I need the actual edge (accurately), not a bounding box. The background should be relatively constant between images.

This does reasonably on the first image, but not on the others:

HighlightImage[img1, 
   DeleteSmallComponents@EdgeDetect[CurvatureFlowFilter[img1, 10], 15]]

enter image description here

$\endgroup$
2
$\begingroup$

Refer to the Green chromaticity of the overlaid fluorescence channel

I suggest to adopt the inverted red chromaticity channel as used for the third channel of the YCC color space, as the green fluorescence visible in your images might be the most stable cell shape related information. I also added a parabolic tonality curve, have left the curvature flow filter as you were using, added an Otsu binarization and a filling transform, so please see the outlines this method provides:

ParallelMap[
 HighlightImage[
  #, 
  EdgeDetect@
   FillingTransform@
    Binarize@
     CurvatureFlowFilter[#,10]&@
      ImageAdjust[#,{0,0,2}]&@
       ColorNegate@ImageApply[1/2+{1/2,-587/1402,-57/701}.#&,#], 
  "HighlightColor"->Red,Method->{"Boundary",10}
 ]&,
 {img1, img2, img3}
]

output of the chromaticity approach

Or try a GradientFilter based approach

ParallelMap[
 HighlightImage[#, 
  FillingTransform@
   Closing[#,5]&@
    DeleteSmallComponents@
     Binarize@
      GradientFilter[#,10], 
  "HighlightColor"->Red,Method->{"Boundary",10}
 ]&,
 {img1,img2,img3}
]

output of the gradient filter approach

What always remains problematic are varying halos (also depending on the contrast method being applied). So please be careful, as your cells appear to have different thicknesses.

$\endgroup$
  • $\begingroup$ Thank you (and sorry for the delay). They are actually 2d slices of 3D cysts rather than cells, so what you can see as different thicknesses is partly due to that. Can you explain what you are doing with the ImageApply in the first example? $\endgroup$ – KraZug May 2 at 15:08
  • $\begingroup$ I should have seen that this is something but not a cell :-) Well, using ImageApply I refer to YCbCr and simply use the negative of the Cr channel, which emphasises the Green fluorencent overlaid channel. I do this since you already have mixed if with the transmission channel.{1/2, -587/1402, -57/701} is nothing but {0.5, -0.418688, -0.0813124} as you find in the third line of the matrix. What I do using ImageApply is to compute the scalar products from RGB to Cr, and ColorNegatecomputes the negative, $\endgroup$ – UDB May 2 at 17:16
  • $\begingroup$ Ok, thanks. I did call it a cell in my initial post, so a reasonable thing to miss. $\endgroup$ – KraZug May 2 at 18:09
  • $\begingroup$ Do you prefer the solution with the chromaticity? BTW, the pure function ColorNegate@ImageApply[1/2+{1/2,-587/1402,-57/701}.#& simply can be abbreviated using ImageApply[1/2-{1/2,-587/1402,-57/701}.#&. The offset 1/2 is required to put the result on a scale between 0. and 1.. May I ask if you let the 3D cysts grow in a petri dish or thelike? Are these experiments with intestinal organoids? Appears to be quite interesting. $\endgroup$ – UDB May 2 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.