Posted by
Kenneth Sloan on
Aug 12, 2013; 2:54pm
URL: http://imagej.273.s1.nabble.com/sorting-a-stack-tp5004395.html
I would like a bit of help writing a utility Java plug-in.
Given a stack of images, with names of the form abcKEYxyz, I want to sort on "KEY". So, for example, I could
define:
static int compareOnKey(<slice>a, <slice>b)
{
return extractKey(a).compareTo(extractKey(b));
}
Where "extractKey" produces a String (for example, part of the filename).
Then, I need:
static void exchange(<slice>a, <slice>b)
What I need help on is the details of:
a) what's the data type for a "<slice>"?
b) how do I get the name of a <slice>?
c) how do I "exchange" two slices in the stack?
The sort is no problem (I'll probably use InsertionSort). The details of compareOnKey may vary (I may write several such StackSorters, or I might (eventually) write one with a dialog box for options.
The idea is to order the stack of images according to various criteria which can be derived from the filename associated with each image. In particular, we have an age-series of images, where the age appears in a fixed location in the filename. I'd like to sort the stack by age, and then make a montage.
I'll go off and dive into the API now - but I suspect that someone has this knowledge "off the top of their head". All clues gratefully rented.
The perfect reply would be the guts of a plugin that sorts on filename (keeping in mind that I will have to modify it by altering "extractKey()")
--
Kenneth Sloan
[hidden email]
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html