From SVG to ROIs

Tags: #<Tag:0x00007fd542d62ad0> #<Tag:0x00007fd542d62990> #<Tag:0x00007fd542d62850>


Hi all,

We recently got a project where we would like to import ROIs into ImageJ from an svg file containing closed paths.
First I though it would be simple to just parse the svg and append each segment to make a polygon ROI, however there are also cubic bezier curves involved.
Most of what I found on the net involves creating svg paths, but not going from SVG to something else, like a sampled point ROI.

So before I embark on a quest to make a semi-generic SVG to ImageJ ROI reader, I would like to know if anyone has experimented with this.

All the best


Hi @oburri,
Well I do not know too much, put the ImageJ PolygonRoi class can do splines.

Could that help?


I also do not know much, but I want to applaud you for asking on the forum before investing lots of developer time. It makes me really happy when developers make a best effort to reuse existing tools.

Fiji does ship the batik library, so maybe that helps. There is also an SVG Reader plugin as part of the old IO suite, but from the source, it won’t meet your needs. Maybe it’s a useful starting point though?


Hi all,

I am having a look at it, thanks but from reading the code over at

It kind of seems that it supports splines fitting internally but you cannot initialize it with splines.
The other thing is that SVG uses cubic or quadratic bezier curves and arcs…

So far, for my approach I am going to go rather simple to get started

Have a function to convert SVG paths (open or closed) into ROIs (Polygons or polylines).
Something that can interpret the types of commands from into sampled ImageJ PolygonRois

Finally, the ROIs will inherit the stroke color of the SVG unless it’s black, wherefore it will default to the stored preference color. Names will also be assigned if an ID tag exists.
I have seen lots of tools for converting B-Splines to Bezier Curves but not the other way, so for now I am going to leave that behind. The bezier curves will simply be sampled an arbitrary number of times.

Lastly, @ctrueden: is there something shipped with Fiji to parse XML files? Thanks for everyone’s support!



Yes, see this related post:


I have a similar problem to solve. Any news on this topic?