[ImageJ-devel] (ImgLib2) operations on two or more images with differing calibrations

Tobias Pietzsch tobias.pietzsch at gmail.com
Tue Nov 29 07:43:08 CST 2011


On 11/29/2011 10:17 AM, Gabriel Landini wrote:
>
> On Monday 28 Nov 2011 17:49:06 Tobias Pietzsch wrote:
>>
>> A while ago, Johannes asked about whether I had any thoughts on how this
>> (see subject) should be done.  I finally had the time to look at
>> it now and found, that the ideas to do it are mostly in place (in my
>> opinion, at least) though implementation is not.
>
> Suppose that you want to operate on 2 images with different calibrations.
> Would it be desirable to allow keeping one of the images "as is" and only
> interpolate/transform the other to match the calibration? I mean is there user
> control over which image gets interpolated to fit the calibration of the
> other?

Hi Gabriel,

This is possible, though with a bit of (writing) effort.

Assume that we have input (raster) image A and B with differing
calibrations.  We want to add them to obtain (raster) image C which
has the same calibration as A.  So we would create an interpolated
view of B which brings it to the same calibration as A and C.

Then to add the images, we would iterate through the pixels of C,
obtaining an integer position for each. We can just pick pixels at
integer positions in A using a RandomAccess. We can also pick pixels
at integer positions in Interpolated(B) using a RealRandomAccess.
After all, a RealRandomAccess implements RealPositionable, which
extends Positionable.

Unfortunately, we cannot just treat RealRandomAccess as RandomAccess,
because it is not Localizable (but only RealLocalizable).  So we have
to be a bit more specific in our algorithm implementation:  For the
input accessors we want something that is Positionable and is a
Sampler.  Both RealRandomAccess and RandomAccess fulfill this
requirement  (Usually, for writing raster image algorithm we would be
lazy and just take a RandomAccess for our input although we don't
really care about it being Localizable...)

I've attached code for the above example. Compiles and would
presumably work just fine if it weren't for the absence of RealViews
right now...

Tobias

>
> Cheers
> Gabriel
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AddRealOrIntegerExample.java
Type: text/x-java
Size: 915 bytes
Desc: not available
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20111129/90d98432/attachment.java>


More information about the ImageJ-devel mailing list