Skip to content
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

Add functions to get and set segment colors to the frontend API #6853

Merged
merged 3 commits into from
Feb 22, 2023

Conversation

daniel-wer
Copy link
Member

@daniel-wer daniel-wer commented Feb 15, 2023

Also, fix a bug in the segment color picker where the color that was preselected after opening the picker was wrong.
The hexToRgb utils function returned the color in [0, 255], but later it was assumed to be in [0, 1] and was scaled to 255 again. Because hexToRgb was only used for the segment color picker, I changed its return value to be in [0, 1] which we usually use in other related functions.

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • Create an annotation on a dataset with a segmentation layer. Select a segment and compute an ad-hoc mesh for it.
  • Change its color using the segments list.
    • Reopen the color picker. The preselected color should be correct.
  • Use webknossos.apiReady(3).then(async (api) => {console.log(api.data.getSegmentColor(<YOUR_SEGMENT_ID>))}) to get the color of the segment via the api -> The color should be the previously selected color in RGB in the interval [0, 1]
  • Use webknossos.apiReady(3).then(async (api) => {console.log(api.data.setSegmentColor(<YOUR_SEGMENT_ID>, [0, 1, 1]))}) to set the color of the segment (and mesh) -> The segment and mesh should change their color to turquoise

Issues:


(Please delete unneeded items, merge only when none are left open)

Also, fix a bug in the segment color picker where the color that
was preselected after opening the picker was wrong.
@daniel-wer daniel-wer self-assigned this Feb 15, 2023
id: number,
customColors?: Array<number> | null | undefined,
customColors?: Array<Vector3> | null | undefined,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the callers uses this parameter which is why I changed its format. I think it's purely there to "mirror" the functionality of the convertCellIdToRGB shader function as pointed out in the comment above. Since the customColors are in RGB format in the shader as well, I figured it's fine to mirror that, here.

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100/100 👍

@bulldozer-boy bulldozer-boy bot merged commit 8ac842c into master Feb 22, 2023
@bulldozer-boy bulldozer-boy bot deleted the segment-color-api-functions branch February 22, 2023 13:03
hotzenklotz added a commit that referenced this pull request Feb 22, 2023
…bar-menu

* 'master' of github.com:scalableminds/webknossos:
  Add functions to get and set segment colors to the frontend API (#6853)
  Ensure that segments are added to segment list when using quick select... (#6867)
hotzenklotz added a commit that referenced this pull request Mar 6, 2023
…come_header_UI

* 'master' of github.com:scalableminds/webknossos: (34 commits)
  Slim down view mode dropdown by using icons (#6900)
  Logging on password reset/change (#6901)
  When merging volume tracings, also merge segment lists (#6882)
  avoid spinner when switching tabs in dashboard (#6894)
  Upgrade Antd to v4.24 (#6865)
  Support n5 end-chunks with chunksize differing from metadata chunksize (#6890)
  Implement http range requests for HttpsSeekableByteChannel (#6869)
  new GH action for adding issues to project board
  Fix links in Changelog (#6881)
  adds dedicated explore method for zarr datasets with a datasource-properties.json (#6879)
  Release 23.03.0 (#6880)
  Fix superUser being wrongly marked as organization owners (#6876)
  Followups for OME-TIFF export (#6874)
  Fix reload-precomputed-mesh functionality (#6875)
  Adds OME-TIFF export (#6838)
  Add evolutions 99,100 to migration guide (#6871)
  Add link to imprint and privacy to help menu (#6870)
  Annotation Locking Mechanism (#6819)
  Update deprecated antd <Menu> (#6860)
  Add functions to get and set segment colors to the frontend API (#6853)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants