Skip to content
Prev 32122 / 398506 Next

Images Import and Analysis

Package 'pixmap' [ install.packages("pixmap") ] has support for "import,
export, plotting and other manipulations of bitmapped images". More
precisely, you can read and write Portable Anymap Images, i.e. ppm
(rgb), pgm (gray), pbm (monochrome). For tiff, png, jpg etc you first
have to convert your images to the above formats before importing them
into R. ImageMagick's (http://www.imagemagick.org/) command line
'convert' command available for many platforms is good for this. With
the right path settings, you can basically do this from within R by
using system(), e.g.

  system("convert foo.jpg foo.ppm")
  img <- read.pnm("foo.ppm")
  plot(img)

However, 'pixmap' do not contain much image analysis functions so those
you have to write yourself.

Henrik Bengtsson
Lund University