Re: Image subtraction then using the resulting image

Posted by Herbie on
URL: http://imagej.273.s1.nabble.com/Image-subtraction-then-using-the-resulting-image-tp5023935p5023948.html

In the sequel please find an ImageJ-macro that does what you've
described in your first post:

/* imagej-macro "subtractionScheme" (Herbie G., 15. Sept. 2020) */
requires("1.53d");
run("MRI Stack"); // load a demo stack
run("32-bit");
stack = getImageID();
n = nSlices + 1;

run("Make Substack...", "  slices=1");
s1 = getTitle();
selectImage(stack);
run("Make Substack...", "  slices=2");
run("Multiply...", "value=-1");
s2 = getTitle();
imageCalculator("add", s2, s1);
close(s1);
rename("img1");

for ( i=3; i<n; i++ ) {
    k = i - 1;
    j = i - 2;
    selectImage(stack);
    run("Make Substack...", "  slices="+i);
    run("Multiply...", "value=-1");
    s = getImageID();
    imageCalculator("add", s, "img"+j);
    rename("img"+k);
}
exit();
/* imagej-macro "subtractionScheme" (Herbie G., 15. Sept. 2020) */

Paste the above macro code to an empty macro window (Plugins >> New >>
Macro) and run it.
(You need an open internet connection to load the demo stack.)

The demo stack has 27 slices (frames) which means that you will get 26
result images.

HTH

Herbie

:::::::::::::::::::::::::::::::::
Am 15.09.20 um 17:45 schrieb h97:

> Dear all,
>
> Hope you are well.
>
> I am new to imagej and need some help with a task which is highly
> appreciated.
>
> Basically, I need to analyse thousands of images which would be excruciating
> to do manually. What my goal is for example i have 500 images(frames).
>
> 1. I want to subtract two consecutive images and get the resulting image.
> 2. Using the resulting image from step 1 i want to make that the reference
> for subtracting from frame #3. for example, frame#1-frame#2=img1. Then i
> want to do the same with img1-frame#3=img2 and so on for how many number of
> frames I have.
>
> Is there any plugin available or macro to do this to automate the process?
> if so, can you please tell me how to install or work with the plugin?
>
>
> Thanks.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html