home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-11-03 | 2.7 KB | 122 lines | [TEXT/Imag] |
- macro 'Convert Line Plot to Points [C]';
- {
- Requires a binary image conatining a black plot on a white
- background. Select the plot before running this macro. It may be
- necessary to increase Max Measurements in Options.
- }
- var
- left,top,width,height,i,nPixels,mean,mode,min,max:integer;
- begin
- RequiresVersion(1.45);
- Measure;
- GetResults(nPixels,mean,mode,min,max);
- if (histogram[0]+histogram[255])<>nPixels then begin
- PutMessage('This macro only works on binary images.');
- exit;
- end;
- if histogram[0]<histogram[255] then begin
- PutMessage('This macro requires a black plot on a white background.');
- exit;
- end;
- SaveState;
- GetRoi(left,top,width,height);
- if width=0 then begin
- PutMessage('Please select the line plot.');
- exit;
- end;
- Duplicate('Particles');
- i:=0;
- SetForegroundColor(0);
- SetLineWidth(1);
- repeat
- MoveTo(i,0);
- LineTo(i,height);
- i:=i+2;
- until i>width;
- RotateRight(true);
- SetOptions('X-Y Center');
- LabelParticles(false);
- SetParticleSize(1,999999);
- InvertY(false);
- AnalyzeParticles;
- RestoreState;
- end;
-
-
- macro 'Plot Points [P]';
- {
- Plots the data points contained in the X and Y results columns. Note
- that X and Y are reversed because Analyze Particles scans from top
- to bottom, not left to right.
- }
- var
- xmin,xmax,ymin,ymax,i,xscale,yscale:real;
- width,height,margin,pwidth,pheight:integer;
- begin
- SaveState;
- margin:=40;
- width:=500;
- height:=300;
- xmin:=999999;
- xmax:=-999999;
- ymin:=999999;
- ymax:=-999999;
- for i:=1 to rCount do begin
- if rX[i]<xmin then xmin:=rX[i];
- if rX[i]>xmax then xmax:=rX[i];
- if rY[i]<ymin then ymin:=rY[i];
- if rY[i]>ymax then ymax:=rY[i];
- end;
- SetNewSize(width,height);
- SetForeground(255);
- SetBackground(0);
- MakeNewWindow('Plot');
- pwidth:=width-2*margin;
- pheight:=height-2*margin;
- xscale:=pheight/(xmax-xmin);
- yscale:=pwidth/(ymax-ymin);
- SetForeground(255);
- SetBackground(0);
- MoveTo(margin,margin);
- for i:=1 to rCount do begin
- LineTo(margin+(rY[i]-ymin)*yscale,margin+(rX[i]-xmin)*xscale);
- end;
- MakeRoi(margin,margin,pwidth+1,pheight+2);
- MoveTo(margin,margin);
- LineTo(margin+pwidth,margin);
- MoveTo(margin,margin);
- LineTo(margin,margin+pheight);
- FlipVertical;
- KillRoi;
- SetFont('Geneva');
- SetFontSize(9);
- SetText('Centered');
- MoveTo(margin+4,margin+pheight+12);
- writeln(ymin:1:2);
- MoveTo(margin+pwidth,margin+pheight+12);
- writeln(ymax:1:2);
- SetText('Right Justified');
- MoveTo(margin-2,margin+pheight-5);
- writeln(xmin:1:2);
- MoveTo(margin-2,margin);
- writeln(xmax:1:2);
- RestoreState;
- end;
-
-
- macro 'Clear Outside [O]'
- {Outline the line plot with the wand tool and then use this macro to}
- {erase everything else.}
- begin
- Copy;
- SelectAll;
- Clear;
- RestoreRoi;
- Paste;
- KillRoi;
- end;
-
-
-
-
-