Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
var
i:integer
left:integer
top:integer
w:integer
h:integer
numiter:real
index:integer
lefto:integer
topo:integer
hi:integer
wi:integer
wo:integer
ho:integer
size:integer
sindex:integer
pixCount:integer
small:integer
leftb:integer
topb:integer
wb:integer
hb:integer
mean:real
meanxx:real
mcount:real
sindexr:real
dsd:real
n:real
sumx:real
sumy:real
sumy2:real
sumx2:real
sumxy:real
b:real
b1:real
b2:real
b3:real
b4:real
b5:real
b6:real
b7:real
b8:real
b9:real
b10:real
sxx:real
sxy:real
syy:real
coeff:real
a:real
sigmab:real
sigmaa:real
see:real
r2:real
{rUser1 will hold slope values and rUser2 will hold r2 values for the regression}
procedure Fits; {this is a least mean squares fit, with y=ln(stdev*area) and
x=ln(area)}
{used for single slope caclulation}
begin
b:=0; sumx:=0; sumy:=0; sumx2:=0;sumxy:=0; sumy2:=0;
numiter := rCount;
for index:=1 to numiter do begin
sumx:=sumx+ln(rArea[index]);
sumy:=sumy+ln(rStdDev[index]*rArea[index]);
sumx2:=sumx2+(ln(rArea[index])*ln(rArea[index]));
sumxy:=sumxy+(ln(rArea[index])*ln(rStdDev[index]*rArea[index]));
sumy2:=sumy2+
(ln(rStdDev[index]*rArea[index])*ln(rStdDev[index]*rArea[index]));
end;
sxx:=sumx2-(sumx*sumx/numiter);
sxy:=sumxy-(sumx*sumy/numiter);
syy:=sumy2-(sumy*sumy/numiter);
b:=sxy/sxx;
a:=((sumx2*sumy-sumx*sumxy)/numiter)/sxx;
coeff:=sxy/sqrt(sxx*sxy);
r2:=(sxy*sxy)/(sxx*syy);
see:=sqrt((sumy2 - a*sumy - b*sumxy)/(numiter-1));
sigmab:=see/sqrt(sxx);
sigmaa:=sqrt(sumx2/numiter);
end;
macro 'MakeRoi'
begin
sindex:=1;
{this resets counter for shrinking rectangle}
ResetCounter;
GetRoi(left,top,w,h);
{but we want to remember the original Roi}
lefto:=left;topo:=top;wo:=w;ho:=h;small:=0;
{this shrinks the Roi and measures}
while (w-2>0) and (h-2>0) do begin
Measure;
small:=small+1;
InsetRoi(1);
GetRoi(left,top,w,h);
end;
GetRoi(left,top,w,h);
leftb:=left;topb:=top;wb:=w;hb:=h;
Fit;
{we have the first estimate of D}
rUser1[sindex]:=b; rUser2[sindex]:=r2;
sindex:=sindex+1;
{let's do it again, this time we shrink from the bottom left to the top right}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
ResetCounter;
i:=1;
GetRoi(left,top,w,h);
while (w-1 >1) and (h-1>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left+1,top,w-1,h-1);
GetRoi(left,top,w,h);
end;
Fit;
{we have the second estimate of D}
rUser1[sindex]:=b; rUser2[sindex]:=r2;
sindex:=sindex+1;
{let's do it again, this time we shrink the rectangle from the top left to the
bottom right}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
ResetCounter;
i:=1;
GetRoi(left,top,w,h);
while (w-1 >1) and (h-1>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left+1,top+1,w-1,h-1);
GetRoi(left,top,w,h);
end;
Fit;
{we have our third estimate of D}
rUser1[sindex]:=b; rUser2[sindex]:=r2;
sindex:=sindex+1;
{let's do it again, this time we shrink the rectangle from the top right to the
bottom left}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
ResetCounter;
i:=1;
GetRoi(left,top,w,h);
while (w-1 >1) and (h-1>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left,top+1,w-1,h-1);
GetRoi(left,top,w,h);
end;
Fit;
{we have our fourth estimate of D}
rUser1[sindex]:=b; rUser2[sindex]:=r2;
sindex:=sindex+1;
{let's do it again, this time we shrink the rectangle from the bottom right to the
top left}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
ResetCounter;
i:=1;
GetRoi(left,top,w,h);
while (w-1 >1) and (h-1>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left,top,w-1,h-1);
GetRoi(left,top,w,h);
end;
Fit;
{we have our fifth estimate of D}
rUser1[sindex]:=b; rUser2[sindex]:=r2;
sindex:=sindex+1;
{let's do it again, this time we shrink the rectangle from top to bottom}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
ResetCounter;
i:=1;
GetRoi(left,top,w,h);
while (w-2 >1) and (h-2>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left+1,top+1,w-1,h-1);
GetRoi(left,top,w,h);
end;
Fit;
{we have our sixth estimate of D}
rUser1[sindex]:=b; rUser2[sindex]:=r2;
sindex:=sindex+1;
{let's do it again, this time we shrink the rectangle from bottom to top}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
ResetCounter;
i:=1;
GetRoi(left,top,w,h);
while (w-2 >1) and (h-2>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left+1,top,w-1,h-1);
GetRoi(left,top,w,h);
i:=i+1;
end;
Fit;
{we have our seventh estimate of D}
rUser1[sindex]:=b; rUser2[sindex]:=r2;
sindex:=sindex+1;
begin
sindex:=1;
{this resets counter for shrinking rectangle}
ResetCounter;
GetRoi(left,top,w,h);
{but we want to remember the original Roi}
lefto:=left;topo:=top;wo:=w;ho:=h;small:=0;
{this shrinks the Roi and measures}
while (w-2>0) and (h-2>0) do begin
Measure;
small:=small+1;
InsetRoi(1);
GetRoi(left,top,w,h);
end;
{let's do it again, this time we shrink from the bottom left to the top right}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
i:=1;
GetRoi(left,top,w,h);
while (w-1 >1) and (h-1>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left+1,top,w-1,h-1);
GetRoi(left,top,w,h);
end;
{let's do it again, this time we shrink the rectangle from the top left to the
bottom right}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
i:=1;
GetRoi(left,top,w,h);
while (w-1 >1) and (h-1>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left+1,top+1,w-1,h-1);
GetRoi(left,top,w,h);
end;
{let's do it again, this time we shrink the rectangle from the top right to the
bottom left}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
i:=1;
GetRoi(left,top,w,h);
while (w-1 >1) and (h-1>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left,top+1,w-1,h-1);
GetRoi(left,top,w,h);
end;
{let's do it again, this time we shrink the rectangle from the bottom right to the
top left}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
i:=1;
GetRoi(left,top,w,h);
while (w-1 >1) and (h-1>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left,top,w-1,h-1);
GetRoi(left,top,w,h);
end;
{let's do it again, this time we shrink the rectangle from top to bottom}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
i:=1;
GetRoi(left,top,w,h);
while (w-2 >1) and (h-2>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left+1,top+1,w-1,h-1);
GetRoi(left,top,w,h);
end;
{let's do it again, this time we shrink the rectangle from bottom to top}
KillRoi;
MakeRoi(lefto,topo,wo,ho);
i:=1;
GetRoi(left,top,w,h);
while (w-2 >1) and (h-2>1) do begin
GetRoi(left,top,w,h);
Measure;
MakeRoi(left+1,top,w-1,h-1);
GetRoi(left,top,w,h);
i:=i+1;
end;