This repository has been archived by the owner on Jul 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 304
Return rgb when rgba is loaded #734
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
649a886
return rgb when rgba is loaded
yuyu2172 f707028
fix typo
yuyu2172 213a3e7
add alpha option
yuyu2172 08d736b
use cv2.IMREAD_UNCHANGED when alpha is not None
yuyu2172 0ab431d
fix bug
yuyu2172 b7b5cbc
test
yuyu2172 ad09b22
make test more strict
yuyu2172 c2335c9
flake8
yuyu2172 b8bbb51
fix bug
yuyu2172 2aaa9ed
merge master
yuyu2172 0f38d43
fix doc
yuyu2172 8cd06d0
support python2
yuyu2172 d586772
fix comment
yuyu2172 11aecce
fix typo
yuyu2172 b8b71d8
merge
yuyu2172 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,11 @@ def _read_image_cv2(path, dtype, color): | |
# reshape (H, W) -> (1, H, W) | ||
return img[np.newaxis].astype(dtype) | ||
else: | ||
# alpha channel is inclued | ||
if img.shape[-1] == 4: | ||
bgr = img[:, :, :3] | ||
alpha = img[:, :, 3:] / 255 | ||
img = bgr * alpha + 255 * np.ones_like(bgr) * (1 - alpha) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there are three options.
Why do you choose 3.? Personally, I prefer 1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is because the alpha channel contains meaningful information (for some part, the value is in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is 2 better? |
||
img = img[:, :, ::-1] # BGR -> RGB | ||
img = img.transpose((2, 0, 1)) # HWC -> CHW | ||
return img.astype(dtype) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
included
?