ImageJ X-Y image subtraction

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ImageJ X-Y image subtraction

Protra
Hello,

After looking to many plugins, I had to resign myself to ask here if any body knows about.

I want to use ImageJ for the subtraction between two 32bit calibrated images (they hold STM information).
But the point is that I should be able to move right/left/up/down one of the images in order to align them by hand (the automatic procedures fail because I do not want to align all the objects).

The images have the same size (512x512 pixels) but naturally the result image would be smaller due to the x/y displacement of one of the images during the alignment.

Is there some easy way to do it? Perhaps I should write the plugin, but I have no idea how it does work for ImageJ ...

Any input would help!

Thanks,

Protra
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ X-Y image subtraction

Paulo Acioly
Easy, Easy Protra,

In the ImageJ  column PROCESS, dowon you will find IMAGE  CALCULATOR … option.

go and put your images and seletct SUBTRACTION..

I hope that it will help you..

God Work !!!!!

Paulo Acioly

Prof.Dr. Paulo Acioly Marques dos Santos
Universidade Federal Fluminense
Laboratório de Óptica Não Linear & Aplicada
Departamento de Física,Instituto de Física


> On 22/02/2016, at 09:30, Protra <[hidden email]> wrote:
>
> Hello,
>
> After looking to many plugins, I had to resign myself to ask here if any
> body knows about.
>
> I want to use ImageJ for the subtraction between two 32bit calibrated images
> (they hold STM information).
> But the point is that I should be able to move right/left/up/down one of the
> images in order to align them by hand (the automatic procedures fail because
> I do not want to align all the objects).
>
> The images have the same size (512x512 pixels) but naturally the result
> image would be smaller due to the x/y displacement of one of the images
> during the alignment.
>
> Is there some easy way to do it? Perhaps I should write the plugin, but I
> have no idea how it does work for ImageJ ...
>
> Any input would help!
>
> Thanks,
>
> Protra
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/ImageJ-X-Y-image-subtraction-tp5015686.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ X-Y image subtraction

Peter Haub
In reply to this post by Protra
Check section 'Aligning' in ImageJ Wiki

http://imagejdocu.tudor.lu/doku.php?id=plugin:aligning:align_slice:start

Regards,
Peter

On 22.02.2016 13:30, Protra wrote:

> Hello,
>
> After looking to many plugins, I had to resign myself to ask here if any
> body knows about.
>
> I want to use ImageJ for the subtraction between two 32bit calibrated images
> (they hold STM information).
> But the point is that I should be able to move right/left/up/down one of the
> images in order to align them by hand (the automatic procedures fail because
> I do not want to align all the objects).
>
> The images have the same size (512x512 pixels) but naturally the result
> image would be smaller due to the x/y displacement of one of the images
> during the alignment.
>
> Is there some easy way to do it? Perhaps I should write the plugin, but I
> have no idea how it does work for ImageJ ...
>
> Any input would help!
>
> Thanks,
>
> Protra
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/ImageJ-X-Y-image-subtraction-tp5015686.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ X-Y image subtraction

Protra
In reply to this post by Paulo Acioly
Hello,

@Paulo: Yes, I am aware of this tool, but I cannot x/y-displace one of the images before to do the subtraction.
@Peter: I found there the 4-align plugin, thanks!!

Then, I will try to combine the two answers, ie to integrate an image subtraction as I need into the 4-align plugin. I need just to create a new window displaying the result of the calculation after having displaced one image inside its frame (if it wasn't clear, images are 512x512 pixel and I need to move one image inside this frame of 512 pixels).

Let's see what will come out :-)

Many thanks for the inputs!


PS: Any one knows where is the .java file for the IMAGE CALCULATOR of ImageJ?


Protra
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ X-Y image subtraction

Michael Elbaum
In reply to this post by Protra
The TomoJ plugin (intended for election tomography) has a very nice tool for manual alignment.
Michael



> On 22 בפבר׳ 2016, at 05:10, Protra <[hidden email]> wrote:
>
> Hello,
>
> After looking to many plugins, I had to resign myself to ask here if any
> body knows about.
>
> I want to use ImageJ for the subtraction between two 32bit calibrated images
> (they hold STM information).
> But the point is that I should be able to move right/left/up/down one of the
> images in order to align them by hand (the automatic procedures fail because
> I do not want to align all the objects).
>
> The images have the same size (512x512 pixels) but naturally the result
> image would be smaller due to the x/y displacement of one of the images
> during the alignment.
>
> Is there some easy way to do it? Perhaps I should write the plugin, but I
> have no idea how it does work for ImageJ ...
>
> Any input would help!
>
> Thanks,
>
> Protra
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/ImageJ-X-Y-image-subtraction-tp5015686.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ X-Y image subtraction

Michael Schmid
In reply to this post by Protra
Hi Potra,

not exactly what you want, but something similar:

Here is a macro for aligning stack slices. On each slice, click on the same object; press the space bar when done. It creates a union, not intersection of the images, and even adds a few pixels ('extraspace') but this can be changed - modify the calculation containing 'extraspace' near the end accordingly; and put the 'Canvas Size' command below the loop, not above it.
For your application, you can easily add a few lines to split the stack when done and subtract the images.

Of course, a more elegant solution would be a plugin showing the difference of two images while moving one of them manually (I'd love to have one), but that would be a bit more work.

Michael
________________________________________________________________


macro 'Manual Stack Register [F7]' {
  extraspace = 5; //padding at all sides by this value

  requires("1.42j");
  n=nSlices();
  if (n<2) exit ("stack required");
  xs=newArray(nSlices);
  ys=newArray(nSlices);
  for (i=0; i<n; i++)
    xs[i] = -1; //initialize positions as unset

  nClicked = 0;
  i=getSliceNumber()-1;
  flags=0;
  lasti = -1;
  posS = "";
  while (!isKeyDown("space")) {
    getCursorLoc(x, y, z, flags);
    if (flags&leftClick !=0) {
      makePoint(x,y);
      xs[i] = x;
      ys[i] = y;
      nClicked++;
      lasti = i;
      do {
        wait(50);
        getCursorLoc(x, y, z, flags);
      } while (flags&leftClick !=0);
    }
    if (i != z) {     //slice changed
      i = z;
      if (xs[i]>=0) {
        makePoint(xs[i],ys[i]);
        lasti = i;
      }
      while (isKeyDown("alt")) wait(50);
    }
    wait(20);
    if (lasti>=0) posS = "pos. from "+(lasti+1);
    showStatus("','=prev, '.'=next, space=done, esc=abort. "+posS);
  }
  if (nClicked<2) exit("Abort - at least two positions required");
  lasti = -1;
  for (i=0; i<n; i++) {
    if (xs[i]>=0) {
      if (lasti<0) {
        lastx=xs[i];
        lasty=ys[i];
      }
      for (j=lasti+1; j<i; j++) {  //interpolate
        xs[j] = lastx + (xs[i]-lastx)*(j-lasti)/(i-lasti);
        ys[j] = lasty + (ys[i]-lasty)*(j-lasti)/(i-lasti);
      }
      lastx=xs[i];
      lasty=ys[i];
      lasti=i;
    }
  }
  if (lasti<n-1) {
    for (j=lasti+1; j<n; j++) {
      xs[j] = lastx;
      ys[j] = lasty;
    }
  }
  Array.getStatistics(xs, xmin, xmax, mean, stdDev);
  Array.getStatistics(ys, ymin, ymax, mean, stdDev);
  newwidth = getWidth()+(xmax-xmin)+2*extraspace;
  newheight = getHeight() +(ymax-ymin)+2*extraspace;
  run("Canvas Size...", "width="+ newwidth +" height="+ newheight +" position=Top-Left zero");
  for (i=0; i<n; i++) {
    setSlice(i+1);
    run("Translate...", "x="+(xmax-xs[i]+extraspace)+" y="+(ymax-ys[i]+extraspace)+" slice");
  }
  showStatus("stack registered");

}

________________________________________________________________
On Feb 22, 2016, at 13:30, Protra wrote:

> Hello,
>
> After looking to many plugins, I had to resign myself to ask here if any
> body knows about.
>
> I want to use ImageJ for the subtraction between two 32bit calibrated images
> (they hold STM information).
> But the point is that I should be able to move right/left/up/down one of the
> images in order to align them by hand (the automatic procedures fail because
> I do not want to align all the objects).
>
> The images have the same size (512x512 pixels) but naturally the result
> image would be smaller due to the x/y displacement of one of the images
> during the alignment.
>
> Is there some easy way to do it? Perhaps I should write the plugin, but I
> have no idea how it does work for ImageJ ...
>
> Any input would help!
>
> Thanks,
>
> Protra
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/ImageJ-X-Y-image-subtraction-tp5015686.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ X-Y image subtraction

John Hayes
In reply to this post by Protra
Hi Protra,

For your last question I believe it is in ij.plugin.ImageCalculator.

Best,

John
On Feb 22, 2016 9:27 AM, "Protra" <[hidden email]> wrote:

> Hello,
>
> @Paulo: Yes, I am aware of this tool, but I cannot x/y-displace one of the
> images before to do the subtraction.
> @Peter: I found there the 4-align plugin, thanks!!
>
> Then, I will try to combine the two answers, ie to integrate an image
> subtraction as I need into the 4-align plugin. I need just to create a new
> window displaying the result of the calculation after having displaced one
> image inside its frame (if it wasn't clear, images are 512x512 pixel and I
> need to move one image inside this frame of 512 pixels).
>
> Let's see what will come out :-)
>
> Many thanks for the inputs!
>
>
> PS: Any one knows where is the .java file for the IMAGE CALCULATOR of
> ImageJ?
>
>
> Protra
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/ImageJ-X-Y-image-subtraction-tp5015686p5015689.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ X-Y image subtraction

Protra
In reply to this post by Protra
Ok, I will try to integrate all helps.
Thanks Michel for the macro, I will try to modify it accordingly :-)

And Whao, first post and already well helped. I am so happy!!!!

Thank you all, I will repost when I would have something working.

Protra