Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vt-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
morpheme
vt-python
Commits
a9ca9d85
Commit
a9ca9d85
authored
5 years ago
by
LEGRAND Jonathan
Browse files
Options
Downloads
Patches
Plain Diff
Add an example file for `vtImage`.
parent
75c9888b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/vt_image.py
+57
-0
57 additions, 0 deletions
examples/vt_image.py
with
57 additions
and
0 deletions
examples/vt_image.py
0 → 100644
+
57
−
0
View file @
a9ca9d85
#!/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
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment