Macro help for selecting original picture

Hi all,

I’m trying to write a macro for subtracting one image from another. So far my macro is as shown:

title = getTitle();
setPasteMode("Subtract");
if (indexOf(title, "B1-1") >= 0) {
    selectWindow("34 VG2 BG 1-1.tif")
    run("Select All");
    run("Copy");
    ?????????
    run("Paste");
    run("Close");
}

I was wondering if there is a command that I can replace the ??? with that will select the original image. I know this is a very crude way of image analysis, but I need just need something I can use in the short term.

Thanks in advance.

I ended up using

selectWindow(title)

2 Likes

When working with many images, there is a small chance to have duplicate image titles. To be on the safe side, you can use:

id = getImageID();
// ...
selectImage(id);

You should also consider using the Image Calculator:

imageCalculator("Subtract create", title,"34 VG2 BG 1-1.tif");
1 Like