macro 'Load EPIC PCT image'; begin SetImport('8-bit'); SetCustom(256,256,0); Import(''); ChangeValues(0,0,1); ChangeValues(255,255,254); SetPalette('Grayscale'); end; macro 'Load Synergy Image'; begin SetImport('8-bit'); SetCustom(512,480,16384); Import(''); ChangeValues(0,0,1); ChangeValues(255,255,254); SetPalette('Rainbow'); end; macro 'Draw Vertical Grey Scale'; var left,top,width,height,i,x,y2,inc:integer; y:real; begin GetRoi(left,top,width,height); if width=0 then begin beep; PutMessage('Make a rectangular selection first.'); exit; end; DrawScale; end; macro 'Draw Horizontal Grey Scale'; var left,top,width,height,i,x,y2,inc:integer; y:real; begin GetRoi(left,top,width,height); if width=0 then begin beep; PutMessage('Make a rectangular selection first.'); exit; end; DrawScale; RotateLeft(0); end; macro 'Draw Slow Horizontal Greyscale'; var width,height,x,y: integer; begin GetPicSize(width,height); if width = 0 then begin beep; PutMessage('Image required.'); exit; end; for y:=0 to height-1 do begin LineBuffer[y]:=y; end; for x:=0 to width-1 do begin PutColumn(x,0,height); end; end; macro 'Make Horizontal Grey Scale'; var left,top,width,height,i:integer; begin SaveState; MakeNewWindow('Horizontal Grey Scale'); SelectAll; GetRoi(left,top,Width,Height); if width=0 then begin PutMessage('This macro requires a rectangular selection.'); Exit; end; MakeRoi(left,top,1,height); for i:=0 to width-1 do begin SetForeground(i); fill; MoveRoi(1,0); end; KillRoi; RestoreState; end; macro 'Make Vertical Grey Scale'; var left,top,width,height,i:integer; begin SaveState; MakeNewWindow('Vertical Grey Scale'); SelectAll; GetRoi(left,top,Width,Height); if width=0 then begin PutMessage('This macro requires a rectangular selection.'); Exit; end; MakeRoi(left,top,width,1); for i:=0 to height-1 do begin SetForeground(i); fill; MoveRoi(0,1); end; KillRoi; RestoreState; end; macro 'Plot Histogram'; var max,scale:real; i,margin,width,height:integer; begin SaveState; Margin:=10; width:=256; height:=0.6*256; Measure; SetForegroundColor(255); SetBackgroundColor(0); SetLineWidth(1); SetNewSize(width+2*margin,height+2*margin); MakeNewWindow('Histogram'); MakeRoi(margin,margin-1,width,height+1); DrawBoundary; max:=0; for i:=1 to 254 do if histogram[i]> max then max:=histogram[i]; scale:=height/max; for i:=1 to 254 do begin MakeRoi(margin+i,margin,1,histogram[i]*scale); SetForegroundColor(i); fill; end; SelectAll; FlipVertical; KillRoi; RestoreState; end; macro 'Inject Salt + Pepper Noise'; var r:real; x,y,i:integer; begin SaveState; for i:=1 to 2000 do begin y := 255.9 * random; x := 255.9 * random; putpixel(x,y,0); end; RestoreState; end; procedure ImpulseFilter; {This is an impulse filter (all zeros with a 1 in the middle) minus a 5x5 average (5x5 1's divided by 25), then scaled so the smallest tap is 1 (i.e. times 25).} begin RequiresVersion(1.53); NewTextWindow('5x5 mean diff',150,140); writeln('-1 -1 -1 -1 -1'); writeln('-1 -1 -1 -1 -1'); writeln('-1 -1 24 -1 -1'); writeln('-1 -1 -1 -1 -1'); writeln('-1 -1 -1 -1 -1'); ScaleConvolutions(true); Convolve(''); Dispose; end; macro 'Impulse Filter'; begin RequiresVersion(1.53); ImpulseFilter; end; macro '3x3 Sharpen [F]'; begin NewTextWindow('3x3 sharpen',120,120); writeln('-1 -1 -1'); writeln('-1 9 -1'); writeln('-1 -1 -1'); Convolve(''); Dispose end; macro '5x5 Laplace'; begin NewTextWindow('5x5 laplace',140,120); writeln('-1 -1 -1 -1 -1'); writeln('-1 -1 -1 -1 -1'); writeln('-1 -1 24 -1 -1'); writeln('-1 -1 -1 -1 -1'); writeln('-1 -1 -1 -1 -1'); Convolve(''); Dispose; end; macro '7x7 Gauss'; begin NewTextWindow('7x7 gauss',160,140); writeln(' 1 1 2 2 2 1 1'); writeln(' 1 2 2 4 2 2 1'); writeln(' 2 2 4 8 4 2 2'); writeln(' 2 4 8 16 8 4 2'); writeln(' 2 2 4 8 4 2 2'); writeln(' 1 2 2 4 2 2 1'); writeln(' 1 1 2 2 2 1 1'); Convolve(''); Dispose; end;