Repository navigation
Keep touching objects apart when an AI annotation's image is finer than its voxels - #141
Merged
Merged
Conversation
…an its voxels Accept shrank the model's mask to the write box's voxels by nearest neighbour and only then cut it into 4-connected objects. On voxels coarser than the image's pixels (8 nm pixels into 16 nm voxels) each voxel takes every second pixel, so the one-pixel black line the prompt asks for between touching objects could fall between the pixels taken, and the two objects were written as one id. mask_to_write_shape now labels the mask at the image's resolution and shrinks the object ids, numbered again in the box's raster order; labels_for_box takes those objects instead of a bool mask. The staging keeps the objects, and the preview's overlay and the mask fraction read them as > 0. The browser's maskToWriteShape and labelsForBox do the same, and the parity fixture gains a one-pixel line on coarser voxels. Where the image is as fine as the voxels or coarser, as for every browser-catalog model, the labels are what they were.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is part of the batch, #137. Merging #137 with a merge commit marks this PR merged too.
AI-annotate asks the model to leave a thin black line between objects that touch. On Accept, the mask was shrunk to the annotation voxels first and cut into objects after. When the image's pixels are finer than the voxels, each voxel takes only one pixel in every two, so the line could fall between the pixels taken and two objects were written as one id:
The mask is now cut into objects at the image's resolution, where the model drew the line, and then the object ids are shrunk onto the voxels. Two objects stay two ids even where no black voxel survives between them. The fix is in both the server and the browser.
Who sees a change
Code
pipeline.mask_to_write_shapenow returns the mask's objects on the write box (int32, 0 for background), numbered in the box's raster order.labels_for_boxtakes those objects instead of a bool mask.mask_write.npyholds the objects. The preview's overlay and the mask fraction read them as> 0.maskToWriteShapeandlabelsForBoxmirror the Python. The parity fixture gains a case with a one-pixel line on coarser voxels.Checks
tests/ai_annotate: 278 passed. The full vitest suite passes and the typecheck is clean.