Login  Register

Re: particle size by using intersect line?

Posted by Stein Rørvik on Mar 03, 2019; 9:34pm
URL: http://imagej.273.s1.nabble.com/particle-size-by-using-intersect-line-tp5021832p5021878.html

I don't know of any existing functions that will do what you want.
But if you choose a manual pixel-scan based approach it is not too difficult.
Try the below macro.

You can re-run the macro on the segmented image to get a new analysis if you need to adjust some options. I wrote this in vanilla ImageJ 1.52m, with a manual install of "Statistical Region Merging", as discussed in a previous post.

I think the analysis here would give more or less statistically valid results if you do this in both X and Y directions. The example below is only for X direction. Since the "particles" are merged into a mesh, the line intercept method should provide an estimate of the mesh "width". There might be other approaches that are better; for example making an EDM, and then masking it with the skeleton of the mesh. The greylevel histogram will then provide a distribution of the shortest mesh-width at all points.

if (bitDepth == 8) {
        //is original image, do segmentation
        run("Statistical Region Merging", "q=5 showaverages");
        setThreshold(115.0000, 1e30);
}

if (bitDepth == 32) {
        //is segmented image, do analysis
        run("Clear Results");
        getThreshold(lowerThreshold, upperThreshold);
        numLinesPerHeight = 20;
        lineStep = round(getHeight/numLinesPerHeight);
        lastTransition = 0;
        start = 0;
        stop = 0;
        counter = 0;
        setColor("yellow");
        setLineWidth(1);
        Overlay.remove();
        for (y=0; y < getHeight; y+= lineStep) {
                withinParticle = false;
                withinThreshold = false;
                for (x=0; x < getWidth; x++) {
                        v = getPixel(x,y);
                        withinThreshold = (v >= lowerThreshold);
                        if (!withinParticle && withinThreshold) {
                                //we just entered a particle
                                start = x;
                                withinParticle = true;
                        }
                        if (withinParticle && !withinThreshold || (x==getWidth-1)) {
                                //we just left a particle, or reached the right edge of the image
                                stop = x-1;
                                withinParticle = false;
                                Overlay.drawLine(start, y, stop, y);
                                setResult("X", counter, x);
                                setResult("Y", counter, y);
                                setResult("Length", counter, (stop-start));
                                counter ++;
                        }
                }
        }
        Overlay.show();
}

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of Steven Liu
Sent: 24. februar 2019 15:04
To: [hidden email]
Subject: particle size by using intersect line?

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

intersect line.tif (SRM Q=5-1.0).png (10K) Download Attachment