

Dear list members,
to find colocalization, I am comparing two 8bit 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 8bit tif images gained from a Leica confocal microscope.
Help appreciated!
Best,
Florian Ulrich


Hi,
On Thu, 14 Jul 2005, Florian Ulrich wrote:
> to find colocalization, I am comparing two 8bit 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 8bit 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


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 8bit 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 8bit 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
>
>


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


< [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]>
UserAgent: SquirrelMail/1.4.5 [CVS]
MIMEVersion: 1.0
ContentType: text/plain;charset=iso88591
ContentTransferEncoding: 8bit
XPriority: 3 (Normal)
Importance: Normal
XVirusScanned: by amavisdnew at mpicbg.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
>
>


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


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 bitwise 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 8bit images and 65535
for 16bit images.
Variations that change the conditional expression and
constants to suit the image seem to be optimal.
Regards all,
Ray


At 01:28 PM 7/14/05 +0200, Florian Ulrich wrote:
>to find colocalization, I am comparing two 8bit 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


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 8bit 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
>
>


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 bitwise logical operations should be used with the same image type (8
or 16 bit images (and not using a 32bit as result).
newImage("Test", "8bit Black", 256, 256, 1);
run("Add...", "value=110");
run("Duplicate...", "title=Testcopy");
run("Subtract...", "value=55");
imageCalculator("AND create", "Testcopy","Test");
The result should be 38 as Rex pointed out.
You then can convert the result to 32bit if necessary.
Cheers,
G.

