// Expand or shrink selection by a specified number of pixels var n = 5; macro 'Expand Selection...' { requires("1.30i"); if (selectionType==-1) exit("Selection required"); n = getNumber("Number of Pixels:", n); resize(n); } macro 'Shrink Selection...' { if (selectionType==-1) exit("Selection required"); n = getNumber("Number of Pixels:", n); resize(-n); } function resize(n) { type = selectionType(); if (type==0) { getBoundingRect(x, y, width, height); makeRectangle(x-n, y-n, width+n*2, height+n*2); } else if (type==1) { getBoundingRect(x, y, width, height); makeOval(x-n, y-n, width+n*2, height+n*2); } else resizeMask(n); } function resizeMask(n) { if (selectionType==-1) return; id = getImageID(); run("New...", "name=Temp type=8-bit fill=White width="+getWidth()+" height="+getHeight()); run("Restore Selection"); setColor(0); fill(); run("Select None"); if (n>0) expand = true; else expand = false; iterations = abs(n); run("Set Iterations...", "iterations="+iterations); if (expand) run("Dilate"); else run("Erode"); x2=-1; y2=-1; getBoundingRect(xbase, ybase, width, height); inc = 1; if (width>5 && height>5) inc = 5; for (x=xbase; x