{Macros for performing simple visual translational image registration} {Modified 3/1/93} var ImageToRegister, RegistrationImage:integer; OrigTop,OrigLeft,OrigWidth,OrigHeight,stage:integer; macro 'Define Image to Register [1]'; begin RequiresVersion(1.48); If npics <> 2 then begin Putmessage('You must have exactly two images open. One to register to, the other to register.'); exit; end; GetROI(OrigLeft,OrigTop,OrigWidth,OrigHeight); if OrigWidth=0 then begin PutMessage('Use Select All or create an ROI on the image you want registered.'); exit; end; ImageToRegister := PicNumber; ShowPasteControl; Copy; NextWindow; RegistrationImage:=PicNumber; Showmessage('Run the second macro.'); RestoreRoi; Stage:=1; end; macro 'Register [2]'; begin if stage<>1 then begin PutMessage('Use the Define Image to Register macro first.'); exit; end; Showmessage('Move the ROI to the visual registration point and run the third macro.'); Paste; SetOption; DoXOr; stage:=2; end; macro 'Create registered image [3]'; var MovedTop,MovedLeft,MovedWidth,MovedHeight:integer; OrigMovedTop,OrigMovedLeft,OrigMovedWidth,OrigMovedHeight:integer; NewTop,NewLeft,NewWidth,NewHeight:integer; width, height:integer; BEGIN if stage<>2 then begin PutMessage('Use the Define and Register macros first.'); exit; end; Undo; GetPicSize(width, height); SelectPic(RegistrationImage); RestoreRoi; GetROI(Movedleft,Movedtop,Movedwidth,Movedheight); if MovedTop < 0 then begin OrigMovedTop := OrigTop-Movedtop; NewTop := 0; OrigMovedHeight := OrigHeight + MovedTop; NewHeight := OrigHeight + MovedTop; end else begin OrigMovedTop := Origtop; NewTop := MovedTop; OrigMovedHeight := MovedHeight; NewHeight := MovedHeight; end; if Movedleft < 0 then begin OrigMovedLeft :=OrigLeft-Movedleft; NewLeft := 0; end else begin OrigMovedLeft := OrigLeft; NewLeft := MovedLeft; end; if (Movedleft + MovedWidth) > width then begin OrigMovedwidth := width-Movedleft; NewWidth:= width-Movedleft; end else begin OrigMovedWidth := MovedWidth; NewWidth:= MovedWidth; end; SelectPic(ImageToRegister); KillROI; MakeROI(OrigMovedLeft,OrigMovedTop,OrigMovedwidth,OrigMovedheight); Copy; SetNewSize(width,height); MakeNewWindow('Registered'); MakeROI(Newleft,Newtop,Newwidth,Newheight); Paste; Showmessage('The ROI portion of your original image has been copied to the registered image.'); END;