Login  Register

ImageProcessor and rotate

Posted by Teemu Ihalainen-2 on Apr 29, 2010; 9:15am
URL: http://imagej.273.s1.nabble.com/ImageProcessor-and-rotate-tp3688468.html

Hi all,

I have a simple problem considering image rotation by using ImageProcessor rotate(double angle) method. Ill first try to describe what I want to do and in the end I have a piece of the code. Programming is a quite new thing for me, so there might be some large “logical disasters” in the code.

In the beginning I have two 8-bit images, acquired at different time points. In the latter image the objects have rotated and I need to find an angle of this rotation. So, I have constructed a method what I call. In this method I rotate the second image in 1 deg increments (form 1 to 360 deg) and try to find the angle which gives maximum crosscorrelation between the images. The method then returns this angle as a double value.

The next thing what I would like to do is just rotation of the original image by using this returned value. However this doesnt work, since the rotation method, which returns the angle, rotates the original data. Also, the second, rotated image looks quite weird.

I would be interested to know if there is a better method for this rotation and also if there is a simple way to "clone" ImagePlus objects. I tried to go through the API but with poor results.


code:
.
.
.
AlignImages align = new AlignImages();

ImagePlus openedImage1 = openImage();
ImagePlus openedImage2 = openImage();

/*
Next Ill try to find the angle of the rotation by using findAngle method. In the findAngle I rotate the openedImage2 in 1 deg increments from 1-360 deg.
The angle with maximum correlation between the images is returned.
*/

double angle = align.findAngle(openedImage1, openedImage2);


/*
Next I would like to rotate the original openedImage2 with an angle received from the findAngle-method
*/

openedImage2.getProcessor().rotate(angle);

openedImage1.show();
openedImage2.show();

.
.
.


Best Regards,
Teemu Ihalainen, Ph.D.
-------------------------------------------------
University of Jyväskylä
Department of Biological and Environmental science
Molecular Biology, room B 212.2
Survontie 9 B2, 40500 Jyväskylä, Finland
Tel. +358-14-260 4158
Mobile +358-50-518 7422
-------------------------------------------------