Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/math_color_inline.c
| Context not available. | |||||
| r_col[2] = ((pack) >> 16) & 0xFF; | r_col[2] = ((pack) >> 16) & 0xFF; | ||||
| } | } | ||||
| /* TODO: | |||||
| * | |||||
| * regarding #rgb_to_bw vs #rgb_to_grayscale, | |||||
| * it seems nobody knows why we have both functions which convert color to grays | |||||
| * but with different influences, this is quite stupid, and should be resolved | |||||
| * by someone who knows this stuff: see this thread | |||||
| * http://lists.blender.org/pipermail/bf-committers/2012-June/037180.html | |||||
| * | |||||
| * Only conclusion is that rgb_to_grayscale is used more for compositing. | |||||
| */ | |||||
| MINLINE float rgb_to_bw(const float rgb[3]) | |||||
| { | |||||
| return 0.35f * rgb[0] + 0.45f * rgb[1] + 0.2f * rgb[2]; | |||||
| } | |||||
| /* non-linear luma from ITU-R BT.601-2 | |||||
| * see: http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC11 | |||||
| * note: the values used for are not exact matches to those documented above, | |||||
| * but they are from the same */ | |||||
| MINLINE float rgb_to_grayscale(const float rgb[3]) | |||||
| { | |||||
| return 0.3f * rgb[0] + 0.58f * rgb[1] + 0.12f * rgb[2]; | |||||
| } | |||||
| MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3]) | |||||
| { | |||||
| return (unsigned char)(((76 * (unsigned short)rgb[0]) + | |||||
| (148 * (unsigned short)rgb[1]) + | |||||
| (31 * (unsigned short)rgb[2])) / 255); | |||||
| } | |||||
| /* luma from defined by 'YCC_JFIF', see #rgb_to_ycc */ | |||||
| MINLINE float rgb_to_luma(const float rgb[3]) | |||||
| { | |||||
| return 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2]; | |||||
| } | |||||
| MINLINE unsigned char rgb_to_luma_byte(const unsigned char rgb[3]) | |||||
| { | |||||
| return (unsigned char)(((76 * (unsigned short)rgb[0]) + | |||||
| (150 * (unsigned short)rgb[1]) + | |||||
| (29 * (unsigned short)rgb[2])) / 255); | |||||
| } | |||||
| /* gamma-corrected RGB --> CIE XYZ | |||||
| * for this function we only get the Y component | |||||
| * see: http://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch6/ch6_color_models.html | |||||
| * | |||||
| * also known as: | |||||
| * luminance rec. 709 */ | |||||
| MINLINE float rgb_to_luma_y(const float rgb[3]) | |||||
| { | |||||
| return 0.212671f * rgb[0] + 0.71516f * rgb[1] + 0.072169f * rgb[2]; | |||||
| } | |||||
| MINLINE int compare_rgb_uchar(const unsigned char col_a[3], const unsigned char col_b[3], const int limit) | MINLINE int compare_rgb_uchar(const unsigned char col_a[3], const unsigned char col_b[3], const int limit) | ||||
| { | { | ||||
| const int r = (int)col_a[0] - (int)col_b[0]; | const int r = (int)col_a[0] - (int)col_b[0]; | ||||
| Context not available. | |||||