Skip to content
Snippets Groups Projects

Synthetic image gen

Merged s204159 requested to merge synthetic_image_gen into main
1 file
+ 3
2
Compare changes
  • Side-by-side
  • Inline
+ 3
2
@@ -49,12 +49,13 @@ def overlay_rgb_images(background, foreground, alpha=0.5):
return composite.astype("uint8")
def generate_synthetic_volume(shape, dtype=np.float32):
def generate_synthetic_volume(shape, dtype=np.float32, order=1):
"""Generate a synthetic volume with custom structures.
Args:
shape (tuple): The shape of the volume in (x, y, z) dimensions.
dtype (str): The data type of the volume.
order (int): The order of interpolation for zooming. (Lower is faster)
Returns:
numpy.ndarray: The synthetic volume.
@@ -96,7 +97,7 @@ def generate_synthetic_volume(shape, dtype=np.float32):
k * scale) ) * (1-dist)
# Scale up the volume of organic_shape to size
volume = scipy.ndimage.zoom(organic_shape, [s/shape_dim for s in shape])
volume = scipy.ndimage.zoom(organic_shape, [s/shape_dim for s in shape], order=order)
# clip the low values of the volume to create a coherent volume
volume[volume < 0.5] = 0
Loading