Macro 'Help on Ferets Diameter [F1]'; var s1:string; begin s1:='Select object of interest using the wand tool.'; s1:=concat(s1,' After selecting object, execute the Ferets Diameter Macro'); s1:=concat(s1,' from the Special Menu or by pressing:\\[F2]: Using distance between xyCoordinate arrays'); s1:=concat(s1,'\\[F3]: Using height/width of rotated object'); ShowMessage(s1); SelectWindow('Info'); SelectTool('wand'); end; {This macro calculates the object of interest's Feret's Diameter by} {calculating the distance between successive points (user defines } {increment between successive points, 1 being the slowest but most } {accurate) from the ROI Coordinate arrays within NIH Image. } Macro 'Ferets Diameter: Coordinate Arrays [F2]'; var i,j,k,increment:integer; begin increment:=GetNumber('Increment between array points:',1,0); i:=1; While i<=nCoordinates do begin j:=i+increment; While j<=nCoordinates do begin if SQRT(SQR(xCoordinates[i]-xCoordinates[j])+SQR(yCoordinates[i]-yCoordinates[j]))>k then k:=SQRT(SQR(xCoordinates[i]-xCoordinates[j])+SQR(yCoordinates[i]-yCoordinates[j])); j:=j+increment; end; i:=i+increment; end; PutMessage(concat('The Ferets Diameter is ',k:0,' pixels')); end; {This macro calculates the object of interest's Feret's Diameter by} {calculating the height and width of the objects rectangular ROI at} {a series of angles between 0 and 90 degrees of object rotation. } {It works for a binary object on a white background only (although } {it could easily be modified to work with a thresholded greyscale } {image). Errors in object selection after rotation can occur if } {the object is segmented by the process of rotation (try dilating } {the object before running the macro and subtracting 2 from the } {final result. Also, as a rule of thumb the image window should } {be twice the size of the object to allow for rotation. } Macro 'Ferets Diameter: Rotated Object [F3]'; var i,left,top,width,height,feret,increment:integer; begin SetScaling('Nearest,Same Window'); GetRoi(left,top,width,height); if width>height then feret:=width else feret:=height; increment:=GetNumber('Enter rotation increment:',15,0); for i:=1 to (trunc(90/increment)-1) do begin SelectAll; ScaleandRotate(1,1,increment); AutoOutline(0,trunc(top+height/2)); GetRoi(left,top,width,height); if width>Feret then feret:=width; if height>Feret then feret:=height; end; PutMessage(concat('The Ferets Diameter is ',feret:0,' pixels')); end;