Subtraction of images in two folders

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

Subtraction of images in two folders

Ramon Silva
Hi, i'm trying to do a subtraction of binary images, but what i receive as
result of subtraction is a white image. If you could help me with this
problem i'll appreciate it, because i don't know what is going wrong in my
code (ps.: i'm a beginner).
Since now, thank you!

Here's my actual code:

requires("1.38o");
    showMessage("Folder 1")
    dir1 = getDirectory("Choose a Directory ");
    showMessage("Folder 2:")
    dir2 = getDirectory("Choose a Directory ");
    listOD = getFileList(dir1);
    listOC = getFileList(dir2);
    newDir = "NeuroretinalRim";
    File.makeDirectory(newDir);
    setBatchMode(true);
    for (i=0; i<listOD.length; i++) {
        showProgress(i, listOD.length);
        open(dir1+listOD[i]);
        open(dir2+listOC[i]);
        imageCalculator("Subtract", listOD[i], listOC[i]);
        save(getDirectory("imagej")+"//"+newDir+"//"+(i+1)+".tif");
    }

--

*Ramon Costa Silva*

*Graduando em Ciência da Computação.*

*Voluntário: Laboratório Aprendizagem Computacional e Métodos de Otimização
e Robótica - LACMOR.*

*Estagiário: Núcleo de Tecnologia da Informação - NTI.*
*Universidade Federal do Maranhão - UFMA.*

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

Re: Subtraction of images in two folders

Herbie
Ramon,

in the loop you may try:

open(dir1+listOD[i]);
img1 = getImageID();
open(dir2+listOC[i]);
img2 = getImageID();
imageCalculator("Subtract", img1, img2);
selectImage(img1);
save(getDirectory("imagej")+"/"+newDir+"/"+(i+1)+".tif");
close();
close();

... and perhaps you should use
    setBatchMode(false);
at the end of your macro.

... and as far as I know
    showProgress();
doesn't work this way. Read the manual!

HTH

Herbie

:::::::::::::::::::::::::::::::::::::::::
Am 02.03.16 um 21:36 schrieb Ramon Silva:

> Hi, i'm trying to do a subtraction of binary images, but what i receive as
> result of subtraction is a white image. If you could help me with this
> problem i'll appreciate it, because i don't know what is going wrong in my
> code (ps.: i'm a beginner).
> Since now, thank you!
>
> Here's my actual code:
>
> requires("1.38o");
>      showMessage("Folder 1")
>      dir1 = getDirectory("Choose a Directory ");
>      showMessage("Folder 2:")
>      dir2 = getDirectory("Choose a Directory ");
>      listOD = getFileList(dir1);
>      listOC = getFileList(dir2);
>      newDir = "NeuroretinalRim";
>      File.makeDirectory(newDir);
>      setBatchMode(true);
>      for (i=0; i<listOD.length; i++) {
>          showProgress(i, listOD.length);
>          open(dir1+listOD[i]);
>          open(dir2+listOC[i]);
>          imageCalculator("Subtract", listOD[i], listOC[i]);
>          save(getDirectory("imagej")+"//"+newDir+"//"+(i+1)+".tif");
>      }
>

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

Re: Subtraction of images in two folders

Jan Eglinger
Hi Herbie,

On 02.03.2016 23:15, Herbie wrote:
> ... and as far as I know
>     showProgress();
> doesn't work this way. Read the manual!

yes, it does! See:

https://github.com/imagej/imagej1/blob/master/ij/macro/Functions.java#L2525-L2530

Here's an example:

     for (i=0; i<1000; i++) {
        wait(10);
        showProgress(i, 1000);
     }


While I generally second the advice to read the manual, it seems like in
this case the documentation at
http://imagej.net/developer/macro/functions.html#showProgress is incomplete.

Cheers,
Jan



> Am 02.03.16 um 21:36 schrieb Ramon Silva:
>> Hi, i'm trying to do a subtraction of binary images, but what i
>> receive as
>> result of subtraction is a white image. If you could help me with this
>> problem i'll appreciate it, because i don't know what is going wrong
>> in my
>> code (ps.: i'm a beginner).
>> Since now, thank you!
>>
>> Here's my actual code:
>>
>> requires("1.38o");
>>      showMessage("Folder 1")
>>      dir1 = getDirectory("Choose a Directory ");
>>      showMessage("Folder 2:")
>>      dir2 = getDirectory("Choose a Directory ");
>>      listOD = getFileList(dir1);
>>      listOC = getFileList(dir2);
>>      newDir = "NeuroretinalRim";
>>      File.makeDirectory(newDir);
>>      setBatchMode(true);
>>      for (i=0; i<listOD.length; i++) {
>>          showProgress(i, listOD.length);
>>          open(dir1+listOD[i]);
>>          open(dir2+listOC[i]);
>>          imageCalculator("Subtract", listOD[i], listOC[i]);
>>          save(getDirectory("imagej")+"//"+newDir+"//"+(i+1)+".tif");
>>      }
>>

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