Testing with uint conversion
This commit is contained in:
@@ -121,7 +121,7 @@ class Image:
|
|||||||
if self.path.suffix.lower() in [".tif", ".tiff"]:
|
if self.path.suffix.lower() in [".tif", ".tiff"]:
|
||||||
self._data = imread(str(self.path))
|
self._data = imread(str(self.path))
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError("RGB is not implemented")
|
||||||
# Load with OpenCV (returns BGR format)
|
# Load with OpenCV (returns BGR format)
|
||||||
self._data = cv2.imread(str(self.path), cv2.IMREAD_UNCHANGED)
|
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}")
|
raise ImageLoadError(f"Failed to load image with OpenCV: {self.path}")
|
||||||
|
|
||||||
# Extract metadata
|
# Extract metadata
|
||||||
print(self._data.shape)
|
# print(self._data.shape)
|
||||||
if len(self._data.shape) == 2:
|
if len(self._data.shape) == 2:
|
||||||
self._height, self._width = self._data.shape[:2]
|
self._height, self._width = self._data.shape[:2]
|
||||||
self._channels = 1
|
self._channels = 1
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ def apply_ultralytics_16bit_tiff_patches(*, force: bool = False) -> None:
|
|||||||
- For other formats, falls back to Ultralytics' original implementation.
|
- 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.
|
- 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()
|
ext = os.path.splitext(filename)[1].lower()
|
||||||
if ext in (".tif", ".tiff"):
|
if ext in (".tif", ".tiff"):
|
||||||
arr = Image(filename).get_qt_rgb()[:, :, :3]
|
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.
|
# Ensure contiguous array for downstream OpenCV ops.
|
||||||
# logger.info(f"Loading with monkey-patched imread: {filename}")
|
# logger.info(f"Loading with monkey-patched imread: {filename}")
|
||||||
|
arr *= (2**16 - 1).astype(np.uint16)
|
||||||
return np.ascontiguousarray(arr)
|
return np.ascontiguousarray(arr)
|
||||||
|
|
||||||
# logger.info(f"Loading with original imread: {filename}")
|
# logger.info(f"Loading with original imread: {filename}")
|
||||||
|
|||||||
Reference in New Issue
Block a user