informatics-isi-edu / openseadragon-viewer

2D viewer with openseadragon
Apache License 2.0
5 stars 2 forks source link

Review channel color controls #62

Closed RFSH closed 3 years ago

RFSH commented 3 years ago

Up until now, we were mainly focused on the hue control. Now, we should spend some time and figure out if the current controls that we have make sense or not.

These are the other controls that we have and their definition based on what I gathered (which might not be accurate) and how they actually behave in the openseadragonFiltering plugin that we're using:

I'm not entirely sure what the gamma control does, but contrast and brightness are some of the widely used settings in any displays. Based on what I gathered both are usually presented in a 0-100 scale where 50 is the default (original color) value. But that's not how our controls work.

I suggest changing both controls to 0 to 100 scale with steps of 5. Then for each one OSD viewer has to properly match the percentage value to a proper contrast or brightness factor.

RFSH commented 3 years ago

We had a discussion about this and the following are the result of our discussion:

We could thing of this as two separate issues that we can gradually solve:

  1. Fix the contrast control so the default is some value in between. And then user can increase or decrease it (the same as brightness.) We could replicate the same contrast control as this page.

  2. The first issue will just solve the confusing UI but won't solve the underlying issue that our contrast and brightness controls are not what knowledgable users would expect. Contrast and brightness should not be a simple gain or offset function, and should work together.

The following is a message copied from @karlcz

I think this is the easiest way to understand it, if you can assume real number arithmetic:

  1. the existing filter functions you described are really gain(v, g) ==> v * g and offset(v, o) ==> v + o
  2. I think it is easier to think in terms of normalized ranges, i.e. pretend the image intensity range is [0, 1] rather than 8-bit [0, 255], 16-bit [0,65535] etc.
  3. you want to define a midpoint which is naively 0.5 for [0, 1] range if we ignore gamma and other non-linear perceptual models
  4. a pure contrast function shifts back and forth by the midpoint amount when applying gain: contrast(v, c) ==> offset(gain(offset(v, -0.5), c)), 0.5) with the above, you might define a system like this for normalized [0, 1] inputs:
    • a contrast control w/ useful control range [0, 10] and default 1 no change
    • a brightness control w/ useful range [-1, 1] and default 0 for no change
    • a combined filter output(v, c, b) ==> offset(constrast(v, c), b) ==> offset( offset( gain( offset(v, -0.5), c), 0.5), b) ==> offset( gain( offset(v, -0.5), c), 0.5 + b) I leave off the implicit clamping that maps output values < 0 to 0 and values > 1 to 1.

if I am not confusing myself, the above works for 8-bit w/o normalization just be redefining the brightness range to [-255, 255] and the midpoint to 128. the contrast range stays [0, 10]: output(v, c, b) ==> offset( gain( offset( v, -128), c), 128 + b) i.e. output = (v - 128) * c + 128 + b

of course, if the working arithmetic has sufficient range you can algebraically reduce the formulas further...

output(v, c, b) ==> offset( gain(v, c), 128 * c + 128 + b)

this is relevant for using image-based operators, since only the two func calls operate on the array of pixels and the offset 128 * c + 128 + b only has to be computed once as a constant parameter to the function.


Given this, we might also want to consider using CamanJS instead of the filters that we're using now. I found this library in the demo page of openseadragonFiltering library that we're using. Their contrast and brightness controls are more aligned with what the users would expect from these type of controls. I should investigate this as a solution first since it would solve both of our issues and seems simple enough.

RFSH commented 3 years ago

We got more feedback on the controls from Todd. Based on his experience with the feature, adjusting the slider values is difficult. It's hard to be precise as we're just allowing steps of 5. We might want to consider adding a text box that users can add their own value.

RFSH commented 3 years ago

I've pushed the first version of channel controls to master. I've decided to not use CamanJS since it has been deprecated. So I used OpenSeadragonFiltering as a template to create our own version of Contrast/Brightness filters.

For other planned improvement I created the issue #76