MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Colored ListDensityPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9355] Re: Colored ListDensityPlot
  • From: "Stephen P Luttrell" <luttrell at signal.dra.hmg.gb>
  • Date: Sat, 1 Nov 1997 03:33:41 -0500
  • Organization: Defence Evaluation and Research Agency
  • Sender: owner-wri-mathgroup at wolfram.com

> I am trying to manipulate image data which is described as pixel
> intensity data, with the intensities of various colors in separate
> files. It is easy to read the data in, reformatting it as an array, and
> display a black and white image of any given color using
> ListDensityPlot.
> 
> What I would like to do is to plot it as a false color (or even true
> color) image using something like ListDensityPlot. Ideally I could
> describe the image as an array of vectors {R,G,B} and then plot the
> result as a color image.
> 
> I would be grateful for any suggestions, or even a package, for doing
> this.

Here is an example which plots an {R,G,B} triplet of images as a
coloured image:

n=20;
R=Table[Random[],{n},{n}];
G=Table[Random[],{n},{n}];
B=Table[Random[],{n},{n}];
RGB=MapThread[RGBColor,{r,g,b},2];
Show[Graphics[RasterArray[RGB]],AspectRatio->1];

There are two main tricks used here:

1. MapThread[RGBColor,{r,g,b},2] wraps the {RGB} triple for each image
pixel in the function RGBColor, which is the appropriate graphics
directive for displaying coloured pixels in natural colour format.

2. Graphics[RasterArray[RGB]] then creates a rectangular array of cells
coloured according to the graphics directives in (1) above.

You get other colouring schemes if you use Hue, GrayLevel or CMYKColor
rather than RGBColor.


----------------------------------------------------------------------------
------------------------------------------ Stephen P Luttrell          
luttrell at signal.dra.hmg.gb
Adaptive Systems Theory                           01684-894046 (phone)
Room EX21, DERA                                    01684-894384 (fax)  

    
Malvern, Worcs, WR14 3PS, U.K.            
http://www.dra.hmg.gb/cis5pip/Welcome.html





  • Prev by Date: linking C-program with Mathematica
  • Next by Date: (Newbie) More confusion with integral of absolute vals
  • Previous by thread: Re: linking C-program with Mathematica
  • Next by thread: (Newbie) More confusion with integral of absolute vals