The function
read.ijroi() in
this R file allows you to read
ImageJ ROI files into
R. It's possible to read in polygons, ovals, rectangles and lines, though not all features of the ROI format are implemented. As a demo you might want to try
marking up an image with an ROI in ImageJ and then reading in the image and the ROI into R:
source("roiread.R")
im <- as.raster(readPNG("~/image.png"))
plot(NA, NA, xlim=c(0, ncol(im)), ylim=c(nrow(im), 0), asp=1)
rasterImage(im, 0, nrow(im), ncol(im), 0)
r <- read.roi("~/image.roi")
plot(r, TRUE, col="cyan")
Once the code is a bit neater, I'm intending to find a home in an R package for this code - any suggestions of which package it should belong to would be welcome.