question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom control over segment colors

See original GitHub issue

Currently, users have extraordinarily flexible control over the rendering of image layers, thanks to custom fragment shaders. It would be great to have similar flexibility for segmentation layers. Is that a realistic request? Right now, I have to choose between custom rendering (with image layers) or the selection/deselection UI (segmentation layers). Is it possible to have both?

If full flexibility is not possible in the near term, then the ability to specify a single color for all segments in a layer would be appreciated. This feature request was discussed in a previous thread. In the past I’ve used the saturation trick, but now I want to create multiple layers with distinct uniform segment colors (for millions of segments).

More brainstorming… Perhaps a simple compromise solution is to support a color table. I have millions of segments, so I can’t list each one via a segmentColors mapping. But it would be possible for me to custom-tailor my segment IDs to target a color table of N colors (assuming color = table[segment % N]). Bonus points if the color table can be defined by the user, which would also provide an implicit solution to the “single color” request above. But even a hard-coded color-table would still be useful (assuming it contains a reasonable variety of colors to choose from).

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jbmscommented, Nov 30, 2020

I am planning to implement this feature request when I have chance, hopefully soon.

Regarding the performance issue with uint64 image layers, though:

Neuroglancer has two ways to represent volumetric data in GPU memory: uncompressed (which supports all data types), and compressed_segmentation (which supports uint32 and uint64). If the data is originally in compressed_segmentation format, then Neuroglancer always just uses it directly without any transcoding. If the data is in any other format (e.g. raw, jpeg, compressed via an n5 compression method), Neuroglancer first decodes it to uncompressed, then in certain cases may re-encode as compressed_segmentation. Currently, re-encoding to compressed_segmentation only happens when using a segmentation layer, because compressed_segmentation is only effective if the same ids are repeated within local blocks. The assumption is that the data for an image layer is likely to be continuous and compressed_segmentation won’t be helpful.

Uncompressed uint64 data takes up a lot of memory, which means only a small region can fit in the cache. That may be the reason for the bad performance that you are observing.

If you export your uint64 label volumes as neuroglancer precomputed with compressed_segmentation encoding, that should be a lot faster since it will greatly reduce the memory required, and will also avoid the need to transcode the data as it is downloaded.

0reactions
jbmscommented, Feb 10, 2022

I would be happy to include this change. You would add something like:

builder.addUniform('highp uint', 'uSegmentId', 2);

here:

https://github.com/google/neuroglancer/blob/60c8c036d202cecc7bc09e18b07dc86757bef200/src/neuroglancer/skeleton/frontend.ts#L75

And then make sure to set that uniform when running the shader here (will need to pass in the segment id):

https://github.com/google/neuroglancer/blob/60c8c036d202cecc7bc09e18b07dc86757bef200/src/neuroglancer/skeleton/frontend.ts#L243

Then add some code to be included elsewhere in the shaders to convert uSegmentId into a uint64_t (which is a custom type defined by neuroglancer in shader_lib.ts).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customize segment button colors in the segmented control area
Customize segment button colors in the segmented control area · Access the View Template form. · In the View Template form, select the...
Read more >
Customizing the colors of a UISegmentedControl
UISegmentedControl has a tintColor property -- this allows you to change what color the control is, but not the general "style" (the rounded ......
Read more >
Custom segmented control in SwiftUI • ishtiz.com
I am using a foreach to loop through all options. Inside the ZStack, first rectangle is used for background color and second rectangle...
Read more >
Segmented controls - Human Interface Guidelines - Design
Within a segmented control, all segments are usually equal in width. Like buttons, segments can contain text or images. Segments can also have...
Read more >
Customize Segment Colors - Telerik UI for Xamarin
There are different colors applied to the segments in their different states. The control exposes the following properties: SegmentBackgroundColor: This is the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found