New segment for every colour

Hi there

I have a 16bit raw image stack of a segmentation ‘so it doesn’t have a crazy amount of colors in the image itself’. Is there a way in slicer to generate a segment for every existing color in the image using the segment editor? Hopefully slicer can handle a fairly large number of segments. Sorry if it sounds confusing

Any help would be appreciated

It sounds like you have a labelmap volume (you have discrete values in the volume, each value corresponds to a certain structure). You can follow these instructions to load this image and import to segmentation:

1 Like

Thank you so much for the quick reply, I won’t be able to try this until tomorrow. Just one question in regards to your answer, will I be able to re-sample while using the method in the other thread

Yes, you can crop and resample labelmap volumes the same way as scalar volumes, just make sure to use nearest neighbor interpolator if you want to preserve original voxel values at the boundaries.

1 Like

After trying this method with about 1/8th of the dataset, which is a 700mb nrrd file. It did work but took a very long time to compute and with the labels it uses about 98percent of my 16gigs of ram. I will try some other software packages but I feel like they will also be too resource heavy

Currently, you can can probably edit up to about 30-50 segments at a time and move out other segments to another segmentation or labelmap. We are improving the segment editor to better support some neurosegmentation workflows which may involve a few hundred segments.

What kind of data do you work with? How many segments do you have? What is the volume size?

It is a micro-ct of a mammal and has I estimate it will have north of 200 segments if I was to load in the full dataset. Unfortunately I am interested in preserving as much detail as possible so reducing the quality isn’t really an option. Looking forward to future updates to the segment editor.

What is the volume size?

Sorry I am not sure how to check that. However today I did try to do the same with the 1/8th data set using both Itk-snap and Mimics. I wasn’t able to find where to import a labelmap for mimics ‘it probably doesn’t have this functionality’, but with itk-snap I just clicked open segmentation and opened the nrrd and it imported and created the hundred or so masks within a few seconds, and also had almost no effect on the memory usage (to compare, slicer took about 5 minutes to generate the segments and used 98percent ram once they were imported). Itk also had a really nice export all segments into single vtk scene which didn’t create a file size too large. However the downside with Itk-snap is the mesh it created was not as nice and had holes that were larger than the ones in slicer. Since I am interested in mesh quality, I am leaning more towards slicer, however memory usage and calculation speed is an issue with lots of labels

If you keep your mouse cursor above the CT in the Data module, the tooltip will contain the image size. You can also check these (and more) details in the Volumes module.

ITK-SNAP uses the legacy labelmap volume concept, whereas Slicer uses the more advanced PolySeg segmentations concept that allows overlapping segments, automatic conversions, etc. (see this paper).

Yes, segment editor is much more capable than ITK-snap but currently it uses an separate labelmap for each segment, which may require significantly more memory, especially when you have many segments.

We’ll make editing of hundreds of segments more efficient within a couple of months (allow sharing memory between segments, add filtering/searching in the segment list, etc.). Until then, you can edit up to 30-50 segments at a time and merge them into a single labelmap at the end (or upgrade your computer, mainly by add a lot of RAM).

Sorry to revive this much later, but I hope someone can help: I am having a stack of png-images with 5 different colors in them. I’d like to segment this by color, mainly select the white background and remove it to 3D render the rest.

But when I try to load the image stack as a label map, I just get an error: “Error: Loading slices/slice_000.png - load failed.”

Any hints on how to do this? Sorry, but absolute newbie with Slicer3D here.

Do you have 5 discrete colors in your images (e.g., you painted those using some drawing tools) or you have 5 somewhat similar (not exactly the same) colors (e.g., from scanning images)?

They are exact identical: results from a simulation and then assigned 5 specific RGB values. One is white (255,255,255) and should disappear, the rest should be visible segments.

OK, it means that your data is actually a labelmap volume, not a color image. Therefore, it is better to save it as a scalar (single-channel) image. Use 0 for background and 1, 2, 3, 4, 5 for the segments. You can save it as png, but it would be much better to save the entire array as a single file, in nrrd format. You can find nrrd file writer for all programming languages, but if you are not sure which one to use then let us know.

You can load the nrrd file directly as segmentation, by choosing “Segmentation” in the “Description” column in the “Add data” window. You can make the file open as segmentation by default if you use .seg.nrrd as file extension.

Thanks for the explanation. Unfortunately the PNGs are the data I need to work with. Sounds like I need to transform them to that nrrd format first before I can visualize them.