3) I am reading about support for more (unsigned) primitive data
types, use of generics etc. I consider myself a Java person, but this
is where Java is particularly bad at, not to talk about some notorious
performance issues. How important is Java in this context?
I have seen some concerns in this list about the performance of usage of generics with numerical computations. I think this (@specialized annotation in Scala 2.8.x (to be released this year)), can be used to avoid performance problems, and keep writing generic algorithms. (blog, Numeric trait, discussion). (I am not sure, maybe Johan Hendriksson has been already solved this problem using pure Java. In that case I would be interested how, and is it available somewhere?)
(Regarding abstract classes <-> interfaces - In Scala you can use traits for interfaces and those can hold implementations too.)
I have also looked at the Fiji's imagecontainer1 branch. I think it is more modular, flexible than ImageJ, maybe the way to the future. (Although using public int in the Type class is not so good solution in my humble opinion.)
indeed the solution in java is to code @specialized, most likely with
javassist.
http://www.csg.is.titech.ac.jp/~chiba/javassist/
it provides run-time specialization
+ no need to recompile to support new datatypes
+ smaller binaries
- slower startup
Hi everyone,
One of ImageJDev's goals is to expand the data model (see http://imagejdev.org/proposal, Aim IC). Regarding core image types, we have pledged support for int8, uint32, and float64 images.
Gábor Bakos and Johan Henriksson also mentioned Scala and its "@specialized" tag, though we have not had time to research that option yet. However, I am concerned about introducing any dependence on Scala (even though it is Java-compatible) unless the benefits are very substantial, and cross-platform support remains intact. Johan also mentioned Javassist, though upon cursory inspection I am not sure how we could use that tool to address the image data types issue.
On Thu, Dec 24, 2009 at 1:23 AM, Curtis Rueden <ctrued...@gmail.com> wrote:Gábor Bakos and Johan Henriksson also mentioned Scala and its "@specialized" tag, though we have not had time to research that option yet. However, I am concerned about introducing any dependence on Scala (even though it is Java-compatible) unless the benefits are very substantial, and cross-platform support remains intact. Johan also mentioned Javassist, though upon cursory inspection I am not sure how we could use that tool to address the image data types issue.
I would prefer to avoid scala if possible, there are plenty reasons for doing so (tool support, avoid non-mainstream, avoid mixing languages etc). javassist allows you to take code (=the modified plugin template) and have it compiled on-the-fly. I find it easiest (but yet to confirm) to start from actual source than class binaries because the JVM treats scalars and classes rather different at byte code level. the original code should be possible to compile before javassist takes it apart, otherwise Eclipse et al won't work very well (e.g. refactoring). this all goes down to the nit-bits of the implementation so I will have to work on this. I will try (as planned) to do this in endrov and let you know how it works.
--
/Johan
-----------------------------------------------------------
Johan Henriksson
PhD student, Karolinska Institutet
http://mahogny.areta.org http://www.endrov.net
--
You received this message because you are subscribed to the Google Groups "ImageJX" group.
To post to this group, send email to ima...@googlegroups.com.
To unsubscribe from this group, send email to imagejx+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/imagejx?hl=en.
2009/12/24 Johan Henriksson <mah...@areta.org>On Thu, Dec 24, 2009 at 1:23 AM, Curtis Rueden <ctrued...@gmail.com> wrote:Gábor Bakos and Johan Henriksson also mentioned Scala and its "@specialized" tag, though we have not had time to research that option yet. However, I am concerned about introducing any dependence on Scala (even though it is Java-compatible) unless the benefits are very substantial, and cross-platform support remains intact. Johan also mentioned Javassist, though upon cursory inspection I am not sure how we could use that tool to address the image data types issue.
I would prefer to avoid scala if possible, there are plenty reasons for doing so (tool support, avoid non-mainstream, avoid mixing languages etc). javassist allows you to take code (=the modified plugin template) and have it compiled on-the-fly. I find it easiest (but yet to confirm) to start from actual source than class binaries because the JVM treats scalars and classes rather different at byte code level. the original code should be possible to compile before javassist takes it apart, otherwise Eclipse et al won't work very well (e.g. refactoring). this all goes down to the nit-bits of the implementation so I will have to work on this. I will try (as planned) to do this in endrov and let you know how it works.
Will this approach work for the android port too? (I have not seen mentioning the DalvikVM on the Javassist site, but the plans suggest that it should be supported.) For me this is not a priority, but for those who are targeting that platform might be. (Actually I do not know whether this will work in Scala either.)
--g--
/Johan
-----------------------------------------------------------
Johan Henriksson
PhD student, Karolinska Institutet
http://mahogny.areta.org http://www.endrov.net--
You received this message because you are subscribed to the Google Groups "ImageJX" group.
To post to this group, send email to ima...@googlegroups.com.
To unsubscribe from this group, send email to imagejx+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/imagejx?hl=en.
--
Skill is successfully walking a tightrope over Niagara Falls. Intelligence is not trying. ~~~...--
You received this message because you are subscribed to the Google Groups "ImageJX" group.
To post to this group, send email to ima...@googlegroups.com.
To unsubscribe from this group, send email to imagejx+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/imagejx?hl=en.
best regards,
Dimiter
On Dec 24, 1:23 am, Curtis Rueden <ctrueden.w...@gmail.com> wrote:
> Hi everyone,
>
> One of ImageJDev's goals is to expand the data model (seehttp://imagejdev.org/proposal, Aim IC). Regarding core image types, we have
> pledged support for int8, uint32, and float64 images.
I agree that it would be helpful to have some additional data types
but at the same time we should be modest and consider the
combinatorial number of required conversion methods. Since they are
hard to work with in Java, I would generally avoid UNsigned numeric
types, unless there is a *very* good reason to use them. Currently I
*only* see a good reason for unsigned 8-bit integers ("byte"), because
one wants to use the full 8-bit dynamic range and not loose one bit
for the sign.
In all other cases I would argue to work with SIGNED data to avoid
multiple conversions and make efficient use of Java's arithmetic
infrastructure. In particular, if you need 16 bit unsigned integers
you could use 32 bits signed data without loosing anything. Personally
I use the 32 bit float format universally for almost all numeric
processing, since it has enough precision, it can hold (intermediate)
negative results, calculations are efficient and it is easy to store
(eg. with TIFF).
So my personal "basic data formats wish list" would look like this:
* 8-bit unsigned integer ("byte")
* 16-bit signed integer ("short")
* 32-bit signed integer (int) - NEW
* 32-bit floating-point (float) - hopefully not to be just called
"32bit" any longer!
* 64-bit floating-point (double) - NEW
In addition, I would also wish for a true "binary" (bitmap) fomat, eg.
to represent binary masks, but this seems to be impossible to
implement in Java.
As far as RGB images are concerned, I would strongly argue NOT to use
the packed integer format any longer. While this is reasonable for
storage, it is computationally very inefficient. For practically any
calculation on color images, RGB integers must be decomposed and re-
assembled again. For example, filtering is usually done separately for
each color plane, and the current IJ implementation for color filters
first converts the image to three FloatProcessors, performes the
filter operation on each of them, and then converts back again to the
packed representation. This can be avoided by using a 3-plane data
model from the beginning that is open to use any primitive data type
for the individual color planes. In fact, I would treat RGB images
only as a special case of image stack.
--Wilhelm
On Dec 24, 11:51 am, Johan Henriksson <maho...@areta.org> wrote:
> unsigned integers are hellish to support in java because they are not
> built-in. for endrov I opted to remove them in fact, with the exception of
> uint8 (performance, shouldn't be used for any calculations really). an
> interesting issue for plugin writers is how to handle temporary overflows
> e.g.
> (a+b)/2 can temporarily overflow but the result will never. hence the plugin
> must be clever enough to not just use the generics-imposed format for the
> intermediate but, say, a full int. even more fun is when the plugin takes
> two images and they are of different types; this breaks simple minded
> generics approaches.
Arithmetic overflow is really an interesting issue that is too often
ignored although it causes many hard-to-find (and possibly yet
undetected) errors. As far as I know, there is currently no way in
Java (and C?) to check for arithmetic overflows - although all ALUs do
raise a corresponding flag in such a case. I remember one could easily
handle overflows with PL/I or ADA back in the old days, while Java
designers seem to have forgotten about this important feature. It
would be nice if Java could be asked to throw an exception in such a
case. I think this is one lesson (of many) learned by the C# people.
--Wilhelm
In addition, I would also wish for a true "binary" (bitmap) fomat, eg.
to represent binary masks, but this seems to be impossible to
implement in Java.
As far as RGB images are concerned, I would strongly argue NOT to use
That might be true (don't know). But color images are prevalent in
many other areas and I was actually hoping that IJX could make ImageJ
attractive much beyond biological applications. So I think RGB images
should be considered carefully not only for compatibility reasons.
--Wilhelm
I am puzzled by this, can you expand what do you mean "[not] fit in biological
imaging"?
> That might be true (don't know). But color images are prevalent in
> many other areas and I was actually hoping that IJX could make ImageJ
> attractive much beyond biological applications. So I think RGB images
> should be considered carefully not only for compatibility reasons.
I agree. Also, now that we are at it, I would like to suggest improved support
for cinvertion to HSB, Lab and some other colour space formats.
Currently I do not think that one can convert back and forward between RGB and
HSB without some noticeable rounding errors. This becomes apparent for example
when rotating the hue of an RGB image repeatedly.
Regards
Gabriel
On Dec 25, 12:35 pm, Gabriel Landini <G.Land...@bham.ac.uk> wrote:
> I agree. Also, now that we are at it, I would like to suggest improved support
> for cinvertion to HSB, Lab and some other colour space formats.
> Currently I do not think that one can convert back and forward between RGB and
> HSB without some noticeable rounding errors. This becomes apparent for example
> when rotating the hue of an RGB image repeatedly.
Yes, this is a mess which partially must be blamed on the (bad)
implementation of color conversion in AWT (eg., applying forward/
inverse transforms will generally not produce the original color
values). There is obviously a lack of precision if 8-bit unsigned
integers are used, which also cannot represent out-of-gamut values
that may be produced as intermediate results. I therefore wrote my own
implementation using float components (stacks) to represent colors and
allow precise conversions. For those interested I'll be happy to share
this.
(Not) considering the non-linearities associated with most color
images is another sad issue.
--Wilhelm
On Friday 25 December 2009, Wilhelm Burger wrote:
> > I've gotten rid of RGB-images entirely from endrov. I don't think they
> > fit in biological imaging (but I can have infinite channels, wells,
> > recordings etc instead)
I am puzzled by this, can you expand what do you mean "[not] fit in biological
imaging"?
On Wed, 23 Dec 2009, Curtis Rueden wrote:
> It would be easy enough to leave it at that, but we have an opportunity
> to remove the burden on users of the API to write case logic for each
> data type they wish to support. Stephan Preibisch and Stephan Saalfeld
> have proposed a "generic image processing library" (I believe Fiji's
> imagecontainer1 branch, mentioned below, was an older version of it)
> using Java generics that allows client code to write type-agnostic image
> processing code, with only a modest decrease in performance. (Stephan
> and Stephan: Is this code accessible from Fiji's Git repository? I
> couldn't find it.)
Please bear with us, we are unfortunately very busy with other things
(among other things, we also are offline a lot these days due to partying
Christmas).
So for the moment, I will have to restrict myself with a general
description of this work:
- while we use generics in that library, at no point do we use basic types
in the specialization (for those who know the term "boxing": this is
what makes that specialization undesirable).
- due to a very clever encapsulation scheme devised by Stephan Saalfeld
and Stephan Preibisch, the library allows data type, dimension and
storage layout independent implementations of algorithms, while
maintaining performance close to hand-crafted specific code.
- by the same token, abstraction between the different components implies
that it is very easy to add new data types, such as complex numbers
(float16 comes to mind).
I am sorry, but at this point, I cannot do more than describe the
capabilities in these general terms, and say that the library is in heavy
use (proving above claims in practice). Proper documentation, example
code and more is in preparation, but will take some time.
In particular, I want to stress the fact that this library does not
restrict the developer in such a way that basically everything would be
converted to double -- or int, as has been claimed falsely (which would
most often only waste time and memory).
It is also important to point out that the library does not limit any
developer to a scripting language such as Scala, or to a set of platforms
that exclude some popular ones such as Android.
Ciao,
Johannes