@photivra/engine 1.4.0 → 2.0.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.
- package/CHANGELOG.md +401 -6
- package/CITATION.cff +1 -1
- package/NODE_SUPPORT.md +64 -12
- package/README.md +301 -182
- package/SECURITY.md +37 -28
- package/THIRD_PARTY.md +148 -4
- package/dist/camera/equivalent-focal-length.d.ts +13 -14
- package/dist/camera/equivalent-focal-length.js +15 -13
- package/dist/camera/equivalent-focal-length.js.map +1 -1
- package/dist/camera/field-of-view.d.ts +30 -19
- package/dist/camera/field-of-view.js +67 -18
- package/dist/camera/field-of-view.js.map +1 -1
- package/dist/camera/lens-projection.d.ts +170 -0
- package/dist/camera/lens-projection.js +444 -0
- package/dist/camera/lens-projection.js.map +1 -0
- package/dist/camera/projected-object-size.d.ts +10 -11
- package/dist/camera/projected-object-size.js +12 -10
- package/dist/camera/projected-object-size.js.map +1 -1
- package/dist/capture/capture-export-metadata.d.ts +9 -10
- package/dist/capture/capture-export-metadata.js +8 -5
- package/dist/capture/capture-export-metadata.js.map +1 -1
- package/dist/capture/dng-import.d.ts +91 -0
- package/dist/capture/dng-import.js +343 -0
- package/dist/capture/dng-import.js.map +1 -0
- package/dist/capture/environment-raw-producer.d.ts +37 -17
- package/dist/capture/environment-raw-producer.js +43 -19
- package/dist/capture/environment-raw-producer.js.map +1 -1
- package/dist/capture/export-jpeg.d.ts +35 -4
- package/dist/capture/export-jpeg.js +133 -47
- package/dist/capture/export-jpeg.js.map +1 -1
- package/dist/capture/export-tiff.d.ts +48 -24
- package/dist/capture/export-tiff.js +91 -31
- package/dist/capture/export-tiff.js.map +1 -1
- package/dist/capture/focus-control.d.ts +42 -65
- package/dist/capture/focus-control.js +56 -75
- package/dist/capture/focus-control.js.map +1 -1
- package/dist/capture/host-yield-cadence.d.ts +25 -0
- package/dist/capture/host-yield-cadence.js +25 -0
- package/dist/capture/host-yield-cadence.js.map +1 -0
- package/dist/capture/linear-encoding.d.ts +14 -12
- package/dist/capture/linear-encoding.js +14 -13
- package/dist/capture/linear-encoding.js.map +1 -1
- package/dist/capture/lossless-jpeg.d.ts +27 -0
- package/dist/capture/lossless-jpeg.js +237 -0
- package/dist/capture/lossless-jpeg.js.map +1 -0
- package/dist/capture/native-environment-lean.d.ts +227 -0
- package/dist/capture/native-environment-lean.js +974 -0
- package/dist/capture/native-environment-lean.js.map +1 -0
- package/dist/capture/native-environment-optical-stage.d.ts +97 -0
- package/dist/capture/native-environment-optical-stage.js +340 -0
- package/dist/capture/native-environment-optical-stage.js.map +1 -0
- package/dist/capture/native-environment-raw.d.ts +140 -6
- package/dist/capture/native-environment-raw.js +435 -34
- package/dist/capture/native-environment-raw.js.map +1 -1
- package/dist/capture/native-raw-development.d.ts +118 -5
- package/dist/capture/native-raw-development.js +224 -59
- package/dist/capture/native-raw-development.js.map +1 -1
- package/dist/capture/native-raw-dng.d.ts +60 -0
- package/dist/capture/native-raw-dng.js +167 -0
- package/dist/capture/native-raw-dng.js.map +1 -0
- package/dist/capture/native-raw.d.ts +67 -10
- package/dist/capture/native-raw.js +90 -24
- package/dist/capture/native-raw.js.map +1 -1
- package/dist/capture/packed-sensor-raw.d.ts +160 -0
- package/dist/capture/packed-sensor-raw.js +221 -0
- package/dist/capture/packed-sensor-raw.js.map +1 -0
- package/dist/capture/photographic-export.d.ts +58 -35
- package/dist/capture/photographic-export.js +177 -70
- package/dist/capture/photographic-export.js.map +1 -1
- package/dist/capture/raw-development-kernel.d.ts +52 -0
- package/dist/capture/raw-development-kernel.js +88 -0
- package/dist/capture/raw-development-kernel.js.map +1 -0
- package/dist/capture/raw-frame-limits.d.ts +7 -7
- package/dist/capture/raw-frame-limits.js +7 -6
- package/dist/capture/raw-frame-limits.js.map +1 -1
- package/dist/capture/raw-frame-reconstruction.d.ts +8 -9
- package/dist/capture/raw-frame-reconstruction.js +9 -8
- package/dist/capture/raw-frame-reconstruction.js.map +1 -1
- package/dist/capture/raw-white-level.d.ts +55 -0
- package/dist/capture/raw-white-level.js +165 -0
- package/dist/capture/raw-white-level.js.map +1 -0
- package/dist/capture/release-sequence.d.ts +5 -7
- package/dist/capture/release-sequence.js +15 -13
- package/dist/capture/release-sequence.js.map +1 -1
- package/dist/capture/sensor-raw-frame.d.ts +5 -6
- package/dist/capture/sensor-raw-frame.js +26 -9
- package/dist/capture/sensor-raw-frame.js.map +1 -1
- package/dist/capture/sensor-raw-producer.d.ts +21 -13
- package/dist/capture/sensor-raw-producer.js +86 -25
- package/dist/capture/sensor-raw-producer.js.map +1 -1
- package/dist/capture/simulated-capture.d.ts +15 -16
- package/dist/capture/simulated-capture.js +22 -12
- package/dist/capture/simulated-capture.js.map +1 -1
- package/dist/color/camera-color-matrix.d.ts +69 -0
- package/dist/color/camera-color-matrix.js +132 -0
- package/dist/color/camera-color-matrix.js.map +1 -0
- package/dist/color/capture-color.d.ts +17 -10
- package/dist/color/capture-color.js +50 -17
- package/dist/color/capture-color.js.map +1 -1
- package/dist/color/chromatic-adaptation.d.ts +63 -0
- package/dist/color/chromatic-adaptation.js +91 -0
- package/dist/color/chromatic-adaptation.js.map +1 -0
- package/dist/color/color-difference.d.ts +104 -0
- package/dist/color/color-difference.js +205 -0
- package/dist/color/color-difference.js.map +1 -0
- package/dist/color/color-matching-functions.d.ts +168 -0
- package/dist/color/color-matching-functions.js +309 -0
- package/dist/color/color-matching-functions.js.map +1 -0
- package/dist/color/colorimetry-math.d.ts +52 -0
- package/dist/color/colorimetry-math.js +144 -0
- package/dist/color/colorimetry-math.js.map +1 -0
- package/dist/color/gamut-mapping.d.ts +54 -0
- package/dist/color/gamut-mapping.js +107 -0
- package/dist/color/gamut-mapping.js.map +1 -0
- package/dist/color/illuminants.d.ts +182 -0
- package/dist/color/illuminants.js +434 -0
- package/dist/color/illuminants.js.map +1 -0
- package/dist/color/rgb-color-spaces.d.ts +79 -0
- package/dist/color/rgb-color-spaces.js +115 -0
- package/dist/color/rgb-color-spaces.js.map +1 -0
- package/dist/color/sensor-color-development.d.ts +33 -11
- package/dist/color/sensor-color-development.js +104 -30
- package/dist/color/sensor-color-development.js.map +1 -1
- package/dist/color/srgb-icc.d.ts +9 -2
- package/dist/color/srgb-icc.js +16 -5
- package/dist/color/srgb-icc.js.map +1 -1
- package/dist/color/srgb-transfer.d.ts +1 -2
- package/dist/color/srgb-transfer.js +1 -1
- package/dist/color/srgb-transfer.js.map +1 -1
- package/dist/color/white-balance.d.ts +68 -19
- package/dist/color/white-balance.js +168 -35
- package/dist/color/white-balance.js.map +1 -1
- package/dist/composition/image-formation-plan.d.ts +152 -128
- package/dist/composition/image-formation-plan.js +292 -138
- package/dist/composition/image-formation-plan.js.map +1 -1
- package/dist/composition/plan-consumer.d.ts +6 -7
- package/dist/composition/plan-consumer.js +14 -11
- package/dist/composition/plan-consumer.js.map +1 -1
- package/dist/core/calculation-result.d.ts +21 -14
- package/dist/core/calculation-result.js +209 -11
- package/dist/core/calculation-result.js.map +1 -1
- package/dist/core/canonical-json.d.ts +13 -8
- package/dist/core/canonical-json.js +34 -15
- package/dist/core/canonical-json.js.map +1 -1
- package/dist/core/configuration-error.d.ts +5 -4
- package/dist/core/configuration-error.js +5 -3
- package/dist/core/configuration-error.js.map +1 -1
- package/dist/core/evidence-provenance.d.ts +12 -12
- package/dist/core/evidence-provenance.js +10 -9
- package/dist/core/evidence-provenance.js.map +1 -1
- package/dist/core/image-formation.d.ts +11 -10
- package/dist/core/image-formation.js +11 -9
- package/dist/core/image-formation.js.map +1 -1
- package/dist/core/owned-data.d.ts +9 -17
- package/dist/core/owned-data.js +9 -16
- package/dist/core/owned-data.js.map +1 -1
- package/dist/core/portable-math.d.ts +15 -0
- package/dist/core/portable-math.js +56 -0
- package/dist/core/portable-math.js.map +1 -0
- package/dist/core/record-validation.d.ts +48 -9
- package/dist/core/record-validation.js +93 -19
- package/dist/core/record-validation.js.map +1 -1
- package/dist/core/scientific-assurance.d.ts +16 -14
- package/dist/core/scientific-assurance.js +22 -18
- package/dist/core/scientific-assurance.js.map +1 -1
- package/dist/core/spectral-composition.d.ts +13 -14
- package/dist/core/spectral-composition.js +30 -27
- package/dist/core/spectral-composition.js.map +1 -1
- package/dist/core/spectral.d.ts +5 -6
- package/dist/core/spectral.js +9 -7
- package/dist/core/spectral.js.map +1 -1
- package/dist/core/validation.d.ts +3 -6
- package/dist/core/validation.js +3 -5
- package/dist/core/validation.js.map +1 -1
- package/dist/core/version.d.ts +6 -6
- package/dist/core/version.js +6 -5
- package/dist/core/version.js.map +1 -1
- package/dist/equipment/exposure-capabilities.d.ts +10 -10
- package/dist/equipment/exposure-capabilities.js +40 -30
- package/dist/equipment/exposure-capabilities.js.map +1 -1
- package/dist/equipment/generic-tier-assets.d.ts +13 -6
- package/dist/equipment/generic-tier-assets.js +34 -15
- package/dist/equipment/generic-tier-assets.js.map +1 -1
- package/dist/equipment/generic-tier-presets.d.ts +5 -6
- package/dist/equipment/generic-tier-presets.js +15 -13
- package/dist/equipment/generic-tier-presets.js.map +1 -1
- package/dist/equipment/iso-capabilities.d.ts +21 -22
- package/dist/equipment/iso-capabilities.js +49 -44
- package/dist/equipment/iso-capabilities.js.map +1 -1
- package/dist/equipment/metering-capabilities.d.ts +5 -6
- package/dist/equipment/metering-capabilities.js +22 -19
- package/dist/equipment/metering-capabilities.js.map +1 -1
- package/dist/equipment/release-capabilities.d.ts +3 -4
- package/dist/equipment/release-capabilities.js +18 -14
- package/dist/equipment/release-capabilities.js.map +1 -1
- package/dist/exposure/exposure-duration-control.d.ts +19 -17
- package/dist/exposure/exposure-duration-control.js +27 -23
- package/dist/exposure/exposure-duration-control.js.map +1 -1
- package/dist/exposure/exposure-mode-resolver.d.ts +42 -39
- package/dist/exposure/exposure-mode-resolver.js +127 -82
- package/dist/exposure/exposure-mode-resolver.js.map +1 -1
- package/dist/exposure/exposure.d.ts +17 -16
- package/dist/exposure/exposure.js +22 -15
- package/dist/exposure/exposure.js.map +1 -1
- package/dist/exposure/flash-ttl.d.ts +135 -0
- package/dist/exposure/flash-ttl.js +193 -0
- package/dist/exposure/flash-ttl.js.map +1 -0
- package/dist/exposure/flash.d.ts +144 -36
- package/dist/exposure/flash.js +259 -59
- package/dist/exposure/flash.js.map +1 -1
- package/dist/exposure/metering-scene-radiance.d.ts +10 -10
- package/dist/exposure/metering-scene-radiance.js +42 -23
- package/dist/exposure/metering-scene-radiance.js.map +1 -1
- package/dist/exposure/metering-target.d.ts +8 -8
- package/dist/exposure/metering-target.js +30 -20
- package/dist/exposure/metering-target.js.map +1 -1
- package/dist/exposure/metering-temporal.d.ts +16 -15
- package/dist/exposure/metering-temporal.js +41 -19
- package/dist/exposure/metering-temporal.js.map +1 -1
- package/dist/exposure/metering.d.ts +64 -17
- package/dist/exposure/metering.js +159 -30
- package/dist/exposure/metering.js.map +1 -1
- package/dist/exposure/program-line.d.ts +5 -5
- package/dist/exposure/program-line.js +20 -13
- package/dist/exposure/program-line.js.map +1 -1
- package/dist/facade/camera-preset.d.ts +8 -0
- package/dist/facade/camera-preset.js +102 -0
- package/dist/facade/camera-preset.js.map +1 -0
- package/dist/facade/chart-radiance-batch.d.ts +57 -0
- package/dist/facade/chart-radiance-batch.js +121 -0
- package/dist/facade/chart-radiance-batch.js.map +1 -0
- package/dist/facade/chart-scenes.d.ts +177 -0
- package/dist/facade/chart-scenes.js +232 -0
- package/dist/facade/chart-scenes.js.map +1 -0
- package/dist/facade/host-yield.d.ts +7 -0
- package/dist/facade/host-yield.js +23 -0
- package/dist/facade/host-yield.js.map +1 -0
- package/dist/facade/scene-radiance.d.ts +117 -0
- package/dist/facade/scene-radiance.js +205 -0
- package/dist/facade/scene-radiance.js.map +1 -0
- package/dist/facade/simulate-capture.d.ts +284 -0
- package/dist/facade/simulate-capture.js +1026 -0
- package/dist/facade/simulate-capture.js.map +1 -0
- package/dist/gpu/chart-radiance-gpu.d.ts +17 -0
- package/dist/gpu/chart-radiance-gpu.js +176 -0
- package/dist/gpu/chart-radiance-gpu.js.map +1 -0
- package/dist/gpu/image-kernel-accelerator.d.ts +132 -0
- package/dist/gpu/image-kernel-accelerator.js +720 -0
- package/dist/gpu/image-kernel-accelerator.js.map +1 -0
- package/dist/gpu/image-kernel-execution.d.ts +92 -0
- package/dist/gpu/image-kernel-execution.js +84 -0
- package/dist/gpu/image-kernel-execution.js.map +1 -0
- package/dist/gpu/sensor-stage-gpu.d.ts +44 -0
- package/dist/gpu/sensor-stage-gpu.js +317 -0
- package/dist/gpu/sensor-stage-gpu.js.map +1 -0
- package/dist/gpu/temporal-sum-gpu.d.ts +23 -0
- package/dist/gpu/temporal-sum-gpu.js +150 -0
- package/dist/gpu/temporal-sum-gpu.js.map +1 -0
- package/dist/gpu/webgpu-runtime.d.ts +63 -0
- package/dist/gpu/webgpu-runtime.js +215 -0
- package/dist/gpu/webgpu-runtime.js.map +1 -0
- package/dist/gpu/wgsl-chart-kernel.d.ts +30 -0
- package/dist/gpu/wgsl-chart-kernel.js +165 -0
- package/dist/gpu/wgsl-chart-kernel.js.map +1 -0
- package/dist/gpu/wgsl-kernels.d.ts +53 -0
- package/dist/gpu/wgsl-kernels.js +365 -0
- package/dist/gpu/wgsl-kernels.js.map +1 -0
- package/dist/gpu/wgsl-sensor-kernel.d.ts +64 -0
- package/dist/gpu/wgsl-sensor-kernel.js +409 -0
- package/dist/gpu/wgsl-sensor-kernel.js.map +1 -0
- package/dist/index.d.ts +89 -25
- package/dist/index.js +59 -15
- package/dist/index.js.map +1 -1
- package/dist/motion/camera-rotation.d.ts +92 -40
- package/dist/motion/camera-rotation.js +84 -47
- package/dist/motion/camera-rotation.js.map +1 -1
- package/dist/motion/capture-rotation-inverse-mapping.d.ts +37 -34
- package/dist/motion/capture-rotation-inverse-mapping.js +32 -24
- package/dist/motion/capture-rotation-inverse-mapping.js.map +1 -1
- package/dist/motion/capture-rotation-temporal-quadrature.d.ts +39 -35
- package/dist/motion/capture-rotation-temporal-quadrature.js +37 -28
- package/dist/motion/capture-rotation-temporal-quadrature.js.map +1 -1
- package/dist/motion/capture-rotation-trajectory.d.ts +32 -28
- package/dist/motion/capture-rotation-trajectory.js +36 -26
- package/dist/motion/capture-rotation-trajectory.js.map +1 -1
- package/dist/motion/capture-translation-parallax-temporal-quadrature.d.ts +23 -21
- package/dist/motion/capture-translation-parallax-temporal-quadrature.js +33 -14
- package/dist/motion/capture-translation-parallax-temporal-quadrature.js.map +1 -1
- package/dist/motion/extended-object-projection.d.ts +19 -16
- package/dist/motion/extended-object-projection.js +38 -18
- package/dist/motion/extended-object-projection.js.map +1 -1
- package/dist/motion/projected-motion.d.ts +18 -17
- package/dist/motion/projected-motion.js +25 -17
- package/dist/motion/projected-motion.js.map +1 -1
- package/dist/motion/temporal-exposure-sum.d.ts +55 -0
- package/dist/motion/temporal-exposure-sum.js +141 -0
- package/dist/motion/temporal-exposure-sum.js.map +1 -0
- package/dist/motion/video-sequence.d.ts +111 -0
- package/dist/motion/video-sequence.js +179 -0
- package/dist/motion/video-sequence.js.map +1 -0
- package/dist/optics/aperture.d.ts +14 -15
- package/dist/optics/aperture.js +13 -11
- package/dist/optics/aperture.js.map +1 -1
- package/dist/optics/atmospheric-haze.d.ts +83 -0
- package/dist/optics/atmospheric-haze.js +113 -0
- package/dist/optics/atmospheric-haze.js.map +1 -0
- package/dist/optics/brown-conrady-distortion.d.ts +116 -0
- package/dist/optics/brown-conrady-distortion.js +291 -0
- package/dist/optics/brown-conrady-distortion.js.map +1 -0
- package/dist/optics/circle-of-confusion.d.ts +10 -10
- package/dist/optics/circle-of-confusion.js +15 -11
- package/dist/optics/circle-of-confusion.js.map +1 -1
- package/dist/optics/complex-pupil-psf.d.ts +64 -33
- package/dist/optics/complex-pupil-psf.js +190 -98
- package/dist/optics/complex-pupil-psf.js.map +1 -1
- package/dist/optics/depth-of-field.d.ts +25 -15
- package/dist/optics/depth-of-field.js +67 -27
- package/dist/optics/depth-of-field.js.map +1 -1
- package/dist/optics/diffraction.d.ts +14 -13
- package/dist/optics/diffraction.js +14 -10
- package/dist/optics/diffraction.js.map +1 -1
- package/dist/optics/focus-breathing.d.ts +88 -27
- package/dist/optics/focus-breathing.js +114 -23
- package/dist/optics/focus-breathing.js.map +1 -1
- package/dist/optics/focus-state.d.ts +18 -18
- package/dist/optics/focus-state.js +21 -15
- package/dist/optics/focus-state.js.map +1 -1
- package/dist/optics/front-of-lens-filter.d.ts +45 -14
- package/dist/optics/front-of-lens-filter.js +259 -88
- package/dist/optics/front-of-lens-filter.js.map +1 -1
- package/dist/optics/illumination-vignetting.d.ts +16 -17
- package/dist/optics/illumination-vignetting.js +40 -17
- package/dist/optics/illumination-vignetting.js.map +1 -1
- package/dist/optics/irradiance-convolution.d.ts +59 -0
- package/dist/optics/irradiance-convolution.js +138 -0
- package/dist/optics/irradiance-convolution.js.map +1 -0
- package/dist/optics/lateral-chromatic-aberration.d.ts +33 -30
- package/dist/optics/lateral-chromatic-aberration.js +33 -23
- package/dist/optics/lateral-chromatic-aberration.js.map +1 -1
- package/dist/optics/lens-psf-kernels.d.ts +89 -0
- package/dist/optics/lens-psf-kernels.js +175 -0
- package/dist/optics/lens-psf-kernels.js.map +1 -0
- package/dist/optics/lens-psf-profile.d.ts +78 -46
- package/dist/optics/lens-psf-profile.js +335 -124
- package/dist/optics/lens-psf-profile.js.map +1 -1
- package/dist/optics/longitudinal-chromatic-aberration.d.ts +102 -0
- package/dist/optics/longitudinal-chromatic-aberration.js +210 -0
- package/dist/optics/longitudinal-chromatic-aberration.js.map +1 -0
- package/dist/optics/polygon-diffraction.d.ts +80 -23
- package/dist/optics/polygon-diffraction.js +130 -25
- package/dist/optics/polygon-diffraction.js.map +1 -1
- package/dist/optics/profile-contract.d.ts +5 -6
- package/dist/optics/profile-contract.js +14 -11
- package/dist/optics/profile-contract.js.map +1 -1
- package/dist/optics/psf-foundation.d.ts +23 -23
- package/dist/optics/psf-foundation.js +24 -21
- package/dist/optics/psf-foundation.js.map +1 -1
- package/dist/optics/pupil-vignetting.d.ts +118 -0
- package/dist/optics/pupil-vignetting.js +264 -0
- package/dist/optics/pupil-vignetting.js.map +1 -0
- package/dist/optics/radial-distortion.d.ts +34 -33
- package/dist/optics/radial-distortion.js +37 -30
- package/dist/optics/radial-distortion.js.map +1 -1
- package/dist/optics/scene-to-sensor-irradiance.d.ts +47 -33
- package/dist/optics/scene-to-sensor-irradiance.js +73 -45
- package/dist/optics/scene-to-sensor-irradiance.js.map +1 -1
- package/dist/optics/scene-to-sensor-quadrature.d.ts +23 -18
- package/dist/optics/scene-to-sensor-quadrature.js +16 -11
- package/dist/optics/scene-to-sensor-quadrature.js.map +1 -1
- package/dist/optics/sensor-aperture-rays.d.ts +20 -4
- package/dist/optics/sensor-aperture-rays.js +32 -14
- package/dist/optics/sensor-aperture-rays.js.map +1 -1
- package/dist/optics/sensor-environment-query.d.ts +81 -16
- package/dist/optics/sensor-environment-query.js +145 -12
- package/dist/optics/sensor-environment-query.js.map +1 -1
- package/dist/optics/sensor-psf-quadrature.d.ts +12 -10
- package/dist/optics/sensor-psf-quadrature.js +18 -11
- package/dist/optics/sensor-psf-quadrature.js.map +1 -1
- package/dist/optics/sensor-psf-support.d.ts +8 -6
- package/dist/optics/sensor-psf-support.js +8 -5
- package/dist/optics/sensor-psf-support.js.map +1 -1
- package/dist/optics/stray-light.d.ts +22 -19
- package/dist/optics/stray-light.js +18 -12
- package/dist/optics/stray-light.js.map +1 -1
- package/dist/optics/thin-lens.d.ts +10 -9
- package/dist/optics/thin-lens.js +12 -8
- package/dist/optics/thin-lens.js.map +1 -1
- package/dist/optics/zernike-wavefront.d.ts +154 -0
- package/dist/optics/zernike-wavefront.js +352 -0
- package/dist/optics/zernike-wavefront.js.map +1 -0
- package/dist/output/capture-corrected-sdr.d.ts +16 -8
- package/dist/output/capture-corrected-sdr.js +16 -8
- package/dist/output/capture-corrected-sdr.js.map +1 -1
- package/dist/output/capture-geometry.d.ts +34 -36
- package/dist/output/capture-geometry.js +52 -32
- package/dist/output/capture-geometry.js.map +1 -1
- package/dist/output/capture-sdr.d.ts +7 -6
- package/dist/output/capture-sdr.js +11 -8
- package/dist/output/capture-sdr.js.map +1 -1
- package/dist/output/crop.d.ts +22 -6
- package/dist/output/crop.js +40 -6
- package/dist/output/crop.js.map +1 -1
- package/dist/output/geometric-transforms.d.ts +60 -23
- package/dist/output/geometric-transforms.js +111 -24
- package/dist/output/geometric-transforms.js.map +1 -1
- package/dist/output/lens-corrections.d.ts +27 -19
- package/dist/output/lens-corrections.js +29 -13
- package/dist/output/lens-corrections.js.map +1 -1
- package/dist/output/native-capture-sdr.d.ts +71 -16
- package/dist/output/native-capture-sdr.js +190 -33
- package/dist/output/native-capture-sdr.js.map +1 -1
- package/dist/output/png-encoder.d.ts +65 -0
- package/dist/output/png-encoder.js +461 -0
- package/dist/output/png-encoder.js.map +1 -0
- package/dist/output/print-contrast-reference.d.ts +10 -9
- package/dist/output/print-contrast-reference.js +10 -8
- package/dist/output/print-contrast-reference.js.map +1 -1
- package/dist/output/print-detail.d.ts +18 -17
- package/dist/output/print-detail.js +12 -10
- package/dist/output/print-detail.js.map +1 -1
- package/dist/output/print-jpeg.d.ts +26 -5
- package/dist/output/print-jpeg.js +117 -50
- package/dist/output/print-jpeg.js.map +1 -1
- package/dist/output/print-plan.d.ts +19 -19
- package/dist/output/print-plan.js +11 -10
- package/dist/output/print-plan.js.map +1 -1
- package/dist/output/print-region-statistics.d.ts +14 -15
- package/dist/output/print-region-statistics.js +11 -11
- package/dist/output/print-region-statistics.js.map +1 -1
- package/dist/output/sdr-rendering.d.ts +48 -10
- package/dist/output/sdr-rendering.js +114 -25
- package/dist/output/sdr-rendering.js.map +1 -1
- package/dist/output/subject-framing-crop.d.ts +6 -10
- package/dist/output/subject-framing-crop.js +23 -13
- package/dist/output/subject-framing-crop.js.map +1 -1
- package/dist/processing/demosaic.d.ts +90 -0
- package/dist/processing/demosaic.js +275 -0
- package/dist/processing/demosaic.js.map +1 -0
- package/dist/processing/denoise.d.ts +68 -0
- package/dist/processing/denoise.js +214 -0
- package/dist/processing/denoise.js.map +1 -0
- package/dist/processing/focus-stacking.d.ts +17 -0
- package/dist/processing/focus-stacking.js +80 -0
- package/dist/processing/focus-stacking.js.map +1 -0
- package/dist/processing/hdr.d.ts +54 -0
- package/dist/processing/hdr.js +172 -0
- package/dist/processing/hdr.js.map +1 -0
- package/dist/processing/image-ops.d.ts +66 -0
- package/dist/processing/image-ops.js +192 -0
- package/dist/processing/image-ops.js.map +1 -0
- package/dist/processing/panorama.d.ts +51 -0
- package/dist/processing/panorama.js +305 -0
- package/dist/processing/panorama.js.map +1 -0
- package/dist/processing/processing-task.d.ts +85 -0
- package/dist/processing/processing-task.js +164 -0
- package/dist/processing/processing-task.js.map +1 -0
- package/dist/processing/tone-mapping.d.ts +69 -0
- package/dist/processing/tone-mapping.js +310 -0
- package/dist/processing/tone-mapping.js.map +1 -0
- package/dist/schema/camera.d.ts +5 -4
- package/dist/schema/illumination-spectral.d.ts +13 -19
- package/dist/schema/illumination-spectral.js +23 -19
- package/dist/schema/illumination-spectral.js.map +1 -1
- package/dist/schema/illumination-temporal.d.ts +12 -15
- package/dist/schema/illumination-temporal.js +43 -28
- package/dist/schema/illumination-temporal.js.map +1 -1
- package/dist/schema/illumination.d.ts +5 -4
- package/dist/schema/illumination.js +55 -20
- package/dist/schema/illumination.js.map +1 -1
- package/dist/schema/scene-radiance-temporal.d.ts +9 -11
- package/dist/schema/scene-radiance-temporal.js +26 -23
- package/dist/schema/scene-radiance-temporal.js.map +1 -1
- package/dist/schema/scene-radiance.d.ts +17 -17
- package/dist/schema/scene-radiance.js +56 -34
- package/dist/schema/scene-radiance.js.map +1 -1
- package/dist/schema/scene.d.ts +14 -13
- package/dist/schema/validation.d.ts +0 -1
- package/dist/schema/validation.js +17 -15
- package/dist/schema/validation.js.map +1 -1
- package/dist/sensor/accumulated-charge.d.ts +45 -64
- package/dist/sensor/accumulated-charge.js +41 -47
- package/dist/sensor/accumulated-charge.js.map +1 -1
- package/dist/sensor/architecture.d.ts +22 -25
- package/dist/sensor/architecture.js +17 -16
- package/dist/sensor/architecture.js.map +1 -1
- package/dist/sensor/camera-saturation-capacity.d.ts +21 -28
- package/dist/sensor/camera-saturation-capacity.js +36 -34
- package/dist/sensor/camera-saturation-capacity.js.map +1 -1
- package/dist/sensor/capture-color-sampling-binding.d.ts +46 -51
- package/dist/sensor/capture-color-sampling-binding.js +39 -41
- package/dist/sensor/capture-color-sampling-binding.js.map +1 -1
- package/dist/sensor/capture-mode-timing.d.ts +8 -9
- package/dist/sensor/capture-mode-timing.js +24 -21
- package/dist/sensor/capture-mode-timing.js.map +1 -1
- package/dist/sensor/capture-mode.d.ts +28 -30
- package/dist/sensor/capture-mode.js +33 -31
- package/dist/sensor/capture-mode.js.map +1 -1
- package/dist/sensor/color-sampling.d.ts +30 -33
- package/dist/sensor/color-sampling.js +32 -37
- package/dist/sensor/color-sampling.js.map +1 -1
- package/dist/sensor/constant-rate-temporal-integration.d.ts +19 -23
- package/dist/sensor/constant-rate-temporal-integration.js +28 -26
- package/dist/sensor/constant-rate-temporal-integration.js.map +1 -1
- package/dist/sensor/dark-current.d.ts +53 -49
- package/dist/sensor/dark-current.js +87 -46
- package/dist/sensor/dark-current.js.map +1 -1
- package/dist/sensor/environment-photo-signal.d.ts +71 -30
- package/dist/sensor/environment-photo-signal.js +127 -46
- package/dist/sensor/environment-photo-signal.js.map +1 -1
- package/dist/sensor/eqe-electron-rate.d.ts +14 -13
- package/dist/sensor/eqe-electron-rate.js +34 -14
- package/dist/sensor/eqe-electron-rate.js.map +1 -1
- package/dist/sensor/eqe-local-exposure.d.ts +24 -24
- package/dist/sensor/eqe-local-exposure.js +15 -11
- package/dist/sensor/eqe-local-exposure.js.map +1 -1
- package/dist/sensor/eqe-temporal-exposure.d.ts +11 -11
- package/dist/sensor/eqe-temporal-exposure.js +15 -10
- package/dist/sensor/eqe-temporal-exposure.js.map +1 -1
- package/dist/sensor/exposure-window.d.ts +48 -34
- package/dist/sensor/exposure-window.js +77 -36
- package/dist/sensor/exposure-window.js.map +1 -1
- package/dist/sensor/fixed-pattern-noise.d.ts +108 -0
- package/dist/sensor/fixed-pattern-noise.js +166 -0
- package/dist/sensor/fixed-pattern-noise.js.map +1 -0
- package/dist/sensor/iso-gain.d.ts +44 -0
- package/dist/sensor/iso-gain.js +119 -0
- package/dist/sensor/iso-gain.js.map +1 -0
- package/dist/sensor/iso-signal-chain.d.ts +25 -48
- package/dist/sensor/iso-signal-chain.js +52 -66
- package/dist/sensor/iso-signal-chain.js.map +1 -1
- package/dist/sensor/local-exposure-binding.d.ts +21 -21
- package/dist/sensor/local-exposure-binding.js +22 -18
- package/dist/sensor/local-exposure-binding.js.map +1 -1
- package/dist/sensor/optical-stack.d.ts +36 -40
- package/dist/sensor/optical-stack.js +34 -37
- package/dist/sensor/optical-stack.js.map +1 -1
- package/dist/sensor/photon-energy.d.ts +22 -28
- package/dist/sensor/photon-energy.js +42 -34
- package/dist/sensor/photon-energy.js.map +1 -1
- package/dist/sensor/physical-charge-capacity.d.ts +20 -30
- package/dist/sensor/physical-charge-capacity.js +35 -36
- package/dist/sensor/physical-charge-capacity.js.map +1 -1
- package/dist/sensor/pixel-pitch.d.ts +2 -3
- package/dist/sensor/pixel-pitch.js +4 -2
- package/dist/sensor/pixel-pitch.js.map +1 -1
- package/dist/sensor/radiometry-readiness.d.ts +13 -15
- package/dist/sensor/radiometry-readiness.js +20 -17
- package/dist/sensor/radiometry-readiness.js.map +1 -1
- package/dist/sensor/raw-readout.d.ts +173 -83
- package/dist/sensor/raw-readout.js +425 -160
- package/dist/sensor/raw-readout.js.map +1 -1
- package/dist/sensor/raw-reconstruction.d.ts +112 -44
- package/dist/sensor/raw-reconstruction.js +200 -47
- package/dist/sensor/raw-reconstruction.js.map +1 -1
- package/dist/sensor/readout-exposure-linkage.d.ts +103 -34
- package/dist/sensor/readout-exposure-linkage.js +125 -27
- package/dist/sensor/readout-exposure-linkage.js.map +1 -1
- package/dist/sensor/readout-timing.d.ts +43 -44
- package/dist/sensor/readout-timing.js +38 -30
- package/dist/sensor/readout-timing.js.map +1 -1
- package/dist/sensor/response-application-compatibility.d.ts +21 -28
- package/dist/sensor/response-application-compatibility.js +35 -34
- package/dist/sensor/response-application-compatibility.js.map +1 -1
- package/dist/sensor/response-operating-range.d.ts +26 -35
- package/dist/sensor/response-operating-range.js +40 -39
- package/dist/sensor/response-operating-range.js.map +1 -1
- package/dist/sensor/responsivity-photocurrent.d.ts +21 -29
- package/dist/sensor/responsivity-photocurrent.js +57 -40
- package/dist/sensor/responsivity-photocurrent.js.map +1 -1
- package/dist/sensor/sampling-aperture.d.ts +21 -25
- package/dist/sensor/sampling-aperture.js +29 -28
- package/dist/sensor/sampling-aperture.js.map +1 -1
- package/dist/sensor/scene-eqe-temporal-exposure.d.ts +14 -12
- package/dist/sensor/scene-eqe-temporal-exposure.js +13 -8
- package/dist/sensor/scene-eqe-temporal-exposure.js.map +1 -1
- package/dist/sensor/sensor-geometry.d.ts +28 -32
- package/dist/sensor/sensor-geometry.js +35 -20
- package/dist/sensor/sensor-geometry.js.map +1 -1
- package/dist/sensor/signal-noise.d.ts +14 -16
- package/dist/sensor/signal-noise.js +15 -13
- package/dist/sensor/signal-noise.js.map +1 -1
- package/dist/sensor/spatial-sample-reduction.d.ts +45 -60
- package/dist/sensor/spatial-sample-reduction.js +39 -48
- package/dist/sensor/spatial-sample-reduction.js.map +1 -1
- package/dist/sensor/spatial-sampling-quadrature.d.ts +46 -54
- package/dist/sensor/spatial-sampling-quadrature.js +31 -36
- package/dist/sensor/spatial-sampling-quadrature.js.map +1 -1
- package/dist/sensor/spatio-spectral-reduction.d.ts +32 -42
- package/dist/sensor/spatio-spectral-reduction.js +24 -29
- package/dist/sensor/spatio-spectral-reduction.js.map +1 -1
- package/dist/sensor/spectral-coverage.d.ts +6 -9
- package/dist/sensor/spectral-coverage.js +9 -6
- package/dist/sensor/spectral-coverage.js.map +1 -1
- package/dist/sensor/spectral-quadrature.d.ts +46 -60
- package/dist/sensor/spectral-quadrature.js +38 -48
- package/dist/sensor/spectral-quadrature.js.map +1 -1
- package/dist/sensor/spectral-response.d.ts +53 -41
- package/dist/sensor/spectral-response.js +80 -47
- package/dist/sensor/spectral-response.js.map +1 -1
- package/dist/sensor/stochastic-seed.d.ts +50 -0
- package/dist/sensor/stochastic-seed.js +123 -0
- package/dist/sensor/stochastic-seed.js.map +1 -0
- package/dist/sensor/temporal-eqe-sum.d.ts +2 -4
- package/dist/sensor/temporal-eqe-sum.js +5 -6
- package/dist/sensor/temporal-eqe-sum.js.map +1 -1
- package/dist/sensor/temporal-photo-signal.d.ts +5 -6
- package/dist/sensor/temporal-photo-signal.js +11 -10
- package/dist/sensor/temporal-photo-signal.js.map +1 -1
- package/dist/sensor/temporal-sample-binding.d.ts +1 -2
- package/dist/sensor/temporal-sample-binding.js +3 -3
- package/dist/sensor/temporal-sample-binding.js.map +1 -1
- package/dist/simulation/poc-simulation.d.ts +16 -16
- package/dist/simulation/poc-simulation.js +20 -15
- package/dist/simulation/poc-simulation.js.map +1 -1
- package/dist/stabilization/camera-shake.d.ts +42 -18
- package/dist/stabilization/camera-shake.js +43 -20
- package/dist/stabilization/camera-shake.js.map +1 -1
- package/dist/stabilization/system.d.ts +44 -41
- package/dist/stabilization/system.js +196 -108
- package/dist/stabilization/system.js.map +1 -1
- package/docs/AGENT_GUIDE.md +183 -0
- package/docs/API_REFERENCE.md +761 -2
- package/docs/QUICK_START.md +495 -0
- package/docs/USAGE.md +1719 -714
- package/docs/api/camera-equivalent-focal-length.md +6 -7
- package/docs/api/camera-field-of-view.md +16 -8
- package/docs/api/camera-lens-projection.md +246 -0
- package/docs/api/camera-projected-object-size.md +6 -5
- package/docs/api/capture-capture-export-metadata.md +10 -10
- package/docs/api/capture-dng-import.md +134 -0
- package/docs/api/capture-environment-raw-producer.md +17 -11
- package/docs/api/capture-export-jpeg.md +16 -0
- package/docs/api/capture-focus-control.md +25 -47
- package/docs/api/capture-linear-encoding.md +21 -12
- package/docs/api/capture-lossless-jpeg.md +49 -0
- package/docs/api/capture-native-environment-optical-stage.md +75 -0
- package/docs/api/capture-native-environment-raw.md +161 -4
- package/docs/api/capture-native-raw-development.md +69 -4
- package/docs/api/capture-native-raw-dng.md +84 -0
- package/docs/api/capture-native-raw.md +23 -8
- package/docs/api/capture-packed-sensor-raw.md +156 -0
- package/docs/api/capture-photographic-export.md +69 -31
- package/docs/api/capture-raw-frame-reconstruction.md +8 -8
- package/docs/api/capture-raw-white-level.md +37 -0
- package/docs/api/capture-release-sequence.md +6 -7
- package/docs/api/capture-sensor-raw-frame.md +6 -6
- package/docs/api/capture-sensor-raw-producer.md +17 -11
- package/docs/api/capture-simulated-capture.md +15 -15
- package/docs/api/color-camera-color-matrix.md +103 -0
- package/docs/api/color-capture-color.md +22 -11
- package/docs/api/color-chromatic-adaptation.md +82 -0
- package/docs/api/color-color-difference.md +134 -0
- package/docs/api/color-color-matching-functions.md +259 -0
- package/docs/api/color-colorimetry-math.md +54 -0
- package/docs/api/color-gamut-mapping.md +72 -0
- package/docs/api/color-illuminants.md +280 -0
- package/docs/api/color-rgb-color-spaces.md +151 -0
- package/docs/api/color-sensor-color-development.md +27 -0
- package/docs/api/color-srgb-icc.md +2 -4
- package/docs/api/color-white-balance.md +95 -19
- package/docs/api/composition-image-formation-plan.md +124 -95
- package/docs/api/composition-plan-consumer.md +7 -7
- package/docs/api/core-calculation-result.md +18 -14
- package/docs/api/core-configuration-error.md +1 -1
- package/docs/api/core-image-formation.md +7 -7
- package/docs/api/core-scientific-assurance.md +12 -10
- package/docs/api/core-spectral-composition.md +14 -14
- package/docs/api/core-spectral.md +6 -6
- package/docs/api/core-validation.md +3 -3
- package/docs/api/core-version.md +7 -6
- package/docs/api/equipment-exposure-capabilities.md +11 -10
- package/docs/api/equipment-generic-tier-assets.md +7 -2
- package/docs/api/equipment-generic-tier-presets.md +6 -6
- package/docs/api/equipment-iso-capabilities.md +18 -18
- package/docs/api/equipment-metering-capabilities.md +6 -6
- package/docs/api/equipment-release-capabilities.md +4 -4
- package/docs/api/exports.json +2213 -8
- package/docs/api/exposure-exposure-duration-control.md +9 -9
- package/docs/api/exposure-exposure-mode-resolver.md +35 -31
- package/docs/api/exposure-exposure.md +10 -10
- package/docs/api/exposure-flash-ttl.md +182 -0
- package/docs/api/exposure-flash.md +183 -28
- package/docs/api/exposure-metering-scene-radiance.md +11 -10
- package/docs/api/exposure-metering-target.md +9 -8
- package/docs/api/exposure-metering-temporal.md +8 -8
- package/docs/api/exposure-metering.md +69 -9
- package/docs/api/exposure-program-line.md +6 -5
- package/docs/api/facade-chart-radiance-batch.md +96 -0
- package/docs/api/facade-chart-scenes.md +240 -0
- package/docs/api/facade-scene-radiance.md +122 -0
- package/docs/api/facade-simulate-capture.md +324 -0
- package/docs/api/gpu-image-kernel-accelerator.md +157 -0
- package/docs/api/gpu-image-kernel-execution.md +152 -0
- package/docs/api/motion-camera-rotation.md +43 -26
- package/docs/api/motion-capture-rotation-inverse-mapping.md +24 -23
- package/docs/api/motion-capture-rotation-temporal-quadrature.md +22 -22
- package/docs/api/motion-capture-rotation-trajectory.md +15 -15
- package/docs/api/motion-capture-translation-parallax-temporal-quadrature.md +15 -14
- package/docs/api/motion-extended-object-projection.md +10 -8
- package/docs/api/motion-projected-motion.md +8 -8
- package/docs/api/motion-temporal-exposure-sum.md +98 -0
- package/docs/api/motion-video-sequence.md +159 -0
- package/docs/api/optics-aperture.md +8 -8
- package/docs/api/optics-atmospheric-haze.md +104 -0
- package/docs/api/optics-brown-conrady-distortion.md +123 -0
- package/docs/api/optics-circle-of-confusion.md +5 -4
- package/docs/api/optics-complex-pupil-psf.md +57 -16
- package/docs/api/optics-depth-of-field.md +12 -6
- package/docs/api/optics-diffraction.md +8 -7
- package/docs/api/optics-focus-breathing.md +104 -16
- package/docs/api/optics-focus-state.md +9 -10
- package/docs/api/optics-front-of-lens-filter.md +72 -14
- package/docs/api/optics-illumination-vignetting.md +10 -10
- package/docs/api/optics-irradiance-convolution.md +95 -0
- package/docs/api/optics-lateral-chromatic-aberration.md +22 -21
- package/docs/api/optics-lens-psf-kernels.md +72 -0
- package/docs/api/optics-lens-psf-profile.md +48 -26
- package/docs/api/optics-longitudinal-chromatic-aberration.md +128 -0
- package/docs/api/optics-polygon-diffraction.md +78 -13
- package/docs/api/optics-profile-contract.md +4 -4
- package/docs/api/optics-psf-foundation.md +12 -12
- package/docs/api/optics-pupil-vignetting.md +132 -0
- package/docs/api/optics-radial-distortion.md +12 -12
- package/docs/api/optics-scene-to-sensor-irradiance.md +25 -14
- package/docs/api/optics-scene-to-sensor-quadrature.md +15 -12
- package/docs/api/optics-sensor-aperture-rays.md +3 -2
- package/docs/api/optics-sensor-environment-query.md +52 -9
- package/docs/api/optics-sensor-psf-quadrature.md +13 -10
- package/docs/api/optics-stray-light.md +12 -11
- package/docs/api/optics-thin-lens.md +4 -3
- package/docs/api/optics-zernike-wavefront.md +229 -0
- package/docs/api/output-capture-corrected-sdr.md +10 -7
- package/docs/api/output-capture-geometry.md +35 -36
- package/docs/api/output-capture-sdr.md +4 -4
- package/docs/api/output-crop.md +7 -4
- package/docs/api/output-geometric-transforms.md +65 -19
- package/docs/api/output-lens-corrections.md +17 -15
- package/docs/api/output-native-capture-sdr.md +26 -13
- package/docs/api/output-png-encoder.md +105 -0
- package/docs/api/output-print-contrast-reference.md +8 -8
- package/docs/api/output-print-detail.md +14 -14
- package/docs/api/output-print-jpeg.md +22 -5
- package/docs/api/output-print-plan.md +18 -18
- package/docs/api/output-print-region-statistics.md +14 -14
- package/docs/api/output-sdr-rendering.md +52 -10
- package/docs/api/output-subject-framing-crop.md +5 -6
- package/docs/api/processing-demosaic.md +120 -0
- package/docs/api/processing-denoise.md +148 -0
- package/docs/api/processing-focus-stacking.md +41 -0
- package/docs/api/processing-hdr.md +113 -0
- package/docs/api/processing-panorama.md +82 -0
- package/docs/api/processing-processing-task.md +107 -0
- package/docs/api/processing-tone-mapping.md +142 -0
- package/docs/api/schema-camera.md +6 -4
- package/docs/api/schema-illumination-spectral.md +10 -11
- package/docs/api/schema-illumination-temporal.md +13 -15
- package/docs/api/schema-illumination.md +4 -4
- package/docs/api/schema-scene-radiance-temporal.md +10 -11
- package/docs/api/schema-scene-radiance.md +18 -17
- package/docs/api/schema-scene.md +9 -9
- package/docs/api/schema-validation.md +1 -1
- package/docs/api/sensor-accumulated-charge.md +12 -20
- package/docs/api/sensor-architecture.md +15 -16
- package/docs/api/sensor-camera-saturation-capacity.md +9 -11
- package/docs/api/sensor-capture-color-sampling-binding.md +47 -51
- package/docs/api/sensor-capture-mode-timing.md +9 -9
- package/docs/api/sensor-capture-mode.md +29 -30
- package/docs/api/sensor-color-sampling.md +31 -33
- package/docs/api/sensor-constant-rate-temporal-integration.md +10 -11
- package/docs/api/sensor-dark-current.md +30 -14
- package/docs/api/sensor-environment-photo-signal.md +13 -6
- package/docs/api/sensor-eqe-electron-rate.md +9 -8
- package/docs/api/sensor-eqe-local-exposure.md +18 -17
- package/docs/api/sensor-eqe-temporal-exposure.md +12 -11
- package/docs/api/sensor-exposure-window.md +24 -24
- package/docs/api/sensor-fixed-pattern-noise.md +104 -0
- package/docs/api/sensor-iso-gain.md +63 -0
- package/docs/api/sensor-iso-signal-chain.md +13 -22
- package/docs/api/sensor-local-exposure-binding.md +12 -13
- package/docs/api/sensor-optical-stack.md +37 -40
- package/docs/api/sensor-photon-energy.md +10 -11
- package/docs/api/sensor-physical-charge-capacity.md +8 -13
- package/docs/api/sensor-pixel-pitch.md +1 -1
- package/docs/api/sensor-radiometry-readiness.md +9 -9
- package/docs/api/sensor-raw-readout.md +118 -52
- package/docs/api/sensor-raw-reconstruction.md +97 -20
- package/docs/api/sensor-readout-exposure-linkage.md +120 -24
- package/docs/api/sensor-readout-timing.md +33 -35
- package/docs/api/sensor-response-application-compatibility.md +9 -11
- package/docs/api/sensor-response-operating-range.md +14 -18
- package/docs/api/sensor-responsivity-photocurrent.md +9 -12
- package/docs/api/sensor-sampling-aperture.md +22 -25
- package/docs/api/sensor-scene-eqe-temporal-exposure.md +9 -8
- package/docs/api/sensor-sensor-geometry.md +23 -24
- package/docs/api/sensor-signal-noise.md +10 -10
- package/docs/api/sensor-spatial-sample-reduction.md +27 -30
- package/docs/api/sensor-spatial-sampling-quadrature.md +37 -39
- package/docs/api/sensor-spatio-spectral-reduction.md +27 -29
- package/docs/api/sensor-spectral-coverage.md +5 -5
- package/docs/api/sensor-spectral-quadrature.md +33 -35
- package/docs/api/sensor-spectral-response.md +28 -16
- package/docs/api/sensor-temporal-photo-signal.md +6 -6
- package/docs/api/simulation-poc-simulation.md +17 -16
- package/docs/api/stabilization-camera-shake.md +29 -10
- package/docs/api/stabilization-system.md +25 -21
- package/docs/examples/production-request.json +3821 -2157
- package/docs/examples/simulate-capture.mjs +14 -0
- package/llms.txt +35 -0
- package/package.json +32 -12
- package/AGENTS.md +0 -674
- package/CONTRIBUTING.md +0 -76
- package/DCO +0 -33
- package/dist/camera/equivalent-focal-length.d.ts.map +0 -1
- package/dist/camera/field-of-view.d.ts.map +0 -1
- package/dist/camera/projected-object-size.d.ts.map +0 -1
- package/dist/capture/capture-export-metadata.d.ts.map +0 -1
- package/dist/capture/environment-raw-producer.d.ts.map +0 -1
- package/dist/capture/export-jpeg.d.ts.map +0 -1
- package/dist/capture/export-tiff.d.ts.map +0 -1
- package/dist/capture/focus-control.d.ts.map +0 -1
- package/dist/capture/linear-encoding.d.ts.map +0 -1
- package/dist/capture/native-environment-raw.d.ts.map +0 -1
- package/dist/capture/native-raw-development.d.ts.map +0 -1
- package/dist/capture/native-raw.d.ts.map +0 -1
- package/dist/capture/photographic-export.d.ts.map +0 -1
- package/dist/capture/raw-frame-limits.d.ts.map +0 -1
- package/dist/capture/raw-frame-reconstruction.d.ts.map +0 -1
- package/dist/capture/release-sequence.d.ts.map +0 -1
- package/dist/capture/sensor-raw-frame.d.ts.map +0 -1
- package/dist/capture/sensor-raw-producer.d.ts.map +0 -1
- package/dist/capture/simulated-capture.d.ts.map +0 -1
- package/dist/color/capture-color.d.ts.map +0 -1
- package/dist/color/sensor-color-development.d.ts.map +0 -1
- package/dist/color/srgb-icc.d.ts.map +0 -1
- package/dist/color/srgb-transfer.d.ts.map +0 -1
- package/dist/color/white-balance.d.ts.map +0 -1
- package/dist/composition/image-formation-plan.d.ts.map +0 -1
- package/dist/composition/plan-consumer.d.ts.map +0 -1
- package/dist/core/calculation-result.d.ts.map +0 -1
- package/dist/core/canonical-json.d.ts.map +0 -1
- package/dist/core/configuration-error.d.ts.map +0 -1
- package/dist/core/evidence-provenance.d.ts.map +0 -1
- package/dist/core/image-formation.d.ts.map +0 -1
- package/dist/core/owned-data.d.ts.map +0 -1
- package/dist/core/record-validation.d.ts.map +0 -1
- package/dist/core/scientific-assurance.d.ts.map +0 -1
- package/dist/core/spectral-composition.d.ts.map +0 -1
- package/dist/core/spectral.d.ts.map +0 -1
- package/dist/core/validation.d.ts.map +0 -1
- package/dist/core/version.d.ts.map +0 -1
- package/dist/equipment/exposure-capabilities.d.ts.map +0 -1
- package/dist/equipment/generic-tier-assets.d.ts.map +0 -1
- package/dist/equipment/generic-tier-presets.d.ts.map +0 -1
- package/dist/equipment/iso-capabilities.d.ts.map +0 -1
- package/dist/equipment/metering-capabilities.d.ts.map +0 -1
- package/dist/equipment/release-capabilities.d.ts.map +0 -1
- package/dist/exposure/exposure-duration-control.d.ts.map +0 -1
- package/dist/exposure/exposure-mode-resolver.d.ts.map +0 -1
- package/dist/exposure/exposure.d.ts.map +0 -1
- package/dist/exposure/flash.d.ts.map +0 -1
- package/dist/exposure/metering-scene-radiance.d.ts.map +0 -1
- package/dist/exposure/metering-target.d.ts.map +0 -1
- package/dist/exposure/metering-temporal.d.ts.map +0 -1
- package/dist/exposure/metering.d.ts.map +0 -1
- package/dist/exposure/program-line.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/motion/camera-rotation.d.ts.map +0 -1
- package/dist/motion/capture-rotation-inverse-mapping.d.ts.map +0 -1
- package/dist/motion/capture-rotation-temporal-quadrature.d.ts.map +0 -1
- package/dist/motion/capture-rotation-trajectory.d.ts.map +0 -1
- package/dist/motion/capture-translation-parallax-temporal-quadrature.d.ts.map +0 -1
- package/dist/motion/extended-object-projection.d.ts.map +0 -1
- package/dist/motion/projected-motion.d.ts.map +0 -1
- package/dist/optics/aperture.d.ts.map +0 -1
- package/dist/optics/circle-of-confusion.d.ts.map +0 -1
- package/dist/optics/complex-pupil-psf.d.ts.map +0 -1
- package/dist/optics/depth-of-field.d.ts.map +0 -1
- package/dist/optics/diffraction.d.ts.map +0 -1
- package/dist/optics/focus-breathing.d.ts.map +0 -1
- package/dist/optics/focus-state.d.ts.map +0 -1
- package/dist/optics/front-of-lens-filter.d.ts.map +0 -1
- package/dist/optics/illumination-vignetting.d.ts.map +0 -1
- package/dist/optics/lateral-chromatic-aberration.d.ts.map +0 -1
- package/dist/optics/lens-psf-profile.d.ts.map +0 -1
- package/dist/optics/polygon-diffraction.d.ts.map +0 -1
- package/dist/optics/profile-contract.d.ts.map +0 -1
- package/dist/optics/psf-foundation.d.ts.map +0 -1
- package/dist/optics/radial-distortion.d.ts.map +0 -1
- package/dist/optics/scene-to-sensor-irradiance.d.ts.map +0 -1
- package/dist/optics/scene-to-sensor-quadrature.d.ts.map +0 -1
- package/dist/optics/sensor-aperture-rays.d.ts.map +0 -1
- package/dist/optics/sensor-environment-query.d.ts.map +0 -1
- package/dist/optics/sensor-psf-quadrature.d.ts.map +0 -1
- package/dist/optics/sensor-psf-support.d.ts.map +0 -1
- package/dist/optics/stray-light.d.ts.map +0 -1
- package/dist/optics/thin-lens.d.ts.map +0 -1
- package/dist/output/capture-corrected-sdr.d.ts.map +0 -1
- package/dist/output/capture-geometry.d.ts.map +0 -1
- package/dist/output/capture-sdr.d.ts.map +0 -1
- package/dist/output/crop.d.ts.map +0 -1
- package/dist/output/geometric-transforms.d.ts.map +0 -1
- package/dist/output/lens-corrections.d.ts.map +0 -1
- package/dist/output/native-capture-sdr.d.ts.map +0 -1
- package/dist/output/print-contrast-reference.d.ts.map +0 -1
- package/dist/output/print-detail.d.ts.map +0 -1
- package/dist/output/print-jpeg.d.ts.map +0 -1
- package/dist/output/print-plan.d.ts.map +0 -1
- package/dist/output/print-region-statistics.d.ts.map +0 -1
- package/dist/output/sdr-rendering.d.ts.map +0 -1
- package/dist/output/subject-framing-crop.d.ts.map +0 -1
- package/dist/schema/camera.d.ts.map +0 -1
- package/dist/schema/camera.js +0 -3
- package/dist/schema/camera.js.map +0 -1
- package/dist/schema/illumination-spectral.d.ts.map +0 -1
- package/dist/schema/illumination-temporal.d.ts.map +0 -1
- package/dist/schema/illumination.d.ts.map +0 -1
- package/dist/schema/scene-radiance-temporal.d.ts.map +0 -1
- package/dist/schema/scene-radiance.d.ts.map +0 -1
- package/dist/schema/scene.d.ts.map +0 -1
- package/dist/schema/scene.js +0 -3
- package/dist/schema/scene.js.map +0 -1
- package/dist/schema/validation.d.ts.map +0 -1
- package/dist/sensor/accumulated-charge.d.ts.map +0 -1
- package/dist/sensor/architecture.d.ts.map +0 -1
- package/dist/sensor/camera-saturation-capacity.d.ts.map +0 -1
- package/dist/sensor/capture-color-sampling-binding.d.ts.map +0 -1
- package/dist/sensor/capture-mode-timing.d.ts.map +0 -1
- package/dist/sensor/capture-mode.d.ts.map +0 -1
- package/dist/sensor/color-sampling.d.ts.map +0 -1
- package/dist/sensor/constant-rate-temporal-integration.d.ts.map +0 -1
- package/dist/sensor/dark-current.d.ts.map +0 -1
- package/dist/sensor/environment-photo-signal.d.ts.map +0 -1
- package/dist/sensor/eqe-electron-rate.d.ts.map +0 -1
- package/dist/sensor/eqe-local-exposure.d.ts.map +0 -1
- package/dist/sensor/eqe-temporal-exposure.d.ts.map +0 -1
- package/dist/sensor/exposure-window.d.ts.map +0 -1
- package/dist/sensor/iso-signal-chain.d.ts.map +0 -1
- package/dist/sensor/local-exposure-binding.d.ts.map +0 -1
- package/dist/sensor/optical-stack.d.ts.map +0 -1
- package/dist/sensor/photon-energy.d.ts.map +0 -1
- package/dist/sensor/physical-charge-capacity.d.ts.map +0 -1
- package/dist/sensor/pixel-pitch.d.ts.map +0 -1
- package/dist/sensor/radiometry-readiness.d.ts.map +0 -1
- package/dist/sensor/raw-readout.d.ts.map +0 -1
- package/dist/sensor/raw-reconstruction.d.ts.map +0 -1
- package/dist/sensor/readout-exposure-linkage.d.ts.map +0 -1
- package/dist/sensor/readout-timing.d.ts.map +0 -1
- package/dist/sensor/response-application-compatibility.d.ts.map +0 -1
- package/dist/sensor/response-operating-range.d.ts.map +0 -1
- package/dist/sensor/responsivity-photocurrent.d.ts.map +0 -1
- package/dist/sensor/sampling-aperture.d.ts.map +0 -1
- package/dist/sensor/scene-eqe-temporal-exposure.d.ts.map +0 -1
- package/dist/sensor/sensor-geometry.d.ts.map +0 -1
- package/dist/sensor/signal-noise.d.ts.map +0 -1
- package/dist/sensor/spatial-sample-reduction.d.ts.map +0 -1
- package/dist/sensor/spatial-sampling-quadrature.d.ts.map +0 -1
- package/dist/sensor/spatio-spectral-reduction.d.ts.map +0 -1
- package/dist/sensor/spectral-coverage.d.ts.map +0 -1
- package/dist/sensor/spectral-quadrature.d.ts.map +0 -1
- package/dist/sensor/spectral-response.d.ts.map +0 -1
- package/dist/sensor/temporal-eqe-sum.d.ts.map +0 -1
- package/dist/sensor/temporal-photo-signal.d.ts.map +0 -1
- package/dist/sensor/temporal-sample-binding.d.ts.map +0 -1
- package/dist/simulation/poc-simulation.d.ts.map +0 -1
- package/dist/stabilization/camera-shake.d.ts.map +0 -1
- package/dist/stabilization/system.d.ts.map +0 -1
- package/docs/API_STYLE.md +0 -235
- package/docs/ARCHITECTURE.md +0 -356
- package/docs/AUTOMATION_COORDINATION.md +0 -190
- package/docs/CAPTURE_COLOR.md +0 -25
- package/docs/CAPTURE_CORRECTED_SDR.md +0 -25
- package/docs/CAPTURE_EXPORT_METADATA.md +0 -27
- package/docs/CAPTURE_SDR.md +0 -22
- package/docs/DEVELOPERS.md +0 -68
- package/docs/DIGITAL_OPTICS_FOUNDATION.md +0 -69
- package/docs/ENVIRONMENT_RAW_CAPTURE.md +0 -208
- package/docs/EXPORT_ACCEPTANCE.md +0 -133
- package/docs/GENERIC_TIER_PRESETS.md +0 -269
- package/docs/GEOMETRIC_PREPARATION_REUSE.md +0 -141
- package/docs/IMAGE_FORMATION.md +0 -247
- package/docs/LINEAR_CAPTURE_ENCODING.md +0 -25
- package/docs/MOTION_AND_SIGNAL.md +0 -250
- package/docs/NATIVE_CAPTURE_SDR.md +0 -70
- package/docs/NATIVE_CAPTURE_SDR_REVIEW.md +0 -37
- package/docs/NATIVE_CAPTURE_SDR_VALIDATION.md +0 -34
- package/docs/NATIVE_RAW_AND_PRINT.md +0 -47
- package/docs/NUMERICAL_CORRECTNESS.md +0 -191
- package/docs/PERFORMANCE_BASELINE.md +0 -56
- package/docs/PHOTOGRAPHIC_EXPORT.md +0 -206
- package/docs/PHYSICS_FOUNDATION.md +0 -426
- package/docs/POC_API.md +0 -278
- package/docs/POC_PROJECTION_PLATFORM_REFERENCE.md +0 -12
- package/docs/POC_PROJECTION_REUSE.md +0 -124
- package/docs/PRINT_195_196_REVIEW.md +0 -93
- package/docs/PRINT_196_ENGINE_ACCEPTANCE.md +0 -45
- package/docs/PRINT_CONTRAST_REFERENCE.md +0 -43
- package/docs/PRINT_DETAIL_ASSESSMENT.md +0 -81
- package/docs/PRINT_DETAIL_JPEG_EVIDENCE.md +0 -36
- package/docs/PRINT_DETAIL_SDR_EVIDENCE.md +0 -29
- package/docs/PRINT_DETAIL_VALIDATION.md +0 -36
- package/docs/PRINT_PLANNING.md +0 -75
- package/docs/PRINT_REGION_STATISTICS.md +0 -38
- package/docs/PROCESSED_OUTPUT.md +0 -157
- package/docs/PRODUCTION_COMPOSITION.md +0 -373
- package/docs/PRODUCTION_ENVIRONMENT_CAPTURE.md +0 -131
- package/docs/PROVENANCE.md +0 -115
- package/docs/PSF_FOUNDATION.md +0 -165
- package/docs/RAW_FRAME_ENVELOPE.md +0 -56
- package/docs/RAW_FRAME_RECONSTRUCTION.md +0 -30
- package/docs/RELEASE_1_0.md +0 -66
- package/docs/RELEASE_1_0_1.md +0 -61
- package/docs/RELEASE_1_1_0.md +0 -25
- package/docs/RELEASE_1_2_0.md +0 -51
- package/docs/RELEASE_1_3_0.md +0 -15
- package/docs/RELEASE_1_4_0.md +0 -23
- package/docs/RELEASE_AUDIT.md +0 -39
- package/docs/SCENE_RADIANCE_AND_ILLUMINATION.md +0 -298
- package/docs/SCENE_SENSOR_QUADRATURE.md +0 -98
- package/docs/SCENE_SENSOR_TEMPORAL_EXPOSURE.md +0 -86
- package/docs/SCIENTIFIC_ASSURANCE.md +0 -280
- package/docs/SCIENTIFIC_CONFORMANCE.md +0 -83
- package/docs/SDR_RENDERING.md +0 -33
- package/docs/SENSOR_APERTURE_RAYS.md +0 -23
- package/docs/SENSOR_ENVIRONMENT_QUERY.md +0 -86
- package/docs/SENSOR_EQE_LOCAL_EXPOSURE.md +0 -104
- package/docs/SENSOR_EQE_TEMPORAL_EXPOSURE.md +0 -74
- package/docs/SENSOR_PSF_QUADRATURE.md +0 -90
- package/docs/SENSOR_RAW_FRAME.md +0 -20
- package/docs/SENSOR_RAW_PRODUCER.md +0 -77
- package/docs/SIGNAL_CONFORMANCE.md +0 -23
- package/docs/SIMULATED_CAPTURE.md +0 -65
- package/docs/STABILIZATION.md +0 -234
- package/docs/TEMPORAL_PHOTO_RAW.md +0 -83
- package/docs/TIER_ACCEPTANCE.md +0 -129
- package/docs/TIER_PRESET_ACCEPTANCE.md +0 -59
- package/docs/V1_COMPOSITION_MAP.md +0 -123
- package/docs/V1_HELPER_REUSE_REVIEW.md +0 -60
- package/docs/V1_PERFORMANCE_DISPOSITION.md +0 -88
- package/docs/benchmarks/2026-10-01-main-baseline.json +0 -694
- package/docs/benchmarks/2026-10-02-geometric-preparation-reuse.json +0 -2190
- package/docs/benchmarks/2026-10-02-poc-projection-reuse.json +0 -2423
- package/docs/benchmarks/2026-10-02-v1-environment-gc-profile.json +0 -210
- package/docs/benchmarks/2026-10-02-v1-environment-ordinary.json +0 -187
- package/docs/benchmarks/2026-10-02-v1-geometry-gc-profile.json +0 -756
- package/docs/benchmarks/2026-10-02-v1-geometry-ordinary-1.json +0 -711
- package/docs/benchmarks/2026-10-02-v1-geometry-ordinary-2.json +0 -711
- package/docs/benchmarks/2026-10-02-v1-poc-gc-profile.json +0 -885
- package/docs/benchmarks/2026-10-02-v1-poc-ordinary-1.json +0 -868
- package/docs/benchmarks/2026-10-02-v1-poc-ordinary-2.json +0 -868
- package/docs/licenses/castleCSF-MIT.txt +0 -21
- package/docs/validation/documentation-fragments.json +0 -212
- package/docs/validation/native-capture-sdr-darwin-arm64-node26-review.jsonl +0 -4
- package/docs/validation/native-capture-sdr-darwin-arm64.jsonl +0 -3
- package/docs/validation/native-raw-print-2026-10-04/fractional-asymmetric-crop.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/gray-ramp.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/linear-area-checker.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/manifest.json +0 -218
- package/docs/validation/native-raw-print-2026-10-04/megapixel-native.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/native-color.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/photivra-native-full-megapixel-validation.json +0 -9
- package/docs/validation/native-raw-print-2026-10-04/photivra-native-full-megapixel.json +0 -29
- package/docs/validation/native-raw-print-2026-10-04/photivra-native-full-megapixel.json.codes.u16le.gz +0 -0
- package/docs/validation/native-raw-print-2026-10-04/photivra-native-full-megapixel.json.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/photivra-native-full-megapixel.json.rgb.gz +0 -0
- package/docs/validation/native-raw-print-2026-10-04/srgb.icc +0 -0
- package/docs/validation/native-raw-print-2026-10-04/validation.json +0 -41
- package/docs/validation/print-196-candidate-capabilities.json +0 -28
- package/docs/validation/print-196-candidate-evidence.json +0 -356
- package/docs/validation/print-196-engine-acceptance.json +0 -81
- package/docs/validation/print-detail-capabilities.json +0 -103
- package/docs/validation/print-detail-jpeg-evidence.json +0 -116
- package/docs/validation/print-detail-sdr-evidence.json +0 -81
- package/docs/validation/release-audit-inventory.json +0 -1306
- package/docs/validation/tier-acceptance-report-v1.json +0 -2538
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* HDR from linear RAW brackets and HDR output encoding.
|
|
4
|
+
*
|
|
5
|
+
* Merge (`createHdrBracketMergeTask`): for each sample, every frame whose code is below its white level
|
|
6
|
+
* and not flagged gives an independent estimate of the photo-electron rate Φ (e⁻/s):
|
|
7
|
+
* e_k = (code_k − black_k)·K_k, Φ̂_k = e_k / t_k,
|
|
8
|
+
* Var[e_k] = max(Φ, 0)·t_k + σ_read,k² + K_k²/12 (Poisson shot + Gaussian read + uniform quantization,
|
|
9
|
+
* the same shot+read variance as `calculateSignalToNoise`, plus the EMVA 1288 quantization term).
|
|
10
|
+
* The estimates are combined with inverse-variance weights w_k = t_k²/Var[e_k]. This is the
|
|
11
|
+
* lowest-noise linear combination for a linear camera (Granados et al., CVPR 2010; Hasinoff, Durand &
|
|
12
|
+
* Freeman, CVPR 2010). The Φ inside the variance is not known in advance. So it starts from the
|
|
13
|
+
* shot-noise-limited estimate Σe_k/Σt_k and is refined by a fixed number of reweighting passes.
|
|
14
|
+
* Var[Φ̂] = 1/Σw_k.
|
|
15
|
+
* - A sample saturated in every frame gets the largest representable rate (a lower bound) and a
|
|
16
|
+
* count of 0.
|
|
17
|
+
* - Inputs must be linear RAW codes. Non-linear inputs (with a camera response curve) are not
|
|
18
|
+
* supported, so no Debevec–Malik response recovery is done.
|
|
19
|
+
* - Works with any per-sample layout (CFA mosaic or RGB).
|
|
20
|
+
*
|
|
21
|
+
* Encoding (`createHdrImageEncodingTask`): linear RGB is converted to BT.2020 primaries (matrices from
|
|
22
|
+
* `resolveRgbColorSpace`) and returned as unclipped float32 linear BT.2020. The PQ and HLG transfer
|
|
23
|
+
* functions are not part of 2.0 (owner decision, 2026-10-17: their patent holders offer only
|
|
24
|
+
* licence-on-request declarations; see THIRD_PARTY.md).
|
|
25
|
+
* @see docs/PROCESSING.md for equations, sources and limits.
|
|
26
|
+
*/
|
|
27
|
+
import { InvalidConfigurationError } from "../core/configuration-error.js";
|
|
28
|
+
import { InvalidScientificInputError } from "../core/validation.js";
|
|
29
|
+
import { resolveRgbColorSpace } from "../color/rgb-color-spaces.js";
|
|
30
|
+
import { rgbSpaceOf } from "./image-ops.js";
|
|
31
|
+
import { createProcessingTask, finiteRows, maximumWorkingBytes, optionalIntegerIn, processingProvenance, requireEnum, requireFiniteIn, requireImage, requireIntegerIn, requireOptions, PROCESSING_MAX_FRAMES, PROCESSING_MAX_PIXELS } from "./processing-task.js";
|
|
32
|
+
/**
|
|
33
|
+
* Shortest accepted bracket exposure, 1 ns. Far below any photographic shutter (about 1/32000 s ≈ 3·10⁻⁵ s for
|
|
34
|
+
* fast electronic shutters), it keeps every merge quantity finite: t² ≥ 10⁻¹⁸ cannot underflow (at 10⁻¹⁷⁰ s it
|
|
35
|
+
* does, and the weights become 0/0), and the largest rate (white − black)·K/t ≤ 2⁵³ · 10⁹ / 10⁻⁹ ≈ 9·10³³ e⁻/s
|
|
36
|
+
* stays inside the float32 output range (≈ 3.4·10³⁸).
|
|
37
|
+
*/
|
|
38
|
+
const HDR_MINIMUM_EXPOSURE_TIME_SECONDS = 1e-9;
|
|
39
|
+
/** Largest finite float32. */
|
|
40
|
+
const FLOAT32_MAX = 3.4028234663852886e38;
|
|
41
|
+
/** Noise-optimal merge of linear RAW exposure brackets into a scene-linear photo-electron rate. */
|
|
42
|
+
export function createHdrBracketMergeTask(input, provider) {
|
|
43
|
+
const r = requireOptions(input, ["sampleCount", "frames", "iterations", "maximumWorkingBytes"], "createHdrBracketMergeTask input");
|
|
44
|
+
const n = requireIntegerIn(r.sampleCount, "sampleCount", 1, 3 * PROCESSING_MAX_PIXELS);
|
|
45
|
+
if (!Array.isArray(r.frames) || r.frames.length < 1 || r.frames.length > PROCESSING_MAX_FRAMES) {
|
|
46
|
+
throw new InvalidConfigurationError("frames must contain 1 to " + PROCESSING_MAX_FRAMES + " brackets.");
|
|
47
|
+
}
|
|
48
|
+
const frames = r.frames.map((value, i) => {
|
|
49
|
+
const f = requireOptions(value, ["exposureTimeSeconds", "codes", "blackLevelCode", "whiteLevelCode", "saturationFlags",
|
|
50
|
+
"conversionGainElectronsPerCode", "readNoiseElectrons"], "frames[" + i + "]");
|
|
51
|
+
if (!(f.codes instanceof Uint16Array || f.codes instanceof Float32Array) || f.codes.length !== n) {
|
|
52
|
+
throw new InvalidConfigurationError("frames[" + i + "].codes must be a Uint16Array or Float32Array of sampleCount codes.");
|
|
53
|
+
}
|
|
54
|
+
if (f.saturationFlags !== undefined && (!(f.saturationFlags instanceof Uint8Array) || f.saturationFlags.length !== n)) {
|
|
55
|
+
throw new InvalidConfigurationError("frames[" + i + "].saturationFlags must be a Uint8Array of sampleCount flags.");
|
|
56
|
+
}
|
|
57
|
+
const black = requireFiniteIn(f.blackLevelCode, "frames[" + i + "].blackLevelCode", 0, Number.MAX_SAFE_INTEGER);
|
|
58
|
+
const white = requireFiniteIn(f.whiteLevelCode, "frames[" + i + "].whiteLevelCode", black, Number.MAX_SAFE_INTEGER, true);
|
|
59
|
+
const read = requireFiniteIn(f.readNoiseElectrons, "frames[" + i + "].readNoiseElectrons", 0, 1e9);
|
|
60
|
+
return { t: requireFiniteIn(f.exposureTimeSeconds, "frames[" + i + "].exposureTimeSeconds", HDR_MINIMUM_EXPOSURE_TIME_SECONDS, 1e6), codes: f.codes, black, white,
|
|
61
|
+
flags: f.saturationFlags ?? null,
|
|
62
|
+
k: requireFiniteIn(f.conversionGainElectronsPerCode, "frames[" + i + "].conversionGainElectronsPerCode", 0, 1e9, true), read2: read * read };
|
|
63
|
+
});
|
|
64
|
+
const iterations = optionalIntegerIn(r.iterations, 2, "iterations", 0, 16);
|
|
65
|
+
// Saturated everywhere: the largest representable rate of any frame is a lower bound.
|
|
66
|
+
const ceiling = Math.max(...frames.map((f) => (f.white - f.black) * f.k / f.t));
|
|
67
|
+
const rows = Math.ceil(n / 4096);
|
|
68
|
+
return createProcessingTask({
|
|
69
|
+
provider, totalTileCount: rows * (frames.length + 1), estimatedWorkingBytes: n * 9, maximumWorkingBytes: maximumWorkingBytes(r.maximumWorkingBytes),
|
|
70
|
+
body: function* () {
|
|
71
|
+
for (const [i, f] of frames.entries())
|
|
72
|
+
for (let row = 0; row < rows; row++) {
|
|
73
|
+
for (let j = row * 4096, end = Math.min(n, j + 4096); j < end; j++) {
|
|
74
|
+
if (!Number.isFinite(f.codes[j]))
|
|
75
|
+
throw new InvalidScientificInputError("frames[" + i + "].codes must be finite.");
|
|
76
|
+
}
|
|
77
|
+
yield;
|
|
78
|
+
}
|
|
79
|
+
const rate = new Float32Array(n), sd = new Float32Array(n), count = new Uint8Array(n);
|
|
80
|
+
let allSaturated = 0;
|
|
81
|
+
for (let row = 0; row < rows; row++) {
|
|
82
|
+
for (let j = row * 4096, end = Math.min(n, j + 4096); j < end; j++) {
|
|
83
|
+
let sumE = 0, sumT = 0, used = 0;
|
|
84
|
+
for (const f of frames) {
|
|
85
|
+
const code = f.codes[j];
|
|
86
|
+
if (code >= f.white || (f.flags !== null && f.flags[j] !== 0))
|
|
87
|
+
continue;
|
|
88
|
+
sumE += (code - f.black) * f.k;
|
|
89
|
+
sumT += f.t;
|
|
90
|
+
used++;
|
|
91
|
+
}
|
|
92
|
+
if (used === 0) {
|
|
93
|
+
rate[j] = ceiling;
|
|
94
|
+
sd[j] = 0;
|
|
95
|
+
allSaturated++;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
let phi = sumE / sumT, weightSum = 0;
|
|
99
|
+
// Pass `it` weights by the current Φ. Passes 1..iterations update Φ; the last pass also gives Var[Φ̂].
|
|
100
|
+
for (let it = 0; it <= iterations; it++) {
|
|
101
|
+
let num = 0;
|
|
102
|
+
weightSum = 0;
|
|
103
|
+
for (const f of frames) {
|
|
104
|
+
const code = f.codes[j];
|
|
105
|
+
if (code >= f.white || (f.flags !== null && f.flags[j] !== 0))
|
|
106
|
+
continue;
|
|
107
|
+
const variance = Math.max(phi, 0) * f.t + f.read2 + f.k * f.k / 12, w = f.t * f.t / variance;
|
|
108
|
+
num += w * ((code - f.black) * f.k / f.t);
|
|
109
|
+
weightSum += w;
|
|
110
|
+
}
|
|
111
|
+
if (it < iterations)
|
|
112
|
+
phi = num / weightSum;
|
|
113
|
+
}
|
|
114
|
+
const deviation = Math.sqrt(1 / weightSum);
|
|
115
|
+
// Fail closed rather than store NaN or ±Infinity (for example with a near-zero conversion gain).
|
|
116
|
+
if (!(Math.abs(phi) <= FLOAT32_MAX) || !(deviation <= FLOAT32_MAX)) {
|
|
117
|
+
throw new InvalidScientificInputError("HDR merge gives a non-finite rate at sample " + j + "; check exposure times, conversion gains and read noise.");
|
|
118
|
+
}
|
|
119
|
+
rate[j] = phi;
|
|
120
|
+
sd[j] = deviation;
|
|
121
|
+
count[j] = used;
|
|
122
|
+
}
|
|
123
|
+
yield;
|
|
124
|
+
}
|
|
125
|
+
return { radianceElectronsPerSecond: rate, standardDeviationElectronsPerSecond: sd, contributingFrameCount: count, saturatedInAllFramesCount: allSaturated,
|
|
126
|
+
provenance: processingProvenance("hdr-linear-raw-bracket-merge-inverse-variance", [
|
|
127
|
+
"Linear RAW only: Phi_k = (code - black)K/t per unsaturated, unflagged frame.",
|
|
128
|
+
"Inverse-variance weights t^2/(Phi t + read^2 + K^2/12) (Granados et al. 2010; Hasinoff et al. 2010), Phi refined by fixed reweighting iterations.",
|
|
129
|
+
"Dark current, fixed-pattern noise and inter-frame motion are not modelled; frames must be registered.",
|
|
130
|
+
"Samples saturated in all frames carry the largest representable rate as a lower bound."
|
|
131
|
+
]) };
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/** Converts linear RGB to unclipped float32 linear BT.2020 (relative values, no transfer function or quantization). */
|
|
136
|
+
export function createHdrImageEncodingTask(input, provider) {
|
|
137
|
+
const r = requireOptions(input, ["image", "inputColorSpace", "transfer", "maximumWorkingBytes"], "createHdrImageEncodingTask input");
|
|
138
|
+
const image = requireImage(r.image, "image");
|
|
139
|
+
const space = requireEnum(r.inputColorSpace, ["linear-srgb-d65", "linear-display-p3-d65", "linear-rec2020-d65"], "inputColorSpace");
|
|
140
|
+
const transfer = requireEnum(r.transfer, ["linear-float32"], "transfer");
|
|
141
|
+
const src = resolveRgbColorSpace(rgbSpaceOf(space)).value, dst = resolveRgbColorSpace("rec2020").value;
|
|
142
|
+
const m = [0, 1, 2].map((i) => [0, 1, 2].map((j) => dst.xyzToRgb[i][0] * src.rgbToXyz[0][j] + dst.xyzToRgb[i][1] * src.rgbToXyz[1][j] +
|
|
143
|
+
dst.xyzToRgb[i][2] * src.rgbToXyz[2][j]));
|
|
144
|
+
if (space === "linear-rec2020-d65")
|
|
145
|
+
for (let i = 0; i < 3; i++)
|
|
146
|
+
for (let j = 0; j < 3; j++)
|
|
147
|
+
m[i][j] = i === j ? 1 : 0;
|
|
148
|
+
const samples = image.width * image.height * 3;
|
|
149
|
+
return createProcessingTask({
|
|
150
|
+
provider, totalTileCount: 2 * image.height, estimatedWorkingBytes: samples * 4,
|
|
151
|
+
maximumWorkingBytes: maximumWorkingBytes(r.maximumWorkingBytes),
|
|
152
|
+
body: function* () {
|
|
153
|
+
yield* finiteRows(image.data, image.width, image.height, 3, "image");
|
|
154
|
+
const linear = new Float32Array(samples);
|
|
155
|
+
const d = image.data, stride = image.width * 3;
|
|
156
|
+
for (let y = 0; y < image.height; y++) {
|
|
157
|
+
for (let i = y * stride; i < (y + 1) * stride; i += 3) {
|
|
158
|
+
const a = d[i], b = d[i + 1], c = d[i + 2];
|
|
159
|
+
for (let k = 0; k < 3; k++)
|
|
160
|
+
linear[i + k] = m[k][0] * a + m[k][1] * b + m[k][2] * c;
|
|
161
|
+
}
|
|
162
|
+
yield;
|
|
163
|
+
}
|
|
164
|
+
return { width: image.width, height: image.height, colorSpace: "rec2020", transfer, linear,
|
|
165
|
+
provenance: processingProvenance("hdr-linear-rec2020-output", [
|
|
166
|
+
"Linear input converted to BT.2020 primaries through XYZ with matrices derived from the published primaries and D65 (ITU-R BT.2020-2; method as in W3C CSS Color 4).",
|
|
167
|
+
"Unclipped float32 linear BT.2020; no transfer function or quantization."
|
|
168
|
+
]) };
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=hdr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hdr.js","sourceRoot":"","sources":["../../src/processing/hdr.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,oBAAoB,EAAE,UAAU,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,WAAW,EAAE,eAAe,EAC5H,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,EAE7F,MAAM,sBAAsB,CAAC;AAqC9B;;;;;GAKG;AACH,MAAM,iCAAiC,GAAG,IAAI,CAAC;AAC/C,8BAA8B;AAC9B,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAI1C,mGAAmG;AACnG,MAAM,UAAU,yBAAyB,CAAC,KAA2B,EAAE,QAA4B;IACjG,MAAM,CAAC,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,qBAAqB,CAAC,EAAE,iCAAi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CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtC,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC;oBAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;wBAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC;gBAC5F,CAAC;gBACD,KAAK,CAAC;YACR,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM;gBACxF,UAAU,EAAE,oBAAoB,CAAC,2BAA2B,EAAE;oBAC5D,qKAAqK;oBACrK,yEAAyE;iBAAC,CAAC,EAAE,CAAC;QACpF,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * HDR from linear RAW brackets and HDR output encoding.\n *\n * Merge (`createHdrBracketMergeTask`): for each sample, every frame whose code is below its white level\n * and not flagged gives an independent estimate of the photo-electron rate Φ (e⁻/s):\n * e_k = (code_k − black_k)·K_k, Φ̂_k = e_k / t_k,\n * Var[e_k] = max(Φ, 0)·t_k + σ_read,k² + K_k²/12 (Poisson shot + Gaussian read + uniform quantization,\n * the same shot+read variance as `calculateSignalToNoise`, plus the EMVA 1288 quantization term).\n * The estimates are combined with inverse-variance weights w_k = t_k²/Var[e_k]. This is the\n * lowest-noise linear combination for a linear camera (Granados et al., CVPR 2010; Hasinoff, Durand &\n * Freeman, CVPR 2010). The Φ inside the variance is not known in advance. So it starts from the\n * shot-noise-limited estimate Σe_k/Σt_k and is refined by a fixed number of reweighting passes.\n * Var[Φ̂] = 1/Σw_k.\n * - A sample saturated in every frame gets the largest representable rate (a lower bound) and a\n * count of 0.\n * - Inputs must be linear RAW codes. Non-linear inputs (with a camera response curve) are not\n * supported, so no Debevec–Malik response recovery is done.\n * - Works with any per-sample layout (CFA mosaic or RGB).\n *\n * Encoding (`createHdrImageEncodingTask`): linear RGB is converted to BT.2020 primaries (matrices from\n * `resolveRgbColorSpace`) and returned as unclipped float32 linear BT.2020. The PQ and HLG transfer\n * functions are not part of 2.0 (owner decision, 2026-10-17: their patent holders offer only\n * licence-on-request declarations; see THIRD_PARTY.md).\n * @see docs/PROCESSING.md for equations, sources and limits.\n */\n\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { InvalidScientificInputError } from \"../core/validation.js\";\nimport { resolveRgbColorSpace } from \"../color/rgb-color-spaces.js\";\nimport { rgbSpaceOf } from \"./image-ops.js\";\nimport {\n createProcessingTask, finiteRows, maximumWorkingBytes, optionalIntegerIn, processingProvenance, requireEnum, requireFiniteIn,\n requireImage, requireIntegerIn, requireOptions, PROCESSING_MAX_FRAMES, PROCESSING_MAX_PIXELS,\n type ProcessingBody, type ProcessingLinearColorSpace, type ProcessingProvenance, type ProcessingProvider, type ProcessingRgbImage, type ProcessingTask\n} from \"./processing-task.js\";\n\nexport interface HdrBracketFrame {\n exposureTimeSeconds: number;\n /** Linear RAW codes, one per sample. */\n codes: Uint16Array | Float32Array;\n blackLevelCode: number;\n /** Codes at or above this level are saturated and excluded. */\n whiteLevelCode: number;\n /** Optional per-sample flags. Non-zero excludes the sample (for example physical saturation before the ADC). */\n saturationFlags?: Uint8Array;\n /** System conversion gain K, electrons per code (includes the frame's ISO gain). */\n conversionGainElectronsPerCode: number;\n /** RMS read noise in electrons for this frame's readout regime. */\n readNoiseElectrons: number;\n}\n\nexport interface HdrBracketMergeInput {\n /** Samples per frame (e.g. width·height for a mosaic, width·height·3 for RGB). */\n sampleCount: number;\n frames: readonly HdrBracketFrame[];\n /** Variance reweighting iterations after the shot-noise-limited start; default 2. */\n iterations?: number;\n maximumWorkingBytes?: number;\n}\n\nexport interface HdrBracketMergeOutput {\n /** Scene-linear photo-electron rate per sample, e⁻/s (relative scene radiance; not absolute). */\n radianceElectronsPerSecond: Float32Array;\n /** Model standard deviation of each estimate, e⁻/s. */\n standardDeviationElectronsPerSecond: Float32Array;\n /** Frames that contributed; 0 marks a sample saturated in every frame (value is a lower bound). */\n contributingFrameCount: Uint8Array;\n saturatedInAllFramesCount: number;\n provenance: ProcessingProvenance;\n}\n\n/**\n * Shortest accepted bracket exposure, 1 ns. Far below any photographic shutter (about 1/32000 s ≈ 3·10⁻⁵ s for\n * fast electronic shutters), it keeps every merge quantity finite: t² ≥ 10⁻¹⁸ cannot underflow (at 10⁻¹⁷⁰ s it\n * does, and the weights become 0/0), and the largest rate (white − black)·K/t ≤ 2⁵³ · 10⁹ / 10⁻⁹ ≈ 9·10³³ e⁻/s\n * stays inside the float32 output range (≈ 3.4·10³⁸).\n */\nconst HDR_MINIMUM_EXPOSURE_TIME_SECONDS = 1e-9;\n/** Largest finite float32. */\nconst FLOAT32_MAX = 3.4028234663852886e38;\n\ninterface ParsedFrame { t: number; codes: Uint16Array | Float32Array; black: number; white: number; flags: Uint8Array | null; k: number; read2: number }\n\n/** Noise-optimal merge of linear RAW exposure brackets into a scene-linear photo-electron rate. */\nexport function createHdrBracketMergeTask(input: HdrBracketMergeInput, provider: ProcessingProvider): ProcessingTask<HdrBracketMergeOutput> {\n const r = requireOptions(input, [\"sampleCount\", \"frames\", \"iterations\", \"maximumWorkingBytes\"], \"createHdrBracketMergeTask input\");\n const n = requireIntegerIn(r.sampleCount, \"sampleCount\", 1, 3 * PROCESSING_MAX_PIXELS);\n if (!Array.isArray(r.frames) || r.frames.length < 1 || r.frames.length > PROCESSING_MAX_FRAMES) {\n throw new InvalidConfigurationError(\"frames must contain 1 to \" + PROCESSING_MAX_FRAMES + \" brackets.\");\n }\n const frames: ParsedFrame[] = r.frames.map((value: unknown, i: number) => {\n const f = requireOptions(value, [\"exposureTimeSeconds\", \"codes\", \"blackLevelCode\", \"whiteLevelCode\", \"saturationFlags\",\n \"conversionGainElectronsPerCode\", \"readNoiseElectrons\"], \"frames[\" + i + \"]\");\n if (!(f.codes instanceof Uint16Array || f.codes instanceof Float32Array) || f.codes.length !== n) {\n throw new InvalidConfigurationError(\"frames[\" + i + \"].codes must be a Uint16Array or Float32Array of sampleCount codes.\");\n }\n if (f.saturationFlags !== undefined && (!(f.saturationFlags instanceof Uint8Array) || f.saturationFlags.length !== n)) {\n throw new InvalidConfigurationError(\"frames[\" + i + \"].saturationFlags must be a Uint8Array of sampleCount flags.\");\n }\n const black = requireFiniteIn(f.blackLevelCode, \"frames[\" + i + \"].blackLevelCode\", 0, Number.MAX_SAFE_INTEGER);\n const white = requireFiniteIn(f.whiteLevelCode, \"frames[\" + i + \"].whiteLevelCode\", black, Number.MAX_SAFE_INTEGER, true);\n const read = requireFiniteIn(f.readNoiseElectrons, \"frames[\" + i + \"].readNoiseElectrons\", 0, 1e9);\n return { t: requireFiniteIn(f.exposureTimeSeconds, \"frames[\" + i + \"].exposureTimeSeconds\", HDR_MINIMUM_EXPOSURE_TIME_SECONDS, 1e6), codes: f.codes, black, white,\n flags: (f.saturationFlags as Uint8Array | undefined) ?? null,\n k: requireFiniteIn(f.conversionGainElectronsPerCode, \"frames[\" + i + \"].conversionGainElectronsPerCode\", 0, 1e9, true), read2: read * read };\n });\n const iterations = optionalIntegerIn(r.iterations, 2, \"iterations\", 0, 16);\n // Saturated everywhere: the largest representable rate of any frame is a lower bound.\n const ceiling = Math.max(...frames.map((f) => (f.white - f.black) * f.k / f.t));\n const rows = Math.ceil(n / 4096);\n return createProcessingTask({\n provider, totalTileCount: rows * (frames.length + 1), estimatedWorkingBytes: n * 9, maximumWorkingBytes: maximumWorkingBytes(r.maximumWorkingBytes),\n body: function* (): ProcessingBody<HdrBracketMergeOutput> {\n for (const [i, f] of frames.entries()) for (let row = 0; row < rows; row++) {\n for (let j = row * 4096, end = Math.min(n, j + 4096); j < end; j++) {\n if (!Number.isFinite(f.codes[j]!)) throw new InvalidScientificInputError(\"frames[\" + i + \"].codes must be finite.\");\n }\n yield;\n }\n const rate = new Float32Array(n), sd = new Float32Array(n), count = new Uint8Array(n);\n let allSaturated = 0;\n for (let row = 0; row < rows; row++) {\n for (let j = row * 4096, end = Math.min(n, j + 4096); j < end; j++) {\n let sumE = 0, sumT = 0, used = 0;\n for (const f of frames) {\n const code = f.codes[j]!;\n if (code >= f.white || (f.flags !== null && f.flags[j] !== 0)) continue;\n sumE += (code - f.black) * f.k; sumT += f.t; used++;\n }\n if (used === 0) { rate[j] = ceiling; sd[j] = 0; allSaturated++; continue; }\n let phi = sumE / sumT, weightSum = 0;\n // Pass `it` weights by the current Φ. Passes 1..iterations update Φ; the last pass also gives Var[Φ̂].\n for (let it = 0; it <= iterations; it++) {\n let num = 0; weightSum = 0;\n for (const f of frames) {\n const code = f.codes[j]!;\n if (code >= f.white || (f.flags !== null && f.flags[j] !== 0)) continue;\n const variance = Math.max(phi, 0) * f.t + f.read2 + f.k * f.k / 12, w = f.t * f.t / variance;\n num += w * ((code - f.black) * f.k / f.t); weightSum += w;\n }\n if (it < iterations) phi = num / weightSum;\n }\n const deviation = Math.sqrt(1 / weightSum);\n // Fail closed rather than store NaN or ±Infinity (for example with a near-zero conversion gain).\n if (!(Math.abs(phi) <= FLOAT32_MAX) || !(deviation <= FLOAT32_MAX)) {\n throw new InvalidScientificInputError(\"HDR merge gives a non-finite rate at sample \" + j + \"; check exposure times, conversion gains and read noise.\");\n }\n rate[j] = phi; sd[j] = deviation; count[j] = used;\n }\n yield;\n }\n return { radianceElectronsPerSecond: rate, standardDeviationElectronsPerSecond: sd, contributingFrameCount: count, saturatedInAllFramesCount: allSaturated,\n provenance: processingProvenance(\"hdr-linear-raw-bracket-merge-inverse-variance\", [\n \"Linear RAW only: Phi_k = (code - black)K/t per unsaturated, unflagged frame.\",\n \"Inverse-variance weights t^2/(Phi t + read^2 + K^2/12) (Granados et al. 2010; Hasinoff et al. 2010), Phi refined by fixed reweighting iterations.\",\n \"Dark current, fixed-pattern noise and inter-frame motion are not modelled; frames must be registered.\",\n \"Samples saturated in all frames carry the largest representable rate as a lower bound.\"]) };\n }\n });\n}\n\n// ------------------------------------------------------------------ HDR output encoding\n\n/** The only output transfer in 2.0: unclipped float32 linear values (PQ and HLG are not shipped). */\nexport type HdrTransfer = \"linear-float32\";\n\nexport interface HdrImageEncodingInput {\n image: ProcessingRgbImage;\n inputColorSpace: ProcessingLinearColorSpace;\n transfer: HdrTransfer;\n maximumWorkingBytes?: number;\n}\n\nexport interface HdrImageEncodingOutput {\n width: number;\n height: number;\n colorSpace: \"rec2020\";\n transfer: HdrTransfer;\n /** Interleaved linear BT.2020 RGB (relative, unclipped). */\n linear: Float32Array;\n provenance: ProcessingProvenance;\n}\n\n/** Converts linear RGB to unclipped float32 linear BT.2020 (relative values, no transfer function or quantization). */\nexport function createHdrImageEncodingTask(input: HdrImageEncodingInput, provider: ProcessingProvider): ProcessingTask<HdrImageEncodingOutput> {\n const r = requireOptions(input, [\"image\", \"inputColorSpace\", \"transfer\", \"maximumWorkingBytes\"], \"createHdrImageEncodingTask input\");\n const image = requireImage(r.image, \"image\");\n const space = requireEnum(r.inputColorSpace, [\"linear-srgb-d65\", \"linear-display-p3-d65\", \"linear-rec2020-d65\"] as const, \"inputColorSpace\");\n const transfer = requireEnum(r.transfer, [\"linear-float32\"] as const, \"transfer\");\n const src = resolveRgbColorSpace(rgbSpaceOf(space)).value, dst = resolveRgbColorSpace(\"rec2020\").value;\n const m = [0, 1, 2].map((i) => [0, 1, 2].map((j) => dst.xyzToRgb[i]![0] * src.rgbToXyz[0][j]! + dst.xyzToRgb[i]![1] * src.rgbToXyz[1][j]! +\n dst.xyzToRgb[i]![2] * src.rgbToXyz[2][j]!));\n if (space === \"linear-rec2020-d65\") for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) m[i]![j] = i === j ? 1 : 0;\n const samples = image.width * image.height * 3;\n return createProcessingTask({\n provider, totalTileCount: 2 * image.height, estimatedWorkingBytes: samples * 4,\n maximumWorkingBytes: maximumWorkingBytes(r.maximumWorkingBytes),\n body: function* (): ProcessingBody<HdrImageEncodingOutput> {\n yield* finiteRows(image.data, image.width, image.height, 3, \"image\");\n const linear = new Float32Array(samples);\n const d = image.data, stride = image.width * 3;\n for (let y = 0; y < image.height; y++) {\n for (let i = y * stride; i < (y + 1) * stride; i += 3) {\n const a = d[i]!, b = d[i + 1]!, c = d[i + 2]!;\n for (let k = 0; k < 3; k++) linear[i + k] = m[k]![0]! * a + m[k]![1]! * b + m[k]![2]! * c;\n }\n yield;\n }\n return { width: image.width, height: image.height, colorSpace: \"rec2020\", transfer, linear,\n provenance: processingProvenance(\"hdr-linear-rec2020-output\", [\n \"Linear input converted to BT.2020 primaries through XYZ with matrices derived from the published primaries and D65 (ITU-R BT.2020-2; method as in W3C CSS Color 4).\",\n \"Unclipped float32 linear BT.2020; no transfer function or quantization.\"]) };\n }\n });\n}\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal image operations on typed arrays, shared by the processing operators. Not exported from
|
|
3
|
+
* the package root.
|
|
4
|
+
*
|
|
5
|
+
* Every spatial operation uses symmetric whole-sample (reflect-101) borders, the same mapping as the
|
|
6
|
+
* RAW mirror border handling. Row generators yield once per output row of each pass. The matching
|
|
7
|
+
* `*Rows` functions return exactly that count, so task plans know their total in advance.
|
|
8
|
+
*
|
|
9
|
+
* Pyramids follow Burt & Adelson (1983):
|
|
10
|
+
* - REDUCE blurs with the separable 5-tap kernel w = [1, 4, 6, 4, 1]/16 (a = 0.375) and keeps every
|
|
11
|
+
* second sample (size ⌈n/2⌉).
|
|
12
|
+
* - EXPAND upsamples with the same kernel, times two per axis.
|
|
13
|
+
* - A Laplacian level is G_l − EXPAND(G_{l+1}). Collapsing with the same EXPAND rebuilds G_0 exactly,
|
|
14
|
+
* up to float32 rounding, whatever the border rule.
|
|
15
|
+
*/
|
|
16
|
+
import { reflectRawSiteIndex as reflect } from "../sensor/raw-reconstruction.js";
|
|
17
|
+
import type { ProcessingBody, ProcessingLinearColorSpace } from "./processing-task.js";
|
|
18
|
+
import { type RgbColorSpaceId } from "../color/rgb-color-spaces.js";
|
|
19
|
+
export { reflect };
|
|
20
|
+
/** Normalized 1-D Gaussian taps for standard deviation σ (pixels), truncated at ⌈3σ⌉; σ = 0 → [1]. */
|
|
21
|
+
export declare function gaussianKernel(sigma: number): Float64Array;
|
|
22
|
+
/** Rows yielded by `convolveSeparable`. */
|
|
23
|
+
export declare const convolveRows: (height: number) => number;
|
|
24
|
+
/** Separable convolution of a `channels`-interleaved plane with a symmetric kernel; `tmp` and `dst` have the source length. */
|
|
25
|
+
export declare function convolveSeparable(src: Float32Array, width: number, height: number, channels: number, kernel: Float64Array, tmp: Float32Array, dst: Float32Array): ProcessingBody<void>;
|
|
26
|
+
/** Size of the next coarser pyramid level. */
|
|
27
|
+
export declare const half: (n: number) => number;
|
|
28
|
+
/** Level dimensions for `levels` levels starting at (width, height). */
|
|
29
|
+
export declare function levelSizes(width: number, height: number, levels: number): {
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
}[];
|
|
33
|
+
/** Automatic level count: halve until the smaller side is 1 (at most `cap`). */
|
|
34
|
+
export declare function autoLevels(width: number, height: number, cap: number): number;
|
|
35
|
+
export declare const reduceRows: (height: number) => number;
|
|
36
|
+
/** REDUCE: blur with the Burt–Adelson kernel and keep even samples. */
|
|
37
|
+
export declare function reduce(src: Float32Array, width: number, height: number, channels: number, dst: Float32Array): ProcessingBody<void>;
|
|
38
|
+
export declare const expandRows: (coarseHeight: number, height: number) => number;
|
|
39
|
+
/**
|
|
40
|
+
* EXPAND a (cw × ch) level to (width × height): out(x) = 2 Σ_k w(k) in((x − k)/2) per axis over even
|
|
41
|
+
* x − k, coarse indices mirrored. `mode` "set" writes, "add" adds, "subtract-from" writes dst − expand.
|
|
42
|
+
*/
|
|
43
|
+
export declare function expand(src: Float32Array, cw: number, ch: number, width: number, height: number, channels: number, dst: Float32Array, mode: "set" | "add" | "subtract-from"): ProcessingBody<void>;
|
|
44
|
+
export interface Pyramid {
|
|
45
|
+
levels: Float32Array[];
|
|
46
|
+
sizes: {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
}[];
|
|
50
|
+
channels: number;
|
|
51
|
+
}
|
|
52
|
+
export declare function gaussianPyramidRows(width: number, height: number, levels: number): number;
|
|
53
|
+
/** Gaussian pyramid; level 0 is a copy of `src`. */
|
|
54
|
+
export declare function gaussianPyramid(src: Float32Array, width: number, height: number, channels: number, levels: number): ProcessingBody<Pyramid>;
|
|
55
|
+
export declare function laplacianPyramidRows(width: number, height: number, levels: number): number;
|
|
56
|
+
/** Laplacian pyramid: L_l = G_l − EXPAND(G_{l+1}); the last level is the coarsest Gaussian level. */
|
|
57
|
+
export declare function laplacianPyramid(src: Float32Array, width: number, height: number, channels: number, levels: number): ProcessingBody<Pyramid>;
|
|
58
|
+
export declare function collapseRows(width: number, height: number, levels: number): number;
|
|
59
|
+
/** Collapses a Laplacian pyramid in place (level 0 becomes the image). */
|
|
60
|
+
export declare function collapse(p: Pyramid): ProcessingBody<Float32Array>;
|
|
61
|
+
/** Bytes of a pyramid of `levels` levels for float32 storage. */
|
|
62
|
+
export declare function pyramidBytes(width: number, height: number, channels: number, levels: number): number;
|
|
63
|
+
/** Named colour space of a processing linear space. */
|
|
64
|
+
export declare function rgbSpaceOf(space: ProcessingLinearColorSpace): RgbColorSpaceId;
|
|
65
|
+
/** Luminance weights: the Y row of the space's RGB→XYZ matrix (derived from primaries and white, white Y = 1). */
|
|
66
|
+
export declare function luminanceWeights(space: ProcessingLinearColorSpace): readonly [number, number, number];
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Internal image operations on typed arrays, shared by the processing operators. Not exported from
|
|
4
|
+
* the package root.
|
|
5
|
+
*
|
|
6
|
+
* Every spatial operation uses symmetric whole-sample (reflect-101) borders, the same mapping as the
|
|
7
|
+
* RAW mirror border handling. Row generators yield once per output row of each pass. The matching
|
|
8
|
+
* `*Rows` functions return exactly that count, so task plans know their total in advance.
|
|
9
|
+
*
|
|
10
|
+
* Pyramids follow Burt & Adelson (1983):
|
|
11
|
+
* - REDUCE blurs with the separable 5-tap kernel w = [1, 4, 6, 4, 1]/16 (a = 0.375) and keeps every
|
|
12
|
+
* second sample (size ⌈n/2⌉).
|
|
13
|
+
* - EXPAND upsamples with the same kernel, times two per axis.
|
|
14
|
+
* - A Laplacian level is G_l − EXPAND(G_{l+1}). Collapsing with the same EXPAND rebuilds G_0 exactly,
|
|
15
|
+
* up to float32 rounding, whatever the border rule.
|
|
16
|
+
*/
|
|
17
|
+
import { reflectRawSiteIndex as reflect } from "../sensor/raw-reconstruction.js";
|
|
18
|
+
import { resolveRgbColorSpace } from "../color/rgb-color-spaces.js";
|
|
19
|
+
export { reflect };
|
|
20
|
+
/** Normalized 1-D Gaussian taps for standard deviation σ (pixels), truncated at ⌈3σ⌉; σ = 0 → [1]. */
|
|
21
|
+
export function gaussianKernel(sigma) {
|
|
22
|
+
if (sigma === 0)
|
|
23
|
+
return Float64Array.of(1);
|
|
24
|
+
const radius = Math.max(1, Math.ceil(3 * sigma)), k = new Float64Array(2 * radius + 1);
|
|
25
|
+
let sum = 0;
|
|
26
|
+
for (let i = -radius; i <= radius; i++)
|
|
27
|
+
sum += (k[i + radius] = Math.exp(-(i * i) / (2 * sigma * sigma)));
|
|
28
|
+
for (let i = 0; i < k.length; i++)
|
|
29
|
+
k[i] = k[i] / sum;
|
|
30
|
+
return k;
|
|
31
|
+
}
|
|
32
|
+
/** Rows yielded by `convolveSeparable`. */
|
|
33
|
+
export const convolveRows = (height) => 2 * height;
|
|
34
|
+
/** Separable convolution of a `channels`-interleaved plane with a symmetric kernel; `tmp` and `dst` have the source length. */
|
|
35
|
+
export function* convolveSeparable(src, width, height, channels, kernel, tmp, dst) {
|
|
36
|
+
const r = (kernel.length - 1) / 2, stride = width * channels;
|
|
37
|
+
for (let y = 0; y < height; y++) {
|
|
38
|
+
const row = y * stride;
|
|
39
|
+
for (let x = 0; x < width; x++)
|
|
40
|
+
for (let c = 0; c < channels; c++) {
|
|
41
|
+
let s = 0;
|
|
42
|
+
for (let k = -r; k <= r; k++)
|
|
43
|
+
s += kernel[k + r] * src[row + reflect(x + k, width) * channels + c];
|
|
44
|
+
tmp[row + x * channels + c] = s;
|
|
45
|
+
}
|
|
46
|
+
yield;
|
|
47
|
+
}
|
|
48
|
+
for (let y = 0; y < height; y++) {
|
|
49
|
+
const row = y * stride;
|
|
50
|
+
for (let k = -r; k <= r; k++) {
|
|
51
|
+
const w = kernel[k + r], from = reflect(y + k, height) * stride;
|
|
52
|
+
if (k === -r)
|
|
53
|
+
for (let i = 0; i < stride; i++)
|
|
54
|
+
dst[row + i] = w * tmp[from + i];
|
|
55
|
+
else
|
|
56
|
+
for (let i = 0; i < stride; i++)
|
|
57
|
+
dst[row + i] = dst[row + i] + w * tmp[from + i];
|
|
58
|
+
}
|
|
59
|
+
yield;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const BURT = [0.0625, 0.25, 0.375, 0.25, 0.0625];
|
|
63
|
+
/** Size of the next coarser pyramid level. */
|
|
64
|
+
export const half = (n) => Math.ceil(n / 2);
|
|
65
|
+
/** Level dimensions for `levels` levels starting at (width, height). */
|
|
66
|
+
export function levelSizes(width, height, levels) {
|
|
67
|
+
const out = [{ width, height }];
|
|
68
|
+
for (let l = 1; l < levels; l++)
|
|
69
|
+
out.push({ width: half(out[l - 1].width), height: half(out[l - 1].height) });
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/** Automatic level count: halve until the smaller side is 1 (at most `cap`). */
|
|
73
|
+
export function autoLevels(width, height, cap) {
|
|
74
|
+
return Math.min(cap, 1 + Math.floor(Math.log2(Math.min(width, height))));
|
|
75
|
+
}
|
|
76
|
+
export const reduceRows = (height) => height + half(height);
|
|
77
|
+
/** REDUCE: blur with the Burt–Adelson kernel and keep even samples. */
|
|
78
|
+
export function* reduce(src, width, height, channels, dst) {
|
|
79
|
+
const w2 = half(width), h2 = half(height), tmp = new Float32Array(w2 * height * channels);
|
|
80
|
+
for (let y = 0; y < height; y++) {
|
|
81
|
+
const row = y * width * channels, out = y * w2 * channels;
|
|
82
|
+
for (let x = 0; x < w2; x++)
|
|
83
|
+
for (let c = 0; c < channels; c++) {
|
|
84
|
+
let s = 0;
|
|
85
|
+
for (let k = -2; k <= 2; k++)
|
|
86
|
+
s += BURT[k + 2] * src[row + reflect(2 * x + k, width) * channels + c];
|
|
87
|
+
tmp[out + x * channels + c] = s;
|
|
88
|
+
}
|
|
89
|
+
yield;
|
|
90
|
+
}
|
|
91
|
+
const stride = w2 * channels;
|
|
92
|
+
for (let y = 0; y < h2; y++) {
|
|
93
|
+
for (let i = 0; i < stride; i++) {
|
|
94
|
+
let s = 0;
|
|
95
|
+
for (let k = -2; k <= 2; k++)
|
|
96
|
+
s += BURT[k + 2] * tmp[reflect(2 * y + k, height) * stride + i];
|
|
97
|
+
dst[y * stride + i] = s;
|
|
98
|
+
}
|
|
99
|
+
yield;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export const expandRows = (coarseHeight, height) => coarseHeight + height;
|
|
103
|
+
/**
|
|
104
|
+
* EXPAND a (cw × ch) level to (width × height): out(x) = 2 Σ_k w(k) in((x − k)/2) per axis over even
|
|
105
|
+
* x − k, coarse indices mirrored. `mode` "set" writes, "add" adds, "subtract-from" writes dst − expand.
|
|
106
|
+
*/
|
|
107
|
+
export function* expand(src, cw, ch, width, height, channels, dst, mode) {
|
|
108
|
+
const tmp = new Float32Array(width * ch * channels);
|
|
109
|
+
for (let y = 0; y < ch; y++) {
|
|
110
|
+
const row = y * cw * channels, out = y * width * channels;
|
|
111
|
+
for (let x = 0; x < width; x++)
|
|
112
|
+
for (let c = 0; c < channels; c++) {
|
|
113
|
+
let s = 0;
|
|
114
|
+
for (let k = -2; k <= 2; k++)
|
|
115
|
+
if (((x - k) & 1) === 0)
|
|
116
|
+
s += BURT[k + 2] * src[row + reflect((x - k) / 2, cw) * channels + c];
|
|
117
|
+
tmp[out + x * channels + c] = 2 * s;
|
|
118
|
+
}
|
|
119
|
+
yield;
|
|
120
|
+
}
|
|
121
|
+
const stride = width * channels;
|
|
122
|
+
for (let y = 0; y < height; y++) {
|
|
123
|
+
const at = y * stride;
|
|
124
|
+
for (let i = 0; i < stride; i++) {
|
|
125
|
+
let s = 0;
|
|
126
|
+
for (let k = -2; k <= 2; k++)
|
|
127
|
+
if (((y - k) & 1) === 0)
|
|
128
|
+
s += BURT[k + 2] * tmp[reflect((y - k) / 2, ch) * stride + i];
|
|
129
|
+
const v = 2 * s;
|
|
130
|
+
dst[at + i] = mode === "set" ? v : mode === "add" ? dst[at + i] + v : dst[at + i] - v;
|
|
131
|
+
}
|
|
132
|
+
yield;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export function gaussianPyramidRows(width, height, levels) {
|
|
136
|
+
return levelSizes(width, height, levels).slice(0, -1).reduce((s, l) => s + reduceRows(l.height), 0);
|
|
137
|
+
}
|
|
138
|
+
/** Gaussian pyramid; level 0 is a copy of `src`. */
|
|
139
|
+
export function* gaussianPyramid(src, width, height, channels, levels) {
|
|
140
|
+
const sizes = levelSizes(width, height, levels), out = [src.slice()];
|
|
141
|
+
for (let l = 1; l < levels; l++) {
|
|
142
|
+
const s = sizes[l], dst = new Float32Array(s.width * s.height * channels);
|
|
143
|
+
yield* reduce(out[l - 1], sizes[l - 1].width, sizes[l - 1].height, channels, dst);
|
|
144
|
+
out.push(dst);
|
|
145
|
+
}
|
|
146
|
+
return { levels: out, sizes, channels };
|
|
147
|
+
}
|
|
148
|
+
export function laplacianPyramidRows(width, height, levels) {
|
|
149
|
+
const sizes = levelSizes(width, height, levels);
|
|
150
|
+
let rows = gaussianPyramidRows(width, height, levels);
|
|
151
|
+
for (let l = 0; l < levels - 1; l++)
|
|
152
|
+
rows += expandRows(sizes[l + 1].height, sizes[l].height);
|
|
153
|
+
return rows;
|
|
154
|
+
}
|
|
155
|
+
/** Laplacian pyramid: L_l = G_l − EXPAND(G_{l+1}); the last level is the coarsest Gaussian level. */
|
|
156
|
+
export function* laplacianPyramid(src, width, height, channels, levels) {
|
|
157
|
+
const g = yield* gaussianPyramid(src, width, height, channels, levels);
|
|
158
|
+
for (let l = 0; l < levels - 1; l++) {
|
|
159
|
+
const a = g.sizes[l], b = g.sizes[l + 1];
|
|
160
|
+
yield* expand(g.levels[l + 1], b.width, b.height, a.width, a.height, channels, g.levels[l], "subtract-from");
|
|
161
|
+
}
|
|
162
|
+
return g;
|
|
163
|
+
}
|
|
164
|
+
export function collapseRows(width, height, levels) {
|
|
165
|
+
const sizes = levelSizes(width, height, levels);
|
|
166
|
+
let rows = 0;
|
|
167
|
+
for (let l = 0; l < levels - 1; l++)
|
|
168
|
+
rows += expandRows(sizes[l + 1].height, sizes[l].height);
|
|
169
|
+
return rows;
|
|
170
|
+
}
|
|
171
|
+
/** Collapses a Laplacian pyramid in place (level 0 becomes the image). */
|
|
172
|
+
export function* collapse(p) {
|
|
173
|
+
for (let l = p.levels.length - 2; l >= 0; l--) {
|
|
174
|
+
const a = p.sizes[l], b = p.sizes[l + 1];
|
|
175
|
+
yield* expand(p.levels[l + 1], b.width, b.height, a.width, a.height, p.channels, p.levels[l], "add");
|
|
176
|
+
}
|
|
177
|
+
return p.levels[0];
|
|
178
|
+
}
|
|
179
|
+
/** Bytes of a pyramid of `levels` levels for float32 storage. */
|
|
180
|
+
export function pyramidBytes(width, height, channels, levels) {
|
|
181
|
+
return levelSizes(width, height, levels).reduce((s, l) => s + l.width * l.height * channels * 4, 0);
|
|
182
|
+
}
|
|
183
|
+
/** Named colour space of a processing linear space. */
|
|
184
|
+
export function rgbSpaceOf(space) {
|
|
185
|
+
return space === "linear-srgb-d65" ? "srgb" : space === "linear-display-p3-d65" ? "display-p3" : "rec2020";
|
|
186
|
+
}
|
|
187
|
+
/** Luminance weights: the Y row of the space's RGB→XYZ matrix (derived from primaries and white, white Y = 1). */
|
|
188
|
+
export function luminanceWeights(space) {
|
|
189
|
+
const row = resolveRgbColorSpace(rgbSpaceOf(space)).value.rgbToXyz[1];
|
|
190
|
+
return [row[0], row[1], row[2]];
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=image-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-ops.js","sourceRoot":"","sources":["../../src/processing/image-ops.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,mBAAmB,IAAI,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,oBAAoB,EAAwB,MAAM,8BAA8B,CAAC;AAE1F,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,sGAAsG;AACtG,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC,GAAG,MAAM,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AAM,CAAC,CAAC,CAAE,CAAC;AACtB,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,MAAc,EAAE,QAAgB,EAAE,MAAc;IAC1F,OAAO,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,GAAG,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AACtG,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,UAAU,CAAC,KAAiC;IAC1D,OAAO,KAAK,KAAK,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,KAAK,uBAAuB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7G,CAAC;AACD,kHAAkH;AAClH,MAAM,UAAU,gBAAgB,CAAC,KAAiC;IAChE,MAAM,GAAG,GAAG,oBAAoB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Internal image operations on typed arrays, shared by the processing operators. Not exported from\n * the package root.\n *\n * Every spatial operation uses symmetric whole-sample (reflect-101) borders, the same mapping as the\n * RAW mirror border handling. Row generators yield once per output row of each pass. The matching\n * `*Rows` functions return exactly that count, so task plans know their total in advance.\n *\n * Pyramids follow Burt & Adelson (1983):\n * - REDUCE blurs with the separable 5-tap kernel w = [1, 4, 6, 4, 1]/16 (a = 0.375) and keeps every\n * second sample (size ⌈n/2⌉).\n * - EXPAND upsamples with the same kernel, times two per axis.\n * - A Laplacian level is G_l − EXPAND(G_{l+1}). Collapsing with the same EXPAND rebuilds G_0 exactly,\n * up to float32 rounding, whatever the border rule.\n */\n\nimport { reflectRawSiteIndex as reflect } from \"../sensor/raw-reconstruction.js\";\nimport type { ProcessingBody, ProcessingLinearColorSpace } from \"./processing-task.js\";\nimport { resolveRgbColorSpace, type RgbColorSpaceId } from \"../color/rgb-color-spaces.js\";\n\nexport { reflect };\n\n/** Normalized 1-D Gaussian taps for standard deviation σ (pixels), truncated at ⌈3σ⌉; σ = 0 → [1]. */\nexport function gaussianKernel(sigma: number): Float64Array {\n if (sigma === 0) return Float64Array.of(1);\n const radius = Math.max(1, Math.ceil(3 * sigma)), k = new Float64Array(2 * radius + 1);\n let sum = 0;\n for (let i = -radius; i <= radius; i++) sum += (k[i + radius] = Math.exp(-(i * i) / (2 * sigma * sigma)));\n for (let i = 0; i < k.length; i++) k[i] = k[i]! / sum;\n return k;\n}\n\n/** Rows yielded by `convolveSeparable`. */\nexport const convolveRows = (height: number): number => 2 * height;\n\n/** Separable convolution of a `channels`-interleaved plane with a symmetric kernel; `tmp` and `dst` have the source length. */\nexport function* convolveSeparable(src: Float32Array, width: number, height: number, channels: number, kernel: Float64Array,\n tmp: Float32Array, dst: Float32Array): ProcessingBody<void> {\n const r = (kernel.length - 1) / 2, stride = width * channels;\n for (let y = 0; y < height; y++) {\n const row = y * stride;\n for (let x = 0; x < width; x++) for (let c = 0; c < channels; c++) {\n let s = 0;\n for (let k = -r; k <= r; k++) s += kernel[k + r]! * src[row + reflect(x + k, width) * channels + c]!;\n tmp[row + x * channels + c] = s;\n }\n yield;\n }\n for (let y = 0; y < height; y++) {\n const row = y * stride;\n for (let k = -r; k <= r; k++) {\n const w = kernel[k + r]!, from = reflect(y + k, height) * stride;\n if (k === -r) for (let i = 0; i < stride; i++) dst[row + i] = w * tmp[from + i]!;\n else for (let i = 0; i < stride; i++) dst[row + i] = dst[row + i]! + w * tmp[from + i]!;\n }\n yield;\n }\n}\n\nconst BURT = [0.0625, 0.25, 0.375, 0.25, 0.0625] as const;\n\n/** Size of the next coarser pyramid level. */\nexport const half = (n: number): number => Math.ceil(n / 2);\n\n/** Level dimensions for `levels` levels starting at (width, height). */\nexport function levelSizes(width: number, height: number, levels: number): { width: number; height: number }[] {\n const out = [{ width, height }];\n for (let l = 1; l < levels; l++) out.push({ width: half(out[l - 1]!.width), height: half(out[l - 1]!.height) });\n return out;\n}\n\n/** Automatic level count: halve until the smaller side is 1 (at most `cap`). */\nexport function autoLevels(width: number, height: number, cap: number): number {\n return Math.min(cap, 1 + Math.floor(Math.log2(Math.min(width, height))));\n}\n\nexport const reduceRows = (height: number): number => height + half(height);\n/** REDUCE: blur with the Burt–Adelson kernel and keep even samples. */\nexport function* reduce(src: Float32Array, width: number, height: number, channels: number, dst: Float32Array): ProcessingBody<void> {\n const w2 = half(width), h2 = half(height), tmp = new Float32Array(w2 * height * channels);\n for (let y = 0; y < height; y++) {\n const row = y * width * channels, out = y * w2 * channels;\n for (let x = 0; x < w2; x++) for (let c = 0; c < channels; c++) {\n let s = 0;\n for (let k = -2; k <= 2; k++) s += BURT[k + 2]! * src[row + reflect(2 * x + k, width) * channels + c]!;\n tmp[out + x * channels + c] = s;\n }\n yield;\n }\n const stride = w2 * channels;\n for (let y = 0; y < h2; y++) {\n for (let i = 0; i < stride; i++) {\n let s = 0;\n for (let k = -2; k <= 2; k++) s += BURT[k + 2]! * tmp[reflect(2 * y + k, height) * stride + i]!;\n dst[y * stride + i] = s;\n }\n yield;\n }\n}\n\nexport const expandRows = (coarseHeight: number, height: number): number => coarseHeight + height;\n/**\n * EXPAND a (cw × ch) level to (width × height): out(x) = 2 Σ_k w(k) in((x − k)/2) per axis over even\n * x − k, coarse indices mirrored. `mode` \"set\" writes, \"add\" adds, \"subtract-from\" writes dst − expand.\n */\nexport function* expand(src: Float32Array, cw: number, ch: number, width: number, height: number, channels: number, dst: Float32Array,\n mode: \"set\" | \"add\" | \"subtract-from\"): ProcessingBody<void> {\n const tmp = new Float32Array(width * ch * channels);\n for (let y = 0; y < ch; y++) {\n const row = y * cw * channels, out = y * width * channels;\n for (let x = 0; x < width; x++) for (let c = 0; c < channels; c++) {\n let s = 0;\n for (let k = -2; k <= 2; k++) if (((x - k) & 1) === 0) s += BURT[k + 2]! * src[row + reflect((x - k) / 2, cw) * channels + c]!;\n tmp[out + x * channels + c] = 2 * s;\n }\n yield;\n }\n const stride = width * channels;\n for (let y = 0; y < height; y++) {\n const at = y * stride;\n for (let i = 0; i < stride; i++) {\n let s = 0;\n for (let k = -2; k <= 2; k++) if (((y - k) & 1) === 0) s += BURT[k + 2]! * tmp[reflect((y - k) / 2, ch) * stride + i]!;\n const v = 2 * s;\n dst[at + i] = mode === \"set\" ? v : mode === \"add\" ? dst[at + i]! + v : dst[at + i]! - v;\n }\n yield;\n }\n}\n\nexport interface Pyramid { levels: Float32Array[]; sizes: { width: number; height: number }[]; channels: number }\n\nexport function gaussianPyramidRows(width: number, height: number, levels: number): number {\n return levelSizes(width, height, levels).slice(0, -1).reduce((s, l) => s + reduceRows(l.height), 0);\n}\n/** Gaussian pyramid; level 0 is a copy of `src`. */\nexport function* gaussianPyramid(src: Float32Array, width: number, height: number, channels: number, levels: number): ProcessingBody<Pyramid> {\n const sizes = levelSizes(width, height, levels), out = [src.slice()];\n for (let l = 1; l < levels; l++) {\n const s = sizes[l]!, dst = new Float32Array(s.width * s.height * channels);\n yield* reduce(out[l - 1]!, sizes[l - 1]!.width, sizes[l - 1]!.height, channels, dst);\n out.push(dst);\n }\n return { levels: out, sizes, channels };\n}\n\nexport function laplacianPyramidRows(width: number, height: number, levels: number): number {\n const sizes = levelSizes(width, height, levels);\n let rows = gaussianPyramidRows(width, height, levels);\n for (let l = 0; l < levels - 1; l++) rows += expandRows(sizes[l + 1]!.height, sizes[l]!.height);\n return rows;\n}\n/** Laplacian pyramid: L_l = G_l − EXPAND(G_{l+1}); the last level is the coarsest Gaussian level. */\nexport function* laplacianPyramid(src: Float32Array, width: number, height: number, channels: number, levels: number): ProcessingBody<Pyramid> {\n const g = yield* gaussianPyramid(src, width, height, channels, levels);\n for (let l = 0; l < levels - 1; l++) {\n const a = g.sizes[l]!, b = g.sizes[l + 1]!;\n yield* expand(g.levels[l + 1]!, b.width, b.height, a.width, a.height, channels, g.levels[l]!, \"subtract-from\");\n }\n return g;\n}\n\nexport function collapseRows(width: number, height: number, levels: number): number {\n const sizes = levelSizes(width, height, levels);\n let rows = 0;\n for (let l = 0; l < levels - 1; l++) rows += expandRows(sizes[l + 1]!.height, sizes[l]!.height);\n return rows;\n}\n/** Collapses a Laplacian pyramid in place (level 0 becomes the image). */\nexport function* collapse(p: Pyramid): ProcessingBody<Float32Array> {\n for (let l = p.levels.length - 2; l >= 0; l--) {\n const a = p.sizes[l]!, b = p.sizes[l + 1]!;\n yield* expand(p.levels[l + 1]!, b.width, b.height, a.width, a.height, p.channels, p.levels[l]!, \"add\");\n }\n return p.levels[0]!;\n}\n\n/** Bytes of a pyramid of `levels` levels for float32 storage. */\nexport function pyramidBytes(width: number, height: number, channels: number, levels: number): number {\n return levelSizes(width, height, levels).reduce((s, l) => s + l.width * l.height * channels * 4, 0);\n}\n\n/** Named colour space of a processing linear space. */\nexport function rgbSpaceOf(space: ProcessingLinearColorSpace): RgbColorSpaceId {\n return space === \"linear-srgb-d65\" ? \"srgb\" : space === \"linear-display-p3-d65\" ? \"display-p3\" : \"rec2020\";\n}\n/** Luminance weights: the Y row of the space's RGB→XYZ matrix (derived from primaries and white, white Y = 1). */\nexport function luminanceWeights(space: ProcessingLinearColorSpace): readonly [number, number, number] {\n const row = resolveRgbColorSpace(rgbSpaceOf(space)).value.rgbToXyz[1];\n return [row[0], row[1], row[2]];\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ProcessingProvenance, type ProcessingProvider, type ProcessingRgbImage, type ProcessingTask } from "./processing-task.js";
|
|
2
|
+
export interface PanoramaFrame {
|
|
3
|
+
image: ProcessingRgbImage;
|
|
4
|
+
/** Rectilinear focal length in pixels (same pixel pitch on both axes). */
|
|
5
|
+
focalLengthPixels: number;
|
|
6
|
+
/** Principal point in pixel coordinates (pixel centres at i + 0.5); default the image centre. */
|
|
7
|
+
principalPointPixels?: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
/** Camera rotation relative to the reference camera: pitch/yaw/roll radians, engine sign convention. */
|
|
12
|
+
rotationRad: {
|
|
13
|
+
pitch: number;
|
|
14
|
+
yaw: number;
|
|
15
|
+
roll: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface PanoramaCanvas {
|
|
19
|
+
projection: "equirectangular" | "cylindrical";
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
/** [min, max] longitude θ in radians across the canvas columns (left → right). */
|
|
23
|
+
longitudeRangeRad: readonly [number, number];
|
|
24
|
+
/** [min, max] latitude φ in radians (bottom → top); cylindrical rows are linear in tan φ. */
|
|
25
|
+
latitudeRangeRad: readonly [number, number];
|
|
26
|
+
}
|
|
27
|
+
export interface PanoramaInput {
|
|
28
|
+
frames: readonly PanoramaFrame[];
|
|
29
|
+
canvas: PanoramaCanvas;
|
|
30
|
+
/** Default `feather`. */
|
|
31
|
+
blending?: "feather" | "multi-band";
|
|
32
|
+
/** Default `gain` (Brown & Lowe 2007); `none` keeps frame intensities. */
|
|
33
|
+
exposureCompensation?: "none" | "gain";
|
|
34
|
+
/** Normalized intensity noise σ_N; default 0.04 (≈ 10/255, the published 8-bit value). */
|
|
35
|
+
gainNoiseSigma?: number;
|
|
36
|
+
/** Gain prior σ_g; default 0.1. */
|
|
37
|
+
gainPriorSigma?: number;
|
|
38
|
+
/** Multi-band pyramid levels; default min(4, auto). Coarse bands wider than the frame overlap mix
|
|
39
|
+
* low frequencies that were normalized differently, so keep 2^(levels−1) well below the overlap width. */
|
|
40
|
+
pyramidLevels?: number;
|
|
41
|
+
maximumWorkingBytes?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface PanoramaOutput extends ProcessingRgbImage {
|
|
44
|
+
/** Number of frames covering each canvas pixel; 0 = uncovered (value 0). */
|
|
45
|
+
coverage: Uint8Array;
|
|
46
|
+
/** Gain applied to each frame (1 when compensation is off). */
|
|
47
|
+
gains: readonly number[];
|
|
48
|
+
provenance: ProcessingProvenance;
|
|
49
|
+
}
|
|
50
|
+
/** Stitches frames with known rotations onto a cylindrical or equirectangular canvas. */
|
|
51
|
+
export declare function createPanoramaTask(input: PanoramaInput, provider: ProcessingProvider): ProcessingTask<PanoramaOutput>;
|