Skip to content

Commit 29cc12a

Browse files
committed
Fix 90 angles for plots
- Simplify `center_of_spot` by removing unnecessary legacy docstring and refining logic. - Fix mismatched parameters in `render` and `plot` methods to ensure proper axis handling and dimensions.
1 parent dca2bdf commit 29cc12a

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

source/algorithms/centroid_calculator.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,7 @@ def run_quickshift(self) -> np.ndarray:
260260

261261
def center_of_spot(self, segments: np.ndarray,
262262
image: np.ndarray | None = None) -> tuple[int, int]:
263-
"""Return the central pixel of the brightest segment.
264263

265-
Considers labels ``0..max(segments)``; non-existent labels are
266-
skipped via ``np.nanargmax``. The legacy positional signature
267-
``center_of_spot(image, segments)`` is preserved by accepting an
268-
optional image; if it is 3-D the first channel is used as intensity.
269-
"""
270264
if image is not None and image is not segments:
271265
intensity = image[..., 0] if image.ndim == 3 else image
272266
else:
@@ -317,7 +311,7 @@ def calculate_superpixels_felzenszwalb(self, plot: bool = False):
317311

318312
def render(self, name: str, segments: np.ndarray, x: int, y: int) -> None:
319313
marked = mark_boundaries(self.image_3ch, segments)
320-
plot_2d(name, marked, x, y, self.height, self.output_dir)
314+
plot_2d(name, marked, x, y, self.width, self.output_dir)
321315
plot_3d_surface(name, self.gray, segments, self.output_dir)
322316
plot_wireframe(name, self.gray, segments, x, y, self.output_dir)
323317

@@ -440,7 +434,7 @@ def calculate_centroid_scikit(image_or_path, *, plot: bool = False,
440434
plt.rcParams.update({"font.size": 30})
441435
fig, ax = plt.subplots(figsize=(11, 12.8))
442436
ax.imshow(np.rot90(image), origin="lower")
443-
ax.plot(cy, gray.shape[0] - cx, "o", markersize=15, color="red")
437+
ax.plot(cy, gray.shape[1] - cx, "o", markersize=15, color="red")
444438
ax.set_xlabel("pixeles")
445439
ax.set_ylabel("pixeles")
446440
save_figure(fig, out, "CCL.png")
@@ -459,7 +453,7 @@ def calculate_centroid_scikit(image_or_path, *, plot: bool = False,
459453
if __name__ == "__main__":
460454
logging.basicConfig(level=logging.INFO, format="%(message)s")
461455
print(f"Acceleration: {gpu_utils.device_summary()}")
462-
path_to_image = "images/l0/image100.png"
456+
path_to_image = "images/c/image0.png"
463457
sp = Superpixels(path_to_image, 125)
464458

465459
timings = {}

0 commit comments

Comments
 (0)