Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
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
Michiel Cottaar
fslpy
Commits
1a811c11
Commit
1a811c11
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
BF: Tell Pillow to allow bigger images. Make sure single-chanel images
are still shaped (w, h, c), where c == 1
parent
9427bb47
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/bitmap.py
+16
-7
16 additions, 7 deletions
fsl/data/bitmap.py
with
16 additions
and
7 deletions
fsl/data/bitmap.py
+
16
−
7
View file @
1a811c11
...
...
@@ -51,12 +51,16 @@ class Bitmap(object):
data.
"""
try
:
import
PIL.Image
as
Image
except
ImportError
:
raise
RuntimeError
(
'
Install Pillow to use the Bitmap class
'
)
if
isinstance
(
bmp
,
six
.
string_types
):
try
:
# Allow big images
import
PIL.Image
as
Image
Image
.
MAX_IMAGE_PIXELS
=
1e9
except
ImportError
:
raise
RuntimeError
(
'
Install Pillow to use the Bitmap class
'
)
source
=
bmp
data
=
np
.
array
(
Image
.
open
(
source
))
...
...
@@ -67,7 +71,13 @@ class Bitmap(object):
else
:
raise
ValueError
(
'
unknown bitmap: {}
'
.
format
(
bmp
))
# Make the array (w, h, c)
# Make the array (w, h, c). Single channel
# (e.g. greyscale) images are returned as
# 2D arrays, whereas multi-channel images
# are returned as 3D. In either case, the
# first two dimensions are (height, width),
# but we watn them the other way aruond.
data
=
np
.
atleast_3d
(
data
)
data
=
np
.
fliplr
(
data
.
transpose
((
1
,
0
,
2
)))
data
=
np
.
array
(
data
,
dtype
=
np
.
uint8
,
order
=
'
C
'
)
w
,
h
=
data
.
shape
[:
2
]
...
...
@@ -132,7 +142,6 @@ class Bitmap(object):
if
nchannels
==
1
:
dtype
=
np
.
uint8
elif
nchannels
==
3
:
dtype
=
np
.
dtype
([(
'
R
'
,
'
uint8
'
),
(
'
G
'
,
'
uint8
'
),
...
...
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