-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ошибка в калькуляторах расстояний #4
Comments
Igor probably got those numbers from the original RgbQuant source [1]. I got those coefficients from Rec 709 [2] for RGB. @Nommyde, where are you getting your coefficients? I could not find them anywhere. Do they look more accurate in your testing? Also, if sRGB is non-linear, then how would different (but still static) coefficients be any more accurate? [1] https://github.com/leeoniya/RgbQuant.js/blob/master/src/rgbquant.js#L703 |
@leeoniya i get these coefficients by applying srgb conversion formula (see Csrgb).
Yes. And if you scale rgb levels with these coefficients and look at same levels (black rectangle)
Non-linear in energy, but approximately linear for human perception, so it can be scaled linearly |
@leeoniya Red and blue are lighter than green in same points. If coeff. will too small (like linear 0.0722), small difference in corresponding coordinate will make big color change, but same difference in other coordinate will make small color change. |
Interesting, thanks! I'll play around with the adjusted coefficients in in RgbQuant as well and see how things look. Though RqbQuant uses a component-scaled Eucledian distance [1] which got better results than a simple scaled sum. |
@leeoniya in your project luma and distance are calculated with square of components (looks like fast average of gamma correction) so Rec.709 coeffs are more suitable. But this project has no gamma correction |
@igor-bezkrovny кстати, ты тоже можешь попробовать вместо изменения коэффициентов применить быструю гамма-коррекцию, возведя в квадрат компоненты, как у @leeoniya |
oh, i see. The Manhattan option [1] doesnt use squares though, so maybe it's worth using the adjusted coefficients for that. [1] https://github.com/leeoniya/RgbQuant.js/blob/master/src/rgbquant.js#L733 |
may be, try them :) |
The quality that btw, until i poke my server. working demos are here: http://leeoniya.github.io/RgbQuant.js/demo/ |
@leeoniya, среди методов этого проекта или вообще среди известных тебе? |
Between all that i've seen before giving up :) Including various combinations of [1] [2]. Maybe there is something better, but I would have a hard time determining if it was actually better or just "different". [1] http://www.codeproject.com/Articles/66341/A-Simple-Yet-Quite-Powerful-Palette-Quantizer-in-C |
http://igor-bezkrovny.github.io/image-q/demo/0.1.4/index.html тут я могу выбрать эту лучшую комбинацию? или это устаревшая демка? |
Я думаю при малом количестве цветов лучше всех работает scolorq Wu: 4 colors scolorq: 4 colors http://bisqwit.iki.fi/jutut/colorquant/index4.html |
In this case, yes. When the color counts are very low, the variation is huge not only between libraries but also between individual samples. At this point you're just choosing what you personally prefer for your specific workload, since every answer is very wrong, just along different axes, lol. I think for >= 16 colors Wu + Riemersma is very hard to beat over a diverse workload. Of course I could be wrong :) |
не спорю :) |
However, the demo also doesn't have a Wu version with component coefficients which often have a large impact and may fix that shift towards red in the wu version. |
Regarding original post: There is an opinion sRGB luminosity should be calculated as follows:
Coefficients So, it seems that best coefficients for Y of sRGB images are |
@igor-bezkrovny anyway calculating Luma as linear combination of non-linear sRGB components (ignoring gamma) is bad idea if you need high precision. It is just approximation. But in Manhattan algorithm i think my coeffs will be better:) try them on real pictures |
Yes, but the best standard now is bt.709, and the only standard for sRGB.
I temporarily added ManhattanNommyde color distance method here: http://igor-bezkrovny.github.io/image-q/demo/1.0.1/index.html. However:
|
@igor-bezkrovny in manhattan algorithm sum of coeffs must not be 1.0 and not applicable in this script (https://jsfiddle.net/Nommyde/3Lxe10pp/). because in simple manhattan sum of coefs is 3.0 :) and it is not a problem. simple manhattan: nommyde manhattan: sRGB manhattan (looks wrong): |
В ManhattanSRGB и EuclideanRgb... методах r, g, b умножаются на коэффициенты
RED = .2126, GREEN = .7152, BLUE = .0722
В этом нет смысла, так как эти коэффициенты применимы к линейным CIE RGB, а не к sRGB (в котором все изображения в вебе). Появится смысл, если эти коэффициенты перевести в sRGB, тогда они примут вид:
RED = 0.4984, GREEN = 0.8625, BLUE = 0.2979
Либо если не умножать компоненты на коэффициенты, а просто перевести пиксель из sRGB в CIE RGB и там уже мерить евклидово расстояние (но в таком случае потеряется смысл с точки зрения человеческого восприятия)
Также эти коэффициенты используются в методе getLuminocity, это тоже неверно. Там лучше взять формулу
Luminance (perceived option 1): (0.299*R + 0.587*G + 0.114*B) [2]
Еще точнее будет просто взять координату Y из CIE XYZ, но это долго вычисляется
The text was updated successfully, but these errors were encountered: