Image Data and Classification with R

August 3, 2010

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


In this post i would like to demonstrate the ability of R to handle and classify image data with the help of ImageJ and Rserve bundled and implemented in Bio7. In general R is a very useful application for image analysis and plenty of “pure” R packages for image analysis are already available. But the combination of a scientific image analysis tool like ImageJ with R offers much more possibilities to edit and analyze images. With the correct image datatype (raw, integer, double) R  is also able to handle and process images >2000*2000 pixels (in combination with java!).
For my own curiosity i tried to find out the limits on a 32-bit and 64-bit OS with the image data present in the virtual maschine and after transfer (by means of Rserve) in R, too.

Hardware: AMD Turion 2.0 GHz Dual core, 3Gb RAM Windows Vista 32-bit
Java enabled memory:  1024Mb
Cluster Analysis (clara): Max 5000*5000*3(RGB) -> 6 centers: 70sec., 12 centers: 100s (byte transfer!).
Transferred 7 Landsat images 7457*6991 (byte transfer) and created a new image from the sum of the 7 images (integer conversion! with a triggering of the garbage collector).
Transferred 8000*8000 image as integer data to R in one shot.
Transferred and returned a 16000*16000 image as byte data (grayscale) to R and ImageJ in one shot.

And with 64-bit (with a personal OSX port of Bio7).
Mac OSX 10.6, 2.93 GHz, 4GB RAM
Java enabled memory:  2512Mb
Cluster Analysis (clara) with R: Max 7000*6157*3(RGB) -> 6 centers: 168sec. (byte transfer!).

R with ImageJ can be used perfectly to classify images. Two examples are shown below. The first example uses the clara algorithm which is generally more appropriate for images >2000*2000.

Example 1: Unsupervised classification with the Bio7 interface (clara).

Example 2: Supervised classification (rpart) with the Bio7 interface.

This examples also demonstrate the general use of R for image analysis. Some more examples of image analysis with R, ImageJ and the Bio7 interface can be found here:

Transfer images from and to R with ImageJ in Bio7 1.3

Analyse videos with ImageJ and R

Transfer selected pixels of all opened images

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: Data science, Big Data, R jobs, 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.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)