Reducing eps if count > 5*minPts
Signed-off-by: James Ketrenos <james_gitlab@ketrenos.com>
This commit is contained in:
parent
026b0cf0a2
commit
f5c3c14257
@ -42,6 +42,7 @@ typedef struct Face {
|
|||||||
|
|
||||||
typedef struct FaceLink {
|
typedef struct FaceLink {
|
||||||
struct FaceLink *pNext;
|
struct FaceLink *pNext;
|
||||||
|
long double distance;
|
||||||
Face *pFace;
|
Face *pFace;
|
||||||
} FaceLink;
|
} FaceLink;
|
||||||
|
|
||||||
@ -145,6 +146,7 @@ FaceLink *RangeQuery(Face **ppFaces, long int faceCount, Face *pQ, double eps) {
|
|||||||
if (pQ->distances[i] > 0.0 && pQ->distances[i] <= eps) {
|
if (pQ->distances[i] > 0.0 && pQ->distances[i] <= eps) {
|
||||||
FaceLink *pLink = malloc(sizeof(*pLink));
|
FaceLink *pLink = malloc(sizeof(*pLink));
|
||||||
memset(pLink, 0, sizeof(*pLink));
|
memset(pLink, 0, sizeof(*pLink));
|
||||||
|
pLink->distance = pQ->distances[i];
|
||||||
pLink->pFace = pFace;
|
pLink->pFace = pFace;
|
||||||
pLink->pNext = pNeighbors;
|
pLink->pNext = pNeighbors;
|
||||||
pNeighbors = pLink;
|
pNeighbors = pLink;
|
||||||
@ -170,8 +172,6 @@ long int chainLength(FaceLink *pLink) {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
long int maxPts = 0;
|
|
||||||
|
|
||||||
long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) {
|
long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) {
|
||||||
long int C = 0;
|
long int C = 0;
|
||||||
for (long int i = 0; i < faceCount; i++) {
|
for (long int i = 0; i < faceCount; i++) {
|
||||||
@ -184,18 +184,22 @@ long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double threshold = eps;
|
||||||
FaceLink *pNeighbors = RangeQuery(ppFaces, faceCount, pFace, eps);
|
FaceLink *pNeighbors = RangeQuery(ppFaces, faceCount, pFace, eps);
|
||||||
long neighborCount = chainLength(pNeighbors);
|
long neighborCount = chainLength(pNeighbors);
|
||||||
if (neighborCount > maxPts) {
|
while (neighborCount > minPts * 5) {
|
||||||
maxPts = neighborCount;
|
fprintf(stderr, "\nWith eps of %f, %ld has %ld neighbors.", threshold, pFace->faceId, neighborCount);
|
||||||
fprintf(stderr, "New max with id %ld: %ld\n", pFace->faceId, maxPts);
|
threshold *= 0.9;
|
||||||
|
freeChain(pNeighbors);
|
||||||
|
pNeighbors = RangeQuery(ppFaces, faceCount, pFace, threshold);
|
||||||
|
neighborCount = chainLength(pNeighbors);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (neighborCount < minPts) {
|
if (neighborCount < minPts) {
|
||||||
pFace->clusterType = NOISE;
|
pFace->clusterType = NOISE;
|
||||||
freeChain(pNeighbors);
|
freeChain(pNeighbors);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("%ld has %ld neighbors.\n", pFace->faceId, neighborCount);
|
//printf("%ld has %ld neighbors.\n", pFace->faceId, neighborCount);
|
||||||
|
|
||||||
C++;
|
C++;
|
||||||
@ -224,11 +228,15 @@ long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) {
|
|||||||
|
|
||||||
FaceLink *pSubNeighbors = RangeQuery(ppFaces, faceCount, pQ, eps);
|
FaceLink *pSubNeighbors = RangeQuery(ppFaces, faceCount, pQ, eps);
|
||||||
neighborCount = chainLength(pSubNeighbors);
|
neighborCount = chainLength(pSubNeighbors);
|
||||||
|
while (neighborCount > minPts * 5) {
|
||||||
|
fprintf(stderr, "\nWith eps of %f, %ld has %ld neighbors.", threshold, pFace->faceId, neighborCount);
|
||||||
|
threshold *= 0.9;
|
||||||
|
freeChain(pNeighbors);
|
||||||
|
pNeighbors = RangeQuery(ppFaces, faceCount, pFace, threshold);
|
||||||
|
neighborCount = chainLength(pNeighbors);
|
||||||
|
}
|
||||||
|
|
||||||
if (neighborCount >= minPts) {
|
if (neighborCount >= minPts) {
|
||||||
if (neighborCount > maxPts) {
|
|
||||||
maxPts = neighborCount;
|
|
||||||
fprintf(stderr, "New max with id %ld: %ld\n", pFace->faceId, maxPts);
|
|
||||||
}
|
|
||||||
pQ->clusterType = CORE;
|
pQ->clusterType = CORE;
|
||||||
/* Append these neighbors to the end of the chain */
|
/* Append these neighbors to the end of the chain */
|
||||||
FaceLink *pTmp = pLink;
|
FaceLink *pTmp = pLink;
|
||||||
@ -376,7 +384,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (profileDistance <= 0.5) {
|
if (profileDistance <= 0.5) {
|
||||||
fprintf(stderr, "Face id %ld distance from profile face: %Lf\n",
|
fprintf(stderr, "\nFace id %ld distance from profile face: %Lf",
|
||||||
ppFaces[processed]->faceId, profileDistance);
|
ppFaces[processed]->faceId, profileDistance);
|
||||||
/* This entry will be skipped */
|
/* This entry will be skipped */
|
||||||
entries--;
|
entries--;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user