Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!convex!texsun!cronkite!exodus!peregrine!falk From: falk@peregrine.Sun.COM (Ed Falk) Newsgroups: comp.graphics Subject: Re: 24 bit SUN Rasterfile and Quaternions Keywords: HELP!!!!! Message-ID: <16046@exodus.Eng.Sun.COM> Date: 1 Jul 91 00:22:44 GMT References: <81735@eerie.acsu.Buffalo.EDU> Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 54 In article <81735@eerie.acsu.Buffalo.EDU> marsha@acsu.buffalo.edu (john c marsha) writes: > > >1) With the ras_depth = 8, there are 256 color to choose from. Does > anyone have a good algorithim for creating a 256 color colormap > from the calculated intensites? There are two issues here; choosing a good colormap to use, and converting rgb colors to use that colormap. The best all-around algorithm is Heckbert's median-cut algorithm referenced in the FAQ list. This algorithm requires that the entire image be available in RGB format before you start (i.e. it doesn't convert on the fly) The next best algorithm uses a pre-determined colormap (called a "color cube" since it represents a 3-d cube in rgb space) and is usually combined with "dithering" to smooth out the errors. These algorithms are both referenced in the FAQ list. Software to convert 24-bit images to 8-bit images is available in the PBM, FBM and Utah Raster Toolkit packages. >2) Is it possible for a SUN rasterfile to support 24 or higher bit depth? > With 24 Bits: > One could reference 16,777,215 colors. > (this would mean a 200x200 image would have a length of > 120,000 bytes and the colormap length would be 360,000 bytes) Yes and no. 24-bit and 32-bit formats exist (just set ras_depth to 24 or 32). These are "direct color" images. The pixels are not 24-bit indices into gigantic colormaps. Typically, you don't have a colormap at all and the 24-bit values are 8 bits each of rgb. You can provide a colormap if you like, but the way it works is that the 'r' value of a pixel is an index into the red map and so on with 'g' and 'b'. >3) Isn't there a way to just say "here is the Red, Green and Blue > intensites (relative to some scale i.e. 0 dark 255 bright) without > using an actual image map? (ras_length = 0 but the maplength would > be depth * width * height * 3 (one for each color). > r[0],b[0],g[0] would actually be the pixel 0,0, not the > "reference" to the color) Yes, see above. What you want to do is set the maplength to 0 and then raslength is width * height * 3. [one note to people using sun rasterfiles: each scanline in an image is rounded up to an even number of bytes. If your image has an even width, this doesn't have any effect. If your image has an odd width, then each scanline is one byte wider. For example for 24-bit images raslength = (width*3+1)*height.] -ed falk, sun microsystems sun!falk, falk@sun.com In the future, somebody will quote Andy Warhol every 15 minutes.