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

Re: changing contrast and brightness on the fly



JD Smith wrote:
> A standard feature of astronomical viewers.  For a solution which uses
> only colormap fiddling (vs. full image rescaling), see atv:
> 
>  http://cfa-www.harvard.edu/~abarth/atv/atv.html
> 
> This brings up the age old question of how best to dynamically redisplay
> images (brightnest/contrast/etc.).  With only 255 colors, making the top
> 100 white to increase brightness is pretty wasteful, and cuts down on
> the dynamic visual range... much better (and slower) is to rescale the
> image range of interest into the full colormap.
> 
> Here's how Andrew (and cohorts) did it:
> 
> +++++++++++++++++++++++++++++++++++++++++++
> pro atv_stretchct, brightness, contrast,  getmouse = getmouse
> 
> ; routine to change color stretch for given values of
> ; brightness and contrast.
> ; Complete rewrite 2000-Sep-21 - Doug Finkbeiner
> ; This routine is now shorter and easier to understand.
> 
> common atv_state
> common atv_color
> 
> ; if GETMOUSE then assume mouse positoin passed; otherwise ignore
> ; inputs
> 
> if (keyword_set(getmouse)) then begin
>    state.brightness = brightness/float(state.draw_window_size[0])
>    state.contrast = contrast/float(state.draw_window_size[1])
> endif
> 
> x = state.brightness*(state.ncolors-1)
> y = state.contrast*(state.ncolors-1) > 2   ; Minor change by AJB
> high = x+y & low = x-y
> diff = (high-low) > 1
> 
> slope = float(state.ncolors-1)/diff ;Scale to range of 0 : nc-1
> intercept = -slope*low
> p = long(findgen(state.ncolors)*slope+intercept) ;subscripts to select
> tvlct, r_vector[p], g_vector[p], b_vector[p], 8
> 
> end
> +++++++++++++++++++++++++++++++++++++++++++


Is it fair to say that this method will only give satisfactory results
when IDL is running in 8-bit display mode?

Cheers,
Liam.