Skip to content

Commit

Permalink
Merge pull request #173 from PUTvision/units_bug_fix
Browse files Browse the repository at this point in the history
#171 Invalid data type processing bug fix
przemyslaw-aszkowski authored Jun 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 71e7c8c + b4af1b0 commit 3aa8b0b
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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:
11 changes: 7 additions & 4 deletions src/deepness/processing/processing_utils.py
Original file line number Diff line number Diff line change
@@ -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(

0 comments on commit 3aa8b0b

Please sign in to comment.