diff --git a/LS_GUI.py b/LS_GUI.py index 52a4972..af264d4 100644 --- a/LS_GUI.py +++ b/LS_GUI.py @@ -566,10 +566,28 @@ def stackFocusStack(self, folder): for stackFolder in onlyFolders: focusStackInstall = self.config.configValues["FocusStackInstall"] - + inputPath = "" + if(self.config.configValues["PruneBeforeStacking"]): + files = [f for f in os.listdir(folder + "/" + stackFolder) if isfile(join(folder + "/" + stackFolder, f))] + files.sort() + onlyJpegs = [jpg for jpg in files if jpg.lower().endswith(".jpg")] + if(len(onlyJpegs) < 1): + continue + # sort the files by filesize and remove the smallest 50% of them files + fileSizes = [] + for file in onlyJpegs: + fileSizes.append(os.path.getsize(folder + "/" + stackFolder + "/" + file)) + median = statistics.median(fileSizes) + for file in onlyJpegs: + if(os.path.getsize(folder + "/" + stackFolder + "/" + file) >= median): + inputPath = inputPath + ' "' + folder + "/" + stackFolder + "/" + file + '"' + else: + inputPath = '"' + folder + "/" + stackFolder + "/*jpg" + '"' + + commandLine = self.config.configValues["FocusStackLaunchPath"] \ .replace('{{Install}}', focusStackInstall) \ - .replace('{{folderPath}}', folder + "/" + stackFolder) \ + .replace('{{folderPath}}', inputPath) \ .replace('{{outputPath}}', folder + "/" + stackFolder + ".jpg") print(commandLine); subprocess.call(commandLine, stdout=DEVNULL, diff --git a/Preferences.py b/Preferences.py index 05ddf06..0d4d304 100644 --- a/Preferences.py +++ b/Preferences.py @@ -127,7 +127,7 @@ def CreateWindow(self, parent): fgSizer1.Add( self.focuslabel, 0, wx.ALL, 5 ) self.focusLaunch = wx.TextCtrl( panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) - fgSizer1.Add( self.focusLaunch, 0, wx.ALL, 5 ) + fgSizer1.Add( self.focusLaunch, 0, wx.ALL|wx.EXPAND, 5 ) fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) @@ -181,6 +181,13 @@ def CreateWindow(self, parent): fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) + fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) + + self.m_pruneBefore = wx.CheckBox( panel, wx.ID_ANY, u"Prune Before Stacking", wx.DefaultPosition, wx.DefaultSize, 0 ) + fgSizer1.Add( self.m_pruneBefore, 0, wx.ALL, 5 ) + + + fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) @@ -225,6 +232,7 @@ def save(self, event=None): self.config.configValues['FocusStackLaunchPath'] = self.focusLaunch.GetValue() self.config.configValues['RightToLeft'] = self.rightToLeft.IsChecked() self.config.configValues['StackerSelection'] = self.m_stackerSelection.GetString(self.m_stackerSelection.GetSelection()) + self.config.configValues['PruneBeforeStacking'] = self.m_pruneBefore.IsChecked() self.config.save_config() def reload(self, event=None): @@ -243,6 +251,7 @@ def reload(self, event=None): self.focusStack.SetValue(self.config.configValues["FocusStackInstall"]) self.focusLaunch.SetValue(self.config.configValues["FocusStackLaunchPath"]) self.rightToLeft.SetValue(self.config.configValues['RightToLeft']) + self.m_pruneBefore.SetValue(self.config.configValues['PruneBeforeStacking']) self.m_stackerSelection.SetSelection(self.m_stackerSelection.FindString(self.config.configValues['StackerSelection'])) diff --git a/config.py b/config.py index 65b191f..5fba95c 100644 --- a/config.py +++ b/config.py @@ -62,9 +62,10 @@ def _load_from_file(self): self.configValues["Overlap"] = self.Config.get("Processing", "Overlap", fallback="0.35") self.configValues["FocusThreshold"] = self.Config.get("Processing", "FocusThreshold", fallback="13.0") self.configValues["RightToLeft"] = True if self.Config.get("Processing", "RightToLeft", fallback="0") == "1" else False + self.configValues["PruneBeforeStacking"] = True if self.Config.get("Processing", "PruneBeforeStacking", fallback="0") == "1" else False self.configValues["StackerSelection"] = self.Config.get("Processing", "StackerSelection", fallback="FocusStack") self.configValues["FocusStackInstall"] = self.Config.get("FocusStack", "Install", fallback=str(homedir.absolute())) - self.configValues["FocusStackLaunchPath"] = self.Config.get("FocusStack", "LaunchPath", fallback='"{{Install}}" --consistency=0 --align-keep-size --no-whitebalance --no-contrast --jpgquality=100 --output="{{outputPath}}" "{{folderPath}}/"*jpg') + self.configValues["FocusStackLaunchPath"] = self.Config.get("FocusStack", "LaunchPath", fallback='"{{Install}}" --consistency=0 --align-keep-size --no-whitebalance --no-contrast --jpgquality=100 --output="{{outputPath}}" {{folderPath}}') def save_config(self): @@ -84,6 +85,7 @@ def save_config(self): self.Config.set("Processing", "VignetteMagic",self.configValues["VignetteMagic"]) self.Config.set("Processing", "Overlap",self.configValues["Overlap"]) self.Config.set("Processing", "RightToLeft","1" if self.configValues["RightToLeft"] else "0") + self.Config.set("Processing", "PruneBeforeStacking","1" if self.configValues["PruneBeforeStacking"] else "0") self.Config.set("Processing", "StackerSelection",self.configValues["StackerSelection"]) self.Config.set("FocusStack", "Install",self.configValues["FocusStackInstall"]) self.Config.set("FocusStack", "LaunchPath",self.configValues["FocusStackLaunchPath"]) diff --git a/stitcher.py b/stitcher.py index f61d34a..6cbc966 100755 --- a/stitcher.py +++ b/stitcher.py @@ -12,7 +12,7 @@ CONFIG={} CONFIG['max_features'] = 500 -CONFIG['scale_factor'] = 0.5 +CONFIG['scale_factor'] = 0.25 CONFIG['flann_checks'] = 12 class Stitcher: @@ -146,7 +146,7 @@ def removeVignette(self, img, vignetteMagicNumber): return np.rint(corrected).astype(np.uint8) def rotateAndCrop(self, image): - scale_percent = 5 # percent of original size + scale_percent = 2.5 # percent of original size width = int(image.shape[1] * scale_percent / 100) height = int(image.shape[0] * scale_percent / 100) dim = (width, height)