Removing unwanted part of image

I have 3D data from a Confocal microscope. For analysis in Fiji, I want to focus only on the nucleus part of the cells. My images have 3-4 nuclei and some signal in cytoplasm. I want to crop (similar to photoshop/mspaint) each nuclei in a z-stack and save them to different files. The final image should have only one nucleus and no part of any other nuclei that was there before in the view.

How can I do that?


Hi @dpimagej,
but do you need that in a manual or in an automatized way?
Have a nice day,

Any way would work @emartini. Automated way will be fully awesome! If not available, a manual procedure will work too.


Hello there,
Could you posting a few examples of your images? It should be easier for people to suggest what can be done then :slight_smile:


@Praveen – That is a good suggestion! You can use the “hela-cells.tif” sample from Fiji’s samples.
In Fiji, click File>Open Samples>"HeLa Cells (1.3M, 48-bit RGB)"
Just run this command in the macro window:
run(“HeLa Cells (1.3M, 48-bit RGB)”);

My images look exactly like the above sample with a z-stack for each channel.


I forgot to mention in my question – with each nuclei (DAPI channel), I would like to save information from the other channels also.


So here is just a quick example of what can be done. I used the Trainable Weka segmentation on the example image you mentioned and trained the plugin to differentiate structures based on four different features in the image… Here is what you get after the segmentation.

The original image with information from four different channels:


These are the filters i used

The training classifications i used:

Any finally the segmented images (‘Get probability’ function in the plugin ) for the four trained classes

  1. Red (nuclei). Here the segmentation is not perfect but you can improve it by choosing other filters and by increaseing the number of selections you give the plugin during the training step.
    2.Green (background)

    3.Violet (the worm like structures)
  2. Yellow (the bright round spots)

You can then use this plugin and train it on a stack of images to get similar results. You may then threshold the segmented images and use the ‘Analyse particle’ function in Fiji to measure the parameters you are interested in.

Sorry about posting a ton of images. Is this what you are looking for?


PS: I just noticed that by choosing the Gaussian blur,Hessian, Structure and Neighbors filters improves the segmentation.


@Praveen I think this is awesome. So awesome that I am tempted to link to this thread from the main Trainable Weka Segmentation page. @iarganda What do you think? We could make a template on the wiki for referencing good forum threads from wiki pages.


@Praveen, Thanks for that trick! I will give it a try.

1 Like

A post was split to a new topic: Linking to the forum from the wiki

@dpimagej If i understand the question correctly, you want multi-channel images of individual nuclei.

The simplest may be as follows,

  • Create a Maximum Z projection
  • Threshold the nuclei in this 2D image
  • use analyse particles to identify and add the individual nuclei to the ROI manager
  • switch back to the 3D data
  • use these ROI’s to crop/duplicate each individual nucleus and associated channels.

Basic script you could adapt for your specific set of images.

#@ File (label = "Input directory", style = "directory") input
#@ File (label = "Output directory", style = "directory") output
#@ String (label = "File suffix", value = ".tif") suffix


// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
	list = getFileList(input);
	list = Array.sort(list);
	for (i = 0; i < list.length; i++) {
		if(File.isDirectory(input + File.separator + list[i]))
			processFolder(input + File.separator + list[i]);
		if(endsWith(list[i], suffix))
			processFile(input, output, list[i]);

function processFile(input, output, file) {
	print("Processing: " + input + File.separator + file);
	open(input + File.separator + file);
	name = File.nameWithoutExtension;
	//create projection of stack & generate Nuceli ROI's
	run("Z Project...", "projection=[Max Intensity]");
	run("Split Channels");
	selectWindow("C1-MAX_"+name); //C3 denotes the channel number that shows the Nuclei
	setAutoThreshold("Otsu dark");
	run("Analyze Particles...", "size=5-Infinity exclude add");

	//Loop through ROI's and save
	for (i = 0; i < roiManager("count"); i++) {
		roiManager("Select", 0);
		run("Duplicate...", "duplicate");
		print("Saving nuclei: " + (i+1) +" of "+ (roiManager("count")+1));
		saveAs("tiff", output + File.separator + name + "_"+ i);
	run("Close All");