Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Rewrite of image infrastructure#5718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
cf11aea3b7d1bbc9cae504a053020aa222a0793aa21384c7c9148c7f820479efad84c864e84ea0be04c0a8643f15df79f0b436f1adfbc39d9d3b468f9d85347b32cd86e60ebfdc66ed07cccfb35073f6e625e80ac778cfc9fe6658d61ac2ab3318fdffbbf05fbb55c834d6cc84c5a3bf944820883f4bc9d5030a455c1abbfe376c45266fde9285c3ae2b2bbeb8946834e43c8b8665697d21a6ed2d2a1266d3518a0b8d6930f43f68cd0e7e0e62832fe7d54d53e532e1cfad8d9e52c26f0469ab7b391f0889365c17f2f3759827d1f5be66debd521cdd6b22a5fff1d66da6c00bc9b2425File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -306,18 +306,21 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, | ||
| out_height = int(out_height_base) | ||
| if not unsampled: | ||
| ifA.ndim == 2: | ||
| A = self.norm(A) | ||
| if A.dtype.kind == 'f': | ||
| # For floating-point greyscale images, we treat negative | ||
| # numbers as transparent. | ||
| # TODO: Use np.full when we support Numpy 1.9 as a | ||
| # minimum | ||
| output = np.empty((out_height, out_width), dtype=A.dtype) | ||
| output[...] = -100.0 | ||
Member 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. Perhaps add a TODO here to update this with Member 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. 1.9, I believe. MemberAuthor 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. Good point. Added. | ||
| else: | ||
| output = np.zeros((out_height, out_width), dtype=A.dtype) | ||
| alpha = 1.0 | ||
| elifA.ndim == 3: | ||
| # Always convert to RGBA, even if only RGB input | ||
| if A.shape[2] == 3: | ||
| A = _rgb_to_rgba(A) | ||
| @@ -340,7 +343,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, | ||
| output = self.to_rgba(output, bytes=True, norm=False) | ||
| # Apply alpha *after* if the input was greyscale | ||
| ifA.ndim == 2: | ||
| alpha = self.get_alpha() | ||
| if alpha is not None and alpha != 1.0: | ||
| alpha_channel = output[:, :, 3] | ||
| @@ -715,7 +718,7 @@ def make_image(self, renderer, magnification=1.0): | ||
| raise RuntimeError('You must first set the image array') | ||
| A = self._A | ||
| ifA.ndim == 2: | ||
| if A.dtype != np.uint8: | ||
| A = self.to_rgba(A, bytes=True) | ||
| self.is_grayscale = self.cmap.is_gray() | ||
| @@ -763,12 +766,12 @@ def set_data(self, x, y, A): | ||
| if len(x.shape) != 1 or len(y.shape) != 1\ | ||
| or A.shape[0:2] != (y.shape[0], x.shape[0]): | ||
| raise TypeError("Axes don't match array shape") | ||
| ifA.ndim not in [2, 3]: | ||
| raise TypeError("Can only plot 2D or 3D data") | ||
| ifA.ndim == 3 and A.shape[2] not in [1, 3, 4]: | ||
| raise TypeError("3D arrays must have three (RGB) " | ||
| "or four (RGBA) color components") | ||
| ifA.ndim == 3 and A.shape[2] == 1: | ||
| A.shape = A.shape[0:2] | ||
| self._A = A | ||
| self._Ax = x | ||