-
Notifications
You must be signed in to change notification settings - Fork 13
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
Segmentation support in MoBIE BVV integration #1186
Comments
Hello @tischi, before we start digging. Are meshes loaded from the disk, where they are stored in some format (.stl)? |
The are created on the fly; they are not stored on disk. |
I slightly widened the title of the issue. For me it would also be interesting to check how a label mask image volume rendered with Glasbey LUT would look like; maximum projection would likely not be useful for label masks :-) |
Max proj no, but 'volumetric' should be ok. You just need to narrow down alpha value so everything is not transparent, but keep LUT wide. |
Is the alpha value adjustable? I would add the "normal" volume rendering as an option for the label masks to our branch such that we can test this, ok? Is there any way that I could test the Glasbey LUT from within my IntelliJ IDE? I think there was some trick to "link in" the Fiji folder, but I am not sure... |
It is adjustable, check the readme of There is a method to load IndexColorModel in the Converter setup, so you just need to read glabsbey values into it from disk (ImageJ LUT) or somewhere else. I can check it for you tomorrow. |
Thanks! That would be very helpful for the testing. |
I added code to display label mask images (aka segmentations) with BVV.
Is that expected? Could be that there is no support in SpimData... |
For cached multires it is only |
That would be great! Maybe cyclic would be best such that segments >65535 would still be rendered with different colours. |
Hello @tischi, I've made Glasbey LUT version and But main conclusion to me is that it seems like the multires image is not the best way to show segmentation results in 3D. The areas of fine, thin labels (with thickness below the current optimal/displayed resolution) are getting scrambled. Well, you can check the result and play with it yourself. |
Not sure if that information helps, maybe you know all of this already: The resolution pyramid for the labels was created using a nearest neighbour / sampling strategy, thus there should be no averaging of label values. In BDV, for the display one has to also use nearest neighbour interpolation (this can be configured, pressing the
Where does that factor 2 scaling happen in BVV? Could one configure it to do something else than averaging? For instance, taking a random sample?
Around 16000 I think
Yes, that's why so far in MoBIE I am using meshes for the display of segmentations. However, only (the few) segments that are actively selected by the user are rendered, because creating 16000 meshes on the fly would be too slow and I am not sure whether the 3D Image Viewer could handle it. But I don't think I ever really tried to benchmark/push this... Anyway, I think a good start would be to just reproducing my current 3D Viewer Mesh implementation with BVV.
Will do. |
Version 1 is better I think, one can get to Version 2 manually by "moving into the sample". |
If the pyramid was built using nearest neighbor, than I guess my hypothesis was wrong and it is not a culprit.
Not in a written form, no, it is unpublished.
Kind of, not really. It is making alpha blending of accumulated voxels along the ray in the shaders . It should stop when alpha value is more than 1. I am going investigate a bit.
Yeah, this is why I think that future |
Here is the "proper" mipmap loading upon the start on my laptop 20241111_mipmap_loading.mp4 |
The high-res looks perfect!
Yes, that's what I am also sort of doing:
☝️ I am ignoring here the |
What is your algorithm for assigning colors? So that BVV render is the same? |
mobie-viewer-fiji/src/main/java/org/embl/mobie/lib/bdv/view/AnnotationSliceView.java Line 109 in 5d95fac
But this is tricky, because this converts I guess you are currently working with the underlying label mask image, which is some unsigned integer type.... The mapping from the label-id in the label mask to the AnnotationType is done here: mobie-viewer-fiji/src/main/java/org/embl/mobie/lib/annotation/DefaultAnnotationAdapter.java Line 78 in 5d95fac
This is all quite involved. I am not sure you will be able to reverse-engineer all of this.... I think the easiest would be if we could just do
Because then we could simply add the sac that already outputs the correct colours. Assuming that the volume rendering operates directly on the |
I could also dig a bit into |
Yes, exactly.
Cached multires sources of |
I guess I can use Maybe from something like this? |
Ok, I got the colors for all annotations ~32000. Turns out, that my implementation of LUTs for BVV does not support a LUT with 32000 colors. It is a shame. |
Unfortunately, I don't think so, because the pixel type for which I have a converter is The logic is: I think I will have to look at the code myself in a bit more detail to see what could be done. I would suggest you push your latest additions into the bvvpg branch and wait until I get back to you. I will try this week. OK? |
Hi @ekatrukha, I added some code for converting the integer to an ARGBType that seems to work:
I think this is what you could use instead of (inside of) your current |
Thank youuuu. Now I am going to modify
and cut a new release of it. Once it is done, I will ping you. Just a detail behind the LUT story: so far I have been uploading sources LUTs as a linear 1D texture to GPU, but OpenGL has a limitation on the maximum size of this array. |
By the way, there is ...I am saying that because I assuming that the the conversion function will be called a lot during the rendering? |
Ah, I see, I will add that. |
OK, then we would need, at some point, to make |
Hello @tischi, I've updated max LUT size in BVV, now it should support up to 65536 values. That means it can show up to 65535 annotations. I guess this part is working now.
Let me know what you think and what are results of your tests. |
Hello @tischi with this LUT mapping. In principle, if we put all LUT alpha values to zero and some selected to 0.5 or 1.0, we can show only specific (for example, user selected) labels. 20241122_label_selection.mp4 |
Hi, yes, in fact I was thinking about the same for only showing selected segments. There is an Regarding the |
Hi @ekatrukha, the I could not find a place in the current code where this value would be used... I guess we could use it here and simply multiply the colour values with the alpha? Is that what you did / have in mind?
|
I tried like this but that seems to be too naive...does not produce that desired effect...
|
This also does not work, because the black non-selected segments seem to hide the other ones:
How did you achieve the above rendering that only the selected ones are visible? |
And, I got so excited about the non-selected segments colouring that I forgot to say 😅: It is of course awesome that you managed to tweak the BVV colouring such that we have now identical colours in BDV and BDV 🥳 . |
Hello @tischi, thank you! In the previous version of |
Made an issue for the ColoringListener here (I will work on this)(it is done). |
Hi @ekatrukha,
Starting an issue about showing meshes in BVV from MoBIE.
The current mesh code is all here:
https://github.com/mobie/mobie-viewer-fiji/tree/main/src/main/java/org/embl/mobie/lib/volume
Here is where a specific mesh is added to the current volume viewer:
mobie-viewer-fiji/src/main/java/org/embl/mobie/lib/volume/SegmentVolumeViewer.java
Line 283 in 5d95fac
I guess converting the current mesh into an imagej-mesh should not be a big deal. I can also help looking into this. Let me know if I should have a look!
The text was updated successfully, but these errors were encountered: