15

I would like to know how I would go about performing image analysis in R. My goal is to convert images into matrices (pixel-wise information), extract/quantify color, estimate the presence of shapes and compare images based on such metrics/patterns.

I am aware of relevant packages available in Python (suggestions relevant to Python are also welcome), but I am looking to accomplish these tasks in R.

Thank you for your feedback.

-Harsh

harshsinghal
  • 3,720
  • 8
  • 35
  • 32

5 Answers5

9

I'd start with EBImage - check out the vignette which demonstrates many of the tasks you mention.

hadley
  • 102,019
  • 32
  • 183
  • 245
8

Also check out the RASTER package on the R-Forge website:

http://r-forge.r-project.org/projects/raster/

It is not released to CRAN yet but it is an excellent package to import, analyse, extract, subset images and convert them to matrices). Spatial analysis is also possible.

You can download the package in R via:

install.packages("raster",repos="http://r-forge.r-project.org")
require(raster)

An example for R:

#from file
r <- raster(system.file("external/test.grd", package="raster"))
logo <- raster(system.file("external/rlogo.grd", package="raster"), values=TRUE) 
plot(logo)

Check out

?raster # and go to index of the package for an overview of all the options for image analysis.
Janvb
  • 1,290
  • 2
  • 16
  • 17
1

I believe the CRAN Task View on Medical Imaging should have something for you.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Thanks Dirk. I did look at the CRAN Task View, but was interested in knowing if there is more info/suggestions out there. – harshsinghal Oct 17 '10 at 20:35
  • 1
    Next time please make it more clear what you have considered and what you haven't -- in order to make the questions a tad more more focused. – Dirk Eddelbuettel Oct 17 '10 at 22:30
1

You may also be interested in Rpy which allows you to call R functions and use R packages from Python. This may allow you to have your cake (Python's imaging libraries) and eat it too (R's statistical analysis capabilities).

Sharpie
  • 17,323
  • 4
  • 44
  • 47
1

Try the rgdal package. You will be able to read (import) and write (export) GeoTiff image files from/to R.

Marcio Pupin Mello