Daniel Peduzzi (peduzzi@mediaone.net) writes:
> The answer to this question has eluded me for some time now, and I'm wondering
> if some kind IDL guru could point me in the right direction.
>
> I have an 8-bit image (satellite data) which is being displayed on a 24-bit
> system. I'm currently using
>
> device, true_color=24, decomposed=0
>
> to do this, since I have the 8-bit image and corresponding r-g-b arrays.
>
> I also have some bitplane data, in another 8-bit 2D array, where each of
> the 8 bitplanes correspond to a cloud type. (For example, any pixel containing
> cirrus would have a bit set in plane number 5.)
>
> What I would like to do is to display any one of these 8 masks, in its own distinct
> color, over the original satellite data. I don't need to see the underlying imagery,
> so a solid color would be fine, but I do need the capability of toggling the mask on
> and off with reasonable speed (less than a second.)
>
> Is this possible using IDL?
Oh, *anything* is possible using IDL! :-)
Here is a quick and dirty program named CLOUD that does
what you ask for. I didn't spend more than 15 minutes on
it, I don't think. It does make use of some of my programs
that you can find on my web page:
http://www.dfanning.com/programs/loaddata.pro
http://www.dfanning.com/programs/tvimage.pro
If I were really going to do this, however, I don't think
I would do it this way. I would probably have a closer look
at the program IMAGE_BLEND and use the alpha blending function
available to object graphics images.
http://www.dfanning.com/programs/image_blend.pro
I think it would be nicer to see through the clouds. :-)
I'm sorry the cloud images aren't nicer, but I didn't
want my wife to catch me working on this. I was suppose
to be folding laundry. :-(
Cheers,
David
**************Cut Here ><))****************************
PRO Cloud_Off, event
Widget_Control, event.top, Get_UValue=info, /No_Copy
; Display image.
WSet, info.wid
TVImage, info.image
Widget_Control, event.top, Set_UValue=info, /No_Copy
END ;----------------------------------------------------------
PRO Cloud_Button_Events, event
Widget_Control, event.top, Get_UValue=info, /No_Copy
; Get button value, which is equivalent to bit.
Widget_Control, event.id, Get_Value=buttonValue
buttonValue = Fix(buttonValue)
; Copy of image.
image = info.image
; Make cloud bits a particular color.
image[Where((info.cloud AND 2^buttonValue) GT 0)] $
= 241 + buttonValue
; Display image.
WSet, info.wid
TVImage, image
Widget_Control, event.top, Set_UValue=info, /No_Copy
END ;-----------------------------------------------------------
PRO CLOUD
Device, Decomposed=0
; Create some fake cloud data.
image = Loaddata(18)
cloud = BytArr(400,400)
FOR j=0,7 DO BEGIN
index = Where(image GE 2^j AND image LT 2^(j+1))
cloud[index] = 2^j
ENDFOR
; Get an image.
image = LoadData(7)
image = Congrid(image, 400, 400)
image = BytScl(image, Top=240)
; Load some colors.
LoadCT, 0, NColors=241
LoadCT, 33, NColors=8, Bottom=241
; Create some widgets.
tlb = Widget_Base(Row=1)
butBaseID = Widget_Base(tlb, Column=1, $
Event_Pro='Cloud_Button_Events')
label = Widget_Label(butBaseID, Value=' Select Cloud Bit ')
FOR j=0,7 DO $
button = Widget_Button(butBaseID, Value=StrTrim(j))
button = Widget_Button(butBaseID, Value='Clouds OFF', $
Event_Pro='Cloud_Off')
drawID = Widget_Draw(tlb, XSize=500, YSize=500)
Widget_Control, tlb, /Realize
Widget_Control, drawID, Get_Value=wid
WSet, wid
TVImage, image
info = {wid:wid, image:image, cloud:cloud}
Widget_Control, tlb, Set_UValue=info, /No_Copy
XManager, 'cloud', tlb, /No_Block
END ;----------------------------------------------------------
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|