Export annotations as vector paths / svgs

Hi, I was wondering if it would be possible to export the annotated areas on an image as vector paths / svgs?

to be more specific, I’m referring to the segments… I’d like to get the outline of the drawn segment as a vector instead of dealing with everything in raster form

Operating system: OS X

Slicer version: 4.11.0

I building a website in which I render segmentations I generated in 3D slicer, and want to manipulate them with html/css (for eg. change the color of a specific segment).
Is there any export format in 3D slicer that would allow me to convert segmentations (or label maps) into vector paths that I can save in an svg file? Or any other structured data format that specifies the points (x,y) that make up the outline for an individual segment?

There should be no reason to develop such things from scratch, but instead you can use a DICOM web viewer for this (and extend/customize/improve it as needed). You can push a DICOM segmentation object from Slicer directly to a DICOMweb server and use OHIF viewer to view the images and segmentations. You can also launch a locally installed Slicer from the web viewer, create segmentation, and upload the result back to the server. You can use a very lightweight DICOM server, such as https://github.com/dcmjs-org/dicomweb-server, or for demo/test purposes the Kheops demo server.

I’ll create a demo video of this tomorrow, it works very nicely.

Thanks for the quick response. Looking into the links you shared. If I did want to do this anyway though, is there a way I might be able to export the coordinates of the paths in any structured data format?

In all modern segmentation software, 3D image segmentations are natively stored in binary labelmaps. Conversion of arbitrary labelmaps to smooth curves is inherently very fragile and may result in very large point sets and loss of details. If you really must reimplement a segmentation viewer then I would recommend to use the native binary labelmap representation (render it as an additional image layer). OHIF viewer is free, open-source, restriction-free software, so you can copy-paste its segmentation renderer into your code (of course I would not recommend doing it, but it is still less waste of time than redeveloping from scratch).

If you are just interested to see how you can generate smooth parallel contours from segmentations then you choose to visualize a segmentation’s closed surface representation in slice views (Segmentations module / Display / Advanced / Representation in 2D views -> Closed surface). See implementation here, using vtkPlaneCutter and vtkContourTriangulator. You can play with it and see what kind of quality problems and performance issues you will run into if you decided to store segmentations as parallel contours. Another issue that we learnt from legacy DICOM RT structure set representations, is that it is practically impossible to reliably reconstruct a 3D surface from parallel contours. So, you would go to lots of unnecessary trouble if you decided to use parallel contours for representing segmentations.