Login  Register

Re: particle size by using intersect line?

Posted by Herbie on Mar 02, 2019; 2:47pm
URL: http://imagej.273.s1.nabble.com/particle-size-by-using-intersect-line-tp5021832p5021868.html

Good day!

Neither from here, nor from the IJ-forum you've received satisfying
solutions and I guess this is due to the fact that your seemingly simple
problem in fact is rather complicated.

I've spent several hours but wasn't successful either.

Here are some hints:

1. "intersect line method" (successive image profiles)
I doubt what you've written elsewhere, namely that one can distinguish
signal and background by *simply* analyzing profiles. The reason is that
the fluctuations are too large.

2. For the provided sample image I was able to compute a reasonable
binary contour image (see attachment). Here is the ImageJ-macro code:

// imagej-macro "meanderContours" (Herbie G., 26. Feb. 2019)
requires( "1.52k" );
setBackgroundColor(0, 0, 0);
setOption("BlackBackground", true);
img=getTitle();
setBatchMode(true);
run("Duplicate...", "title=copy");
run("Median...", "radius=2");
run("Bandpass Filter...", "filter_large=3 filter_small=0 suppress=None
tolerance=5");
setAutoThreshold("RenyiEntropy dark");
run("Convert to Mask");
run("Analyze Particles...", "size=0-50 pixel add");
n=roiManager("count");
a=Array.getSequence(n) ;
roiManager("select", a );
roiManager("combine");
roiManager("add");
roiManager("Delete");
roiManager("Select", 0);
run("Clear", "slice");
close("ROI Manager");
run("Remove Overlay");
run("Select None");
run("Close-");
run("Skeletonize");
setBatchMode(false);
makeRectangle(3,3,668,376);
run("Crop");
run("Select None");
exit();
// imagej-macro "meanderContours" (Herbie G., 26. Feb. 2019)

I have no idea how this approach generalized to other images of this kind!

3. To find the area of the signal or of the background from the binary
contour image turned out being really complicated and I haven't found a
convincing approach yet. Here is an ImageJ-macro code that may give you
an idea of how to start but it doesn't do the complete job (see attached
result image):

// imagej-macro "fillMeander" (Herbie G., 27. Feb. 2019)
requires( "1.52k" );
setForegroundColor(255, 255, 255);
makeRectangle(0,0,668,1);
analyzeProfile();
exit();
function analyzeProfile() {
    p=getProfile();
    p=Array.concat(Array.concat(0,p), 0);
    n=p.length;
    a=newArray(n*0.5);
    idx=1;
    for ( i=0; i<n; i++ ) {
       if (p[i]>0) {
          if (p[i-1]<255 || p[i+1]<255) {a[idx]=i-1; idx++;} else
setPixel(i-1, 0, 0); // care fore line breaks (single code line here)
       }
    }
    a=Array.trim(a, idx+1);
    a[idx]=getWidth()-1;
    a[0]=0;
    floodFill(0.5*a[0], 0);
    odd=false;
    for ( i=0; i<idx; i++ ) {
          x=0.5*(a[i]+a[i+1]);
          val=getPixel(x, 0);
          if (odd) {
             if (val<255) {floodFill(x, 0); }
             odd=false;
          } else {
             if (val<255) odd=true;
          }
    }
}
// imagej-macro "fillMeander" (Herbie G., 27. Feb. 2019)

Good luck

Herbie

::::::::::::::::::::::::::::::::::::::::
Am 24.02.19 um 15:03 schrieb Steven Liu:

> Dear all,
> There are several ways to get the particle size. But I want to try "intersect line method". I know how to get the "Plot Profile". However, I do not know how to get the particle size automatically. Imaging I have many images, it will be convenient to apply Macros.
> Is there available Macros for use? I failed to find one.
> Could anyone help me?
> I attached one example image.
> Thanks!
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

copy.png (9K) Download Attachment
result.png (7K) Download Attachment