Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit b708731

Browse files
committed
fix: avoid black pixels on patch borders
Closes: #236
1 parent 4f66625 commit b708731

12 files changed

+70
-2
lines changed

src/featureMatching/descriptors/__tests__/getBriefDescriptors.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ImageColorModel, Image, ImageCoordinates } from '../../../Image';
22
import { getOrientedFastKeypoints } from '../../keypoints/getOrientedFastKeypoints';
3+
import { getHammingDistance } from '../../matching/getHammingDistance';
34
import { drawKeypoints } from '../../visualize/drawKeypoints';
45
import { getBriefDescriptors } from '../getBriefDescriptors';
56

@@ -111,3 +112,46 @@ test('verify descriptor is correct (descriptorLength = 10)', () => {
111112
new Uint8Array([0, 0, 0, 0, 0, 0, 1, 0, 1, 0]),
112113
);
113114
});
115+
116+
test.only('compare scalene triangle keypoints', () => {
117+
const source = testUtils
118+
.load('featureMatching/polygons/scaleneTriangle.png')
119+
.convertColor(ImageColorModel.GREY);
120+
const sourceKeypoints = getOrientedFastKeypoints(source);
121+
const sourceBrief = getBriefDescriptors(source, sourceKeypoints);
122+
const destination = testUtils
123+
.load('featureMatching/polygons/scaleneTriangle10.png')
124+
.convertColor(ImageColorModel.GREY);
125+
const destinationKeypoints = getOrientedFastKeypoints(destination);
126+
const destinationBrief = getBriefDescriptors(
127+
destination,
128+
destinationKeypoints,
129+
);
130+
let result = [];
131+
132+
for (
133+
let srcIndex = 0;
134+
srcIndex < sourceBrief.descriptors.length;
135+
srcIndex++
136+
) {
137+
for (
138+
let dstIndex = 0;
139+
dstIndex < destinationBrief.descriptors.length;
140+
dstIndex++
141+
) {
142+
const distance = getHammingDistance(
143+
sourceBrief.descriptors[srcIndex],
144+
destinationBrief.descriptors[dstIndex],
145+
);
146+
result.push({ srcIndex, dstIndex, distance });
147+
}
148+
}
149+
150+
// 0-0 and 1-1 are the correct matches, so this looks good
151+
expect(result).toStrictEqual([
152+
{ srcIndex: 0, dstIndex: 0, distance: 15 },
153+
{ srcIndex: 0, dstIndex: 1, distance: 73 },
154+
{ srcIndex: 1, dstIndex: 0, distance: 77 },
155+
{ srcIndex: 1, dstIndex: 1, distance: 11 },
156+
]);
157+
});
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)