Posted by
BenTupper on
URL: http://imagej.273.s1.nabble.com/Disjoint-ROI-selection-using-macro-language-tp3692854p3692860.html
On Apr 17, 2009, at 4:08 AM, Senger Fabrice wrote:
>>
> Hi there,
>
> i'm sorry to not have the answer to your problem but I take the
> opportunity to talk about a problem I have. I'm segmenting cells and
> add them to the manager what I would do next is extract each cell to
> generate a new image by using the corresponding ROI.
> Did someone allready tried such an approach ?
>
> Thanks,
>
> Fabrice.
>
>
Hi Fabrice,
If you want to transfer a region from one image to another then you
could do it with something like the following (note that ROI Manager
is not used).
//START MACRO
run("Blobs (25K)");
setAutoThreshold();
//run("Threshold...");
setThreshold(125, 255);
run("Convert to Mask");
maskID = getImageID();
run("Set Measurements...", "area mean standard modal min centroid
center perimeter bounding fit shape feret's integrated median skewness
kurtosis redirect=None decimal=3");
run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
show=Nothing display clear record ");
//first method creates a new image to accept the subimage
ix = 22;
bx = getResult("BX", ix);
by = getResult("BY", ix);
w = getResult("Width", ix);
h = getResult("Height", ix);
name = "#" + ix+1;
newImage(name, "8-bit White", w,h,1);
img23ID = getImageID();
selectImage(maskID);
makeRectangle(bx,by,w,h);
run("Copy");
selectImage(img23ID);
run("Paste");
run("Invert");
// the second method exploits the File > New > Internal Clipboard menu
item
ix = 30;
bx = getResult("BX", ix);
by = getResult("BY", ix);
w = getResult("Width", ix);
h = getResult("Height", ix);
selectImage(maskID);
makeRectangle(bx,by,w,h);
run("Copy");
name = "#" + ix+1;
run("Internal Clipboard");
rename(name);
//END MACRO
Ben Tupper