Login  Register

Re: saving and accessing tiff tags currently unused by ImageJ

Posted by Jerome Mutterer-3 on May 01, 2010; 6:31am
URL: http://imagej.273.s1.nabble.com/saving-and-accessing-tiff-tags-currently-unused-by-ImageJ-tp3688437p3688440.html

Hi Bill,
A similar thing was done for the Make Montage command to set some meta data
in the produced montage, to remember the used layout.
Here, you would need the 'Crop' function to set metadata about what it
does:

getSelectionBounds(x, y, w, h);
ci="cropInfo="+x+","+y+","+w+","+h;
run("Crop");
setMetadata (ci);
run("Show Info...");

This meta data will be saved with your tif image anyway, so you do not need
using any special tif tag.
Then you can use getMetadata() to retrieve the cropInfo values. This example
crops a region from one image and pastes it in a different image, at the
original position, using the cropInfo metedata:

run("AuPbSn 40 (56K)");
makeRectangle(90, 61, 136, 98);
getSelectionBounds(x, y, w, h);
ci="cropInfo="+x+","+y+","+w+","+h;
run("Crop");
setMetadata (ci);
run("Copy"); // or save as tif

List.setList(getMetadata);
c = split(List.get("cropInfo"),",");
run("Boats (356K)");
makeRectangle(c[0], c[1], c[2], c[3]);
run("Paste");
/// end


Jerome



On Sat, May 1, 2010 at 3:48 AM, Bill Christens-Barry <[hidden email]
> wrote:

> Frequently, I save both a cropped image and its uncropped parent. Later, I
> often want to precisely register the cropped version with its uncropped
> parent or some other image, for which I need to know the offsets between the
> two images. One way this could be done would be to write the needed x- and
> y-offsets in the header of the cropped image file, and then expose them for
> use when an image is opened.
>
> There are several candidate tiff tags that seem suitable for this (e.g. x-
> and y-position tags, 286 and 287 respectively), but they aren't currently
> implemented in TiffEncoder or TiffDecoder. I'm wondering how I can use these
> tags so that the offset information can be utilized for registration in
> ImageJ and in other programs. In particular, if I modify the TiffEncoder
> source so that the tag information gets saved in a newly created cropped
> image file, what will happen if I open such an image file with a version of
> ImageJ that has not been modified? Will TiffDecode simply ignore this tag it
> knows nothing about?
>
> Of course, such offsets in an image file are only meaningful in relation to
> some other file (one it is intended to be registered to), so I'll need to
> think through how to best make use of offset information. But for now, can
> anyone describe how this problem is usually approached or offer suggestions
> for how I should be thinking about it? Tiff tags 286 and 287 are in
> resolution (i.e. distance) units, while what I'd really like is to directly
> use pixel units; are other tiff tags more appropriate for this? Have I
> missed some existing capability in ImageJ that would facilitate this?
>
> Thanks.
>
> Bill
>