shinestacker 1.9.1__py3-none-any.whl → 1.9.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of shinestacker might be problematic. Click here for more details.

shinestacker/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '1.9.1'
1
+ __version__ = '1.9.2'
@@ -65,6 +65,20 @@ _HOMOGRAPHY_THRESHOLDS = {
65
65
  'max_aspect_ratio': 2.0, # max aspect ratio change
66
66
  }
67
67
 
68
+ _AFFINE_THRESHOLDS_LARGE = {
69
+ 'max_rotation': 20.0, # degrees
70
+ 'min_scale': 0.5,
71
+ 'max_scale': 1.5,
72
+ 'max_shear': 10.0, # degrees
73
+ 'max_translation_ratio': 0.2, # 20% of image dimension
74
+ }
75
+
76
+ _HOMOGRAPHY_THRESHOLDS_LARGE = {
77
+ 'max_skew': 12.0, # degrees
78
+ 'max_scale_change': 2.0, # max area change ratio
79
+ 'max_aspect_ratio': 4.0, # max aspect ratio change
80
+ }
81
+
68
82
 
69
83
  def decompose_affine_matrix(m):
70
84
  a, b, tx = m[0, 0], m[0, 1], m[0, 2]
@@ -562,6 +576,9 @@ class AlignFramesBase(SubAction):
562
576
  def get_transform_thresholds(self):
563
577
  return _AFFINE_THRESHOLDS, _HOMOGRAPHY_THRESHOLDS
564
578
 
579
+ def get_transform_thresholds_large(self):
580
+ return _AFFINE_THRESHOLDS_LARGE, _HOMOGRAPHY_THRESHOLDS_LARGE
581
+
565
582
  def image_str(self, idx):
566
583
  return f"{self.process.frame_str(idx)}, " \
567
584
  f"{os.path.basename(self.process.input_filepath(idx))}"
@@ -771,7 +788,7 @@ class AlignFrames(AlignFramesBase):
771
788
  f"{self.process.name}-matches-{idx_str}.pdf")
772
789
  else:
773
790
  plot_path = None
774
- affine_thresholds, homography_thresholds = self.get_transform_thresholds()
791
+ affine_thresholds, homography_thresholds = self.get_transform_thresholds_large()
775
792
  n_good_matches, _m, img = align_images(
776
793
  img_ref, img_0,
777
794
  feature_config=self.feature_config,
@@ -104,7 +104,6 @@ class AlignFramesParallel(AlignFramesBase):
104
104
  self._img_locks[i] = 0
105
105
  elif self._img_cache[i] is not None:
106
106
  cached_images += 1
107
- # self.print_message(f"cached images: {cached_images}")
108
107
  gc.collect()
109
108
 
110
109
  def begin(self, process):
@@ -176,17 +175,22 @@ class AlignFramesParallel(AlignFramesBase):
176
175
  self._transforms[idx] = None
177
176
  gc.collect()
178
177
  missing_transforms = 0
179
- thresholds = self.get_transform_thresholds()
178
+ thresholds = self.get_transform_thresholds_large()
180
179
  for i in range(n_frames):
181
180
  if self._cumulative_transforms[i] is not None:
182
181
  self._cumulative_transforms[i] = self._cumulative_transforms[i].astype(np.float32)
183
- is_valid, _reason, result = check_transform(
182
+ is_valid, reason, result = check_transform(
184
183
  self._cumulative_transforms[i], self._img_shapes[i],
185
184
  transform_type, *thresholds)
186
185
  if is_valid:
187
186
  self.save_transform_result(i, result)
188
187
  else:
188
+ self.print_message(
189
+ f"invalid cumulative transform for {self.image_str(i)}",
190
+ color=constants.LOG_COLOR_WARNING, level=logging.WARNING)
191
+ if self.alignment_config['abort_abnormal']:
189
192
  self._cumulative_transforms[i] = None
193
+ raise RuntimeError(f"invalid cumulative transformation: {reason}")
190
194
  else:
191
195
  missing_transforms += 1
192
196
  msg = "feature extaction completed"
@@ -337,9 +341,9 @@ class AlignFramesParallel(AlignFramesBase):
337
341
  m = self._cumulative_transforms[idx]
338
342
  if m is None:
339
343
  self.print_message(
340
- f"no transformation for {self.image_str(idx)}, skipping alignment",
344
+ f"no transformation for {self.image_str(idx)}, image skipped",
341
345
  color=constants.LOG_COLOR_WARNING, level=logging.WARNING)
342
- return img_0
346
+ return None
343
347
  transform_type = self.alignment_config['transform']
344
348
  if transform_type == constants.ALIGN_RIGID and m.shape != (2, 3):
345
349
  self.print_message(f"invalid matrix shape for rigid transform: {m.shape}")