-
Notifications
You must be signed in to change notification settings - Fork 140
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX Correctly handle NaNs in VertexRGB
and VolumeRGB
#458
Conversation
This is definitely better than before. Two nitpicks:
We could address both issues with the slightly more complicated solution: def __init__(...):
...
self.alpha = alpha
@property
def alpha(self):
"""Compute alpha transparency"""
alpha = self._alpha
if alpha is None:
alpha = np.ones(self.red.vertices.shape)
alpha = Vertex(alpha, self.red.subject, vmin=0, vmax=1)
if not isinstance(alpha, Vertex):
alpha = Vertex(alpha, self.red.subject)
rgb = np.array([self.red.data, self.green.data, self.blue.data])
mask = np.isnan(rgb).any(axis=0)
alpha._data[mask] = alpha.vmin
return alpha
@alpha.setter
def alpha(self, alpha):
self._alpha = alpha |
Done. I copied your suggestion as it was, with a small change: # alpha._data[mask] = alpha.vmin
alpha._data[..., mask] = alpha.vmin If alpha is set to |
Nevermind. |
Thanks for adding it to edit: Nevermind, creating a Volume/Vertex for alpha might be hard to merge into one code. We might as well duplicate the code. |
Yeah, I started doing that, but then realized that I also had to modify |
VertexRGB
VertexRGB
and VolumeRGB
When creating a new
VertexRGB
object with vertices containing NaNs, the values of those vertices would be cast to uint8 and transformed to 0. However, the alpha value would be set to 1, causing the Nan vertices to appear black. This PR fixes this issue by automatically setting a correct alpha of 0 for NaN values. It partially addresses #455.Minimal example:
Before:
After: