Object to background ratio

I have a number of cells transfected and labelled under different conditions, unfortunately on many the background from the staining is quite high.
In order to compare the fluorescence intensity, I want to take the ratio of the object (cell) integrated density to that of the background (or other way round).
I Plan to do this by

  1. segmenting the image
  2. measure integrated density of the cell
  3. inverse the selection by (Edit -> Selection -> Create selection and then Make Inverse)
  4. measure integrated density of the background
  5. ratio the values from 2 and 4 for each cell to see the background-corrected labelling for each condition

And because I am learning programming now, I want to make a macro for this to (in batch mode as well). I couldn’t find anything exactly like this so my questions to the more experienced image analysts here are:

  1. Has anyone encountered a macro doing exactly this (in which case I won’t waste my time and just study the macro instead)?
  2. Does it make sense what I want to do or am I over-complicating it and there is a simpler already established way to do the same thing?

Thanks! :slight_smile:


this sounds good. Normalization is always important.

Just make sure that you differentiate between background (offset from the camera) and the fluorescent background. The Offset you can and should globally subtract from the image. The (variable?) fluorescent background you can use for your normalization.

For the batch processing just use the template that ImageJ provides:

 * Macro template to process multiple images in a folder

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

// See also Process_Folder.py for a version of this code
// in the Python scripting language.


// 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) {
	// Do the processing here by adding your own code.
	// Leave the print statements until things work, then remove them.
	print("Processing: " + input + File.separator + file);
	print("Saving to: " + output);