📄 lines3h.h
字号:
//*******************************************************************
#define comment_alllines
#ifndef comment_alllines
void alllines(int *Ends,int Nfi4,int xSize,
int *rulelines,int *lines,int Enfi1)
{ // if not USEPEANO or ROTATING_BOX, this must be reconsidere
// By now we do not use this function since it seems does not speed up (as it was intended)
int E=0,rl=0,l=0,nfi,NP,it_beg,it_end,xB,yB,Count,it,xSizeBN=xSize*BN,
xB_inc,yB_inc,np;
for (nfi=0;nfi<=Nfi4;nfi++)
{
rulelines[rl++]=Ends[E++];// - nfi here
NP=rulelines[rl++]=Ends[E++];// - NP=2*Np+1 - number of lines for given fi
xB_inc=Ends[E++];yB_inc=Ends[E++];
for (np=0;np<NP;np++)
{ it_beg=rulelines[rl++]=Ends[E++];
it_end=rulelines[rl++]=Ends[E++];
xB=Ends[E++];
yB=Ends[E++];
Count=it_end-it_beg+1;
for (it=Count;it>0;it--) // line is traced:
{
//lines[l++]=(xB>>dg)+xSize*(yB>>dg);
/* NPV(xB)PVN(dg)PS("check : xB>0?")PAU
int X=xB>>dg,Y=yB>>dg;if ((X<0)||(X>400)||(Y<0)||(Y>200))
PAUSE(" ???lines3h,1Quad Wants a pixel out of image");
*/
lines[l++]=dilute[xB>>dg]+dilute0[yB>>dg];
//"the 1st only difference from line2h.h"
// the coordinated are X=xB>>dg;Y=yB>>dg;
xB += xB_inc;
yB += yB_inc;
}
}//for (np
}//for (nfi=
E=Enfi1;
int Nfi=2*Nfi4;
for (nfi=Nfi-1;nfi>Nfi4;nfi--)//nfi is in reverse order
{
rulelines[rl++]=Nfi-Ends[E++]; // should be nfi
NP=rulelines[rl++]=Ends[E++]; // should be NP=2*Np+1
xB_inc=Ends[E++];yB_inc=-Ends[E++];
for (np=0;np<NP;np++)
{ it_end=-Ends[E++];
it_beg=-Ends[E++];
rulelines[rl++]=it_beg;rulelines[rl++]=it_end;
Count=it_end-it_beg+1;
xB=xSizeBN-Ends[E++]-xB_inc*(Count-1);
yB=Ends[E++]-yB_inc*(Count-1);
for (it=Count;it>0;it--) // line is traced:
{
//NPV(NP)PV(Count)PV(xB)PV(yB)PVN(dg)PAU PAUSE("check lines3h 2Quad");
// int X=xB>>dg,Y=yB>>dg;if ((X<0)||(X>400)||(Y<0)||(Y>200))
// PAUSE(" ???lines3h,2Quad Wants a pixel out of image");
//lines[l++]=(xB>>dg)+xSize*(yB>>dg);
lines[l++]=dilute[xB>>dg]+dilute0[yB>>dg];
//"the 2nd only difference from line2h.h"
// the coordinated are X=xB>>dg;Y=yB>>dg;
xB += xB_inc;
yB += yB_inc;
}
}//for (p
}//for (nfi=
}//END.
#endif //comment
////////////////////////////////allEndsRotatingBox
//the same: const int dg=12,BN=1<<dg;const int BN2=1<<(dg-1);
int *allEndsRotatingBox(int xSize,int ySize,int Nfi4,double dp,double dt,
int*MaxInd_p,int*Enfi1,int*Ltrack)
// This corresponds trace transform such that
// fi takes 4*Nfi4 values,p takes *MaxInd_p (odd) values,
// t takes L (odd) values
// Format int*Ends
// "number_of_trace_lines_for_this_nfi" = Dimp,it is independent of fi
// "it_beg","it_end" are fixed, they are
// nfi=0, ,xB_inc,yB_inc,
// xB,yB - for the first line
// xB,yB - for the second line
// ...
// nfi=1(-its address=pnfi1),xB_inc,yB_inc,
// xB,yB - for the first line
// xB,yB - for the second line
// ...
// ...
// nfi=Nfi4,xB_inc,yB_inc,
// it_end,xB,yB - for the first line
// it_end,xB,yB - for the second line
// ...
// nfi=Nfi4+1,xB_inc,yB_inc,
// xB,yB - for the first line
// xB,yB - for the second line
// ...
//************************************************************
{
//A pixel is a square of 1x1; Centers of pixels start form O=(0,0) in the plane
int Xsz1=xSize-1,Ysz1=ySize-1;//-OXY coordinates of far most pixel corner
double cX=Xsz1/2.0,cY=Ysz1/2.0; //image geometrical center in OXY, 2.-point is essential
//int Zsize=min(xSize,ySize);Zsz1=Zsize-1;
double xszH=0.5+cX,yszH=0.5+cY;//image semi-width
double zszH=minD(xszH,yszH);
double tHUGE=sqrt(0.5)*zszH-0.001;//maximal possible abs(t) and abs(p)
int Np=*MaxInd_p= (int) floor(tHUGE/dp);//along p we have no fine coordinates, so 0.001 is enough
//*****************************************
int Nfi=2*Nfi4; double dfi=pi/Nfi;
int xSizeBN=xSize*BN,ySizeBN=ySize*BN;//,zSizeBN=zSize*BN;
int it_end=(int) floor( (zszH-1./(2.*BN)) / (sqrt(2)*dt+1./BN) -0.001),
it_beg=-it_end;
int L=*Ltrack=it_end-it_beg+1; //=int(1+2*floor(tHUGE/dt));
int nfi;
double fi,cfi,sfi,ort1,ort2;int np;
// p loop:
double p,xbase,ybase;
int xB, xB_inc,yB, yB_inc;
int Count1=it_end-it_beg,rem1,rem2;
int maxparallellines=1+2*(*MaxInd_p);
int *ends=new int[2*(*MaxInd_p)];int e=0;///dimension????????
int LEnds = 1+(Nfi4+1)*(3+2*maxparallellines);
int *Ends=new int[LEnds];int E=0;
nfi=0; Ends[E++]=nfi;
cfi=1,sfi=0,ort1=-sfi,ort2=cfi;
xB_inc=0; yB_inc=round((dt*ort2)*BN);//-going to fine coordinates
Ends[E++]=xB_inc;Ends[E++]=yB_inc;
ybase=0;
yB=round((cY+ybase)*BN)+yB_inc*it_beg+BN2;
rem1=xB_inc*it_beg+BN2;
for (np=-Np;np<=Np;np++)
{ p=np*dp; xbase=p,
xB=round((cX+xbase)*BN)+rem1;
Ends[E++]=xB;
Ends[E++]=yB;
}
*Enfi1=E;
for (nfi=1;nfi<Nfi4;nfi++)
{Ends[E++]=nfi;
fi=dfi*nfi,cfi=cos(fi),sfi=sin(fi),ort1=-sfi,ort2=cfi;
// Given fi and Size find pmax by projecting one (it is sufficient) corners of the image
// to the vector (cfi,sfi); then p in [-pmax,pmax]
xB_inc=round((dt*ort1)*BN); yB_inc=round((dt*ort2)*BN);//-going to fine coordinates
Ends[E++]=xB_inc;Ends[E++]=yB_inc;
e=0; int remm1=xB_inc*it_beg+BN2,remm2=yB_inc*it_beg+BN2,
remm3=xB_inc*Count1,remm4=yB_inc*Count1;
for (np=-Np;np<0;np++)
{p=np*dp;xbase=p*cfi,ybase=p*sfi; //the nearest point in the track line to the center of the image
// Going to fine coordinates:
xB=round((cX+xbase)*BN)+remm1;
yB=round((cY+ybase)*BN)+remm2;
Ends[E++]=xB;
Ends[E++]=yB;
ends[e++]=xB+remm3; //???take a part out of loop
ends[e++]=yB+remm4;
}
np=0;
{xbase=0,ybase=0; //the nearest point in the track line to the center of the image
// the track line equations: x=xbase+t*ort1;y=ybase+t*ort2;
// Going to fine coordinates:
xB=round((cX+xbase)*BN)+xB_inc*it_beg+BN2;
yB=round((cY+ybase)*BN)+yB_inc*it_beg+BN2;
Ends[E++]=xB;
Ends[E++]=yB;
}
for (np=1;np<=Np;np++)
{
yB= ySizeBN-ends[--e];
xB= xSizeBN-ends[--e];//"+BN" =+2*BN2, it is due to rounding
Ends[E++]=xB;
Ends[E++]=yB;
}
}///for (nfi=1;nfi<Nfi4;nfi++)
nfi=Nfi4;
Ends[E++]=nfi;
fi=dfi*nfi,cfi=0,sfi=1,ort1=-sfi,ort2=cfi;
xB_inc=round((dt*ort1)*BN); yB_inc=0;//-going to fine coordinates
Ends[E++]=xB_inc;Ends[E++]=yB_inc;
xbase=0;
xB=round((cX+xbase)*BN)+xB_inc*it_beg+BN2; // -going to fine coordinates
rem2=yB_inc*it_beg+BN2;
for (np=-Np;np<=Np;np++)
{p=np*dp; ybase=p;
yB=round((cY+ybase)*BN)+rem2; // -going to fine coordinates
Ends[E++]=xB;
Ends[E++]=yB;
}
return Ends;
}//END.int *allEnds(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -