Applying multiple Thresholds to a stack / Creating mask for each slice in stack

Hello!

I’m hoping I can get a little direction in the best way / most practical way to do this; I am trying to apply both Otsu’s and then Yen thresholding to an image stack.

But applying a threshold to the stack converts it to Black White so after that no more can be applied.

I also realised that I cannot apply these as a mask as the mask tool is done using single slice at a time.

Other than looping through each slice at a time and applying this. I am wondering is this the smartest way to do this, or is there an obvious solution I’m missing.

If anyone is wondering, I need Otsu to remove background noise from some 3D scanned oats, and then Yen allows me to filter out the shells and to see the seeds inside. Using only one creates problems that distort the image. For me.

Hi @SirSharpest,

Not sure if that will answer the two parts of your question completely but as I understand the issue the following procedure could be a solution:

  1. You apply the Otsu threshold on your stack
  2. On a second copy of the original stack you apply the Yen threshold
  3. You run >Process >Image Calculator, select the two binary stacks and combine them with the boolean operator AND.
    This will give you only the regions which are positive in both extractions.

It would be different if you need to apply the thresholds sequentially and first need to mask the original image with the Otsu thresholded stack before applying the Yen (because then the second threshold calculation will be different). This would work for example with the following small macro snippet.

original = getTitle();
run("Duplicate...", "title=["+original+"_dup] duplicate");
duplicate = getTitle();

run("Auto Threshold", "method=Otsu white stack");
run("32-bit");
run("Enhance Contrast...", "saturated=0 normalize process_all");
run("8-bit");
run("Auto Threshold", "method=Yen white stack");

The 32-bit conversion in combination with the contrast adjustment (which will not do anything to the image) allows the masking because everything which is extracted receives the value 1 and the rest is 0.