{=================================================================} {=================================================================} Macro 'Frame Eliminate [F5]'; { This Macro will select the appropriate slices to analyze and store the results (replacing the existing file). Copyright 1995, Theodore Hodapp, Jesse Smasal, Hamline University Physics Department. } var slindex, start, stop, numsl: Integer begin numsl := nSlices; start := GetNumber('Enter the first good frame #: ', 1, 0); stop := GetNumber('Enter the last good frame #: ', numsl, 0); ShowMessage('Start,stop,frames=',start,stop,numsl); If stop < numsl then begin For slindex := stop+1 to numsl do begin ChooseSlice(stop+1); DeleteSlice; end; end; If start > 1 then begin For slindex := 1 to start-1 do begin ChooseSlice(1); DeleteSlice; end; end; end; {=================================================================} {=================================================================} macro 'Extract Even&Odd Fields [F6]'; { Replaces each slice of the given stack with two new slices that have had their odd and even scan lines replaced with the average of neighboring even or odd lines respectively. Can be used to improve the quality of images that have even and odd fields that are out of sync as the result of subject movement during capture. Copyright 1995, Theodore Hodapp, Jesse Smasal, Hamline University Physics Department. } var CountSlices,Counter,i,width,height,evenrow1,evenrow2,oddrow1,oddrow2:integer; n,stack:integer; begin if (nPics > 1) then begin PutMessage('This macro will not work when more than one window is open.'); exit; end; CountSlices:=nSlices; NextWindow; for Counter:=1 to CountSlices do begin ChooseSlice(Counter); SaveState; { Get Even rows } Duplicate('Even Field ',Counter:0:1); GetPicSize(width,height); evenrow1:=0; evenrow2:=0; oddrow1:=1; oddrow2:=1; for i:=1 to height/2 do begin GetRow(0,evenrow1,width); PutRow(0,evenrow2,width); evenrow1:=evenrow1+2; evenrow2:=evenrow2+1; end; { Scale and save them } MakeRoi(0,0,width,height/2); Copy; MakeRoi(0,height/4-1,width,height/2); Paste; RestoreRoi; SetScaling('Bilinear; Same Window'); ScaleAndRotate(1,2,0); RestoreState; NextWindow; { Get Odd rows } Duplicate('Odd Field ',Counter:0:1); for i:=1 to height/2 do begin GetRow(0,oddrow1,width); PutRow(0,oddrow2,width); oddrow1:=oddrow1+2; oddrow2:=oddrow2+1; end; { Scale and save them } MakeRoi(0,0,width,height/2); Copy; MakeRoi(0,height/4-1,width,height/2); Paste; RestoreRoi; SetScaling('Bilinear; Same Window'); ScaleAndRotate(1,2,0); RestoreState; NextWindow; end; Close; { Now convert open windows to a stack -- This routine basically from NIH } if nPics<=1 then begin PutMessage('At least two images must be open.'); exit; end; if (nSlices>0) then begin PutMessage('This macro does not work with stacks.'); exit; end; if odd(width) then width:=width-1; n:=nPics; SaveState; SetNewSize(width,height); MakeNewStack('Stack'); stack:=nPics; for i:=1 to n do begin SelectPic(1); MakeRoi(0,0,width,height); copy; Dispose; SelectPic(nPics); paste; if i<>n then AddSlice; end; KillRoi; RestoreState; end; {=================================================================} {=================================================================} macro 'Get X-Y Points [F7]'; { This macro gets a set of x-y data points from a movie. The movie is rewound, and then each frame is displayed sequentially. The user picks a point with the mouse, and its coordinates are recorded in a data window. At the end, the data is saved. Copyright 1995, Theodore Hodapp, Jesse Smasal, Hamline University Physics Department. } var CountSlices,Counter, width, height:integer; x,y:integer; begin if (nPics > 1) then begin PutMessage('This macro will not work when more than one window is open.'); exit; end; GetPicSize(width,height); InvertY(true); { Open a window for the data. } NewTextWindow('Data',250,250); MoveWindow(250,320); Writeln('Frame, X, Y'); SetCursor('cross'); CountSlices:=nSlices; for Counter:=1 to CountSlices do begin ChooseSlice(Counter); NextWindow; ShowMessage('Select a point on your object with the cursor and then press the mouse button.'); Repeat Until Button; GetMouse(x,y); Wait(.1); SelectWindow('Data'); Writeln(Counter:5:0,',',x:5:0,',',(height-y):5:0,); end; ShowMessage(''); Save; end; {=================================================================} {=================================================================} macro 'Shuffle odd for even [F8]'; { Shuffles a stack by inverting the order of odd and even frames in the stack. Useful when you read in a video image and extract odd/even fields, as sometimes they come out in reverse order! Copyright 1995, Theodore Hodapp, Hamline University Physics Department } var badslices, Counter, width, height, bad, good:integer; begin badslices:=nSlices; bad := PicNumber; if (nSlices < 2) then begin PutMessage('This macro must have a stack to work.'); exit; end; if (nPics > 1) then begin PutMessage('This macro will not work when more than one window is open.'); exit; end; GetPicSize(width,height); SetNewSize(width,height); MakeNewStack('Stack 2 (unshuffled)'); good := PicNumber; Counter := 2; While (Counter <= badslices) do begin SelectPic(bad); ChooseSlice(Counter); MakeRoi(0,0,width,height); copy; SelectPic(good); paste; AddSlice; SelectPic(bad); ChooseSlice(Counter-1); MakeRoi(0,0,width,height); copy; SelectPic(good); paste; AddSlice; Counter := Counter + 2; end; DeleteSlice; KillRoi; end; {=================================================================} {=================================================================} macro 'Close all image windows but the active one [F9]'; { This Macro closes all open image windows except the active one! Copyright 1995, Theodore Hodapp, Hamline University Physics Department } var current:integer; begin current := PidNumber; While (nPics > 1) do begin NextWindow; Dispose; SelectPic(current); end; end; {=================================================================} {=================================================================}