Re: saving and accessing tiff tags currently unused by ImageJ
Posted by Bill Christens-Barry on May 01, 2010; 12:31pm
URL: http://imagej.273.s1.nabble.com/saving-and-accessing-tiff-tags-currently-unused-by-ImageJ-tp3688437p3688438.html
Thanks, Jerome, Gabriel, and Wayne for the helpful response information you gave. Here's what I had come up with, based on one of Wayne's examples, using metadata and properties:
macro "UseOffsets [1]" {
print("\\Clear");
properties = getMetadata("Info");
List.setList(properties);
if(lengthOf(List.get("X-offset"))>0 || lengthOf(List.get("Y-offset"))>0) {
x0 = parseInt(List.get("X-offset"));
print("X-offset: " + List.get("X-offset"));
y0 = parseInt(List.get("Y-offset"));
print("Y-offset: " + List.get("Y-offset"));
}
if(lengthOf(List.get("X-offset"))==0 && lengthOf(List.get("Y-offset"))==0) {
x0 = 0;
y0 = 0;
print("No \"X-offset\" or \"Y-offset\" properties defined.");
}
if(selectionType()==0) {
getSelectionBounds(xoff, yoff, wid, hgt);
run("Crop");
List.clear;
List.set("Name", getTitle);
List.set("Dir", getDirectory("image"));
List.set("Size", getWidth*getHeight);
List.set("X-offset", x0 + xoff);
List.set("Y-offset", y0 + yoff);
setMetadata("Info", List.getList);
path = getDirectory("temp")+"test.tif";
saveAs("tif", path);
close;
open(path);
properties = getMetadata("Info");
List.setList(properties);
print(path);
print("Name: "+List.get("Name"));
print("Dir: "+List.get("Dir"));
print("Size: "+List.get("Size"));
print("X-offset: "+List.get("X-offset"));
print("Y-offset: "+List.get("Y-offset"));
}
}
This is meant to cover the case of sequential cropping, referenced back to an original source image. I'm still hoping to put the offsets into a tiff tag so they can be utilized by other programs, but this works fine with ImageJ.
Bill