background subtraction does not work

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

background subtraction does not work

juju
hello everyone...

I wrote a macro which processes a sequence of rawimages and backgroundimages. This Macro should subtract every backgroundimage from the corresponding rawimage. Unfortunately this does not work properly: All pixel of the resultimage have the value 0 which is not correct...
Here is the Code...

macro "Macro 2 [b]"  
{
dir1 = getDirectory("Choose a Directory ");
count = 0;
dir2 = getDirectory("Choose a Directory ");


list1 = getFileList(dir1);
list2 = getFileList(dir2);
    for (i=0; i<list.length; i++) {
        if (endsWith(list[i], "/"))
           listFiles(""+dir1+list1[i]);}
        //else
        //   print((count++) + ": " + dir1 + list1[i]);}

    for (i=0; i<fist.length; i++) {
        if (endsWith(fist[i], "/"))
           listFiles(""+dir2+list2[i]);}
        //else
        //   print((count++) + ": " + dir2 + list2[i]);}


sort1 = Array.sort(list1)
sort2 = Array.sort(list2)

    for (i=0;i<1;i++){
        imag1 = dir1 + sort1[i];
        imag2 = dir2 + sort2[i];
        run("Raw...", "open=imag1 image=[16-bit Unsigned] width=512 height=512 offset=68 number=40 gap=0 little-endian");
        a = getImageID();
        run("Raw...", "open=imag2 image=[16-bit Unsigned] width=512 height=512 offset=68 number=1 gap=0 little-endian");
        b = getImageID();
        run("Image Calculator...","selectImage(a) operation=Subtract create selectImage(b)");}

Can someone help me fix this problem??

Thank you

regards
Juju  
Reply | Threaded
Open this post in threaded view
|

Re: background subtraction does not work

Arne Seitz
Hi JuJu,

if you replace the last line in you macro with the following code: imageCalculator("Subtract create", a,b);
it should work.

Cheers Arne


---------------------------------------------------------------
Arne Seitz
Head of Bioimaging and Optics Platform (PT-BIOP)
Ecole Polytechnique Fédérale de Lausanne (EPFL)
Faculty of Life Sciences
Station 15, AI 0241
CH-1015 Lausanne

Phone: +41 21 693 9618
Fax:      +41 21 693 9585
http://biop.epfl.ch/
---------------------------------------------------------------



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of juju
Sent: jeudi 4 novembre 2010 15:28
To: [hidden email]
Subject: background subtraction does not work

hello everyone...

I wrote a macro which processes a sequence of rawimages and
backgroundimages. This Macro should subtract every backgroundimage from the
corresponding rawimage. Unfortunately this does not work properly: All pixel
of the resultimage have the value 0 which is not correct...
Here is the Code...

macro "Macro 2 [b]"  
{
dir1 = getDirectory("Choose a Directory ");
count = 0;
dir2 = getDirectory("Choose a Directory ");


list1 = getFileList(dir1);
list2 = getFileList(dir2);
    for (i=0; i<list.length; i++) {
        if (endsWith(list[i], "/"))
           listFiles(""+dir1+list1[i]);}
        //else
        //   print((count++) + ": " + dir1 + list1[i]);}

    for (i=0; i<fist.length; i++) {
        if (endsWith(fist[i], "/"))
           listFiles(""+dir2+list2[i]);}
        //else
        //   print((count++) + ": " + dir2 + list2[i]);}


sort1 = Array.sort(list1)
sort2 = Array.sort(list2)

    for (i=0;i<1;i++){
        imag1 = dir1 + sort1[i];
        imag2 = dir2 + sort2[i];
        run("Raw...", "open=imag1 image=[16-bit Unsigned] width=512
height=512 offset=68 number=40 gap=0 little-endian");
        a = getImageID();
        run("Raw...", "open=imag2 image=[16-bit Unsigned] width=512
height=512 offset=68 number=1 gap=0 little-endian");
        b = getImageID();
        run("Image Calculator...","selectImage(a) operation=Subtract create
selectImage(b)");}

Can someone help me fix this problem??

Thank you

regards
Juju  
--
View this message in context: http://imagej.588099.n2.nabble.com/background-subtraction-does-not-work-tp5705506p5705506.html
Sent from the ImageJ mailing list archive at Nabble.com.