[R-sig-Geo] clustering multi band images

Agustin Lobo Agustin.Lobo at ija.csic.es
Thu Jun 12 10:16:58 CEST 2008


If your images are large (and images typically are large because pixel size
has to be small compared to the extent of the image for the image to
be of acceptable quality for our vision system), I do not advice you
to get them into R for processing as R has severe memory limits
and many classification techniques are not precisely memory-efficient
(but see clara() in package cluster, actually read 
http://cran.r-project.org/web/views/Cluster.html).

I think that you should sample your image in a RS/GIS environment making 
sure you cover all
the radiometric space and import only a table pixels x bands into R, the 
actual nb. of pixels depending on your HW/SW configuration (but 10000 
would be a good start). Then use the numerous R classification tools to 
define the centroids and once you have them use again your RS/GIS 
program to actually assign each pixel in the image to a centroid 
according to a given rule (i.e. maximum likelihood). There might be
ways of writing an efficient assignation step within R itself also, I 
think that mclust package does it.

Another way of reducing the number of individuals to classify is 
performing a segmentation of the image first and then classify segments
instead of pixels (i.e.
# Lobo, A. 1997.  Image segmentation and discriminant analysis for the 
identification of land cover units in Ecology. IEEE Transactions on 
Geoscience and Remote Sensing, 35(5): 1- 11.
http://wija.ija.csic.es/gt/obster/ABSTRACTS/alobo_ieee97.pdf
perhaps other articles in 
http://wija.ija.csic.es/gt/obster/alobo_publis.html
might be of help)

In any case, note that img in your code should be converted into
a multivariate table pixels x bands for most classification
functions in R to work. Note that this fact makes obvious
that classification approaches to image processing do not make
use of the spatial information of the image, which is actually
a fundamental part of the information of any image.

Agus

Laura Poggio escribió:
> Dear list,
> I am trying to do some clustering on images. And I have two main problems:
> 
> 1) Clustering multiband images.
> I managed to be successful with a single band image, but when trying to
> apply to a 3 band I get the following warning message:
> In as.matrix.SpatialGridDataFrame(x) :
>   as.matrix.SpatialPixelsDataFrame uses first column;
>  pass subset or [] for other columns
> 
> 
> 2) saving clustering results as grid or image.
> I get a vector of clusters, but without both coordinates. How it is possible
> to transform it in a grid?
> 
> Here the code I use to read the image itself and to do the clustering:
> 
> library(rgdal)
> fld <- system.file("E:/data/IMG/fr/", package="rgdal")
> img <- readGDAL("123_rawR.tif")
> 
> kl <- kmeans(img, 5)
> 
> I am quite new to image processing, especially within R, and any help is
> greatly appreciated.
> 
> Thank you in advance
> 
> LP
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster




More information about the R-sig-Geo mailing list