Plots in R and the ImageJ visualization

April 1, 2010

(This article was first published on » R, and kindly contributed to R-bloggers)

If you plot data in R and you would like to display the same data in the ImageJ view it is necessary to transfer the data matrix to ImageJ. The first thing which can be noticed is that the image data is displayed rotated because of the Bio7 approach to transfer data forth and back in the following way: imagedata(x,y) whereas (x0,y0) can be found in the upper left corner (Java coordinates in images!). In R values in a matrix are referenced with matrix(rows, columns) thats why images plotted with R and images (matrix data) displayed in ImageJ are different oriented.

Plot created with R using a spatstat (spatial analysis package) example and displayed in ImageJ

Pure R matrix data transferred as Floats, coloured with a LUT (LookUpTable) and displayed in ImageJ (Scalebar could be added, too).

If you would like to get the same view in ImageJ as the R plot simply transform the image (for the spatstat example rotate the image 90° in the left direction; for an image plot view like R flip the image vertically).

Of course another possibility to get the same result would be to adjust the coordinate system in the R plot. But this example illustrates the differences between the R coordinates and the ImageJ (Java) coordinates.

To leave a comment for the author, please follow the link and comment on their blog: » R. offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.