Commit 61106a5f5dd7a86a4a87b168e76b813f8323bf2d
1 parent
d3e4908c
Exists in
master
Fixed problem with uint16 bitmap files
Showing
2 changed files
with
8 additions
and
6 deletions
Show diff stats
invesalius/data/imagedata_utils.py
... | ... | @@ -345,6 +345,8 @@ def bitmap2memmap(files, slice_size, orientation, spacing, resolution_percentage |
345 | 345 | for n, f in enumerate(files): |
346 | 346 | image_as_array = bitmap_reader.ReadBitmap(f) |
347 | 347 | |
348 | + print(image_as_array.dtype) | |
349 | + | |
348 | 350 | image = converters.to_vtk(image_as_array, spacing=spacing,\ |
349 | 351 | slice_number=1, orientation=orientation.upper()) |
350 | 352 | |
... | ... | @@ -374,9 +376,9 @@ def bitmap2memmap(files, slice_size, orientation, spacing, resolution_percentage |
374 | 376 | array = numpy_support.vtk_to_numpy(image.GetPointData().GetScalars()) |
375 | 377 | |
376 | 378 | if array.dtype == 'uint16': |
377 | - array = array - 32768/2 | |
378 | - | |
379 | - array = array.astype("int16") | |
379 | + new_array = np.empty_like(array, dtype=np.int16) | |
380 | + new_array = array - 32768 | |
381 | + array = new_array | |
380 | 382 | |
381 | 383 | if orientation == 'CORONAL': |
382 | 384 | array.shape = matrix.shape[0], matrix.shape[2] |
... | ... | @@ -622,4 +624,4 @@ def random_sample_sphere(radius=3, size=100): |
622 | 624 | r = np.random.uniform(0, 1, (size, 1)) ** 1.5 |
623 | 625 | scale = radius * np.divide(r, norm) |
624 | 626 | xyz = scale * uvw |
625 | - return xyz | |
626 | 627 | \ No newline at end of file |
628 | + return xyz | ... | ... |
invesalius/gui/widgets/slice_menu.py
... | ... | @@ -262,8 +262,8 @@ class SliceMenu(wx.Menu): |
262 | 262 | if self.cdialog is None: |
263 | 263 | slc = sl.Slice() |
264 | 264 | histogram = slc.histogram |
265 | - init = slc.matrix.min() | |
266 | - end = slc.matrix.max() | |
265 | + init = int(slc.matrix.min()) | |
266 | + end = int(slc.matrix.max()) | |
267 | 267 | nodes = slc.nodes |
268 | 268 | self.cdialog = ClutImagedataDialog(histogram, init, end, nodes) |
269 | 269 | self.cdialog.Show() | ... | ... |