Optics: add PSF luminance cutoff
This commit is contained in:
1 parent
9e23c3fcdb
commit
e8deb1ff19
7 files changed
+123
-38
No files matched your search
+29
-13
@@ -851,15 +851,18 @@ typedef struct {
|
||||
const PsfKernelCache *psf_cache;
|
||||
double max_cache_psf_flux;
|
||||
double psf_relative_tail;
|
||||
double psf_min_y;
|
||||
size_t images;
|
||||
size_t direct_fallbacks;
|
||||
size_t cached_wing_clipped;
|
||||
size_t discarded_below_min_y;
|
||||
} TriangleSplatContext;
|
||||
|
||||
typedef struct {
|
||||
size_t images;
|
||||
size_t direct_fallbacks;
|
||||
size_t cached_wing_clipped;
|
||||
size_t discarded_below_min_y;
|
||||
#ifdef GR_DEBUG
|
||||
double max_raw_magnification;
|
||||
size_t magnification_clamped_triangles;
|
||||
@@ -872,9 +875,11 @@ static void copy_psf_splat_stats(PsfSplatStats *destination,
|
||||
if (destination == NULL)
|
||||
return;
|
||||
*destination = (PsfSplatStats){.cached_splats =
|
||||
source.images - source.direct_fallbacks,
|
||||
source.images - source.direct_fallbacks -
|
||||
source.discarded_below_min_y,
|
||||
.cached_wing_clipped = source.cached_wing_clipped,
|
||||
.direct_fallbacks = source.direct_fallbacks,
|
||||
.discarded_below_min_y = source.discarded_below_min_y,
|
||||
#ifdef GR_DEBUG
|
||||
.max_raw_magnification = source.max_raw_magnification,
|
||||
.magnification_clamped_triangles =
|
||||
@@ -919,9 +924,10 @@ static int splat_catalog_tile(const Star *stars, size_t count,
|
||||
context->hdr, context->width, context->height, image_x, image_y, color,
|
||||
flux,
|
||||
context->psf, context->psf_cache, context->max_cache_psf_flux,
|
||||
context->psf_relative_tail);
|
||||
context->psf_relative_tail, context->psf_min_y);
|
||||
context->direct_fallbacks += direct_fallback == 1;
|
||||
context->cached_wing_clipped += direct_fallback == 2;
|
||||
context->discarded_below_min_y += direct_fallback == 3;
|
||||
#ifdef GR_DEBUG
|
||||
if (direct_fallback == 1)
|
||||
/* This is deliberately emitted by the active splat worker: a direct
|
||||
@@ -944,6 +950,7 @@ static CatalogSplatStats splat_catalog_triangles(
|
||||
int height, double exposure, const PointSpreadFunction *psf,
|
||||
const PsfKernelCache *psf_cache, double max_magnification,
|
||||
double max_cache_psf_flux, double psf_relative_tail,
|
||||
double psf_min_y,
|
||||
size_t first_triangle, size_t last_triangle) {
|
||||
CatalogSplatStats stats = {0};
|
||||
for (size_t t = first_triangle; t < last_triangle; ++t) {
|
||||
@@ -978,12 +985,14 @@ static CatalogSplatStats splat_catalog_triangles(
|
||||
.exposure = exposure, .magnification = magnification,
|
||||
.psf = psf, .psf_cache = psf_cache,
|
||||
.max_cache_psf_flux = max_cache_psf_flux,
|
||||
.psf_relative_tail = psf_relative_tail};
|
||||
.psf_relative_tail = psf_relative_tail,
|
||||
.psf_min_y = psf_min_y};
|
||||
if (catalog_visit_source_triangle(catalog, direction, 0, splat_catalog_tile,
|
||||
&context) == 0)
|
||||
stats.images += context.images;
|
||||
stats.direct_fallbacks += context.direct_fallbacks;
|
||||
stats.cached_wing_clipped += context.cached_wing_clipped;
|
||||
stats.discarded_below_min_y += context.discarded_below_min_y;
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
@@ -1016,6 +1025,7 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
double max_magnification,
|
||||
double max_cache_psf_flux,
|
||||
double psf_relative_tail,
|
||||
double psf_min_y,
|
||||
int limit_workers_by_memory,
|
||||
int catalog_load_workers,
|
||||
CatalogPrefetchStats *prefetch_stats,
|
||||
@@ -1026,7 +1036,7 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
isnan(max_magnification) || max_magnification <= 0.0 ||
|
||||
!isfinite(max_cache_psf_flux) || max_cache_psf_flux < 1.0 ||
|
||||
!isfinite(psf_relative_tail) || psf_relative_tail <= 0.0 ||
|
||||
psf_relative_tail >= 1.0)
|
||||
psf_relative_tail >= 1.0 || !isfinite(psf_min_y) || psf_min_y < 0.0)
|
||||
return 0;
|
||||
|
||||
/* A bounded parallel read phase completes before splatting. Its serial cache
|
||||
@@ -1050,7 +1060,7 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
{
|
||||
const CatalogSplatStats stats = splat_catalog_triangles(
|
||||
mesh, catalog, hdr, width, height, exposure, psf, psf_cache,
|
||||
max_magnification, max_cache_psf_flux, psf_relative_tail,
|
||||
max_magnification, max_cache_psf_flux, psf_relative_tail, psf_min_y,
|
||||
0, mesh->triangle_count);
|
||||
copy_psf_splat_stats(psf_stats, stats);
|
||||
return stats.images;
|
||||
@@ -1067,7 +1077,7 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
{
|
||||
const CatalogSplatStats stats = splat_catalog_triangles(
|
||||
mesh, catalog, hdr, width, height, exposure, psf, psf_cache,
|
||||
max_magnification, max_cache_psf_flux, psf_relative_tail,
|
||||
max_magnification, max_cache_psf_flux, psf_relative_tail, psf_min_y,
|
||||
0, mesh->triangle_count);
|
||||
copy_psf_splat_stats(psf_stats, stats);
|
||||
return stats.images;
|
||||
@@ -1078,7 +1088,7 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
{
|
||||
const CatalogSplatStats stats = splat_catalog_triangles(
|
||||
mesh, catalog, hdr, width, height, exposure, psf, psf_cache,
|
||||
max_magnification, max_cache_psf_flux, psf_relative_tail,
|
||||
max_magnification, max_cache_psf_flux, psf_relative_tail, psf_min_y,
|
||||
0, mesh->triangle_count);
|
||||
copy_psf_splat_stats(psf_stats, stats);
|
||||
return stats.images;
|
||||
@@ -1095,13 +1105,14 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
free(private_hdr);
|
||||
const CatalogSplatStats stats = splat_catalog_triangles(
|
||||
mesh, catalog, hdr, width, height, exposure, psf, psf_cache,
|
||||
max_magnification, max_cache_psf_flux, psf_relative_tail,
|
||||
max_magnification, max_cache_psf_flux, psf_relative_tail, psf_min_y,
|
||||
0, mesh->triangle_count);
|
||||
copy_psf_splat_stats(psf_stats, stats);
|
||||
return stats.images;
|
||||
}
|
||||
|
||||
size_t images = 0, direct_fallbacks = 0, cached_wing_clipped = 0;
|
||||
size_t images = 0, direct_fallbacks = 0, cached_wing_clipped = 0,
|
||||
discarded_below_min_y = 0;
|
||||
#ifdef GR_DEBUG
|
||||
double max_raw_magnification = 0.0;
|
||||
size_t magnification_clamped_triangles = 0;
|
||||
@@ -1109,9 +1120,9 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
/* Keep the ordinary render loop byte-for-byte free of progress checks. */
|
||||
if (progress != NULL && progress->worker_callback != NULL) {
|
||||
#ifdef GR_DEBUG
|
||||
#pragma omp parallel num_threads((int)worker_count) reduction(+ : images, direct_fallbacks, cached_wing_clipped, magnification_clamped_triangles) reduction(max : max_raw_magnification)
|
||||
#pragma omp parallel num_threads((int)worker_count) reduction(+ : images, direct_fallbacks, cached_wing_clipped, discarded_below_min_y, magnification_clamped_triangles) reduction(max : max_raw_magnification)
|
||||
#else
|
||||
#pragma omp parallel num_threads((int)worker_count) reduction(+ : images, direct_fallbacks, cached_wing_clipped)
|
||||
#pragma omp parallel num_threads((int)worker_count) reduction(+ : images, direct_fallbacks, cached_wing_clipped, discarded_below_min_y)
|
||||
#endif
|
||||
{
|
||||
const size_t worker = (size_t)omp_get_thread_num();
|
||||
@@ -1126,10 +1137,12 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
const CatalogSplatStats stats = splat_catalog_triangles(
|
||||
mesh, catalog, private_hdr[worker], width, height, exposure, psf,
|
||||
psf_cache, max_magnification, max_cache_psf_flux, psf_relative_tail,
|
||||
psf_min_y,
|
||||
triangle, triangle + 1);
|
||||
images += stats.images;
|
||||
direct_fallbacks += stats.direct_fallbacks;
|
||||
cached_wing_clipped += stats.cached_wing_clipped;
|
||||
discarded_below_min_y += stats.discarded_below_min_y;
|
||||
#ifdef GR_DEBUG
|
||||
max_raw_magnification = fmax(max_raw_magnification, stats.max_raw_magnification);
|
||||
magnification_clamped_triangles += stats.magnification_clamped_triangles;
|
||||
@@ -1147,9 +1160,9 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
}
|
||||
} else {
|
||||
#ifdef GR_DEBUG
|
||||
#pragma omp parallel num_threads((int)worker_count) reduction(+ : images, direct_fallbacks, cached_wing_clipped, magnification_clamped_triangles) reduction(max : max_raw_magnification)
|
||||
#pragma omp parallel num_threads((int)worker_count) reduction(+ : images, direct_fallbacks, cached_wing_clipped, discarded_below_min_y, magnification_clamped_triangles) reduction(max : max_raw_magnification)
|
||||
#else
|
||||
#pragma omp parallel num_threads((int)worker_count) reduction(+ : images, direct_fallbacks, cached_wing_clipped)
|
||||
#pragma omp parallel num_threads((int)worker_count) reduction(+ : images, direct_fallbacks, cached_wing_clipped, discarded_below_min_y)
|
||||
#endif
|
||||
{
|
||||
const size_t worker = (size_t)omp_get_thread_num();
|
||||
@@ -1158,10 +1171,12 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
const CatalogSplatStats stats = splat_catalog_triangles(
|
||||
mesh, catalog, private_hdr[worker], width, height, exposure, psf,
|
||||
psf_cache, max_magnification, max_cache_psf_flux, psf_relative_tail,
|
||||
psf_min_y,
|
||||
triangle, triangle + 1);
|
||||
images += stats.images;
|
||||
direct_fallbacks += stats.direct_fallbacks;
|
||||
cached_wing_clipped += stats.cached_wing_clipped;
|
||||
discarded_below_min_y += stats.discarded_below_min_y;
|
||||
#ifdef GR_DEBUG
|
||||
max_raw_magnification = fmax(max_raw_magnification, stats.max_raw_magnification);
|
||||
magnification_clamped_triangles += stats.magnification_clamped_triangles;
|
||||
@@ -1180,6 +1195,7 @@ size_t frame_splat_catalog(const FrameLensMesh *mesh,
|
||||
.images = images,
|
||||
.direct_fallbacks = direct_fallbacks,
|
||||
.cached_wing_clipped = cached_wing_clipped,
|
||||
.discarded_below_min_y = discarded_below_min_y,
|
||||
#ifdef GR_DEBUG
|
||||
.max_raw_magnification = max_raw_magnification,
|
||||
.magnification_clamped_triangles =
|
||||
|
||||
Reference in new issue
Block a user