Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dolfin_dic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
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
Admin message
GitLab upgrade completed. Current version is 17.8.2.
Show more breadcrumbs
ALVAREZ BARRIENTOS Felipe
dolfin_dic
Commits
00059c9a
Commit
00059c9a
authored
5 years ago
by
Martin Genet
Browse files
Options
Downloads
Patches
Plain Diff
Better mechanism to overwrite/keep temporary images in generate_images
parent
4fe93567
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
downsample_images.py
+17
-7
17 additions, 7 deletions
downsample_images.py
generate_images.py
+20
-15
20 additions, 15 deletions
generate_images.py
normalize_images.py
+2
-1
2 additions, 1 deletion
normalize_images.py
with
39 additions
and
23 deletions
downsample_images.py
+
17
−
7
View file @
00059c9a
...
...
@@ -31,6 +31,7 @@ def downsample_images(
downsampling_factors
,
images_ext
=
"
vti
"
,
keep_resolution
=
0
,
overwrite_orig_images
=
1
,
write_temp_images
=
0
,
verbose
=
0
):
...
...
@@ -185,7 +186,11 @@ def downsample_images(
else
:
rfft
.
SetInputData
(
image_downsampled
)
# MG20190520: Not sure why this does not work.
writer
.
SetInputConnection
(
rfft
.
GetOutputPort
())
extract
=
vtk
.
vtkImageExtractComponents
()
extract
.
SetInputConnection
(
rfft
.
GetOutputPort
())
extract
.
SetComponents
(
0
)
writer
.
SetInputConnection
(
extract
.
GetOutputPort
())
if
(
keep_resolution
):
for
k_frame
in
range
(
images_nframes
):
...
...
@@ -201,7 +206,7 @@ def downsample_images(
writer_mul
.
SetFileName
(
images_folder
+
"
/
"
+
images_basename
+
"
_mul
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images_zfill
)
+
"
.
"
+
images_ext
)
writer_mul
.
Write
()
writer
.
SetFileName
(
images_folder
+
"
/
"
+
images_basename
+
"
_downsampled
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images_zfill
)
+
"
.
"
+
images_ext
)
writer
.
SetFileName
(
images_folder
+
"
/
"
+
images_basename
+
(
"
_downsampled
"
)
*
(
not
overwrite_orig_images
)
+
"
_
"
+
str
(
k_frame
).
zfill
(
images_zfill
)
+
"
.
"
+
images_ext
)
writer
.
Write
()
else
:
for
k_frame
in
range
(
images_nframes
):
...
...
@@ -255,11 +260,16 @@ def downsample_images(
writer_sel
.
SetFileName
(
images_folder
+
"
/
"
+
images_basename
+
"
_sel
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images_zfill
)
+
"
.
"
+
images_ext
)
writer_sel
.
Write
()
rfft
=
vtk
.
vtkImageRFFT
()
# MG20190520: Not sure why this is needed.
rfft
.
SetDimensionality
(
images_ndim
)
# MG20190520: Not sure why this is needed.
rfft
.
SetInputData
(
image_downsampled
)
# MG20190520: Not sure why this is needed.
rfft
=
vtk
.
vtkImageRFFT
()
# MG20190520: Not sure why this is needed.
rfft
.
SetDimensionality
(
images_ndim
)
# MG20190520: Not sure why this is needed.
rfft
.
SetInputData
(
image_downsampled
)
# MG20190520: Not sure why this is needed.
rfft
.
Update
()
writer
.
SetInputData
(
rfft
.
GetOutput
())
# MG20190520: Not sure why this is needed.
writer
.
SetFileName
(
images_folder
+
"
/
"
+
images_basename
+
"
_downsampled
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images_zfill
)
+
"
.
"
+
images_ext
)
extract
=
vtk
.
vtkImageExtractComponents
()
# MG20190520: Not sure why this is needed.
extract
.
SetInputData
(
rfft
.
GetOutput
())
# MG20190520: Not sure why this is needed.
extract
.
SetComponents
(
0
)
# MG20190520: Not sure why this is needed.
extract
.
Update
()
# MG20190520: Not sure why this is needed.
writer
.
SetInputData
(
extract
.
GetOutput
())
# MG20190520: Not sure why this is needed.
writer
.
SetFileName
(
images_folder
+
"
/
"
+
images_basename
+
(
"
_downsampled
"
)
*
(
not
overwrite_orig_images
)
+
"
_
"
+
str
(
k_frame
).
zfill
(
images_zfill
)
+
"
.
"
+
images_ext
)
writer
.
Write
()
This diff is collapsed.
Click to expand it.
generate_images.py
+
20
−
15
View file @
00059c9a
...
...
@@ -62,7 +62,8 @@ def generate_images(
noise
,
deformation
,
evolution
,
generate_image_gradient
=
False
,
generate_image_gradient
=
0
,
keep_temp_images
=
0
,
verbose
=
0
):
mypy
.
my_print
(
verbose
,
"
*** generate_images ***
"
)
...
...
@@ -188,16 +189,18 @@ def generate_images(
images_basename
=
images
[
"
basename
"
],
downsampling_factors
=
images
[
"
upsampling_factors
"
],
keep_resolution
=
0
,
overwrite_orig_images
=
(
not
keep_temp_images
),
write_temp_images
=
0
,
verbose
=
verbose
)
for
k_frame
in
range
(
images
[
"
n_frames
"
]):
os
.
rename
(
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
],
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_upsampled
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
])
os
.
rename
(
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_downsampled
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
],
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
])
if
(
keep_temp_images
):
for
k_frame
in
range
(
images
[
"
n_frames
"
]):
os
.
rename
(
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
],
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_upsampled
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
])
os
.
rename
(
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_downsampled
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
],
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
])
if
(
images
[
"
data_type
"
]
in
(
"
float
"
)):
normalizing
=
False
...
...
@@ -208,12 +211,14 @@ def generate_images(
images_folder
=
images
[
"
folder
"
],
images_basename
=
images
[
"
basename
"
],
images_datatype
=
images
[
"
data_type
"
],
overwrite_orig_images
=
(
not
keep_temp_images
),
verbose
=
verbose
)
for
k_frame
in
range
(
images
[
"
n_frames
"
]):
os
.
rename
(
src
=
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
],
dst
=
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_prenormalized
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
])
os
.
rename
(
src
=
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_normalized
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
],
dst
=
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
])
if
(
keep_temp_images
):
for
k_frame
in
range
(
images
[
"
n_frames
"
]):
os
.
rename
(
src
=
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
],
dst
=
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_prenormalized
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
])
os
.
rename
(
src
=
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_normalized
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
],
dst
=
images
[
"
folder
"
]
+
"
/
"
+
images
[
"
basename
"
]
+
"
_
"
+
str
(
k_frame
).
zfill
(
images
[
"
zfill
"
])
+
"
.
"
+
images
[
"
ext
"
])
This diff is collapsed.
Click to expand it.
normalize_images.py
+
2
−
1
View file @
00059c9a
...
...
@@ -30,6 +30,7 @@ def normalize_images(
images_basename
,
images_datatype
,
images_ext
=
"
vti
"
,
overwrite_orig_images
=
1
,
verbose
=
0
):
mypy
.
my_print
(
verbose
,
"
*** normalize_images ***
"
)
...
...
@@ -94,5 +95,5 @@ def normalize_images(
mypy
.
my_print
(
verbose
,
"
k_frame =
"
+
str
(
k_frame
))
reader
.
SetFileName
(
images_folder
+
"
/
"
+
images_basename
+
"
_
"
+
str
(
k_frame
).
zfill
(
images_zfill
)
+
"
.
"
+
images_ext
)
writer
.
SetFileName
(
images_folder
+
"
/
"
+
images_basename
+
"
_normalized
"
+
"
_
"
+
str
(
k_frame
).
zfill
(
images_zfill
)
+
"
.
"
+
images_ext
)
writer
.
SetFileName
(
images_folder
+
"
/
"
+
images_basename
+
(
"
_normalized
"
)
*
(
not
overwrite_orig_images
)
+
"
_
"
+
str
(
k_frame
).
zfill
(
images_zfill
)
+
"
.
"
+
images_ext
)
writer
.
Write
()
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