Reduce size of multiple ROIs in ROI-Manager

Hi guys,
I wrote a Macro which enlarges my (very small) ROIs, which are stored in the ROI-Manager. For a different set of analysis, however, I have to reduce the the size of the ROIs. Somehow my code does not do what I want. Here the code with some made up ROIs.

makeRectangle(782, 457, 4, 8);
roiManager("Add");
makeRectangle(792, 457, 4, 8);
roiManager("Add");
makeRectangle(682, 457, 4, 8);
roiManager("Add");
roiManager("Show All");

macro "Resize Selections" {
      requires("1.38e");
      dx = -3;
      Dialog.create("Adjust size of your ROIs");
      Dialog.addNumber("Increase by:", dx);
      Dialog.show();
      dx = Dialog.getNumber();
      n = roiManager("count");
      if (n==0)
          exit("The ROI Manager is empty");
      for (i=0; i<n; i++) {
          roiManager("select", i);
          run("Enlarge...", "enlarge="+dx);
          roiManager("update");
      }

When I increase the size, I can reduce the size afterwards (by enlarging with negative values), but I cannot reduce the size below the original ROI. Maybe because they are already very small? Any ideas how to do this?

Thanks a lot for your help

Cheers

Sorry. After a coffee I found the solution. The increments where to big for the size of the ROI. Sorry about the confusion.
Maybe the code helps other people.

1 Like

Dear @mugel2110,

thanks for keeping us posted! :clap:

There is an option to mark a post as a solution to the issue: click the three dots below the post and click the checkmark icon! (I have done that already for this thread)

Best,
Stefan

1 Like