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

Re: Write_bmp procedure changes RGB color order to BGR for input image




sandeep.dalal@philips.com (Sandeep Dalal) writes:
...
> 
> To my surprise, I discovered that using the RGB keyword in the IDL
> procedure "write_bmp" actually changes the color order of the supplied
> input image from RGB to BGR color order. This is non-intuitive. I
> would have expected that the keyword was only to indicate that the
> array is being supplied in the standard RGB color order. When IDL
> writes the file with the RGB keyword set, it should swap the red and
> blue buffers of the original image being written to the BMP file, but
> not swap them in the original image.
> 
> For e.g.
> IDL> img = read_image(some_true_color_image_file)  ; in RGB color order
> IDL> tv, img, /true                                ; looks good
> IDL> write_bmp, filename.bmp, img, /rgb 
> IDL> tv, img, /true                                ; no good (:-(!

This is a classic error in IDL programming: a procedure modifying
parameters that it shouldn't.  A smart procedure takes great care not
to modify its arguments.

The disappointment is that this lame code comes from RSI.

By the way this doesn't appear in IDL 5.0 or 5.2, so it's a new
addition.

Craig

-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------