Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD 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
Evan Edmond
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
Tags containing commit
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