Login  Register

Re: How to cut an image into image parts ?

Posted by edsimmons on Sep 26, 2011; 3:18pm
URL: http://imagej.273.s1.nabble.com/How-to-cut-an-image-into-image-parts-tp3682979p3682981.html

<quote author="edsimmons">
Hi,

You could start by trying something like Find Maxima.
Using the image you linked to, I got good results with:

run("Find Maxima...", "noise=60 output=[Point Selection] exclude");
roiManager("Add");
run("Set Measurements...", "  centroid display redirect=None decimal=3");

r=nResults();
//Label=newArray(r);
X=newArray(r);
Y=newArray(r);
d=newArray(r);
for(i=0;i<r;i++) {
        selectWindow("Rocket-toddlers.gif");
        X[i]=getResult("X",i);
        Y[i]=getResult("Y",i);
        doWand(X[i],Y[i]);
        run("Cut");
            newImage(i, "8-bit White", 400, 400, 1);
        run("Paste");
}

Hows that for starters?

Best,
Ed
</quote>

Really sorry, missed a bit in the macro... here it is again, this time actually working properly.

run("Find Maxima...", "noise=60 output=[Point Selection] exclude");
roiManager("Add");
run("Set Measurements...", "  centroid display redirect=None decimal=3");
run("Measure");
r=nResults();
X=newArray(r);
Y=newArray(r);
d=newArray(r);
for(i=0;i<r;i++) {
        selectWindow("Rocket-toddlers.gif");
        X[i]=getResult("X",i);
        Y[i]=getResult("Y",i);
        doWand(X[i],Y[i]);
        run("Cut");
        newImage(i, "8-bit White", 400, 400, 1);
        run("Paste");
}

Hope that helps,
Ed