{Name: remover-macro} {Author: Wade Schuette (schuette@umich.edu) } { date: Jan 23, 1998 } {Project: NIH Image user requested macro } {Function: Takes a selected image, removes parts which touch the edges} { under assumption that autothresholding is appropriate} { Input: any selected image, which is not altered or disposed} { Process: uses and disposes 'mask' as working image} { output: 'cleanversion' of original image} Macro 'remover'; Var height, width: integer; top, bottom: integer; row, col: integer; left, top: integer; w,h: integer; pidimage, pidmask: integer; BEGIN PutMessage('assumes your desired image has been selected'); { SelectWindow('image'); } Selectall; pidimage:=pidnumber; Duplicate('mask'); SelectAll; pidmask:=pidnumber; {SetThreshold(100);} PutMessage('Note: Autothresholding, removing edge-touchers'); Autothreshold; MakeBinary; GetPicsize(height, width); {clear top} For col:=1 to (width-1) do begin if GetPixel(col,0)>200 then begin AutoOutline(col, 0); GetRoi(left,top,w, h); if w>0 then clear; end; end; {clear bottom} For col:=1 to (width-1) do begin if GetPixel(col,height-1)>200 then begin AutoOutline(col, height-1); GetRoi(left,top,w, h); if w>0 then clear; end; end; {clear left} For row:=1 to (height-1) do begin if GetPixel(0,row)>200 then begin AutoOutline(0, row); GetRoi(left,top,w, h); if w>0 then clear; end; end; {clear right} For row:=1 to (height-1) do begin if GetPixel((width-1),row)>200 then begin AutoOutline((width-1), row); GetRoi(left,top,w, h); if w>0 then clear; end; end; SelectAll; ImageMath('And',pidimage,pidmask,1.0,0.0,'cleanversion'); selectwindow('mask'); dispose; SelectWindow('cleanversion'); END;