This is a great suggestion, thanks Lee.
Indeed the current behavior where the default ImageWarp is in the same type as the input must be modified. For the time being, I am thinking of keeping the double precision floating point as the default output and using a `type' option to allow the user to set the output type as they like (similar to what is implemented in MakeProfiles, see MakeProfiles options, under the `type' option). I will do this while correcting it as part of task #14245 (I haven't got to ImageWarp yet!).
But the automatic type determination is a very intriguing feature, it was a great suggestion! Infact it isn't too separate from task #13563 (No need for polygon calculation when simple transformations are needed). Essentially, when we have easy transformations (not just `scale', for example also flip, or rotation by 90 degrees), we don't need to go through all the trouble that ImageWarp goes in now to allow any kind of Homographic transform (calculating the area of each output pixel on an input pixel and etc.). This will make the processing on the simple transformations much more faster. In the process, we can also do automatic type determinations like what you mentioned for the simple transformations.
Based on your suggestion I thought of a more general solution that can apply to any of the programs, not just ImageWarp. For example, I am really impressed by how the `%g' option in C works: it will print a floating point number into the most accurate representation (for example printing `1' for `1.0000000', and the proper number of decimals for floating points). I would be really curious if we could implement something like the `%g' and check the best type for all the pixels in an image, and based on that, choose the best type for the whole image without loosing mathematical precision.
It doesn't just have to be applied to floats, so when the dataset is in integer type, it will also check and for example if none of the values are larger than `255' and `>=0', then use `unsigned char' and so on. We can do all of this with a common option like `automatictype' so when the user doesn't like the default type of a program's output, they can add this option and get the most appropriate type output. It can also be implemented as an operator in Arithmetic.
But I am too busy to implement the `automatictype' option right now, so if anyone is interested, please post a comment here and start the work, I would be happy to help ;).
