Re: How to cut an image into image parts ?
Posted by
edsimmons on
Sep 26, 2011; 2:46pm
URL: http://imagej.273.s1.nabble.com/How-to-cut-an-image-into-image-parts-tp3682979p3682980.html
rajava wrote
I am trying to write a macro to cut a simple line drawing image into image parts. I am trying to use the wand tool and cut but it doesn't seem to work. The is the sample image
Here is the code i was trying ,
open("
http://www.coloringparty.eu/images/zoom/toddlers/viewsize/Rocket-toddlers.gif")
doWand(177, 478);
run("Cut");
doWand(338,321);
run("Cut");
Also, Is there a way to find a point(x,y) to doWand so that it comprises of a part and find as much part as possible programmatically ? Any help is this matter is greatly appreciated, Thanks.

Cut image should something like this , but this was cut using wand manually,

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