Create binary images or labels from x,y coordinates

Hello,
I have the x,y coordinates of a certain structure/outline and would like to convert them into a binary image or label. At present we are doing this with R view and momocs package, but is there perhaps a way do this directly in KNIME.
Thanks in advance
Stefan

You can create a one-pixel BitType image, set the offsets according to the coordinates, and use the Compose Labeling (or Compose Image for the binary image) aggregation function (e.g. in the GroupBy or Pivoting nodes) to generate your labeling.

The following workflow illustrates this:

Create labeling from coordinates.knwf (28.0 KB)

3 Likes

Works perfectly (…although I do not quite understand what each node is doing). I embedded your suggestion into one of my workflow. In my case the coordinates describe a contour. By filling the space inside t labehe countour labels I was able to create one defined label to overlay on an image. I used this to compare manual feature annotations with deep learning annotations.
Thanks a lot for the quick response and tailored solution.
stefan

Dear imagejan,
is there also a chance to do the opposite? I now have an outline label and would like to convert this into coordinates. I could not find an appropriate possibility in feature extraction or calculation for labels.
Thanks in advance, stefan

For a similar requirement, I coded up this little IJ2 command, wrapping around the Contour op that returns a Polygon2D:

It is available as a KNIME node via the FMI KNIME Plugins update site.

This node takes the binary mask (2D) as input (not the outline) and returns all coordinates of the contour in two Double vector cells in the output table.

If you have your contour label already, you might want to iterate over the pixels of your label image directly. I don’t know if a node that does this exists anywhere, but it should be possible to script something up (either using the Java Snippet node, or making an IJ2 plugin as above) that suits your specific task.

3 Likes

Thanks a lot again, works perfect and since my label was generated from a binary image (or could be converted into binary images) I could apply the imagJ2 FMI node directly to the binary image.
Stefan

2 Likes