Re: [R] about image() function in R and colors

From: Tuszynski, Jaroslaw W. <JAROSLAW.W.TUSZYNSKI_at_saic.com>
Date: Thu 07 Jul 2005 - 22:22:27 EST


I do not know the solution to your problem, but I had the similar problems with image() function and most of derived functions. It seems that 'image' function was really not meant for displaying image data, instead it was designed to display matrices in the image format. Matlab had the same problem and ended up creating 2 functions: 'image' (similar to R's 'image') and 'imshow' (designed for displaying image data).

There are three major processing steps in the 'image' that are hard to control or reverse:
1) scaling of the data intensities ( problem explained by Javier). Scaling is not much of a problem if continuous palette of colors is used , or to quote
"?image" when "'col' is a list of colors such as that generated by 'rainbow', 'heat.colors', 'topo.colors', 'terrain.colors' or similar functions". However scaling causes problems in case of discontinuous color-maps (palettes).
2) scaling of the data dimensions so it fits in default size window instead of scaling of the window to fit the data. This results in image with non-square pixels. There might be a way to force 'image' not to scale dimensions, I just did not spend much time looking for it yet. 3) Flipping of the image. As "?image" shows one needs to "transpose and flip matrix horizontally" or perform "image(t(volcano)[ncol(volcano):1,])" for the image data to be visualized in proper orientation.

All those steps make sense in case of visualizing 2D data, but they are a hindrance in case of visualizing images.

Jarek

====================================================\=======

 Jarek Tuszynski, PhD.                           o / \ 
 Science Applications International Corporation  <\__,|  
 (703) 676-4192                                   ">   \
 Jaroslaw.W.Tuszynski@saic.com                     `    \

 

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of javier garcia Sent: Thursday, July 07, 2005 7:23 AM
To: R-Help
Cc: statsgrass@grass.itc.it
Subject: [R] about image() function in R and colors

Hi!

I've got a map in R imported from a GIS (GRASS) as a vector of factors. So I've got 20 different levels in the map and I've created a vector of custom colors of exactly 20 colors in lenght. I'm trying to use image() (really plot.grassmeta() that call image()) to plot the map with those colors but it doesnt work and the colors are changed.

I would like that all points belonging to level1 are color 1 , and so on...

Please could you tell me if this procedure is not correct?

Best regards,

Javier

--
A. Javier Garcia
Water and Soil conservation department
CEBAS-CSIC
Campus Universitario Espinardo
PO BOX 164
30100 Murcia (SPAIN)
Phone: +34 968 39 62 57
Fax: +34 968 39 62 13
email: rn001@cebas.csic.es


______________________________________________
R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________
R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Jul 07 22:26:22 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:19 EST