Skip to content

Commit c60d56c

Browse files
committed
wip: rough alignment of moon eclipse works
1 parent ab2d2ec commit c60d56c

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

scripts/alignStack/testAlignStack.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { crop, writeSync } from '../../src';
1010
const folder = `${__dirname}/BloodMoon`;
1111
let imageNames = readdirSync(folder);
1212

13-
imageNames = imageNames.slice(0, 2);
1413
console.log(imageNames);
1514

1615
const paths = imageNames.map((name) => `${folder}/${name}`);
@@ -26,7 +25,7 @@ console.log(
2625
console.log('Compute absolute translations');
2726
const translations = alignStack(stack, {
2827
debug: true,
29-
scalingFactor: 150,
28+
scalingFactor: 20,
3029
});
3130

3231
console.log('Cropping all images');

src/stack/align/utils/getMinDiffTranslation.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export function getMinDiffTranslation(
3636

3737
const maxRow = destination.height - source.height + topBottomMargin;
3838
const maxColumn = destination.width - source.width + leftRightMargin;
39-
40-
const nbTranslations = (maxRow + 1) * (maxColumn + 1);
41-
console.log({ nbTranslations: (maxRow + 1) * (maxColumn + 1) });
39+
const nbTranslations =
40+
(maxRow + 2 * topBottomMargin) * (maxColumn + 2 * leftRightMargin);
41+
console.log({ nbTranslations });
4242

4343
let minDiff = Number.MAX_SAFE_INTEGER;
4444
let minDiffTranslation: Point = { row: 0, column: 0 };
@@ -55,8 +55,12 @@ export function getMinDiffTranslation(
5555
minDiff = diff;
5656
minDiffTranslation = translation;
5757
}
58+
console.log(
59+
`translation ${
60+
row * (maxRow + topBottomMargin) + column
61+
} / ${nbTranslations}`,
62+
);
5863
}
5964
}
60-
console.log({ minDiff, minDiffTranslation });
6165
return minDiffTranslation;
6266
}

src/stack/align/utils/getNormalisedDifference.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,7 @@ export function getNormalisedDifference(
105105
)
106106
) {
107107
pixelCounted = true;
108-
if (
109-
sourceTranslation.column === 15 &&
110-
sourceTranslation.row === -12
111-
) {
112-
console.log({ column, row, channel });
113-
}
108+
114109
const sourceValue = source.getValue(
115110
column + sourceXOffet,
116111
row + sourceYOffset,
@@ -142,8 +137,6 @@ export function getNormalisedDifference(
142137
// If there are not enough pixels overlapping, we consider the difference to be maximal
143138
return 2 ** source.bitDepth - 1;
144139
}
145-
if (sourceTranslation.column === 15 && sourceTranslation.row === -12) {
146-
console.log({ nbPixels, diff: difference / nbPixels });
147-
}
140+
148141
return difference / nbPixels;
149142
}

0 commit comments

Comments
 (0)