Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
packages = result

setup (name = 'vstarstack',
version = '0.3.4',
version = '0.3.6',
author='Vladislav Tsendrovskii',
description = 'Stacking astrophotos',
package_dir = {'vstarstack': 'src/vstarstack'},
Expand Down
2 changes: 1 addition & 1 deletion src/vstarstack/library/movement/move_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def move_dataframe(dataframe: DataFrame,
else:
weight = np.ones(image.shape)

if channel in dataframe.links["saturation"]:
if "saturation" in dataframe.links and channel in dataframe.links["saturation"]:
saturation_channel = dataframe.links["saturation"][channel]
saturation, _ = dataframe.get_channel(saturation_channel)
else:
Expand Down
10 changes: 6 additions & 4 deletions src/vstarstack/library/stars/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import math
import numpy as np
import cv2
from scipy.ndimage import gaussian_filter
import imutils
import imutils.contours
import matplotlib.pyplot as plt

from skimage import measure

Expand All @@ -42,17 +44,17 @@ def calculate_brightness(image : np.ndarray, x : int, y : int, r : int):
return brightness

def _threshold(image, radius, ratio, safety_threshold):
filtered = cv2.GaussianBlur(image, (2*radius+1, 2*radius+1), 0)
mask = (image > filtered*ratio + safety_threshold).astype('uint8')
filtered = gaussian_filter(image, sigma=radius)
threshold = filtered*ratio + safety_threshold*np.amax(filtered)
mask = (image > threshold).astype('uint8')
return mask

def _find_stars(gray_image : np.ndarray):
"""Find stars on image"""
shape = gray_image.shape

gray_image = (gray_image.astype(np.float32) / np.amax(gray_image) * 255).astype(np.uint8)
gray_image = np.clip(gray_image, 0, None)
gray_image = cv2.GaussianBlur(gray_image, (3, 3), 0)
gray_image = gaussian_filter(gray_image, sigma=2)

thresh = _threshold(gray_image, _detector_cfg["THRESHOLD_BLOCK_SIZE"],
_detector_cfg["THRESHOLD_COEFF"],
Expand Down
1 change: 1 addition & 0 deletions src/vstarstack/tool/stars/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"use_angles": (bool, True),
"brightness_over_neighbours": (float, 2.0),
"min_brightness" : (float, 0.01),
"max_compares": (int, 0),
}

Expand Down
4 changes: 3 additions & 1 deletion src/vstarstack/tool/stars/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def run(project: vstarstack.tool.cfg.Project, argv: list):
mindist = project.config.stars.describe.mindist

thr_coeff = project.config.stars.brightness_over_neighbours
detect.configure_detector(thresh_coeff=thr_coeff)
thr_safety = project.config.stars.min_brightness
logger.info(f"Threshold coefficient {thr_coeff}")
detect.configure_detector(thresh_coeff=thr_coeff, safety_threshold=thr_safety)
if os.path.isdir(path):
_process_dir(path, jsonpath, num_stars, mindist)
else:
Expand Down