Crop out background with similar composition workflow

Hello all!

I’m curious to do some analyses on cross sections of fly brain in the future, and I’m looking to do an analysis of brain tissue like the one used in this paper: Cao et al. (2013) doi: 10.1073/pnas.1306220110

Essentially, these are microscopy images where the central image is brain tissue, but there is other tissue present in the background that stains just the same. I was hoping to find a good workflow that isolates the central tissue (the brain) from other tissues in the image.

  1. Collect image
  2. Isolate brain tissue
  3. Use threshold to quantify surface area covered by white spots
  • White/(Grey-Black) ideally inside brain tissue only (not including background)

I see Process > Find Edges and Process > Subtract Background, but can’t quite do what I want with them. Using the Freehand Selection tool alongside Crop also doesn’t remove the background because it just crops to the length by width, which retains the background tissue. Any suggestions for some sort of lasso crop that can ideally be included in an automated workflow? Using powerpoint’s Remove Background feature, I can actually isolate the brain tissue, but obviously suffer image quality in conversion etc…

Ideally I’d take this image:

and convert it to something like this:

And from there I’d just set an intensity threshold to see how spotty the brain (surface area covered in white) is compared to normal brains like this one:

Hi Crawdaunt,

It looks like you need to research some segmentation literature, maybe start here. Other users will chip in though, I’m sure.

I would suggest setting a threshold (Image -> Adjust -> Threshold…) and making the image binary to isolate the central brain slice as much as possible (without taking away the outer edge). Then somehow using watershed segmentation to isolate the central brain slice. Use Analyze particles (Analyze -> Analyze Particles…) after that to get a selection of the entire brain slice (use include holes option) to use as a mask on your original image.

As an aside, (Edit -> Clear Outside) works to clear the entire outside of a selection, so with the freehand tool you can draw around the brain slice and remove the outside (to make it the selected background colour, i.e. black).

Make sure your brain slices were acquired with the same settings (light intensity, exposure time) to accurately compare the images with the same threshold.



1 Like

Good day!

The dark frame of your initial sample image is disturbing, i.e. it makes automatic object-related cropping difficult.

Where does this frame come from (data from the literature?) ?



Yes, from the literature. I could crop it such that there’s no black box around square. Here’s the original image:
26 PM

They’ve got a ranking system where they just qualitatively judge how bad a brain’s spottiness is by counting total number and size of lesions, and then rank the brain from 0-5. But I figure this should be relatively quantifiable using something like a threshold approach for white in the tissue.

Thanks for the help! I’m very new to ImageJ, so it’s much appreciated. Segmentation definitely looks like something I’ll want to employ. Will be reading up :slight_smile:

1 Like

Well here we go with your initial sample image after the frame has been removed:

If this TIFF-image (and only this one) is open in ImageJ and one applies the following macro, then one should get this result image:


run("Duplicate...", "title=binary.tif");
run("Subtract Background...", "rolling=50 light sliding disable");
setThreshold(168, 255);
setOption("BlackBackground", true);
run("Convert to Mask");
doWand( 40, 20 );
run("Restore Selection");
setBackgroundColor(0, 0, 0);
run("Clear Outside");
run("Select None");

Paste the code to an empty macro window (Plugins >> New >> Macro) and run it.

The problem is to find the best values for the threshold. “Shanbhag” is close to what is needed for this image …

Just a hint for getting started