In R, I have a matrix that equals an image, where each cell is 0 if it is background and >0 if it is a ROI. Each ROI has its distinct number, so if it spans several matrix cells all these cells will have the same number. I want to generate ROI files from this that can be read by ImageJ.
example:
mx <- matrix(data=c(1,1,0,0,0,1,0,2,2,2,0,0,2,2,0,0,0,0,0,0,3,3,0,0,0), ncol=5, nrow=5)
# now some function to save the first, second and third ROI, each as a separate file
The EBImage package is what I use to get this data from my images, but it doesn't provide functions to write ROIs.
EDIT: The ROI names have to be exactly like they are in the matrix. One way to achieve this would be a labeled image (if someone knows how to generate this, please let me know) or even better to directly export the ROIs (more flexible).