Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#171 Invalid data type processing bug fix #173

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def _run(self):
if self.params.export_image_tiles:
file_name = f'tile_img_{tile_params.x_bin_number}_{tile_params.y_bin_number}.png'
file_path = os.path.join(self.output_dir_path, file_name)

if tile_img.dtype in [np.uint32, np.int32]:
print(f'Exporting image with data type {tile_img.dtype} is not supported. Trimming to uint16. Consider changing the data type in the source image.')
tile_img = tile_img.astype(np.uint16)

if tile_img.shape[-1] == 4:
tile_img = cv2.cvtColor(tile_img, cv2.COLOR_RGBA2BGRA)
elif tile_img.shape[-1] == 3:
Expand Down
11 changes: 7 additions & 4 deletions src/deepness/processing/processing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ def get_numpy_data_type_for_qgis_type(data_type_qgis: Qgis.DataType):
return np.uint8
if data_type_qgis == Qgis.DataType.UInt16:
return np.uint16
if data_type_qgis == Qgis.DataType.UInt32:
return np.uint32
if data_type_qgis == Qgis.DataType.Int16:
return np.int16
if data_type_qgis in Qgis.DataType.Float32:
if data_type_qgis == Qgis.DataType.Int32:
return np.int32
if data_type_qgis == Qgis.DataType.Float32:
return np.float32
if data_type_qgis in Qgis.DataType.Float64:
if data_type_qgis == Qgis.DataType.Float64:
return np.float64
# TODO - maybe add support for more data types (change also the numpy type below then)
raise Exception("Invalid input layer data type!")
raise Exception(f"Invalid input layer data type ({data_type_qgis})!")


def get_tile_image(
Expand Down
Loading