Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
python3-imagej-tiff
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
python3-imagej-tiff
Commits
e56bda2f
Commit
e56bda2f
authored
Jul 02, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored, tested for 3D,4D and 5D
parent
8b48ba4a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
imagej_tiffwriter.py
imagej_tiffwriter.py
+23
-11
No files found.
imagej_tiffwriter.py
View file @
e56bda2f
...
@@ -81,10 +81,9 @@ def save(path,images):
...
@@ -81,10 +81,9 @@ def save(path,images):
# 0 or 1 images.shapes are not handled
# 0 or 1 images.shapes are not handled
#
#
# save single channel image in the form of numpy array
# (h,w)
# -
if
len
(
images
.
shape
)
==
2
:
if
len
(
images
.
shape
)
==
2
:
# (h,w) -> (h,w,c=1)
image
=
Image
.
fromarray
(
images
)
image
=
Image
.
fromarray
(
images
)
image
.
save
(
path
)
image
.
save
(
path
)
...
@@ -102,15 +101,14 @@ def save(path,images):
...
@@ -102,15 +101,14 @@ def save(path,images):
t
=
images
.
shape
[
-
5
]
t
=
images
.
shape
[
-
5
]
c_axis
=
len
(
images
.
shape
)
-
1
c_axis
=
-
1
if
c
>
1
:
if
c
==
1
:
channels
=
np
.
squeeze
(
np
.
split
(
images
,
c
,
axis
=
c_axis
))
split_channels
=
images
else
:
else
:
channels
=
np
.
squeeze
(
images
,
axis
=
c_axis
)
channels
=
np
.
array
(
np
.
split
(
images
,
c
,
axis
=
c_axis
))
split_channels
=
np
.
concatenate
(
channels
,
axis
=-
3
)
split_channels
=
np
.
concatenate
(
channels
,
axis
=-
3
)
images_flat
=
np
.
reshape
(
split_channels
,(
-
1
,
h
,
w
))
images_flat
=
np
.
reshape
(
split_channels
,(
-
1
,
h
,
w
))
imlist
=
[]
imlist
=
[]
...
@@ -147,4 +145,18 @@ if __name__ == "__main__":
...
@@ -147,4 +145,18 @@ if __name__ == "__main__":
print
(
str
(
time
.
time
())
+
": Test images generated"
)
print
(
str
(
time
.
time
())
+
": Test images generated"
)
print
(
"Images shape: "
+
str
(
images
.
shape
))
print
(
"Images shape: "
+
str
(
images
.
shape
))
v
=
save
(
"result_2.tiff"
,
images
)
print
(
"5D run"
)
v
=
save
(
"result_5D.tiff"
,
images
)
print
(
"4D run"
)
v
=
save
(
"result_4D.tiff"
,
images
[
0
])
print
(
"3D run"
)
v
=
save
(
"result_3D.tiff"
,
images
[
0
,
0
])
print
(
"3D run, 1 channel"
)
tmp_images
=
images
[
0
,
0
,:,:,
0
]
v
=
save
(
"result_3D1C.tiff"
,
tmp_images
[:,:,
np
.
newaxis
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment