macro 'Mark Centroid [c]'; {marks the centroid of any selection with a small dot} var r,i,j,numx,numy,denomx,denomy,top,left,width,height:integer; x,y:real; begin numx := 0; numy := 0; denomx := 0; denomy := 0; RequiresVersion(1.51); GetRoi(left,top,width,height); if width=0 then begin PutMessage('This macro expects an active selection.'); Exit; end; copy; moveroi(-left,-top); killroi; SetNewSize(width,height); MakeNewWindow('ROI'); paste; for i:=1 to width do begin MakeLineRoi(i,1,i,height); for j:=1 to height do begin r := GetPixel(i,j); numx := numx + (i * r); denomx := denomx + r; numy := numy + (j * r); denomy := denomy + r; end; end; if denomx = 0 then begin PutMessage('Cannot do a COM on a white selection'); Exit; end; x := numx/denomx; y := numy/denomy; makeroi(x-1,y-1,3,3); invert; killroi; end;