Binary file not shown.
@@ -3,6 +3,7 @@ import numpy as np
|
||||
|
||||
from . import scipy
|
||||
from . import skimage as ski
|
||||
from . import scipy as ndi
|
||||
|
||||
# 3rd-party
|
||||
import transforms3d
|
||||
@@ -97,36 +98,43 @@ class Layer():
|
||||
_mask = np.expand_dims(_mask, axis=-1)
|
||||
self.data = _mask * value + (1-_mask) * self.data
|
||||
|
||||
def resize(self, shape:tuple, progress_callback=None):
|
||||
def resize(self, shape: tuple, progress_callback=None):
|
||||
if len(shape) != 3:
|
||||
raise Exception("Shape must be 3 dim")
|
||||
|
||||
data = self.data
|
||||
order = 0 if self.dtype == bool else 1
|
||||
|
||||
# TXYZC > TXYZ
|
||||
if self.kind in ['label', 'scalar']:
|
||||
data = np.amax(data, -1)
|
||||
|
||||
if self.kind in ['scalar']:
|
||||
dtype = data.dtype
|
||||
data = data.astype(np.float32)
|
||||
# if self.kind in ['scalar']:
|
||||
# dtype = data.dtype
|
||||
# data = data.astype(np.float32)
|
||||
|
||||
data_frames = ()
|
||||
for f in range(self.frame_count):
|
||||
if progress_callback:
|
||||
progress_callback(f, self.frame_count)
|
||||
|
||||
frame = ski.resize(data[f, :, :, :],
|
||||
shape,
|
||||
preserve_range=True,
|
||||
anti_aliasing=data.dtype.kind != "b")
|
||||
# frame = ski.resize(data[f, :, :, :],
|
||||
# shape,
|
||||
# preserve_range=True,
|
||||
# anti_aliasing=data.dtype.kind != "b")
|
||||
|
||||
factors = np.divide(self.shape, shape)
|
||||
zoom_factors = [1 / f for f in factors]
|
||||
frame = ndi.zoom(data[f, :, :, :],
|
||||
zoom_factors,
|
||||
order=order)
|
||||
|
||||
data_frames += (frame,)
|
||||
|
||||
data = np.stack(data_frames)
|
||||
|
||||
if self.kind in ['scalar']:
|
||||
data = data.astype(dtype)
|
||||
# if self.kind in ['scalar']:
|
||||
# data = data.astype(dtype)
|
||||
|
||||
# TXYZ > TXYZC
|
||||
if self.kind in ['label', 'scalar']:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
schema_version = "1.0.0"
|
||||
|
||||
id = "bioxelnodes"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
name = "Bioxel Nodes"
|
||||
tagline = "For scientific volumetric data visualization in Blender"
|
||||
maintainer = "Ma Nan <icrdr2010@outlook.com>"
|
||||
|
||||
@@ -134,10 +134,12 @@ class ParseVolumetricData(bpy.types.Operator):
|
||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH") # type: ignore
|
||||
|
||||
skip_read_as: bpy.props.BoolProperty(name="Skip Read As",
|
||||
default=False) # type: ignore
|
||||
default=False,
|
||||
options={"SKIP_SAVE"}) # type: ignore
|
||||
|
||||
skip_series_select: bpy.props.BoolProperty(name="Skip Sries Select",
|
||||
default=True) # type: ignore
|
||||
default=True,
|
||||
options={"SKIP_SAVE"}) # type: ignore
|
||||
|
||||
read_as: bpy.props.EnumProperty(name="Read as",
|
||||
default="scalar",
|
||||
|
||||
@@ -232,7 +232,6 @@ class CombineLabels(bpy.types.Operator, LabelOperator):
|
||||
return {'FINISHED'}
|
||||
base_obj = label_objs[0]
|
||||
label_objs = label_objs[1:]
|
||||
container_obj = base_obj.parent
|
||||
|
||||
base_layer = obj_to_layer(base_obj)
|
||||
modified_layer = base_layer.copy()
|
||||
@@ -241,7 +240,7 @@ class CombineLabels(bpy.types.Operator, LabelOperator):
|
||||
for label_obj in label_objs:
|
||||
label_layer = obj_to_layer(label_obj)
|
||||
label_layer.resize(base_layer.shape)
|
||||
modified_layer.data = np.maximum(base_layer.data, label_layer.data)
|
||||
modified_layer.data = np.maximum(modified_layer.data, label_layer.data)
|
||||
label_names.append(label_layer.name)
|
||||
|
||||
modified_layer.name = f"{'-'.join(label_names)}-Combined"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "bioxelnodes"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
description = ""
|
||||
authors = ["Ma Nan <icrdr2010@outlook.com>"]
|
||||
license = "MIT"
|
||||
|
||||
Reference in New Issue
Block a user