mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 13:10:12 +08:00
fixed bug #1381
This commit is contained in:
parent
1c738820de
commit
86882e5dd1
@ -342,41 +342,30 @@ int DistanceTransformTwoDimensionalProblem(const float *f,
|
||||
{
|
||||
int i, j, tmp;
|
||||
int resOneDimProblem;
|
||||
float *internalDistTrans;
|
||||
int *internalPointsX;
|
||||
int size = n * m;
|
||||
std::vector<float> internalDistTrans(size);
|
||||
std::vector<int> internalPointsX(size);
|
||||
|
||||
// Allocation memory (must be free in this function)
|
||||
internalDistTrans = (float *)malloc(sizeof(float) * size);
|
||||
internalPointsX = (int *)malloc(sizeof(int) * size);
|
||||
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
resOneDimProblem = DistanceTransformOneDimensionalProblem(
|
||||
f + i * m, m,
|
||||
coeff[0], coeff[2],
|
||||
internalDistTrans + i * m,
|
||||
internalPointsX + i * m);
|
||||
&internalDistTrans[i * m],
|
||||
&internalPointsX[i * m]);
|
||||
if (resOneDimProblem != DISTANCE_TRANSFORM_OK)
|
||||
{
|
||||
free(internalDistTrans);
|
||||
return DISTANCE_TRANSFORM_ERROR;
|
||||
} /* if (resOneDimProblem != DISTANCE_TRANSFORM_OK) */
|
||||
}
|
||||
Transpose(internalDistTrans, n, m);
|
||||
Transpose(&internalDistTrans[0], n, m);
|
||||
for (j = 0; j < m; j++)
|
||||
{
|
||||
resOneDimProblem = DistanceTransformOneDimensionalProblem(
|
||||
internalDistTrans + j * n, n,
|
||||
&internalDistTrans[j * n], n,
|
||||
coeff[1], coeff[3],
|
||||
distanceTransform + j * n,
|
||||
pointsY + j * n);
|
||||
if (resOneDimProblem != DISTANCE_TRANSFORM_OK)
|
||||
{
|
||||
free(internalDistTrans);
|
||||
return DISTANCE_TRANSFORM_ERROR;
|
||||
} /* if (resOneDimProblem != DISTANCE_TRANSFORM_OK) */
|
||||
}
|
||||
Transpose(distanceTransform, m, n);
|
||||
Transpose_int(pointsY, m, n);
|
||||
@ -390,8 +379,5 @@ int DistanceTransformTwoDimensionalProblem(const float *f,
|
||||
}
|
||||
}
|
||||
|
||||
// Release allocated memory
|
||||
free(internalDistTrans);
|
||||
free(internalPointsX);
|
||||
return DISTANCE_TRANSFORM_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user