Open ctrueden opened 8 years ago
@lnyng We can discuss when you get back to LOCI. I would like to add shearing to the Ops transform
package. We will need this utility method as part of that.
As an inspiration, you could have a look at BoundingBox
and BoundingBoxTransform
. This class/interface can be easily extended to the RealTransform
case and could be implemented by any RealTransform
that transforms the bounding box in a trivial way.
What should the behavior be for non-linear (e.g. ThinPlateSpline) transforms?
It could:
For non-linear transforms, we should extend the interface (or provide an optional add-on interface—although with Java 8 default methods, this trick is no longer as necessary for backwards compatibility) so that the transform itself can offer its new bounding box. Of course, with arbitrary transforms the new bounding box could be infinite.
I really want to solve the 99% common cases though, where users want to apply some transform in ImageJ and then have the new image window match the new bounds. Otherwise, even simple things like shearing are not really usable for end users.
Note that @lnyng won't actually be working on this soon, since we have other priorities right now. I may try to tackle the very simple "corners" version of this utility method, but probably not for at least several weeks. And I would like to have @axtimwalde or @tpietzsch on board with the existence of such a utility method, before investing any time in it.
I just ran across Intervals.smallestContainingInterval(RealInterval) which is a similar thing.
I agree with @hanslovsky, this has to be a complementary interface that is implemented by RealTransforms that can calculate or know their bounding box.
Thanks @axtimwalde, I agree as well.
At least for affine transforms, it is reasonable to take the corners of the source interval, and feed them into the transform to discern the boundaries of the target interval. This is the default expected behavior when performing common image processing operations such as shearing. See this forum thread.