Here is another example which shows the problem.
PRO my_color
DEVICE,decomposed=0
WINDOW,1,xs=300,ys=300,xpos=0,ypos=300,title='MASTER'
z=DIST(300)
r0=MAKE_ARRAY(256,/index,/BYTE)
g0=MAKE_ARRAY(256,/index,/BYTE)-128b
b0=128b-MAKE_ARRAY(256,/index,/BYTE)
TVLCT,r0,g0,b0
TV,z
TVLCT,r,g,b,/get
PRINT,'Difference between set and get'
print,'max diff.:','min diff.:'
PRINT,'red:',MAX(r0-r,MIN=m),m
PRINT,'green',MAX(g0-g,MIN=m),m
PRINT,'blue',MAX(b0-b,MIN=m),m
col_def=BYTE(STRING(r,format='(i3)')+$
STRING(g,format='(i3)')+$
STRING(b,format='(i3)'))
ix=WHERE(col_def EQ 32b)
col_def[ix]=BYTE('0')
col_def=STRING(col_def)
img=TVRD(true=1)
WINDOW,2,xs=300,ys=300,xpos=300,ypos=300,title='COPY'
TV,img,/true
col_img=BYTE(STRING(img[0,*,*],format='(I3)')+$
STRING(img[1,*,*],format='(I3)')+$
STRING(img[2,*,*],format='(I3)'))
ix=WHERE(col_img EQ 32b)
col_img[ix]=BYTE('0')
col_img=STRING(col_img)
new_img=MAKE_ARRAY(300,300,/BYTE)
n_col_img=SIZE(col_img,/N_ELEMENTS)
FOR i=0L,n_col_img-1 DO BEGIN
ix=WHERE(col_def EQ col_img[i],count_ix)
IF count_ix GT 0 THEN BEGIN
new_img[i]=ix[0]
ENDIF
ENDFOR
re=col_img[uniq(col_img,SORT(col_img))]
HELP,re
WINDOW,3,xs=300,ys=300,xpos=600,ypos=300,title='RESULT'
TV,new_img
PRINT,'my defined color tripled'
PRINT,TRANSPOSE(col_def[sort(col_def)])
PRINT,'============================'
PRINT,'true color color tripled'
PRINT,TRANSPOSE(re)
PRINT,'============================'
PRINT,'many colors aren''t defined, but still there!!'
PRINT,'result shows only colors which are defined'
END
--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
|