image
image copied to clipboard
Using Black/White/Mids -> Picture turns into red
Hi,
I want to use the blacks/whites/mids parameters in adjustColors().
Calling adjustColors() without any parameter give following result:
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()
);
Could you please tell me, why only the red channels are affected, not the others? Or do I misunderstood the parameters?
Thanks in advance! :)
Try normalized [0,1] values for the parameters.
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;
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
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.
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?
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.
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