Rotate image with annotations

Hi,

I’m trying to rotate images that have been annotated (points placed in the original image).
I’ve tried :

  • Image > Transform > Rotate 90 Degrees Right
    It removes the annotations / points (or rotate them outside the image ?)
  • Image > Transform > Rotate... and set 90
    but this doesn’t affect the points that are therefore misplaced in the rotated image…

eventually i’m gonna wrap this up in an ImageJ macro to be applied as a batch job

[edit] annotations (i.e. points) are stored in the TIFF image file

Hm seems that the selection and overlay is not affected by these transformations.

EDIT: my statement was not correct, thanks to a PM of another user :), You can rotate selections by:
Edit > Selection > Rotate

now obsolete:

I think you have two choices:

A) get the coordinates of the points and apply the transformation on the coordinates. Which is feasible but requires a bit of math. Fundamentally thats what these transformations do also to each pixel in the image. For complex manual transformation might be a bit involved though.

B) you make an image out of the point selection… Maxima Finder spits out an image for the detections for example. Maybe the selection coordinates can be turned into an image and use the same operation then on this image and then get the selection from this image again. Its the easier approach, just requires the this selection to image and back step.

Thanks for the tips !
Indeed, the Edit > Selection > Rotate did the trick,
If anyone need this I wrote a macro that combine Image and Annotations rotation for all TIFF images in a directory:

macro "Batch rotate images and annotations" { 
	/* Read images in a chosen directory and rotate them along
        with the annotations (points) and store them inplace */
	
	source_dir = getDirectory("Choose an input Directory ");  // window to select the input directory
	dest_dir = getDirectory("Choose an output Directory ");  // window to select the output directory
	list = getFileList(source_dir);  // list files in it
  	angle = getNumber("choose the clockwise rotation angle", 90);
	
	setBatchMode(true); // activate batch process
	for (i=0; i<list.length; i++) { // loop over files
        	showProgress(i, list.length); // update progressbar
		file_name = list[i];
		if (endsWith(file_name, ".tif")) {
			file_path = source_dir + file_name; 
			new_path = dest_dir + file_name; 
			open(file_path);  // open the current image	    
			run("Rotate...", "rotate angle=" + angle);
			run("Rotate... ", "angle=" + angle + " grid=1 interpolation=None");
			save(new_path);
			close(); 
		}
	} 
} 

[edit] I drop another one in case you also need to extract the annotations coordinates :slight_smile:

1 Like