I think I have this mostly working. Adjusting channels now generates a custom konva filter which performs the rescaling operation on the raw data without the need to generate a data url and re-render the entire canvas from scratch.
Things that could use tidying up:
Greyscale images should have 1 slider for channels. Konva will always consider an image as RGB, but we can just make 1 slider that modifies all channels.
Switching images is less tidy than I'd like, sometimes it needs an extra re-render to fully update.
Some code duplication in ColorAdjustmentOptions between the reset button and the new image detection function.
Not sure how this will play with being able to modify what data is exposed to the tools (esp. disabling channels).
In my hands this approach is much faster, we seem to get an image update in <50ms even when using the Malaria example, and despite it rescaling all channels each time. I think it's promising.
I think I have this mostly working. Adjusting channels now generates a custom konva filter which performs the rescaling operation on the raw data without the need to generate a data url and re-render the entire canvas from scratch.
Things that could use tidying up:
In my hands this approach is much faster, we seem to get an image update in <50ms even when using the Malaria example, and despite it rescaling all channels each time. I think it's promising.