home *** CD-ROM | disk | FTP | other *** search
/ GRIPS 2: Government Rast…rocessing Software & Data / GRIPS_2.cdr / mac / nih_image / image_1_33g / macros / r_macros < prev    next >
Encoding:
Text File  |  1990-09-26  |  1.9 KB  |  111 lines

  1. macro 'Subtract Background [S]';
  2. var
  3.   i:integer;
  4. begin
  5.   if nPics<>1 then begin
  6.     PutMessage('Exactly one window must be open.');
  7.     exit;
  8.   end;
  9.   SelectAll;
  10.   Duplicate('Background Corrected');  {id=2}
  11.   Duplicate('Background');            {id=3}
  12.   ScaleSelection(.25,.25);
  13.   RestoreRoi;
  14.   for i:=1 to 10 do begin
  15.     SetOption; Smooth;
  16.   end;
  17.   ScaleSelection(4,4);
  18.   SelectAll;
  19.   Copy;
  20.   SelectPic(2);
  21.   Paste;
  22.   Subtract;
  23.   ResetGrayMap;
  24.   SelectPic(3);
  25.   Dispose;
  26. end;
  27.  
  28.  
  29. macro 'Clear Outside and set Threshold [C]';
  30.  {Erase region outside current selection to background color.}
  31. var
  32.   i,PixelCount,mean,mode,min,max,RoiLeft,RoiTop,RoiWidth,RoiHeight:integer;
  33. begin
  34.   GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight);
  35.   if RoiWidth=0 then begin
  36.     PutMessage('Define region of interest first.');
  37.     exit;
  38.   end;
  39.   Copy;
  40.   SelectAll;
  41.   Clear;
  42.   RestoreRoi;
  43.   Paste;
  44.   KillRoi;
  45.   RestoreRoi;
  46.   Redirect(false);
  47.   Measure;
  48.   GetResults(PixelCount,mean,mode,min,max);
  49.   SetDensitySlice(mean,mean+40);
  50.   {
  51.   MoveTo(20,20);
  52.   DrawNumber(mean);
  53.   DrawNumber(mean+40);
  54.   }
  55. end;
  56.  
  57.  
  58. macro 'Binary Filtering [B]';
  59. var
  60.   i:integer;
  61. begin
  62.   KillRoi;
  63.   MakeBinary;
  64.   For i:=1 to 3 do Erode;
  65.   for i:=1 to 3 do dilate;
  66.   KillRoi;
  67. end;
  68.  
  69.  
  70. macro 'Paste Background [P]';
  71.   {Paste binary filtered image to orignalimage}
  72. begin
  73.   SelectPic(2);
  74.   SetThreshold(192);
  75.   MakeBinary;
  76.   SelectAll;
  77.   Copy;
  78.   SelectPic(1);
  79.   SetForegroundColor(0);
  80.   Paste;
  81.   DoOr;
  82.   ShowPasteControl;
  83. end;
  84.  
  85.  
  86. macro 'Make Hardcopy [H]';
  87.   begin
  88.     SelectAll;
  89.     Print;
  90.   end;
  91.   
  92.  
  93. macro 'Analyze Particles [A]';
  94.   {Analyze Particles, measure area size}
  95. begin
  96.   Redirect(true);
  97.   LabelParticles(true);
  98.   OutlineParticles(true);
  99.   IgnoreParticlesTouchingEdge(true);
  100.   MeasureArea(true);
  101.   MeasureDensity(true);
  102.   SetParticleSize(200,99999);
  103.   AnalyzeParticles;
  104. end;
  105.  
  106.  
  107. macro 'Dispose Background [D]';
  108.   begin
  109.     SelectPic(3);
  110.     Dispose;
  111.   end;