[ImageJ-devel] Calibration bug when rotating an image by 90°

Rasband, Wayne (NIH/NIMH) [E] rasbandw at mail.nih.gov
Thu Mar 21 19:46:59 CDT 2013


On Mar 21, 2013, at 5:45 AM, Michael Epping wrote:

> Hello,
> I hope this is the right address to report a small bug.
> 
> Problem:
> I use the calibration "Origin (pixels)" with different values for x and 
> y. When I rotate an image by 90°, pixel width and pixel height are 
> swapped as expected. But the origin stays the same.
> The attached code shows that only cal.pixelWidth and cal.pixelHeight are 
> swapped but not cal.xOrigin and cal.yOrigin.

This bug is fixed in the ImageJ 1.47n daily build. Upgrade by using the Help>Update ImageJ command and selecting "daily build" from the drop down menu.

-wayne


Code:
> ij.plugin.filter.Transformer
> 
> public void run(ImageProcessor ip) {
>         if (arg.equals("fliph")) {
>             ip.flipHorizontal();
>             return;
>         }
>         if (arg.equals("flipv")) {
>             ip.flipVertical();
>             return;
>         }
>         if (arg.equals("right") || arg.equals("left")) {
>             StackProcessor sp = new StackProcessor(imp.getStack(), ip);
>             ImageStack s2 = null;
>             if (arg.equals("right"))
>                 s2 = sp.rotateRight();
>             else
>                 s2 = sp.rotateLeft();
>             Calibration cal = imp.getCalibration();
>             imp.setStack(null, s2);
>             double pixelWidth = cal.pixelWidth;
>             cal.pixelWidth = cal.pixelHeight;
>             cal.pixelHeight = pixelWidth;
>             return;
>         }
> 
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagej.net
> http://imagej.net/mailman/listinfo/imagej-devel




More information about the ImageJ-devel mailing list