Exporting ROI coordinates from KNIME

Dear KNIMExperts,

I was wondering whether in KNIME we have the possibility to export ROI outlines after performing segmentation (as done with the Connected Component node in KNIME). Basically, I was thinking about two things:

  1. For each connected component, get the pixel coordinates of the outline describing the segmented object.
  2. Ideally, I would love to have those in a format that is comparable to the ROI manager objects in ImageJ. It would be great, if I could perform a segmentation in KNIME, save the obtained ROIs and then open them in Fiji.

I would be very happy about any kind of ideas how to tackle this…

Hi @Fritzee ,

One possible way to solve this would be to export a Label image (all pixels of an object have the same value) and to convert the label to ROIs in Fiji, using LaRoMe or LabelsToRoi

Using the blobs image a workflow like this would do the job in KNIME

The main issue here is that you’ll store “heavy” Label image compared to “light” roiset…

@imagejan @stelfrich do you have a better way ?



Hi @romainGuiet,

Thanks a lot for the quick answer. I wasn’t aware of LaRoME and LabelsToRoi, both look great!

However, as you also mention, I would like to avoid saving full images as I am working with 1000s of images, which is why I went for KNIME in the first place.
I guess what I am looking for is the KNIME equivalent of:

 for (i=0; i<x.length; i++)
     print("  ", i, x[i], y[i]);

I would then prefer exporting only the coordinates of the ROI’s outline, e.g. as additional column in my results table that I obtain in KNIME. I could then use the shapes described by the outline for further analysis in R etc.

Additionally, once I know how to extract ROI coordinates in KNIME (so far I can only extract centroid locations), also saving them in a format compatible with ImageJ would be great (i.e. additionally saving a .zip file for each image in the ROIset format). This would allow me to verify some of the segmentations later in Fiji.

I know that this is a bit off the classical KNIME path, but I was hoping that maybe some custom ImageJ2 magic (that I am unfortunately not familiar with) might do the trick here…


Wow, by going through this recent thread about the latest NEUBIAS seminar I just realized that @imagejan actually implemented exactly this a while ago already (see also this thread). So after installing the FMI KNIME node extension via Nodepit I can use the Get Polygon Points from 2D Binary Mask node to convert segment outlines to a list of coordinates.

Now, the only bonus would be to convert those to a Fiji roiSet, but for my case the above already helps a lot.
Thanks and amazing work @imagejan !

1 Like

I was just going to reply to this thread :wink:

Yes. The functionality is in the FMI KNIME Plugins, created from this repository:

There is FMI > Get Polygon Points from 2D Binary Mask which will output two Double[] array columns with the x and y coordinates of all contour points. You can split the double arrays into columns using this shared component:

The conversion to WKT contributed by @karbon_kreature is another possibility.

Indeed, this would be a great addition! If you want to get your hands dirty and implement it yourself, I’m happy to provide pointers :slight_smile:

Yes, getting into writing custom KNIME nodes is on my list since a while. I will definitely contact you once I am there. I also feel that making a generalized and simple tutorial for making custom KNIME nodes would be great, since this is a bit missing at the moment in my opinion…
I hope I’ll have time soon to give it a try! Thanks again!

1 Like