Skip to content

Images Import and Analysis

2 messages · Shawn Way, Henrik Bengtsson

#
I'm starting a time study on an area.  To determine if an individual has
entered the area, we are having timed photographs taken of the area.  What I
want to do is import the image files (either one at a time or
simultaneously), convert it to a density image, take the density at multiple
points in the image and determine if they are over an area average
(indicating someone or something is in that area).

Any ideas on how to get started (importing the images) in R? (programming
tool of choice)


Shawn Way
Engineering Manager
Tanox, Inc.
#
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