Imglib2 rotation

Hello,

Is there already something in imglib2 to create a rotated view on an image?
Of course I could write some code to perform a rotation via an affine transform, but I wanted to avoid code duplication, in case something exists already.

Below is where I looked so far, but could not find a explicit rotation method:

I found the solution myself. It is inside the Affine3D class:

1 Like

You can also create an rotated view at any angle using the RealViews class. Note that @bnorthan just implemented an op in ImageJ Ops which uses RealViews.transformView:

There are still some details to sort out, such as the resultant bounding box (see imglib/imglib2-realtransform#6), and what to name it. But this should make its way into an ImageJ Ops release soon.

4 Likes

@Christian_Tischer as @ctrueden mentioned I am currently working on a general transform op. I have two cases I need to handle right away, a sub-resolution pixel shift, and arbitrary 2d rotation (the current rotation op only rotates from one axis, to the other, and the current translate op only takes integer inputs) .

My immediate goal is to get the general transform op done.

After that next step would be to try and create user friendly transform ops.

So you could write code like this…

// rotate the image 
ops.rotate(img, angle);

// rotate image around specified axis
ops.rotate(img, angle, axis);

// translate
shift=new float[]{.2, .3, .1};
ops.translate(img, shift);

The idea is that the ops framework would choose the right underlying op for each situation. So for example, if you are rotating a 2d image, it would choose the 2d rotation, if your shift is integer, it would choose integer translation, if your shift is sub pixel, it would do interpolation.

Ideally you would be able to write your Image Registration Suite using ops. I’m not sure all the ops you would need are there yet, but as part of the project you could potentially try implementing some of the ops you would need.

4 Likes