@photivra/engine 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/CITATION.cff +1 -1
  3. package/README.md +37 -3
  4. package/dist/index.d.ts +15 -2
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +15 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/motion/camera-rotation.d.ts +60 -0
  9. package/dist/motion/camera-rotation.d.ts.map +1 -1
  10. package/dist/motion/camera-rotation.js +95 -0
  11. package/dist/motion/camera-rotation.js.map +1 -1
  12. package/dist/motion/capture-rotation-inverse-mapping.d.ts +100 -0
  13. package/dist/motion/capture-rotation-inverse-mapping.d.ts.map +1 -0
  14. package/dist/motion/capture-rotation-inverse-mapping.js +171 -0
  15. package/dist/motion/capture-rotation-inverse-mapping.js.map +1 -0
  16. package/dist/motion/capture-rotation-temporal-quadrature.d.ts +89 -0
  17. package/dist/motion/capture-rotation-temporal-quadrature.d.ts.map +1 -0
  18. package/dist/motion/capture-rotation-temporal-quadrature.js +116 -0
  19. package/dist/motion/capture-rotation-temporal-quadrature.js.map +1 -0
  20. package/dist/motion/capture-rotation-trajectory.d.ts +98 -0
  21. package/dist/motion/capture-rotation-trajectory.d.ts.map +1 -0
  22. package/dist/motion/capture-rotation-trajectory.js +153 -0
  23. package/dist/motion/capture-rotation-trajectory.js.map +1 -0
  24. package/dist/optics/lateral-chromatic-aberration.d.ts.map +1 -1
  25. package/dist/optics/lateral-chromatic-aberration.js +12 -4
  26. package/dist/optics/lateral-chromatic-aberration.js.map +1 -1
  27. package/dist/optics/radial-distortion.d.ts +4 -2
  28. package/dist/optics/radial-distortion.d.ts.map +1 -1
  29. package/dist/optics/radial-distortion.js +83 -23
  30. package/dist/optics/radial-distortion.js.map +1 -1
  31. package/dist/output/capture-geometry.d.ts.map +1 -1
  32. package/dist/output/capture-geometry.js +24 -11
  33. package/dist/output/capture-geometry.js.map +1 -1
  34. package/dist/sensor/capture-color-sampling-binding.d.ts +211 -0
  35. package/dist/sensor/capture-color-sampling-binding.d.ts.map +1 -0
  36. package/dist/sensor/capture-color-sampling-binding.js +423 -0
  37. package/dist/sensor/capture-color-sampling-binding.js.map +1 -0
  38. package/dist/sensor/capture-mode.d.ts +157 -0
  39. package/dist/sensor/capture-mode.d.ts.map +1 -0
  40. package/dist/sensor/capture-mode.js +434 -0
  41. package/dist/sensor/capture-mode.js.map +1 -0
  42. package/dist/sensor/color-sampling.d.ts +133 -0
  43. package/dist/sensor/color-sampling.d.ts.map +1 -0
  44. package/dist/sensor/color-sampling.js +226 -0
  45. package/dist/sensor/color-sampling.js.map +1 -0
  46. package/dist/sensor/exposure-window.d.ts +103 -0
  47. package/dist/sensor/exposure-window.d.ts.map +1 -0
  48. package/dist/sensor/exposure-window.js +291 -0
  49. package/dist/sensor/exposure-window.js.map +1 -0
  50. package/dist/sensor/optical-stack.d.ts +132 -0
  51. package/dist/sensor/optical-stack.d.ts.map +1 -0
  52. package/dist/sensor/optical-stack.js +286 -0
  53. package/dist/sensor/optical-stack.js.map +1 -0
  54. package/dist/sensor/readout-exposure-linkage.d.ts +111 -0
  55. package/dist/sensor/readout-exposure-linkage.d.ts.map +1 -0
  56. package/dist/sensor/readout-exposure-linkage.js +210 -0
  57. package/dist/sensor/readout-exposure-linkage.js.map +1 -0
  58. package/dist/sensor/readout-timing.d.ts +124 -0
  59. package/dist/sensor/readout-timing.d.ts.map +1 -0
  60. package/dist/sensor/readout-timing.js +230 -0
  61. package/dist/sensor/readout-timing.js.map +1 -0
  62. package/dist/sensor/sampling-aperture.d.ts +154 -0
  63. package/dist/sensor/sampling-aperture.d.ts.map +1 -0
  64. package/dist/sensor/sampling-aperture.js +374 -0
  65. package/dist/sensor/sampling-aperture.js.map +1 -0
  66. package/dist/sensor/spatial-sample-reduction.d.ts +128 -0
  67. package/dist/sensor/spatial-sample-reduction.d.ts.map +1 -0
  68. package/dist/sensor/spatial-sample-reduction.js +299 -0
  69. package/dist/sensor/spatial-sample-reduction.js.map +1 -0
  70. package/dist/sensor/spatial-sampling-quadrature.d.ts +155 -0
  71. package/dist/sensor/spatial-sampling-quadrature.d.ts.map +1 -0
  72. package/dist/sensor/spatial-sampling-quadrature.js +197 -0
  73. package/dist/sensor/spatial-sampling-quadrature.js.map +1 -0
  74. package/docs/ARCHITECTURE.md +17 -0
  75. package/docs/AUTOMATION_COORDINATION.md +188 -0
  76. package/docs/IMAGE_FORMATION.md +26 -0
  77. package/docs/MOTION_AND_SIGNAL.md +142 -0
  78. package/docs/USAGE.md +1273 -3
  79. package/package.json +5 -3
@@ -0,0 +1,211 @@
1
+ import { type EvidenceProvenance } from "../core/evidence-provenance.js";
2
+ import { type CaptureModeProfile, type CaptureModeSampleCombinationDomain, type CaptureModeSensorOffsetNativeSamples, type SourcedCaptureModeFact } from "./capture-mode.js";
3
+ import { type SensorColorSamplingProfile } from "./color-sampling.js";
4
+ import type { NativeImageRaster } from "./sensor-geometry.js";
5
+ export interface NativeEffectiveRasterColorSamplingBindingProfile {
6
+ schemaVersion: "0.1.0";
7
+ bindingId: string;
8
+ colorSamplingProfileId: string;
9
+ /**
10
+ * Exact canonical native effective raster this binding was evidenced for.
11
+ * The binding must not be reused against a different raster merely because
12
+ * another sensor/mode has similar dimensions or a matching aspect ratio.
13
+ */
14
+ nativeRaster: NativeImageRaster;
15
+ /**
16
+ * Evidence supporting the native-effective-grid ↔ color-site-grid
17
+ * relationship itself.
18
+ *
19
+ * Capture-mode and color-topology facts retain separate provenance.
20
+ */
21
+ evidence: readonly EvidenceProvenance[];
22
+ relationship: {
23
+ kind: "regular-native-effective-sample-blocks";
24
+ /**
25
+ * Number of abstract color-sampling sites spanned horizontally by one
26
+ * native effective image sample.
27
+ */
28
+ sitesPerNativeSampleX: number;
29
+ /**
30
+ * Number of abstract color-sampling sites spanned vertically by one
31
+ * native effective image sample.
32
+ */
33
+ sitesPerNativeSampleY: number;
34
+ /**
35
+ * Both grids are anchored to the same native sensor top-left.
36
+ *
37
+ * This keeps phase absolute across later active crops/orientation.
38
+ */
39
+ anchor: "shared-native-top-left";
40
+ };
41
+ }
42
+ export interface ColorSamplingSiteGridDimensions {
43
+ widthSites: number;
44
+ heightSites: number;
45
+ }
46
+ export interface ResolvedNativeEffectiveRasterColorSamplingBinding {
47
+ bindingId: string;
48
+ colorSamplingProfileId: string;
49
+ nativeRaster: NativeImageRaster;
50
+ relationshipMeaning: "one-native-effective-sample-to-one-color-site" | "one-native-effective-sample-to-rectangular-color-site-block";
51
+ relationship: {
52
+ kind: "regular-native-effective-sample-blocks";
53
+ sitesPerNativeSampleX: number;
54
+ sitesPerNativeSampleY: number;
55
+ anchor: "shared-native-top-left";
56
+ };
57
+ colorSamplingSiteGrid: ColorSamplingSiteGridDimensions;
58
+ totalColorSamplingSites: number;
59
+ nativeImageRasterBindingEstablished: true;
60
+ physicalPhotodiodeBindingEstablished: false;
61
+ physicalPhotodiodeCountInference: "not-permitted";
62
+ spectralResponseEstablished: false;
63
+ componentEvidence: {
64
+ binding: readonly EvidenceProvenance[];
65
+ colorSamplingProfile: readonly EvidenceProvenance[];
66
+ };
67
+ }
68
+ export interface NativeEffectiveSampleRect {
69
+ x: number;
70
+ y: number;
71
+ width: number;
72
+ height: number;
73
+ }
74
+ export interface ColorSamplingSiteRect {
75
+ x: number;
76
+ y: number;
77
+ width: number;
78
+ height: number;
79
+ }
80
+ export interface CaptureModeFullFrameSampleIndex {
81
+ /**
82
+ * Zero-based index in the selected mode's full-frame per-frame effective
83
+ * sampling raster. Crop-local coordinates must be translated to absolute
84
+ * full-frame mode indices before calling this API.
85
+ */
86
+ x: number;
87
+ y: number;
88
+ }
89
+ export interface ColorSamplingChannelSiteCount {
90
+ channelId: string;
91
+ siteCount: number;
92
+ }
93
+ export type ColorSamplingChannelComposition = {
94
+ kind: "single-channel";
95
+ channelId: string;
96
+ } | {
97
+ kind: "mixed-channels";
98
+ channelIds: readonly string[];
99
+ };
100
+ export interface GroupedCaptureModeSamplingAnchorDeclaration {
101
+ anchor: "native-effective-raster-top-left";
102
+ evidence: readonly EvidenceProvenance[];
103
+ }
104
+ export interface ResolveCaptureModeColorSamplingContributorsInput {
105
+ nativeRaster: NativeImageRaster;
106
+ captureModeProfile: CaptureModeProfile;
107
+ modeId: string;
108
+ colorSamplingProfile: SensorColorSamplingProfile;
109
+ bindingProfile: NativeEffectiveRasterColorSamplingBindingProfile;
110
+ modeSampleIndexFullFrame: CaptureModeFullFrameSampleIndex;
111
+ /**
112
+ * Required for grouped-native-samples modes because #68 declares grouping
113
+ * factors but does not itself prove the grouping phase/origin.
114
+ */
115
+ groupedSamplingAnchor?: GroupedCaptureModeSamplingAnchorDeclaration;
116
+ }
117
+ export interface ResolvedCaptureModeColorSamplingContributors {
118
+ modeId: string;
119
+ modeSampleCoordinateSystem: "capture-mode-full-frame-effective-sample-index";
120
+ modeSampleIndexFullFrame: CaptureModeFullFrameSampleIndex;
121
+ modeSampleRaster: {
122
+ pixelWidth: number;
123
+ pixelHeight: number;
124
+ };
125
+ modeSamplingKind: "native-effective-raster" | "grouped-native-samples";
126
+ nativeEffectiveSampleRect: NativeEffectiveSampleRect;
127
+ colorSamplingSiteRect: ColorSamplingSiteRect;
128
+ colorSamplingSiteGrid: ColorSamplingSiteGridDimensions;
129
+ totalContributorSites: number;
130
+ channelSiteCounts: readonly ColorSamplingChannelSiteCount[];
131
+ channelComposition: ColorSamplingChannelComposition;
132
+ /**
133
+ * Present only when the selected capture mode groups native effective
134
+ * samples before producing one per-frame effective sample.
135
+ */
136
+ grouping: {
137
+ groupWidthSamples: SourcedCaptureModeFact<number>;
138
+ groupHeightSamples: SourcedCaptureModeFact<number>;
139
+ combinationDomain?: SourcedCaptureModeFact<CaptureModeSampleCombinationDomain>;
140
+ anchor: "native-effective-raster-top-left";
141
+ anchorEvidence: readonly EvidenceProvenance[];
142
+ } | null;
143
+ /**
144
+ * Sensor-shift sequence remains attached to the sensor/capture mode.
145
+ *
146
+ * The sensor and its CFA move together, so these offsets must not be applied
147
+ * as changes to color-site channel assignment.
148
+ */
149
+ interFrameSensorOffsetsNativeSamples?: SourcedCaptureModeFact<readonly CaptureModeSensorOffsetNativeSamples[]>;
150
+ sensorShiftChangesColorSiteAssignment: false;
151
+ sensorShiftOpticalRegistration: "outside-this-contract";
152
+ structuralSourceStage: "pre-reconstruction";
153
+ completeDownstreamPixelDependencyEstablished: false;
154
+ signalCombinationWeightingEstablished: false;
155
+ spectralResponseEstablished: false;
156
+ physicalPhotodiodeBindingEstablished: false;
157
+ physicalPhotodiodeCountInference: "not-permitted";
158
+ componentEvidence: {
159
+ binding: readonly EvidenceProvenance[];
160
+ colorSamplingProfile: readonly EvidenceProvenance[];
161
+ captureMode: readonly EvidenceProvenance[];
162
+ };
163
+ }
164
+ /**
165
+ * Parses the explicit relationship between the canonical native effective image
166
+ * raster and the separate native sensor color-sampling-site lattice.
167
+ *
168
+ * This first binding supports only regular rectangular site blocks with a
169
+ * shared native top-left anchor. Irregular mappings, sparse exceptions and
170
+ * mode-specific declared-effective rasters require later explicit contracts.
171
+ */
172
+ export declare function parseNativeEffectiveRasterColorSamplingBindingProfile(value: unknown): NativeEffectiveRasterColorSamplingBindingProfile;
173
+ /**
174
+ * Validates and resolves the sensor-level binding between NativeImageRaster and
175
+ * an exact monochrome/periodic color-sampling topology.
176
+ *
177
+ * Matching dimensions are never treated as proof of a 1:1 relationship. The
178
+ * relationship exists only because the caller supplied this evidence-backed
179
+ * binding profile.
180
+ */
181
+ export declare function resolveNativeEffectiveRasterColorSamplingBinding(input: {
182
+ nativeRaster: NativeImageRaster;
183
+ colorSamplingProfile: SensorColorSamplingProfile;
184
+ bindingProfile: NativeEffectiveRasterColorSamplingBindingProfile;
185
+ }): ResolvedNativeEffectiveRasterColorSamplingBinding;
186
+ /**
187
+ * Resolves which color-sampling sites form the pre-reconstruction structural source region for one selected
188
+ * capture-mode effective sample.
189
+ *
190
+ * The mode sample index is always absolute in the selected mode's full-frame
191
+ * per-frame raster. The API intentionally does not accept crop-local indices,
192
+ * preventing active-crop origins from silently resetting CFA phase.
193
+ *
194
+ * For grouped-native-sample modes, the returned site rectangle covers all
195
+ * native effective samples in the declared regular group. This is a structural
196
+ * pre-reconstruction association only: the engine reports channel-site counts
197
+ * but never claims complete downstream digital-pixel dependency or invents
198
+ * signal-combination weights, sum/average semantics, spectral response, or
199
+ * photon/electron values.
200
+ *
201
+ * Declared-effective-raster modes fail closed because #68 explicitly says
202
+ * their relationship to the native effective grid is not safely expressible as
203
+ * simple integer grouping.
204
+ *
205
+ * Inter-frame sensor shifts are preserved as capture-mode metadata only. The
206
+ * sensor and CFA move together, so those offsets do not change site channel
207
+ * assignment; their optical-registration effect belongs to a later spatial
208
+ * sampling/image-formation contract.
209
+ */
210
+ export declare function resolveCaptureModeColorSamplingContributors(input: ResolveCaptureModeColorSamplingContributorsInput): ResolvedCaptureModeColorSamplingContributors;
211
+ //# sourceMappingURL=capture-color-sampling-binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture-color-sampling-binding.d.ts","sourceRoot":"","sources":["../../src/sensor/capture-color-sampling-binding.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,gCAAgC,CAAC;AAKxC,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,kCAAkC,EACvC,KAAK,oCAAoC,EACzC,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,MAAM,WAAW,gDAAgD;IAC/D,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,YAAY,EAAE,iBAAiB,CAAC;IAChC;;;;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AAqID;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,2CAA2C,CACzD,KAAK,EAAE,gDAAgD,GACtD,4CAA4C,CAyR9C"}
@@ -0,0 +1,423 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { InvalidConfigurationError } from "../core/configuration-error.js";
3
+ import { parseEvidenceList } from "../core/evidence-provenance.js";
4
+ import { InvalidScientificInputError, requirePositiveInteger } from "../core/validation.js";
5
+ import { resolveCaptureMode } from "./capture-mode.js";
6
+ import { parseSensorColorSamplingProfile } from "./color-sampling.js";
7
+ function requireRecord(value, path) {
8
+ if (typeof value !== "object" ||
9
+ value === null ||
10
+ Array.isArray(value)) {
11
+ throw new InvalidConfigurationError(path + " must be an object.");
12
+ }
13
+ return value;
14
+ }
15
+ function requireNonEmptyString(value, path) {
16
+ if (typeof value !== "string" ||
17
+ value.trim().length === 0) {
18
+ throw new InvalidConfigurationError(path + " must be a non-empty string.");
19
+ }
20
+ return value;
21
+ }
22
+ function requirePositiveSafeInteger(value, path) {
23
+ if (typeof value !== "number" ||
24
+ !Number.isSafeInteger(value) ||
25
+ value <= 0) {
26
+ throw new InvalidConfigurationError(path + " must be a positive safe integer.");
27
+ }
28
+ return value;
29
+ }
30
+ function parseBoundNativeRaster(value) {
31
+ const nativeRaster = requireRecord(value, "colorSamplingBinding.nativeRaster");
32
+ const pixelWidth = requirePositiveSafeInteger(nativeRaster.pixelWidth, "colorSamplingBinding.nativeRaster.pixelWidth");
33
+ const pixelHeight = requirePositiveSafeInteger(nativeRaster.pixelHeight, "colorSamplingBinding.nativeRaster.pixelHeight");
34
+ if (!Number.isSafeInteger(pixelWidth * pixelHeight)) {
35
+ throw new InvalidConfigurationError("colorSamplingBinding.nativeRaster total image-sample count must be a safe integer.");
36
+ }
37
+ return {
38
+ pixelWidth,
39
+ pixelHeight
40
+ };
41
+ }
42
+ function safeProduct(values, path) {
43
+ let result = 1;
44
+ for (const value of values) {
45
+ result *= value;
46
+ if (!Number.isSafeInteger(result)) {
47
+ throw new InvalidScientificInputError(path + " must remain a safe integer.");
48
+ }
49
+ }
50
+ return result;
51
+ }
52
+ function validateNativeRaster(raster) {
53
+ requirePositiveInteger("nativeRaster.pixelWidth", raster.pixelWidth);
54
+ requirePositiveInteger("nativeRaster.pixelHeight", raster.pixelHeight);
55
+ safeProduct([raster.pixelWidth, raster.pixelHeight], "nativeRaster total image-sample count");
56
+ }
57
+ function requireFullFrameSampleIndex(value, path) {
58
+ if (typeof value !== "number" ||
59
+ !Number.isSafeInteger(value) ||
60
+ value < 0) {
61
+ throw new InvalidScientificInputError(path +
62
+ " must be a non-negative safe integer full-frame mode sample index.");
63
+ }
64
+ return value;
65
+ }
66
+ /**
67
+ * Parses the explicit relationship between the canonical native effective image
68
+ * raster and the separate native sensor color-sampling-site lattice.
69
+ *
70
+ * This first binding supports only regular rectangular site blocks with a
71
+ * shared native top-left anchor. Irregular mappings, sparse exceptions and
72
+ * mode-specific declared-effective rasters require later explicit contracts.
73
+ */
74
+ export function parseNativeEffectiveRasterColorSamplingBindingProfile(value) {
75
+ const profile = requireRecord(value, "colorSamplingBinding");
76
+ if (profile.schemaVersion !== "0.1.0") {
77
+ throw new InvalidConfigurationError('colorSamplingBinding.schemaVersion must be "0.1.0".');
78
+ }
79
+ const relationship = requireRecord(profile.relationship, "colorSamplingBinding.relationship");
80
+ if (relationship.kind !==
81
+ "regular-native-effective-sample-blocks") {
82
+ throw new InvalidConfigurationError("colorSamplingBinding.relationship.kind is invalid.");
83
+ }
84
+ if (relationship.anchor !==
85
+ "shared-native-top-left") {
86
+ throw new InvalidConfigurationError('colorSamplingBinding.relationship.anchor must be "shared-native-top-left".');
87
+ }
88
+ return {
89
+ schemaVersion: "0.1.0",
90
+ bindingId: requireNonEmptyString(profile.bindingId, "colorSamplingBinding.bindingId"),
91
+ colorSamplingProfileId: requireNonEmptyString(profile.colorSamplingProfileId, "colorSamplingBinding.colorSamplingProfileId"),
92
+ nativeRaster: parseBoundNativeRaster(profile.nativeRaster),
93
+ evidence: parseEvidenceList(profile.evidence, "colorSamplingBinding.evidence"),
94
+ relationship: {
95
+ kind: "regular-native-effective-sample-blocks",
96
+ sitesPerNativeSampleX: requirePositiveSafeInteger(relationship.sitesPerNativeSampleX, "colorSamplingBinding.relationship.sitesPerNativeSampleX"),
97
+ sitesPerNativeSampleY: requirePositiveSafeInteger(relationship.sitesPerNativeSampleY, "colorSamplingBinding.relationship.sitesPerNativeSampleY"),
98
+ anchor: "shared-native-top-left"
99
+ }
100
+ };
101
+ }
102
+ /**
103
+ * Validates and resolves the sensor-level binding between NativeImageRaster and
104
+ * an exact monochrome/periodic color-sampling topology.
105
+ *
106
+ * Matching dimensions are never treated as proof of a 1:1 relationship. The
107
+ * relationship exists only because the caller supplied this evidence-backed
108
+ * binding profile.
109
+ */
110
+ export function resolveNativeEffectiveRasterColorSamplingBinding(input) {
111
+ validateNativeRaster(input.nativeRaster);
112
+ const colorSamplingProfile = parseSensorColorSamplingProfile(input.colorSamplingProfile);
113
+ const bindingProfile = parseNativeEffectiveRasterColorSamplingBindingProfile(input.bindingProfile);
114
+ if (bindingProfile.colorSamplingProfileId !==
115
+ colorSamplingProfile.profileId) {
116
+ throw new InvalidScientificInputError("Binding colorSamplingProfileId must match colorSamplingProfile.profileId.");
117
+ }
118
+ if (bindingProfile.nativeRaster.pixelWidth !==
119
+ input.nativeRaster.pixelWidth ||
120
+ bindingProfile.nativeRaster.pixelHeight !==
121
+ input.nativeRaster.pixelHeight) {
122
+ throw new InvalidScientificInputError("Binding nativeRaster must exactly match the supplied canonical native effective raster.");
123
+ }
124
+ if (colorSamplingProfile.layout.kind === "layered") {
125
+ throw new InvalidScientificInputError("Layered color sampling cannot be bound to NativeImageRaster until its per-layer spatial sampling relationship is explicitly modeled.");
126
+ }
127
+ if (colorSamplingProfile.coordinateSystem !==
128
+ "native-sensor-color-sampling-site-index") {
129
+ throw new InvalidScientificInputError("Resolvable color sampling binding requires the native sensor color-sampling-site coordinate system.");
130
+ }
131
+ const widthSites = safeProduct([
132
+ input.nativeRaster.pixelWidth,
133
+ bindingProfile.relationship
134
+ .sitesPerNativeSampleX
135
+ ], "color-sampling site-grid width");
136
+ const heightSites = safeProduct([
137
+ input.nativeRaster.pixelHeight,
138
+ bindingProfile.relationship
139
+ .sitesPerNativeSampleY
140
+ ], "color-sampling site-grid height");
141
+ const totalColorSamplingSites = safeProduct([widthSites, heightSites], "color-sampling site-grid total site count");
142
+ const oneToOne = bindingProfile.relationship
143
+ .sitesPerNativeSampleX === 1 &&
144
+ bindingProfile.relationship
145
+ .sitesPerNativeSampleY === 1;
146
+ return {
147
+ bindingId: bindingProfile.bindingId,
148
+ colorSamplingProfileId: bindingProfile.colorSamplingProfileId,
149
+ nativeRaster: {
150
+ ...input.nativeRaster
151
+ },
152
+ relationshipMeaning: oneToOne
153
+ ? "one-native-effective-sample-to-one-color-site"
154
+ : "one-native-effective-sample-to-rectangular-color-site-block",
155
+ relationship: {
156
+ ...bindingProfile.relationship
157
+ },
158
+ colorSamplingSiteGrid: {
159
+ widthSites,
160
+ heightSites
161
+ },
162
+ totalColorSamplingSites,
163
+ nativeImageRasterBindingEstablished: true,
164
+ physicalPhotodiodeBindingEstablished: false,
165
+ physicalPhotodiodeCountInference: "not-permitted",
166
+ spectralResponseEstablished: false,
167
+ componentEvidence: {
168
+ binding: bindingProfile.evidence,
169
+ colorSamplingProfile: colorSamplingProfile.evidence
170
+ }
171
+ };
172
+ }
173
+ function countResidueInRange(start, length, period, residue) {
174
+ const startResidue = start % period;
175
+ const delta = (residue - startResidue + period) %
176
+ period;
177
+ if (delta >= length) {
178
+ return 0;
179
+ }
180
+ return (1 +
181
+ Math.floor((length - 1 - delta) / period));
182
+ }
183
+ function channelCountsForSiteRect(profile, rect) {
184
+ const totalSites = safeProduct([rect.width, rect.height], "color-sampling contributor site count");
185
+ if (profile.layout.kind === "layered") {
186
+ throw new InvalidScientificInputError("Layered color sampling does not have resolvable site contributors in schema 0.1.0.");
187
+ }
188
+ if (profile.layout.kind === "monochrome") {
189
+ return [
190
+ {
191
+ channelId: profile.layout.channelId,
192
+ siteCount: totalSites
193
+ }
194
+ ];
195
+ }
196
+ const counts = new Map();
197
+ for (let tileY = 0; tileY < profile.layout.repeatHeightSites; tileY += 1) {
198
+ const countY = countResidueInRange(rect.y, rect.height, profile.layout.repeatHeightSites, tileY);
199
+ if (countY === 0) {
200
+ continue;
201
+ }
202
+ for (let tileX = 0; tileX < profile.layout.repeatWidthSites; tileX += 1) {
203
+ const countX = countResidueInRange(rect.x, rect.width, profile.layout.repeatWidthSites, tileX);
204
+ if (countX === 0) {
205
+ continue;
206
+ }
207
+ const tileIndex = tileY *
208
+ profile.layout.repeatWidthSites +
209
+ tileX;
210
+ const channelId = profile.layout.siteChannelIds[tileIndex];
211
+ if (channelId === undefined) {
212
+ throw new InvalidScientificInputError("Periodic color-sampling tile resolution failed while calculating contributor counts.");
213
+ }
214
+ const siteCount = safeProduct([countX, countY], "per-channel contributor site count");
215
+ const prior = counts.get(channelId) ?? 0;
216
+ const next = prior + siteCount;
217
+ if (!Number.isSafeInteger(next)) {
218
+ throw new InvalidScientificInputError("Per-channel contributor site count must remain a safe integer.");
219
+ }
220
+ counts.set(channelId, next);
221
+ }
222
+ }
223
+ const result = Array.from(counts, ([channelId, siteCount]) => ({
224
+ channelId,
225
+ siteCount
226
+ }));
227
+ const countedTotal = result.reduce((sum, entry) => sum + entry.siteCount, 0);
228
+ if (countedTotal !== totalSites) {
229
+ throw new InvalidScientificInputError("Color-sampling contributor channel counts do not cover the complete contributor site rectangle.");
230
+ }
231
+ return result;
232
+ }
233
+ /**
234
+ * Resolves which color-sampling sites form the pre-reconstruction structural source region for one selected
235
+ * capture-mode effective sample.
236
+ *
237
+ * The mode sample index is always absolute in the selected mode's full-frame
238
+ * per-frame raster. The API intentionally does not accept crop-local indices,
239
+ * preventing active-crop origins from silently resetting CFA phase.
240
+ *
241
+ * For grouped-native-sample modes, the returned site rectangle covers all
242
+ * native effective samples in the declared regular group. This is a structural
243
+ * pre-reconstruction association only: the engine reports channel-site counts
244
+ * but never claims complete downstream digital-pixel dependency or invents
245
+ * signal-combination weights, sum/average semantics, spectral response, or
246
+ * photon/electron values.
247
+ *
248
+ * Declared-effective-raster modes fail closed because #68 explicitly says
249
+ * their relationship to the native effective grid is not safely expressible as
250
+ * simple integer grouping.
251
+ *
252
+ * Inter-frame sensor shifts are preserved as capture-mode metadata only. The
253
+ * sensor and CFA move together, so those offsets do not change site channel
254
+ * assignment; their optical-registration effect belongs to a later spatial
255
+ * sampling/image-formation contract.
256
+ */
257
+ export function resolveCaptureModeColorSamplingContributors(input) {
258
+ const colorSamplingProfile = parseSensorColorSamplingProfile(input.colorSamplingProfile);
259
+ const binding = resolveNativeEffectiveRasterColorSamplingBinding({
260
+ nativeRaster: input.nativeRaster,
261
+ colorSamplingProfile,
262
+ bindingProfile: input.bindingProfile
263
+ });
264
+ const captureMode = resolveCaptureMode({
265
+ nativeRaster: input.nativeRaster,
266
+ profile: input.captureModeProfile,
267
+ modeId: input.modeId
268
+ });
269
+ if (!captureMode.dependencies.includes("color-sampling-model")) {
270
+ throw new InvalidScientificInputError("Selected capture mode must declare the color-sampling-model dependency before color-site contributors can be resolved.");
271
+ }
272
+ const modeX = requireFullFrameSampleIndex(input.modeSampleIndexFullFrame.x, "modeSampleIndexFullFrame.x");
273
+ const modeY = requireFullFrameSampleIndex(input.modeSampleIndexFullFrame.y, "modeSampleIndexFullFrame.y");
274
+ if (captureMode.perFrameSampling.kind ===
275
+ "declared-effective-raster") {
276
+ throw new InvalidScientificInputError("declared-effective-raster capture modes require a separate mode-specific color-site binding; no relationship may be inferred from raster dimensions alone.");
277
+ }
278
+ const modeSampleRaster = captureMode.perFrameSampling.raster;
279
+ if (modeX >= modeSampleRaster.pixelWidth ||
280
+ modeY >= modeSampleRaster.pixelHeight) {
281
+ throw new InvalidScientificInputError("modeSampleIndexFullFrame must lie within the selected mode's full-frame per-frame sampling raster.");
282
+ }
283
+ let nativeEffectiveSampleRect;
284
+ let grouping;
285
+ if (captureMode.perFrameSampling.kind ===
286
+ "native-effective-raster") {
287
+ if (input.groupedSamplingAnchor !== undefined) {
288
+ throw new InvalidScientificInputError("groupedSamplingAnchor must be omitted for native-effective-raster capture modes.");
289
+ }
290
+ nativeEffectiveSampleRect = {
291
+ x: modeX,
292
+ y: modeY,
293
+ width: 1,
294
+ height: 1
295
+ };
296
+ grouping = null;
297
+ }
298
+ else {
299
+ if (input.groupedSamplingAnchor === undefined ||
300
+ input.groupedSamplingAnchor.anchor !==
301
+ "native-effective-raster-top-left") {
302
+ throw new InvalidScientificInputError("grouped-native-samples capture modes require an explicit native-effective-raster-top-left grouping anchor declaration.");
303
+ }
304
+ const groupingAnchorEvidence = parseEvidenceList(input.groupedSamplingAnchor.evidence, "groupedSamplingAnchor.evidence");
305
+ const groupWidth = captureMode.perFrameSampling
306
+ .groupWidthSamples.value;
307
+ const groupHeight = captureMode.perFrameSampling
308
+ .groupHeightSamples.value;
309
+ nativeEffectiveSampleRect = {
310
+ x: safeProduct([modeX, groupWidth], "native effective sample rectangle x"),
311
+ y: safeProduct([modeY, groupHeight], "native effective sample rectangle y"),
312
+ width: groupWidth,
313
+ height: groupHeight
314
+ };
315
+ grouping = {
316
+ groupWidthSamples: captureMode.perFrameSampling
317
+ .groupWidthSamples,
318
+ groupHeightSamples: captureMode.perFrameSampling
319
+ .groupHeightSamples,
320
+ ...(captureMode.perFrameSampling
321
+ .combinationDomain === undefined
322
+ ? {}
323
+ : {
324
+ combinationDomain: captureMode.perFrameSampling
325
+ .combinationDomain
326
+ }),
327
+ anchor: "native-effective-raster-top-left",
328
+ anchorEvidence: groupingAnchorEvidence
329
+ };
330
+ }
331
+ const sitesPerNativeX = binding.relationship
332
+ .sitesPerNativeSampleX;
333
+ const sitesPerNativeY = binding.relationship
334
+ .sitesPerNativeSampleY;
335
+ const colorSamplingSiteRect = {
336
+ x: safeProduct([
337
+ nativeEffectiveSampleRect.x,
338
+ sitesPerNativeX
339
+ ], "color-sampling contributor rectangle x"),
340
+ y: safeProduct([
341
+ nativeEffectiveSampleRect.y,
342
+ sitesPerNativeY
343
+ ], "color-sampling contributor rectangle y"),
344
+ width: safeProduct([
345
+ nativeEffectiveSampleRect.width,
346
+ sitesPerNativeX
347
+ ], "color-sampling contributor rectangle width"),
348
+ height: safeProduct([
349
+ nativeEffectiveSampleRect.height,
350
+ sitesPerNativeY
351
+ ], "color-sampling contributor rectangle height")
352
+ };
353
+ if (colorSamplingSiteRect.x +
354
+ colorSamplingSiteRect.width >
355
+ binding.colorSamplingSiteGrid.widthSites ||
356
+ colorSamplingSiteRect.y +
357
+ colorSamplingSiteRect.height >
358
+ binding.colorSamplingSiteGrid.heightSites) {
359
+ throw new InvalidScientificInputError("Resolved color-sampling contributor rectangle exceeds the bound color-site grid.");
360
+ }
361
+ const totalContributorSites = safeProduct([
362
+ colorSamplingSiteRect.width,
363
+ colorSamplingSiteRect.height
364
+ ], "total contributor site count");
365
+ const channelSiteCounts = channelCountsForSiteRect(colorSamplingProfile, colorSamplingSiteRect);
366
+ const firstChannel = channelSiteCounts[0];
367
+ if (firstChannel === undefined) {
368
+ throw new InvalidScientificInputError("Resolved structural source region must contain at least one color-sampling channel.");
369
+ }
370
+ const channelComposition = channelSiteCounts.length === 1
371
+ ? {
372
+ kind: "single-channel",
373
+ channelId: firstChannel.channelId
374
+ }
375
+ : {
376
+ kind: "mixed-channels",
377
+ channelIds: channelSiteCounts.map((entry) => entry.channelId)
378
+ };
379
+ return {
380
+ modeId: captureMode.modeId,
381
+ modeSampleCoordinateSystem: "capture-mode-full-frame-effective-sample-index",
382
+ modeSampleIndexFullFrame: {
383
+ x: modeX,
384
+ y: modeY
385
+ },
386
+ modeSampleRaster: {
387
+ ...modeSampleRaster
388
+ },
389
+ modeSamplingKind: captureMode.perFrameSampling.kind,
390
+ nativeEffectiveSampleRect,
391
+ colorSamplingSiteRect,
392
+ colorSamplingSiteGrid: {
393
+ ...binding.colorSamplingSiteGrid
394
+ },
395
+ totalContributorSites,
396
+ channelSiteCounts,
397
+ channelComposition,
398
+ grouping,
399
+ ...(captureMode
400
+ .interFrameSensorOffsetsNativeSamples ===
401
+ undefined
402
+ ? {}
403
+ : {
404
+ interFrameSensorOffsetsNativeSamples: captureMode
405
+ .interFrameSensorOffsetsNativeSamples
406
+ }),
407
+ sensorShiftChangesColorSiteAssignment: false,
408
+ sensorShiftOpticalRegistration: "outside-this-contract",
409
+ structuralSourceStage: "pre-reconstruction",
410
+ completeDownstreamPixelDependencyEstablished: false,
411
+ signalCombinationWeightingEstablished: false,
412
+ spectralResponseEstablished: false,
413
+ physicalPhotodiodeBindingEstablished: false,
414
+ physicalPhotodiodeCountInference: "not-permitted",
415
+ componentEvidence: {
416
+ binding: binding.componentEvidence.binding,
417
+ colorSamplingProfile: binding.componentEvidence
418
+ .colorSamplingProfile,
419
+ captureMode: captureMode.modeEvidence
420
+ }
421
+ };
422
+ }
423
+ //# sourceMappingURL=capture-color-sampling-binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture-color-sampling-binding.js","sourceRoot":"","sources":["../../src/sensor/capture-color-sampling-binding.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAKnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,+BAA+B,EAEhC,MAAM,qBAAqB,CAAC;AA2L7B,SAAS,aAAa,CACpB,KAAc,EACd,IAAY;IAEZ,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EACpB,CAAC;QACD,MAAM,IAAI,yBAAyB,CACjC,IAA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