Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sean Fitzgibbon
SlideR 🍔
Commits
8c599e4c
Commit
8c599e4c
authored
Nov 05, 2021
by
Sean Fitzgibbon
Browse files
Added support for other file formats to APPLYXFM
parent
f7da6821
Changes
1
Hide whitespace changes
Inline
Side-by-side
slider/slide_reg.py
View file @
8c599e4c
...
...
@@ -175,7 +175,8 @@ def _load_image(p):
timg
=
_load_jpg2k
(
p
.
file
,
p
.
resolution
,
p
.
resolution_level
,
p
.
dtype
)
# add mask
tirl
.
scripts
.
mnd
.
image
.
set_mask
(
timg
,
scope
=
globals
(),
**
p
.
mask
)
if
'mask'
in
p
.
keys
():
tirl
.
scripts
.
mnd
.
image
.
set_mask
(
timg
,
scope
=
globals
(),
**
p
.
mask
)
# Export
tirl
.
scripts
.
mnd
.
inout
.
export
(
timg
,
p
.
export
,
default
=
None
)
...
...
@@ -1273,8 +1274,7 @@ def apply_slide_xfm(
fixed_reg
,
out
,
rlevel
=
0
,
inverse
=
False
,
):
inverse
=
False
):
moving_reg
=
tirl
.
load
(
moving_reg
)
fixed_reg
=
tirl
.
load
(
fixed_reg
)
...
...
@@ -1297,8 +1297,30 @@ def apply_slide_xfm(
# load native resolution images
moving_native
=
_load_jpg2k
(
moving
,
moving_res
,
rlevel
)
fixed_native
=
_load_jpg2k
(
fixed
,
fixed_res
,
rlevel
)
moving_native
=
_load_image
(
AttrMap
(
{
'file'
:
moving
,
'resolution'
:
moving_res
,
'resolution_level'
:
rlevel
,
'dtype'
:
'uint8'
,
'export'
:
False
,
'snapshot'
:
'moving_native.png'
,
}
))
fixed_native
=
_load_image
(
AttrMap
(
{
'file'
:
fixed
,
'resolution'
:
fixed_res
,
'resolution_level'
:
rlevel
,
'dtype'
:
'uint8'
,
'export'
:
False
,
'snapshot'
:
'fixed_native.png'
,
}
))
# moving_native = _load_jpg2k(moving, moving_res, rlevel)
# fixed_native = _load_jpg2k(fixed, fixed_res, rlevel)
# fixed pixel coordinates in native res
...
...
@@ -1316,9 +1338,15 @@ def apply_slide_xfm(
)
# TODO: additional ouput types (beyond jp2) should be supported
import
glymur
glymur
.
Jp2k
(
out
,
data
=
np
.
round
(
moving_value_reshaped
).
astype
(
moving_native
.
dtype
))
ext
=
op
.
splitext
(
out
)[
-
1
]
if
ext
==
'.jp2'
:
import
glymur
glymur
.
Jp2k
(
out
,
data
=
np
.
round
(
moving_value_reshaped
).
astype
(
moving_native
.
dtype
))
else
:
import
skimage.io
skimage
.
io
.
imsave
(
out
,
np
.
round
(
moving_value_reshaped
).
astype
(
moving_native
.
dtype
))
# import imageio
# imageio.imsave('test_moving.png', np.round(moving_value_reshaped).astype(moving_native.dtype))
...
...
Write
Preview
Supports
Markdown
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