Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
a42f9d99
Commit
a42f9d99
authored
Feb 20, 2018
by
Zhuliang Yao
Committed by
Soumith Chintala
Feb 19, 2018
Browse files
use PIL's point-function to accelerate adjust_gamma (#410)
parent
f5d486c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+3
-4
No files found.
torchvision/transforms/functional.py
View file @
a42f9d99
...
...
@@ -523,11 +523,10 @@ def adjust_gamma(img, gamma, gain=1):
input_mode
=
img
.
mode
img
=
img
.
convert
(
'RGB'
)
np_img
=
np
.
array
(
img
,
dtype
=
np
.
float32
)
np_img
=
255
*
gain
*
((
np_img
/
255
)
**
gamma
)
np_img
=
np
.
uint8
(
np
.
clip
(
np_img
,
0
,
255
))
gamma_map
=
[
255
*
gain
*
pow
(
ele
/
255.
,
gamma
)
for
ele
in
range
(
256
)]
*
3
img
=
img
.
point
(
gamma_map
)
# use PIL's point-function to accelerate this part
img
=
Image
.
fromarray
(
np_img
,
'RGB'
)
.
convert
(
input_mode
)
img
=
img
.
convert
(
input_mode
)
return
img
...
...
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