Segmentation of complex images help

What could I use to segment these types of images:

AF6B1777-98B8-4447-A234-FE641BB1B54F.tiff (1.3 MB) 316AE156-DADE-4DE0-B856-08966B694D37.tiff (691.9 KB)

I need to segment all of the different cytoskeleton regions in the second image. The first image are the corresponding nuclear regions.

I have tried using some basic pipeline in Cell Profiler but they don’t seem to work correctly.

Anyone have any advice?


I think some hydrology method may be ok. did you try the mesr feature?

Where do I find the mesr feature?
Also, please see the second cytoskeleton image. That is the main task. Hydrology would work on it?

do you want to extract the region on first img from the second img?

I am not sure what do you want.

  1. we have the cytoskeleton image and the nuclear image, we need segment the cytoskeleton.
  2. we have only cytoskeleton image, you give the nuclear image just show us what the result should be?

hydrology algorithms are method based on hydrology. (such as watershed, mesr, local min, local max…) your image looks like some volcanos, and you want to extract the volcano’s holes, right? mser means “Maximally Stable Extremal Regions” So I think mser fits your image. maybe need some prework.

I know opencv has a mser implements, can you write code? If you can not, I can write a mser plugins based on ImagePy.

The nuclei image is easy. Don’t know if the cytoskeleton cells may be segmented because there are areas where cells overlap that cannot be demarcated even by eye. Depending what you need, you could put a band around each nucleus to measure the intensities in the cytoskeleton channel. And do you really need a per cell measurement?

run(“Duplicate…”, " ");
run(“Median…”, “radius=6”);
setAutoThreshold(“Default no-reset”);
setAutoThreshold(“Default dark no-reset”);
run(“Analyze Particles…”, “exclude clear include add”);

Here is a CellProfiler pipeline that should work for you. pipeline.cppipe (11.1 KB)

side note: I’m a little perplexed why the colors don’t match between the nucleus and cytoplasm objects (normally they do, and the segmentation is correct based on the outlined image - can someone help?)

nuclei.pdf (62.0 KB)
Cytoplasm.pdf (271.0 KB)
CytoOultlines.pdf (271.0 KB)


#1 is what I want. we have the cytoskeleton image and the nuclear image, we need segment the cytoskeleton.

Hi @awezm
I’m learning to use the macros with ImageJ
I used your images (stack).
Plus, I’m no biologist so I don’t know what it worth;
Thank you for your feedback.

Stack.tif (4.0 MB)

setOption("BlackBackground", true);
run("Stack to Images");
run("Duplicate...", "title=1");
run("Duplicate...", "title=2");
run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel global");
run("Duplicate...", " ");
run("Subtract...", "value=20");
run("Convert to Mask");
run("Analyze Particles...", "size=2-Infinity display add in_situ");
roiManager("Show All without labels");
roiManager("Set Color", "blue");
roiManager("Set Line Width", 1);
run("From ROI Manager");
setAutoThreshold("MaxEntropy dark");
run("Convert to Mask");
run("Analyze Particles...", "size=500-Infinity circularity=0.20-1.00 display summarize add in_situ");
roiManager("Set Fill Color", "green");
run("From ROI Manager");

So, I think the nuclear image is easy, and the nuclear can help the cytoskeleton one.
the nuclear image:
just threshold, and remove the small noise
for the cytoskeleton:
threshold, and use the nuclear as root, do a watershed!

Is the result OK? If it is OK, I can give a macros.

it looks good, how can i build the macro for it @yxdragon

So, how many images do you have?
you want a automatically macros? or an interactive workflow (which you can adjust some parameters to fit specific image)?

I want automatic way for all images. @yxdragon

step 1: Open ImagePy, Menu: Window > Develop Tool Suit

you will see the develop panel below, and active the macros tag. It is like a recorder/Player, now we has macros to play, so click the [ || ] button to stop recording.

step 2: Import Images, Menu : Import > Import Sequence

Open oen image, or import sequence. If sequence, please make sure the nuclear sequence and cytoskeleton sequence are in the same index.

step 3: click the nuclear image tag then run the macros below

paste the code and click run button.

Duplicate>{‘name’: ‘cell-in’, ‘stack’: True}
Threshold>{‘thr1’: 0, ‘thr2’: 23, ‘stack’:True}
Geometry Filter>{‘con’: ‘4-connect’, ‘inv’: False, ‘area’: 100.0, ‘l’: 0.0, ‘holes’: 0, ‘solid’: 0.0, ‘e’: 0.0, ‘front’: 255, ‘back’: 0, ‘stack’:True}
Fill Holes>{‘stack’:True}

step 2: click the cytoskeleton image tag then run the macros below

paste the code and click run button.

Duplicate>{‘name’: ‘cell-out’, ‘stack’: True}
Gaussian>{‘sigma’: 5.0, ‘stack’:True}
Threshold>{‘thr1’: 0, ‘thr2’: 13, ‘stack’:True}
Image Calculator>{‘img1’: ‘cell-out’, ‘op’: ‘add’, ‘img2’: ‘cell-in’, ‘stack’:True}
Geometry Filter>{‘con’: ‘4-connect’, ‘inv’: False, ‘area’: 1000.0, ‘l’: 0.0, ‘holes’: 0, ‘solid’: 0.0, ‘e’: 0.0, ‘front’: 255, ‘back’: 0, ‘stack’:True}
Geometry Filter>{‘con’: ‘4-connect’, ‘inv’: True, ‘area’: 1000.0, ‘l’: 0.0, ‘holes’: 0, ‘solid’: 0.0, ‘e’: 0.0, ‘front’: 255, ‘back’: 255, ‘stack’:True}
Duplicate>{‘name’: ‘line’, ‘stack’: True}
Distance Transform>{‘stack’:True}
Image Calculator>{‘img1’: ‘line’, ‘op’: ‘add’, ‘img2’: ‘cell-in’}
Find Watershed>{‘sigma’: 0.0, ‘thr’: 254, ‘con’: True, ‘ud’: False, ‘type’: ‘white line’, ‘stack’:True}
Image Calculator>{‘img1’: ‘line’, ‘op’: ‘min’, ‘img2’: ‘cell-out’}

But I am not sure these parameter fit all your images, please adjust them by the result!
The macros code can run in macros recorder. You can also save them in a .mc file, and drag it on ImagePy’s status bar (bottom) to run it. Or put it in ImagePy’s plugins subfolder, when start next time, it would be parsed as a menu.

here is a work flow, It is a mark down file named as .wf. drag it in ImagePy’s status bar, it would be parsed as a panel, just click from left to right, and follow the tips, you will get the result. In this mode, we need operate every step, but we can control the all parameter step by step. And also supports sequence operation!

copy the code below, and save a .wf file, drag on ImagePy’s status bar.

Nuclear And Cytoskeleton Segment
## Nuclear Segment
1. Duplicate
duplicate nuclear images and rename as cell-in
2. 8-bit
trans to 8-bit gray image
3. Threshold
threshold the cell
4. Geometry Filter
check the preview, adjust the area paramater, the region < area would be dark, when it is ok, set back color 0 to remove them.
5. Fill Holes
fill holes in cells
## Cytoskeleton
1. Duplicate
duplicate cytoskeleton images and rename as cell-out
2. 8-bit
trans to 8-bit gray image
3. Gaussian
blur the image to get a pure threshold mask
4. Threshold
threshold, please make sure the cytoskeleton is not broken
5. Image Calculator
put img1 cell-out, and put img2 cell-in, use add method, fill the nuclear holes
6. Geometry Filter
adjust area to remove small region
7. Geometry Filter
check the inv, set back 255, adjust area to remove small holes
8. Duplicate
duplicate result and rename as line
9. Distance Transform
distance transform
0. Image Calculator
put img1 line, and put img2 cell-in, use add method, make nuclear region light
1. Find Watershed
use nuclear region as roods to do watershed on distance map, uncheck ascend, slide to 254, white line mode.
2. Invert
invert image
3. Image Calculator
put img1 line, and put img2 cell-out, use min method, get the final result
1 Like