Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a9ca9d85 authored by LEGRAND Jonathan's avatar LEGRAND Jonathan
Browse files

Add an example file for `vtImage`.

parent 75c9888b
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# File author(s):
# Jonathan Legrand <jonathan.legrand@ens-lyon.fr>
#
# ------------------------------------------------------------------------------
"""
Usage example for data structure `vtImage`.
"""
from vt import vtImage
from vt.tools import shared_data
from vt.tools import random_array
# --- Initialize an EMPTY vtImage:
vt_img = vtImage()
print(vt_img)
print(vt_img.spacing())
print(vt_img.shape())
# --- Creation from a random 2D NumPy array:
arr = random_array((4, 5), type='uint8')
print(arr.shape)
print(arr.dtype)
vt_img = vtImage(arr, [0.2, 0.3, 1.0])
print(vt_img.spacing())
print(vt_img.shape())
vt_arr = vt_img.copy_to_array()
print(vt_arr.shape)
print(vt_arr.dtype)
# --- Creation from a random 3D NumPy array:
arr = random_array((3, 4, 5), type='uint8')
print(arr.shape)
print(arr.dtype)
vt_img = vtImage(arr, [0.2, 0.3, 0.1])
print(vt_img.spacing())
print(vt_img.shape())
vt_arr = vt_img.copy_to_array()
print(vt_arr.shape)
print(vt_arr.dtype)
# - Creation from a loaded 2D image:
vt_img = vtImage(shared_data("io_2D.tif"))
print(vt_img.spacing())
print(vt_img.shape())
# - Creation from a saved 3D image:
vt_img = vtImage(shared_data("p58-t0_INT_down_interp_2x.inr"))
print(vt_img.spacing())
print(vt_img.shape())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment