var width,height,thePic,theStack:integer; setup,markBoth,groupsNamed:boolean; g1,g2,g3,g4,g5,g6:string; {====================================} procedure Error(s:string); begin PutMessage(s); Exit; end; {====================================} macro '[W] Create Diagram Window'; var thePicName:string; begin if nPics<1 then error('You do not have any images open to outline!'); if nSlices>0 then error('This process does not work on stacks!'); thePic:=pidNumber; thePicName:=concat(WindowTitle,' Æ'); GetPicSize(width,height); SetNewSize(width,height); SaveState; SetBackgroundColor(0); MakeNewStack(thePicName); theStack:=pidNumber; selectPic(thePic); selectAll; copy; selectPic(theStack); paste; killROI; addSlice; killROI; selectSlice(1); RestoreState; selectPic(thePic); dispose; resetCounter; setUser1Label('Group'); setOptions('X-Y Center, Area, Length, User1'); setup:=true; end; {====================================} macro '[B] Outline Both? Yes|No'; begin markBoth:=not(markBoth); if markBoth then PutMessage('Both windows will show outline.'); if not(markBoth) then PutMessage('Only diagram window will show diagram.'); end; {====================================} macro '[O] Outline'; var n,whichSlice,x,y,roiWidth,roiHeight:integer; begin if not(setup) then error('Use "Create Diagram Window" First!'); if not(PidExists(theStack)) then error('Use "Create Diagram Window" First!'); getROI(x,y,roiWidth,roiHeight); if width=0 then error('You did not make a selection!'); if markBoth then drawBoundary; measure; selectSlice(2); restoreROI; drawBoundary; killROI; makeROI(0,0,1,1); copy; fill; rUser1[rCount]:=getPixel(0,0); paste; killROI; rX[rCount]:=roiWidth; rY[rCount]:=roiHeight; updateResults; selectSlice(1); end; {====================================} macro '[V] Overlay Diagram Window'; begin if not(setup) then error('Use "Create Diagram Window" First!'); SaveState; SetBackgroundColor(0); SetNewSize(width,height); MakeNewWindow('Overlay'); thePic:=pidNumber; selectPic(theStack); selectSlice(1);selectAll; copy; killROI; selectPic(thePic); paste; killROI; selectPic(theStack); selectSlice(2);selectAll; copy; killROI; selectPic(thePic); paste; doReplace; killROI; restoreState; end; macro'(-';begin end; {====================================} macro '[N] Name Groups...'; begin groupsNamed:=true; g1:=getString('Name of red group? (1)',''); g2:=getString('Name of green group? (2)',''); g3:=getString('Name of blue group? (3)',''); g4:=getString('Name of yellow group? (4)',''); g5:=getString('Name of cyan group? (5)',''); g6:=getString('Name of magenta group? (6)',''); end; {====================================} macro '[S] Sort & Show Results'; var i,j:integer; color:string; begin NewTextWindow('Measurement Results'); SaveState; SetFont('Courier'); writeln(' Group Area Perim Width Height'); writeln('-----------------------------------'); for i:=1 to 6 do begin if i=1 then color:='1 Red '; if i=2 then color:='2 Green '; if i=3 then color:='3 Blue '; if i=4 then color:='4 Yellow '; if i=5 then color:='5 Cyan '; if i=6 then color:='6 Magenta '; for j:= 1 to rCount do begin if rUser1[j]=i then begin writeln(color,rArea[j]:6:1,rLength[j]:6:1,rX[j]:6:1,rY[j]:6:1); end; end; end; if groupsNamed then begin writeln('-----------------------------------'); writeln(''); writeln('Key-----------------------'); if not(g1='') then writeln(' Red Group = ',g1); if not(g2='') then writeln(' Blue Group = ',g2); if not(g3='') then writeln(' Green Group = ',g3); if not(g4='') then writeln(' Yellow Group = ',g4); if not(g5='') then writeln(' Cyan Group = ',g5); if not(g6='') then writeln('Magenta Group = ',g6); writeln('--------------------------'); end; RestoreState; end; {====================================}