imglib / imglib2-realtransform

Spatial transformations for ImgLib2
Other
7 stars 7 forks source link

Create utility method for computing new bounding box after a transform #6

Open ctrueden opened 8 years ago

ctrueden commented 8 years ago

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.

ctrueden commented 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.

hanslovsky commented 8 years ago

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.

bogovicj commented 8 years ago

What should the behavior be for non-linear (e.g. ThinPlateSpline) transforms?

It could:

ctrueden commented 8 years ago

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.

ctrueden commented 7 years ago

I just ran across Intervals.smallestContainingInterval(RealInterval) which is a similar thing.

axtimwalde commented 7 years ago

I agree with @hanslovsky, this has to be a complementary interface that is implemented by RealTransforms that can calculate or know their bounding box.

ctrueden commented 7 years ago

Thanks @axtimwalde, I agree as well.