comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » convert read_bpm(file, R, G, B) to N x M x 3 array?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
convert read_bpm(file, R, G, B) to N x M x 3 array? [message #52777] Wed, 28 February 2007 09:24
Mike[2] is currently offline  Mike[2]
Messages: 99
Registered: December 2005
Member
Dear IDL gang,

If I read a color bitmap file like this:

bmp = READ_BMP(filename, R, G, B)

bmp is an N x M array with values that are indices of the
RGB arrays. For example, if bmp[5,10] = 3, the color
triple for that pixel is R[3], G[3], B[3]. To convert this to
an N x M x 3 for widget_button values, I've used a brute
force method:

bmp = read_bmp(filename, R, G, B)
s = size(bmp, /structure)
Nx = s.dimensions[0]
Ny = s.dimensions[1]
Nc = n_elements(R)
bmpR = bytarr(Nx, Ny)
bmpG = bytarr(Nx, Ny)
bmpB = bytarr(Nx, Ny)
for c = 0, Nc-1 do begin
i = where(bmp eq c, count)
if count gt 0 then begin
bmpR[i] = R[c]
bmpG[i] = G[c]
bmpB[i] = B[c]
endif
endfor
result = [[[bmpR]],[[bmpG]],[[bmpB]]]

It seems like there aught to be a more IDLy way do
this, but my juggling skills are failing me. Can
anyone suggest something that takes fewer lines of
code and is more consistent with The IDL Way?

Mike
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: mpeg creation problem
Next Topic: Re: Help with georeferencing using envi

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:36:47 PDT 2025

Total time taken to generate the page: 0.00512 seconds