Code Monkey home page Code Monkey logo

Comments (3)

Akalivivy avatar Akalivivy commented on June 1, 2024 3

@djhoese Thank you for your answer. In meshvisual, it is indeed necessary to use optimization logic similar to that already present in ImageVisual to avoid the repeated creation of function object。If I have time, I would be happy to try and contribute to the code.

from vispy.

djhoese avatar djhoese commented on June 1, 2024

I agree. I think you're correct. I think this visual has not been optimized for this color logic which is surprising. I think @brisvag or maybe @tlambert03 did some work on the ImageVisual (

if self._need_colortransform_update:
prg = view.view_program
self.shared_program.frag['color_transform'] = self._build_color_transform()
self._need_colortransform_update = False
prg['texture2D_LUT'] = self.cmap.texture_lut()
) to optimize when and how the color transform function is created and updated. I think the MeshVisual may need a similar update and extra care added to it.

I think the original intention of the code or the idea behind it was that if you change the data then the colors array will also change (I'm not sure this is always necessary either). Since colors is an input to the color transform creation it would make sense to assume that the color transform also always has to be updated. But you're right, when you look at it it clearly doesn't.

First, it would need to be updated so the function objects only get created once. I don't think there is a reason this shouldn't work. Next, it should be updated so if we already have a color transform but we are updating only the color limits, then just update the color limits. I think mocking this after the ImageVisual wouldn't be a terrible idea. This would mean something like a self._update_color_transform = True and maybe a self._update_color_limits = True. You can see in the ImageVisual that it even cheats and sets the color limits early if the color transform doesn't need to be updated:

def _update_colortransform_clim(self):
if self._need_colortransform_update:
# we are going to rebuild anyway so just do it later
return
try:
norm_clims = self._texture.clim_normalized
except RuntimeError:
return
else:
# shortcut so we don't have to rebuild the whole color transform
self.shared_program.frag['color_transform'][1]['clim'] = norm_clims

from vispy.

brisvag avatar brisvag commented on June 1, 2024

Yup, agree with the above! I don't have the bandwidth now to do with this, but if anyone wants to open a PR with this I'd be happy to review.

from vispy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.