ImageJ
ImageJ copied to clipboard
MedianCut should scale all color values from [0, 248] -> [0, 255]
I did some tests and MedianCut
tends to make images darker because all colors besides white are with their last 3 bits set to '0'.
https://github.com/imagej/imagej1/blob/faaa7e0b29e91afff5cba11b8c0e700d9e976ea4/ij/process/MedianCut.java#L253-L254
The following replacement does a much better job:
// adjust values, i.e. we had the last 3 bits cut off: [0, 248] --> [0, 255]
r = (255 * r) / 248;
g = (255 * g) / 248;
b = (255 * b) / 248;
This also resets white to its original color.