void EHFS_ScoreGrad::MakeImGradRhoTeta ( Im2D_U_INT1 OutRho, Im2D_U_INT1 OutTeta, Im2D_INT1 InPutGx, Im2D_INT1 InPutGy, INT1 def ) { VerifSize(OutRho); VerifSize(OutTeta); MakeImGradXY(mImLocGX,mImLocGY,InPutGx,InPutGy,def); U_INT1 ** dRho = OutRho.data(); U_INT1 ** dTeta = OutTeta.data(); INT1 ** dGx = mImLocGX.data(); INT1 ** dGy = mImLocGY.data(); for (INT y=0; y<= 2* mNbYMax ; y++) for (INT x=0; x<=mNbX ; x++) { Pt2dr rt = Pt2dr::polar(Pt2dr(dGx[y][x],dGy[y][x]),PI); dRho[y][x] = ElMin(255,round_ni(rt.x)); dTeta[y][x] = mod(round_ni(rt.y*128.0/PI),256); } }
void Revert(Im2D_U_INT1 anIm) { for (INT y=0; y<anIm.ty() ; y++) for (INT x1=0,x2 =anIm.tx()-1; x1<x2 ;x1++,x2-- ) ElSwap(anIm.data()[y][x1],anIm.data()[y][x2]); }
void EHFS_ScoreGrad::MakeImMaxLoc(Im1D_U_INT1 ImMaxLoc,Im2D_U_INT1 InRho) { VerifSize(ImMaxLoc); VerifSize(InRho); U_INT1 * dMax = ImMaxLoc.data(); U_INT1 ** dRho = InRho.data(); for (INT x=0; x<=mNbX ; x++) { INT yMaxL1 = mNbYMax; while ((yMaxL1<2*mNbYMax) && (dRho[yMaxL1][x]<=dRho[yMaxL1+1][x])) yMaxL1++; INT yMaxL2 = mNbYMax; while ((yMaxL2>0) && (dRho[yMaxL2][x]<=dRho[yMaxL2-1][x])) yMaxL2--; dMax[x] = (ElAbs(yMaxL1-mNbYMax)>ElAbs(yMaxL2-mNbYMax)) ? yMaxL1 : yMaxL2; } }
void drawPoint(Im2D_U_INT1 &aImage, int aX, int aY, U_INT1 aValue) { if (aX >=0 && aX < aImage.tx() && aY >= 0 && aY < aImage.ty()) aImage.data()[aY][aX] = aValue; }
bool CalcMaxLoc<Type,TypeBase,Compare>::BandeConnectedVsup ( Pt2di p1, Pt2di p2, Im2D<Type,TypeBase> Im, Type VInf, REAL Tol, Im2D_U_INT1 Marq ) { if (p1==p2) return true; Pt2di Sz = Inf(Im.sz(),Marq.sz()); Box2di Box(Pt2di(0,0), Sz); if (!(Box.contains(p1) && Box.contains(p2))) return false; U_INT1 ** dMarq = Marq.data(); Type ** dIm = Im.data(); mBufCC.clear(); mBufCC.push_back(p1); dMarq[p1.y][p1.x] = 1; Pt2dr aPR1(p1.x,p1.y); Pt2dr aPR2(p2.x,p2.y); SegComp seg12(aPR1,aPR2); bool got = false; for (INT kBuf=0 ; (kBuf!=(INT)mBufCC.size()) && (! got) ; kBuf++) { Pt2di pBuf = mBufCC[ kBuf]; for (INT kV=0 ; kV< 8; kV++) { Pt2di pVois = pBuf + TAB_8_NEIGH[kV]; if ( Box.contains(pVois) && (dMarq[pVois.y][pVois.x] == 0) && (! mCmp(dIm[pVois.y][pVois.x],VInf)) && (seg12.BoxContains(Pt2dr(pVois),1.0,Tol)) ) { if (pVois==p2) got = true; dMarq[pVois.y][pVois.x] = 1; mBufCC.push_back(pVois); } } } { for (INT kBuf=0 ; kBuf<(INT)mBufCC.size() ; kBuf++) { Pt2di pBuf = mBufCC[ kBuf]; dMarq[pBuf.y][pBuf.x] = 0; } } return got; }