Testing with uint conversion

This commit is contained in:
2025-12-19 13:10:36 +02:00
parent 2b0b48921e
commit 5d25378c46
2 changed files with 5 additions and 3 deletions

View File

@@ -121,7 +121,7 @@ class Image:
if self.path.suffix.lower() in [".tif", ".tiff"]:
self._data = imread(str(self.path))
else:
raise NotImplementedError
raise NotImplementedError("RGB is not implemented")
# Load with OpenCV (returns BGR format)
self._data = cv2.imread(str(self.path), cv2.IMREAD_UNCHANGED)
@@ -129,7 +129,7 @@ class Image:
raise ImageLoadError(f"Failed to load image with OpenCV: {self.path}")
# Extract metadata
print(self._data.shape)
# print(self._data.shape)
if len(self._data.shape) == 2:
self._height, self._width = self._data.shape[:2]
self._channels = 1

View File

@@ -54,7 +54,8 @@ def apply_ultralytics_16bit_tiff_patches(*, force: bool = False) -> None:
- For other formats, falls back to Ultralytics' original implementation.
- Always returns HWC (3 dims). For grayscale, returns (H, W, 1) or (H, W, 3) depending on requested flags.
"""
# print("here")
# return _original_imread(filename, flags)
ext = os.path.splitext(filename)[1].lower()
if ext in (".tif", ".tiff"):
arr = Image(filename).get_qt_rgb()[:, :, :3]
@@ -75,6 +76,7 @@ def apply_ultralytics_16bit_tiff_patches(*, force: bool = False) -> None:
# Ensure contiguous array for downstream OpenCV ops.
# logger.info(f"Loading with monkey-patched imread: {filename}")
arr *= (2**16 - 1).astype(np.uint16)
return np.ascontiguousarray(arr)
# logger.info(f"Loading with original imread: {filename}")