Multiple Image Analysis For Colour Thresholding

bonej
color-analysis
thresholding
macro
Tags: #<Tag:0x00007fd547b964b8> #<Tag:0x00007fd547b95db0> #<Tag:0x00007fd547b957c0> #<Tag:0x00007fd547b94eb0>

#1

Hi there,

I just started working on a macro for colour thresholding and quantification. I’m quantifying using BoneJ. i did the macro using the recording feature, and it works fine when used manually for single pictures, but I would like it to analyze several pictures automatically. Not sure where to go now.

So far the macro looks like this:

run("Threshold Colour");
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
run("HSB Stack");
run("Convert Stack to Images");
selectWindow("Hue");
rename("0");
selectWindow("Saturation");
rename("1");
selectWindow("Brightness");
rename("2");
min[0]=116;
max[0]=186;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=255;
filter[2]="pass";
for (i=0;i<3;i++){
  selectWindow(""+i);
  setThreshold(min[i], max[i]);
  run("Convert to Mask");
  if (filter[i]=="stop")  run("Invert");
}
imageCalculator("AND create", "0","1");
imageCalculator("AND create", "Result of 0","2");
for (i=0;i<3;i++){
  selectWindow(""+i);
  close();
}
selectWindow("Result of 0");
close();
selectWindow("Result of Result of 0");
rename(a);
run("Invert");
run("Volume Fraction", "algorithm=Voxel surface=6 use");

I’m just starting so any kind of advice would be helpful

Thanks,

Joao


Number of particles in clusters follow-up
#2

You can use batch processing for this, see:


#3

In this case a macro will be slow and can lead to some issues, it is preferable to make a plugin that does this the same way and you will have more control on the intermediate images. If you know java, python and ruby languages are already supported and are by far more robust than macros. Use macros for very simple repetitive tasks.


#4

@Joao_Garcia: Did you write a plugin for this? I tried to run colour thresholding in batch mode and run out of memory after 2-3 big images. I am looking for a solution for this and never wrote a plugin before