image icon indicating copy to clipboard operation
image copied to clipboard

Using Black/White/Mids -> Picture turns into red

Open S-Man42 opened this issue 3 years ago • 7 comments

Hi,

I want to use the blacks/whites/mids parameters in adjustColors().

Calling adjustColors() without any parameter give following result:

grafik

But when I set any value (between 0 and 255) to any of these parameters, the result turns into a completely red image:

return img.adjustColor(image,
      //   saturation: _currentSaturation,
      //   contrast: _currentContrast,
      // gamma: _currentGamma,
      // exposure: _currentExposure,
      // hue: _currentHue,
      // brightness: _currentBrightness,
      blacks: _currentBlacks.toInt(),
      whites: _currentWhites.toInt(),
      mids: _currentMids.toInt()
);

grafik

Could you please tell me, why only the red channels are affected, not the others? Or do I misunderstood the parameters?

Thanks in advance! :)

S-Man42 avatar Jun 12 '21 14:06 S-Man42

Try normalized [0,1] values for the parameters.

brendan-duncan avatar Jun 12 '21 15:06 brendan-duncan

Thanks for responding. I tried this (B=0.0, W=1.0, M=0.5), but then the entire picture is black.

That makes sense, because the getRed/Green/Blue() parameter is of type int, so it is converted into 0 or 1, but I guess, it expects 0 or 255:


    br = blacks != null ? getRed(blacks) / 255.0 : 0.0;

------

int getRed(int color) => (color) & 0xff;

S-Man42 avatar Jun 12 '21 15:06 S-Man42

I haven't looked into this in a while, so I'm not entirely sure. I have the little test web app in here you can try it interactively. If you get the git download, and from the main directory run Dart's webdev serve program, then you can try it at 127.0.0.1:8000/filter_lab.html

brendan-duncan avatar Jun 12 '21 15:06 brendan-duncan

Though looking at that myself, I realize it doesn't have the black/white/mid parameters in that test app. I'll have to take a look at it. It may very well be broken, I don't think anyone's really used that function much before.

brendan-duncan avatar Jun 12 '21 15:06 brendan-duncan

I already rewrote the saturation/contrast/... codes to get it working (related discussion: #313 ). However I was not able to find a source for the Mids/Blacks/Whites which I could implement.

Do you still know what the source for your code was?

S-Man42 avatar Jul 29 '21 10:07 S-Man42

I'm looking for where the reference code for that came from. It was so long ago that I added it, so I can't remember now and I wasn't on it enough to make note of it. I never expected this library to be used by anyone other than the experimental projects I had at the time...

If those adjustments don't work very well, I'm not apposed to removing them, or switching to other better color adjusting methods. I'm not sure what sorts of things people want to be adjusting.

brendan-duncan avatar Jul 29 '21 17:07 brendan-duncan

I think there was a layer or two of implementation source reference until it got to the version that's in this code now, but the origin is probably from GPUGems color adjustment section on Levels, https://developer.nvidia.com/sites/all/modules/custom/gpugems/books/GPUGems/gpugems_ch22.html

brendan-duncan avatar Jul 29 '21 18:07 brendan-duncan