AND function

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

AND function

Florian Ulrich
Dear list members,

to find colocalization, I am comparing two 8-bit channels with the AND
function. I thought, it would calculate like

first channel value 128
second channel value 180
AND operation gives 128

or

first channel value 110
second channel value 55
AND operation gives 55

etc.

However, imagej sometimes does that, but also sometimes yields different
values for the AND function. How can that be? I am using imagej version
1.33u on 8-bit tif images gained from a Leica confocal microscope.

Help appreciated!

Best,

Florian Ulrich
Reply | Threaded
Open this post in threaded view
|

Re: AND function

dscho
Hi,

On Thu, 14 Jul 2005, Florian Ulrich wrote:

> to find colocalization, I am comparing two 8-bit channels with the AND
> function. I thought, it would calculate like
>
> first channel value 128
> second channel value 180
> AND operation gives 128
>
> or
>
> first channel value 110
> second channel value 55
> AND operation gives 55
>
> etc.
>
> However, imagej sometimes does that, but also sometimes yields different
> values for the AND function. How can that be? I am using imagej version
> 1.33u on 8-bit tif images gained from a Leica confocal microscope.

You calculate the Boolean AND function, which means that each pixel's
value is interpreted as a dual number, i.e. 128 = dual(10000000), and 55 =
dual(110111). The AND function calculates the minimum *per digit*, i.e.
128 AND 55 = 0.

What you probably want is the Minimum function.

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: AND function

Florian Ulrich
Ups, thanks,

just discovered that myself as well... now, I am curious: on which type of
images and for which kind of analysis would you then use the AND function?
What is the significance of the AND function to your images?

All the best,

Florian


> Hi,
>
> On Thu, 14 Jul 2005, Florian Ulrich wrote:
>
>> to find colocalization, I am comparing two 8-bit channels with the AND
>> function. I thought, it would calculate like
>>
>> first channel value 128
>> second channel value 180
>> AND operation gives 128
>>
>> or
>>
>> first channel value 110
>> second channel value 55
>> AND operation gives 55
>>
>> etc.
>>
>> However, imagej sometimes does that, but also sometimes yields different
>> values for the AND function. How can that be? I am using imagej version
>> 1.33u on 8-bit tif images gained from a Leica confocal microscope.
>
> You calculate the Boolean AND function, which means that each pixel's
> value is interpreted as a dual number, i.e. 128 = dual(10000000), and 55 =
> dual(110111). The AND function calculates the minimum *per digit*, i.e.
> 128 AND 55 = 0.
>
> What you probably want is the Minimum function.
>
> Hth,
> Dscho
>
>
Reply | Threaded
Open this post in threaded view
|

Re: AND function

Raymond Lillard
Florian Ulrich wrote:
> Ups, thanks,
>
> just discovered that myself as well... now, I am curious: on which type of
> images and for which kind of analysis would you then use the AND function?
> What is the significance of the AND function to your images?

Masking off lower bits while leaving the upper bits unchanged.
This could be used to blank background noise below a certain
threshold w/o modifying brighter image structures.

There are other clever uses for AND and OR as well.

Ray
Reply | Threaded
Open this post in threaded view
|

(no subject)

Florian Ulrich
    <[hidden email]>
              <[hidden email]>
    <[hidden email]>
Date: Thu, 14 Jul 2005 21:40:44 +0200 (MEST)
Subject: Re: AND function
From: [hidden email]
To: "ImageJ Interest Group" <[hidden email]>
User-Agent: SquirrelMail/1.4.5 [CVS]
MIME-Version: 1.0
Content-Type: text/plain;charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Priority: 3 (Normal)
Importance: Normal
X-Virus-Scanned: by amavisd-new at mpi-cbg.de

Tnx for the answer. My wrong assumption in the beginning is another good
demonstration that what one spontaneously regards as being logical has
nothing to do with mathematical logics...

Best,

Florian

> Florian Ulrich wrote:
>> Ups, thanks,
>>
>> just discovered that myself as well... now, I am curious: on which type
>> of
>> images and for which kind of analysis would you then use the AND
>> function?
>> What is the significance of the AND function to your images?
>
> Masking off lower bits while leaving the upper bits unchanged.
> This could be used to blank background noise below a certain
> threshold w/o modifying brighter image structures.
>
> There are other clever uses for AND and OR as well.
>
> Ray
>
>
Reply | Threaded
Open this post in threaded view
|

Re: AND function

dscho
In reply to this post by Raymond Lillard
Hi,

On Thu, 14 Jul 2005, Raymond Lillard wrote:

> Masking off lower bits while leaving the upper bits unchanged.
> This could be used to blank background noise below a certain
> threshold w/o modifying brighter image structures.

Subtract <small number> is a much better method for this. I think the AND
function is only interesting when overlaying several bilevel channels into
one image.

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: AND function

Raymond Lillard
Johannes Schindelin wrote:
> On Thu, 14 Jul 2005, Raymond Lillard wrote:
>>Masking off lower bits while leaving the upper bits unchanged.
>>This could be used to blank background noise below a certain
>>threshold w/o modifying brighter image structures.
>
> Subtract <small number> is a much better method for this. I think the AND
> function is only interesting when overlaying several bilevel channels into
> one image.

Subtracting will not produce the same result as I described.
Subtracting will also dim the bright structures of the image.
If you do subtraction, you probably will need to follow with
multiplication, which will have the effect of enhancing the
contrast.

The optimal course of action depends on the nature of the
image being studied, and the feature of that image you wish
examine in greater detail.

In the case of creating a single image by overlaying multiple
images, a bit-wise AND will have an odd sort of effect based
on powers of 2.  That might be what you want, but likely not.


On this list, about a year ago I asked the question
marked by ">"s that follow.
 > I have images were I want to conditionally set a
 > pixel to an arbitrary value of my choosing.  For
 > example, given a pixel (p) then:
 >
 >   if ( p > constant1 ) then p = constant2
 >
 > Is this built into ImageJ or do I need to write something?

        Wayne Rasband answered:
        The changeValues() macro function will do this. Use

      changeValues(constant1+1, max, constant2);

        where 'max' is 255 for 8-bit images and 65535
        for 16-bit images.

Variations that change the conditional expression and
constants to suit the image seem to be optimal.

Regards all,
Ray
Reply | Threaded
Open this post in threaded view
|

Re: AND function

Rex Couture
In reply to this post by Florian Ulrich
At 01:28 PM 7/14/05 +0200, Florian Ulrich wrote:
>to find colocalization, I am comparing two 8-bit channels with the AND
>function. I thought, it would calculate like

>first channel value 110
>second channel value 55
>AND operation gives 55...

        110 AND 55 is 38, not 55.

Rex Couture
Reply | Threaded
Open this post in threaded view
|

Re: AND function

Florian Ulrich
yep, but that's what I got.

anyway, the min operation nicely works.

thanks again,

Florian


> At 01:28 PM 7/14/05 +0200, Florian Ulrich wrote:
>>to find colocalization, I am comparing two 8-bit channels with the AND
>>function. I thought, it would calculate like
>
>>first channel value 110
>>second channel value 55
>>AND operation gives 55...
>
>         110 AND 55 is 38, not 55.
>
> Rex Couture
>
>
Reply | Threaded
Open this post in threaded view
|

Re: AND function

Gabriel Landini
On Monday 18 July 2005 15:03, Florian Ulrich wrote:

> > At 01:28 PM 7/14/05 +0200, Florian Ulrich wrote:
> > >>first channel value 110
> >>second channel value 55
> >>AND operation gives 55...
> >
> >         110 AND 55 is 38, not 55.
> >
> > Rex Couture
>
> yep, but that's what I got.

You must be producing a 32 bit result or using 32 bit images.
These bit-wise logical operations should be used with the same image type (8
or 16 bit images (and not using a 32bit as result).

newImage("Test", "8-bit Black", 256, 256, 1);
run("Add...", "value=110");
run("Duplicate...", "title=Test-copy");
run("Subtract...", "value=55");
imageCalculator("AND create", "Test-copy","Test");

The result should be 38 as Rex pointed out.

You then can convert the result to 32bit if necessary.

Cheers,

G.