[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: changing contrast and brightness on the fly
Perhaps no one has said this because it's obvious, but just in case:
Level and width (as described by whatshisname above) is a more natural
way to write your code. If people want brightness and contrast, the
connections are as follows:
Higher contrast means a more narrow window
Brighter image means a lower level
I don't know what the convention is for units of contrast and brightness, but
for example:
a = congrid(indgen(2^6,2^6),300,300) ; dummy image with range of 2^12
aMin = min(a,max=aMax) ; get max and min values of raw image
; scale all 12 bits of data into 8 bits of display
; one might call this contrast = 0 (out of 100) and brightness = 50 (out of 100)
tv,bytscl(a)
; now, to display some other contrast and brightness
contrast = 50
brightness = 25
Level = (1-brightness/100.)*(aMax - aMin) + aMin
width = (1-contrast/100.)*(aMax - aMin)
displayMax = level + width/2
displayMin = level - width/2
tv,bytscl(a,min=displayMin,max=displayMax)
Hope this helps,
Sean La Shell
Massachusetts General Hospital
Radiation Oncology
Northeast Proton Therapy Center