From 20891e34e709a057f64ff4b47c74eadfc1312be3 Mon Sep 17 00:00:00 2001 From: Vladislav Tsendrovskii Date: Tue, 17 Dec 2024 04:43:58 +0100 Subject: [PATCH 1/2] Normalize each channel for flat --- src/vstarstack/library/calibration/flat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vstarstack/library/calibration/flat.py b/src/vstarstack/library/calibration/flat.py index 264eee34..e68d5837 100644 --- a/src/vstarstack/library/calibration/flat.py +++ b/src/vstarstack/library/calibration/flat.py @@ -91,7 +91,8 @@ def prepare_flat_sky(images : vstarstack.library.common.IImageSource, if not flat.get_channel_option(channel, "signal"): continue layer = cv2.GaussianBlur(layer, (15, 15), 0) - flat.add_channel(layer, channel, **opts) + layer = layer / np.amax(layer) + flat.replace_channel(layer, channel, **opts) for channel in list(flat.get_channels()): if not flat.get_channel_option(channel, "weight"): continue @@ -201,5 +202,6 @@ def approximate_flat_image(flat : vstarstack.library.data.DataFrame) -> vstarsta ky = ky * k**2 layer_approximated = generate_flat(layer.shape[1], layer.shape[0], x0, y0, val0, kx, ky) layer_approximated = detect_spots(layer, layer_approximated) + layer_approximated = layer_approximated / np.amax(layer_approximated) flat.replace_channel(layer_approximated, channel, **opts) return flat From abc293e8069b22ac808256c7b2cedabbe8b5f0c8 Mon Sep 17 00:00:00 2001 From: Vladislav Tsendrovskii Date: Tue, 17 Dec 2024 05:29:28 +0100 Subject: [PATCH 2/2] Fix test --- tests/test_flat_approximation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_flat_approximation.py b/tests/test_flat_approximation.py index 65cdd298..7e65a218 100644 --- a/tests/test_flat_approximation.py +++ b/tests/test_flat_approximation.py @@ -22,6 +22,7 @@ def test_flat(): dfg = vstarstack.library.loaders.classic.readjpeg(os.path.join(dir_path, 'flat/flat.jpg')) df = next(dfg) flat,_ = df.get_channel('L') + flat = flat / np.amax(flat) approx = vstarstack.library.calibration.flat.approximate_flat_image(df.copy()) flat_approx,_ = approx.get_channel('L') assert flat_approx.shape == flat.shape