Try the following ImageJ-macro (there may be more elegant solutions):
//-- begin imagej-macro --
requires("1.53g")
run("Set Measurements...", "fit redirect=None decimal=2");
Table.reset("Results");
setBatchMode(true);
run("Duplicate...", " ");
run("Canvas Size...", "width="+(getWidth-50)+" height="+(getHeight-50)+" position=Center");
run("Split Channels"); close(); close();
run("Bandpass Filter...", "filter_large=200 filter_small=0 suppress=None tolerance=0");
setAutoThreshold("Default");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Select All");
setKeyDown("alt");
yP = getProfile();
setKeyDown("none");
yP_len = mtrxStrctr(yP, true);
yP=Array.trim(yP,yP_len);
xP = getProfile();
xP_len = mtrxStrctr(xP, false);
xP=Array.trim(xP,xP_len);
dC = floor(255/((xP_len-1)*(yP_len-1)));
for ( j=0; j<yP_len-1; j++ ) {
for ( i=0; i<xP_len-1; i++ ) {
k = (xP_len-1)*j+i;
makeRectangle(xP[i], yP[j], xP[i+1]-xP[i], yP[j+1]-yP[j]);
run("Analyze Particles...", "size=5000-Infinity show=Nothing display exclude add");
roiManager("Select", k);
roiManager("Rename", k+1);
c = (k+1)*dC;
setForegroundColor(c, c, c);
roiManager("Fill");
}
}
roiManager("Show All");
run("Glasbey");
close("ROI Manager");
run("Labels...", "color=black font=14 show use draw bold");
d = Table.getColumn("Major");
mi = Table.getColumn("Minor");
for ( i=0; i<d.length; i++ ) d[i] = ( d[i] + mi[i] ) * 0.5;
Table.renameColumn("Angle", "Mean Diameter");
Table.setColumn("Mean Diameter", d);
setBatchMode(false );
exit();
function mtrxStrctr( a, rws ) {
for ( i=0; i<a.length; i++ ) if (a[i]<10) a[i]=0;
j = 1;
for ( i=0; i<a.length-1; i++ ) {
if ( a[i]>0 && a[i+1]==0 ) { a[j] = i; j++; }
if ( a[i]==0 && a[i+1]>0 && j>0 ) { a[j-1]=(i+a[j-1] )*0.5; }
}
a[0]=0;
if (rws) a[j-1]=getHeight; else a[j-1]=getWidth;
return j;
}
//-- end imagej-macro --
The table lists the diameters for every row of specimes from left to right.
Be careful with the mean diameters of specimen that are truncated in the binarized image. Use the Major diameter for those!