Resize/Scale Regions of interest

Hello everybody,

When I am resizing an image (i.e. X Scale: 0.75; Y Scale: 0.75), is possible to simultaneously resize also the ROIs I have saved in the ROI manager?

Thank you!

Marta

Hi @MartaR
you will find below some code (macro language) that show you how to overcome this :

// START
//
// open an image and make a downscaled version of it
run("Blobs (25K)");
ori = getTitle();
run("Scale...", "x=0.5 y=0.5 interpolation=Bilinear average create title=downScale");

// Make a ROI on the original image and add it to the ROI manager
selectImage(ori);
makeRectangle(55, 20, 35, 35);
Roi.setName("ROI_originalImage");
roiManager("Add");

// Rescale the ROi on the downscaled version
selectImage("downScale");
roiManager("Select",0);
run("Scale... ", "x=0.5 y=0.5");
Roi.setName("ROI_downscaleImage");
roiManager("Add");
//
// END

Cheers,

Romain

4 Likes

Here is an alternative version that scales all ROIs in the ROI Manager:

// @Double(value=1.5) xScale
// @Double(value=1.5) yScale

// Scale image
run("Scale...", "x=&xScale y=&yScale interpolation=Bilinear average create");

// Iterate all ROIs in ROI Manager
for (i=0; i<roiManager("count"); ++i) {
	roiManager("Select", i);
	
	// Scale ROI
	run("Scale... ", "x=&xScale y=&yScale");

	// Replace old ROI with scaled one
	roiManager("update")
}

Best,
Stefan

2 Likes

Thank you both,

I am very new to imageJ and not practical in macros, but I will try your suggestions!
Thank you!
Marta

Continuing the discussion from Resize/Scale Regions of interest:

These code helped me a lot. Thanks! Cheers!