google / neuroglancer

WebGL-based viewer for volumetric data
Apache License 2.0
1.09k stars 298 forks source link

Segmentation Object Border Display in 2D Overlays #397

Open unidesigner opened 2 years ago

unidesigner commented 2 years ago

For some use cases in connectomics, it is useful to only show the borders/edges of a segmentation object in the 2d overlays in order to see the cell interior in the raw data clearly, but without loosing the context which cell/segmentation object it is with its color.

I was wondering if there's a way to generate such an overlay directly using shader logic for standard segmentation layers (e.g. by changing the transparency value based on the segmentation value of the neighborhood pixels on-the-fly)?

jbms commented 2 years ago

Yes, it should be possible to do this at rendering time in the following way:

  1. Render the uint64 values that should be displayed at each screen position to a separate texture (just the raw uint64 values, not converted to colors)
  2. Render the borders between segments based on the texture produced by the first step.

Currently rendering is done in just a single step, where each chunk of data is rendered directly to its final color.

unidesigner commented 2 years ago

Thanks for your suggestion. It sounds like it would then be very flexible how to actually produce the borders in the second step.

I don't know how to get started with this, would you be able to point me to an example how this two step rendering could be implemented? Can this all be implemented in the shader logic, or would it need changes in the source code?

jbms commented 2 years ago

I don't have an example of how it would be implemented. It would certainly require changes to the javascript code, though.