help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Anybody have a prgram to write a .bmp file?


From: Paul Kienzle
Subject: Re: Anybody have a prgram to write a .bmp file?
Date: Mon, 5 Feb 2007 20:17:55 -0500

On Jan 30, 2007, at 10:01 PM, Robert A. Macy wrote:

Thanks for pointing that function out.  I did a bmp search
all through the octave manual and never found that
function, or any reference to it.

However, it has the same flaw that all the image functions
are doing:
r=ones(256,1)*(0:255)/255;
g=.5*ones(256,256);b=.5*ones(256,256);
[X,map]=rgb2ind(r,g,b);
bmpwrite(X,map,"Xtest.bmp");
when opened the square is not gradually changing color as
expected, but a solid green square.

Same thing this function did:
imshow(r,g,b);
maybe the problem is in that map routine?

I've hardcoded 256 colours in the colourmap, so you can't
use indexed colours with large maps.

The simplest fix is to detect whether the colourmap is
larger then 65536 (in which case, just store the truecolour
image from looking up the colours in the colourmap), or
larger then 256 (in which case, pixel size is 16, and
output data is of type 'ushort' rather than 'uchar').

The next simplest is to give rgb2ind a colourmap argument,
and look up the closest matching colour in the colourmap
to the colour in the image.  This can be improved by
comparing in a perceptual scale rather than rgb.

Someone taking an image signal processing course might
enjoy implementing a version of rgb2ind which accepts
a colourmap length and using a perceptual-based map,
chooses the set of colours which minimizes the
quantization error.

- Paul



reply via email to

[Prev in Thread] Current Thread [Next in Thread]