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

Re: Function BYTSCL



Steffen Kernchen (steffen.kernchen@student.uni-magdeburg.de) writes:
 
> Im 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....  :(

Alright, enough time has passed that Seffen has
probably passed or failed the final. Here is
my take on what BYTSCL does:

   FUNCTION Daves_Bytscl, array, Top=maxVal
   minVal = 0.
   IF N_Elements(maxVal) EQ 0 THEN maxVal = 255. ELSE maxVal = Float(maxVal)
   minVec = Min(array, Max=maxVec)
   sf = [((minVal * maxVec)-(maxVal * minVec)) / $
      (maxVec - minVec), (maxVal - minVal) / (maxVec - minVec)]
   RETURN, Byte(array*sf[1] + sf[0])
   END

To test it:

   IDL> array = Dist(150, 150)
   IDL> Window, XSize=450, YSize=150
   IDL> TV, array, 0
   IDL> TV, Daves_BytScl(array), 1
   IDL> TV, BytScl(array), 2

Cheers,

David

-- 
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