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

Re: Function BYTSCL



Steffen Kernchen wrote:
> 
> Hi...
> 
> I´m just starting with IDL, so here is my first question:   ;-)
> 
> what function(s) can I use instead of BYTSCL?
> I have an array and I want to transform it to get a better contrast.
> But I should NOT use BYTSCL....  :(
> 
> bye
> 
> steffen

Of course you can do by hand something similar what bytscl does:

lets say your array is 'a'

minA=min(a,MAX=maxA)
a=a-minA
a=byte(float(a)/maxA*255)

(2nd line is 'optional')
but why you should not use bytarr?
Only point I can guess is that you have 8bit color and dont want to
use all colors?
In that case you have to find the different used colors in a:

h=histogram(a)
wN0=where(h ne 0,nW)

replace them:

for i=0,nW-1 do begin
  wI=where(a eq wN0[i])
  a[wI]=i
endfor

and modify the color table to assign the remaining values to colors
0..255:

TVLCT, R, G, B, /GET

R[0:nW-1]=byte(float(indgen(nW))/nW*255)
G[0:nW-1]=byte(float(indgen(nW))/nW*255)
B[0:nW-1]=byte(float(indgen(nW))/nW*255)

TVLCT, R, G, B

then you can plot your image.

Cheers,
marc