Skip to content

Commit

Permalink
Convert and assume RGB uint8 image as input
Browse files Browse the repository at this point in the history
  • Loading branch information
Inokinoki committed Aug 9, 2024
1 parent d694609 commit 8d05c85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion giskard_vision/core/dataloaders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ def get_meta(self, idx: int) -> Optional[TypesBase.meta]:
Optional[TypesBase.meta]: Meta information for the given index.
"""
img = self.get_image(idx)
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
if img.dtype != np.uint8:
# Normalize image to 0-255 range with uint8
img = (img * 255 % 255).astype(np.uint8)

gray_img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
size = get_image_size(img)
nb_channels = get_image_channel_number(img)
avg_color = np.mean(img, axis=(0, 1))
Expand Down
2 changes: 1 addition & 1 deletion giskard_vision/core/dataloaders/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def get_brightness(image: np.ndarray) -> float:
Returns:
float: The image brightness normalized to 1.
"""
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
return np.mean(hsv[:, :, 2]) / 255


Expand Down

0 comments on commit 8d05c85

Please sign in to comment.