{ INCLUSION COUNTER: Photoshop Helper v1.0 Jeremy Brown 1997 --------------------------------------------------------- You must have run the macro "Help With Paths" when you first installed Inclusion counter on this Mac or these macros WILL NOT RUN! If you did not, DO SO NOW! This macro-file must be loaded into NIH Image to run. To Load "Photoshop Helper v1.0" choose "Load Macros From Window" from the "Special" menu then close this window. Alternatively press Apple-9 followed by Apple-W. The rage of macros that constitute this part of Inclusion Counter will then be displayed in the "Special" menu. --------------------------------------------------------- } Var ImageScale, MeanValue, n, m, radius, q, i, lower, upper, min, max, x1,x2,y1,y2,ignore1:integer; Sum, SumOfSquares:Boolean; ImageUnits:String; procedure ApplyROI; begin Open('PASTEHERE'); end; end; procedure MeanAreaValue; begin Sum := 0.0; For i := 1 to rCount do begin Sum := Sum + rArea[i]; end; Write(' ',Sum/rCount:0:0); end; end; Procedure StandardDeviation; begin If (rCount<3) then Begin; WriteLn (' 0'); end Else begin; SumOfSquares := 0.0; For i := 1 to rCount do begin; MeanValue := Sum/rCount; SumOfSquares:= SumOfSquares + Sqr( rArea[i] - MeanValue); end; n := rcount-1; M := SumOfSquares / n; WriteLn (' ',sqrt(M)); end; end; Procedure DeleteTouching; Var left,top,width,height:integer; begin SetThreshold(1); MakeBinary; WandAutoMeasure(false); GetROI(left,top,width,height); MakeLineROI(left,top,left+width-1,top); Drawboundary; AutoOutline(left,top); Clear; SetThreshold(1); MakeBinary; MakeLineROI(left,top,left,top+Height-1); Drawboundary; AutoOutline(left,top); Clear; SetThreshold(1); MakeBinary; MakeLineROI(left+width-1,top,left+width-1,top+Height-1); Drawboundary; AutoOutline(left+width-1,top); Clear; SetThreshold(1); MakeBinary; MakeLineROI(left,top+Height-1,left+width-1,top+Height-1); Drawboundary; AutoOutline(left,top+Height-1); Clear; SetThreshold(1); MakeBinary; end end; procedure ROISize; begin PutMessage('Please open your first image.'); Open(''); ApplyROI; SetScale(ImageScale,' ImageUnits'); ResetCounter; Measure; n:= rArea[1]; Dispose; SelectWindow ('Inclusions'); WriteLN(' ROI Area =' n, ImageUnits); end end Macro '[A] About Photoshop Helper v1.0' begin PutMessage('These macros are designed to automatically measure outlined images of inclusions generated in Photoshop 4.0 using the Actions Palette supplied with Inclusion Counter v1.0.'); end; end; macro '(---'; begin end; macro '[1] Set Region of Interest'; begin SetSaveAs('Outline'); SaveAs('PASTEHERE'); {127} end; end; Macro '[2] Set Scale part' begin PutMessage('Open an image of a graticule or other object of known dimensions at the same magnification as the images you wish process in this session.'); Open(''); PutMessage('This macro requires a line selection to set the scale. Use the line selection tool to trace a known distance on the graticule. Then run macro "Set Scale part 2".'); end; end; Macro '[3] Set Scale part' begin PutMessage('Before you proceed make sure that you have run the macro "Set Scale part 2" or completed the steps outlined therein. Fill in the KNOWN DISTANCE and Record the SCALE. '); SetScale(0, '' ); end; end; macro '(---'; begin end; Macro '[4] Process Photoshop Images'; { Image names must be in the form 'Image.0001', 'Image.0002', ..., but this can be changed. } begin ImageScale:=GetNumber('What is the scale of the images:', 1.130); ImageUnits:=GetString('What are the units of measurement:', ' µm2'); NewTextWindow('Manually Counted Inclusions'); SaveAs('Manually Counted Inclusions'); Write('Inclusions Area', ImageUnits ' STDEV'); ROISize; for q:= 1 to 1000 do begin; open('Image.',q:4); SetScale(ImageScale, ' ImageUnits'); AutoThreshold; MakeBinary; SetParticleSize(1, 100000); ApplyROI; DeleteTouching; ApplyROI; AnalyzeParticles('reset, label, outline'); If (rCount=0) then begin; SelectWindow ('Manually Counted Inclusions'); WriteLn (' 0 0 0'); End Else Begin; SelectWindow ('Manually Counted Inclusions'); Write(rCount); MeanAreaValue; StandardDeviation; Save; end; SelectWindow ('Image.',q:4); SaveAs ('Binary.',q:4); Dispose; end; end;