# orientation smoothing

Is there a function for orientation smoothing?

Note: If orientation smooths by cvSmooth the orientation map will be broken.

edit retag close merge delete

What do you mean by the orientation map? Are you talking about affine or perspective transformation matrices? Please update your question with more details.

( 2012-10-25 02:34:10 -0500 )edit

Please search "fingerprint orientation map" .

( 2012-10-26 04:06:17 -0500 )edit

Sort by ยป oldest newest most voted

I solve it by the following code:

#define BH_RAD_TO_DEG   180/CV_PI
{
for (int i=0; i < srcMat->rows ;i++)
{
float* srcP = srcMat->data.fl + srcMat->width * i;
float* dstP = dstMat->data.fl + dstMat->width * i;

for (int j = 0; j < srcMat->cols ;j++)
}
}

void bh2Deg(CvMat* srcMat,CvMat* dstMat)
{
for (int i=0; i < srcMat->rows ;i++)
{
float* srcP = srcMat->data.fl + srcMat->width * i;
float* dstP = dstMat->data.fl + dstMat->width * i;

for (int j = 0; j < srcMat->cols ;j++)
}
}
void bhSin2Mat(CvMat* srcMat,CvMat* dstMat)
{
for (int i=0; i < srcMat->rows;i++)
{
float* srcP = srcMat->data.fl + srcMat->width * i;
float* dstP = dstMat->data.fl + dstMat->width * i;

for (int j=0; j < srcMat->cols;j++)
dstP[j] = sin(2 * srcP[j]);

}
}
void bhCos2Mat(CvMat* srcMat,CvMat* dstMat)
{
for (int i=0; i < srcMat->rows;i++)
{
float* srcP = srcMat->data.fl + srcMat->width * i;
float* dstP = dstMat->data.fl + dstMat->width * i;

for (int j=0; j < srcMat->cols;j++)
dstP[j] = cos(2 * srcP[j]);

}

}

void bhATanMat(CvMat* sinMat,CvMat* cosMat, CvMat* dstMat)
{
for (int i=0; i < dstMat->rows;i++)
{
float* sinP = sinMat->data.fl + sinMat->width * i;
float* cosP = cosMat->data.fl + cosMat->width * i;

float* dstP = dstMat->data.fl + dstMat->width * i;

for (int j=0; j < dstMat->cols;j++)
{
if (dstP[j] < 0) dstP[j] = 180 + dstP[j];
}
}

}
void bhSmoothOrientation(CvMat* srcMat,CvMat* dstMat,bool normalize, int smoothType,int size1 ,int size2 ,double sigma1 ,double sigma2)
{
double min_value,max_value;
if (normalize)
{
cvMinMaxLoc(srcMat,&min_value,&max_value);
cvNormalize(srcMat,dstMat,0,180,CV_MINMAX);
}

CvMat* sinMat = cvCreateMat(dstMat->rows,dstMat->cols,CV_32FC1);
CvMat* cosMat = cvCreateMat(dstMat->rows,dstMat->cols,CV_32FC1);

bhSin2Mat(dstMat,sinMat);
cvSmooth(sinMat,sinMat,smoothType, size1,size2,sigma1,sigma2);
bhCos2Mat(dstMat,cosMat);
cvSmooth(cosMat,cosMat,smoothType, size1,size2,sigma1,sigma2);

bhATanMat(sinMat,cosMat,dstMat);

bh2Deg(dstMat,dstMat);

if (normalize)
cvNormalize(srcMat,dstMat,min_value,max_value,CV_MINMAX);

cvReleaseMat(&sinMat);
cvReleaseMat(&cosMat);
}

more

Official site

GitHub

Wiki

Documentation