Skip to content
Merged
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
19 changes: 13 additions & 6 deletions src/vstarstack/tool/image_processing/drop_unsharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
def measure_sharpness(img : np.ndarray) -> float:
sx = scipy.ndimage.sobel(img, axis=0, mode='constant')
sy = scipy.ndimage.sobel(img, axis=1, mode='constant')
sobel = np.hypot(sx, sy)
sobel = np.sqrt(sx**2 + sy**2)
metric = np.sum(sobel)
return metric
summ = np.sum(img)
return metric / summ

def measure_sharpness_df(df : vstarstack.library.data.DataFrame) -> float:
metric = 0
Expand Down Expand Up @@ -45,8 +46,14 @@ def run(project : vstarstack.tool.cfg.Project, argv : list[str]):
percent = int(argv[1])
files = vstarstack.tool.common.listfiles(path, ".zip")
fnames = [item[1] for item in files]
good = select_sharpests(fnames, percent)
sharpests = select_sharpests(fnames, percent)
for i,fname in enumerate(sharpests):
basename = os.path.basename(fname)
dirname = os.path.dirname(fname)
basename = "%06i_%s" % (i, basename)
os.rename(fname, os.path.join(dirname, basename))
fnames.remove(fname)

for fname in fnames:
if fname not in good:
print(f"Removing {fname}")
os.remove(fname)
print(f"Removing {fname}")
os.remove(fname)