/usr/share/nip2/compat/7.9/Colour.def is in nip2 7.38.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | /* Save a bit of typing.
*/
_colour_conv from to x = map_unary (colour_transform from to) x;
/* convert Mono to various formats
*/
Mono_to = class {
/* convert mono colourspace to mono colourspace
*/
Mono x = _colour_conv Image_type.B_W Image_type.B_W x;
/* convert mono colourspace to XYZ colourspace
*/
XYZ x = _colour_conv Image_type.B_W Image_type.XYZ x;
/* convert mono colourspace to Yxy colourspace
*/
Yxy x = _colour_conv Image_type.B_W Image_type.YXY x;
/* convert mono colourspace to Lab colourspace
*/
Lab x = _colour_conv Image_type.B_W Image_type.LAB x;
/* convert mono colourspace to LCh colourspace
*/
LCh x = _colour_conv Image_type.B_W Image_type.LCH x;
/* convert mono colourspace to UCS colourspace
*/
UCS x = _colour_conv Image_type.B_W Image_type.UCS x;
/* convert mono colourspace to RGB colourspace
*/
RGB x = _colour_conv Image_type.B_W Image_type.RGB x;
/* convert mono colourspace to sRGB colourspace
*/
sRGB x = _colour_conv Image_type.B_W Image_type.sRGB x;
/* convert mono colourspace to LabQ colourspace
*/
LabQ x = _colour_conv Image_type.B_W Image_type.LABQ x;
/* convert mono colourspace to LabS colourspace
*/
LabS x = _colour_conv Image_type.B_W Image_type.LABS x;
}
/* convert XYZ to various formats
*/
XYZ_to = class {
/* convert XYZ colourspace to mono colourspace
*/
Mono x = _colour_conv Image_type.XYZ Image_type.B_W x;
/* convert XYZ colourspace to XYZ colourspace
*/
XYZ x = _colour_conv Image_type.XYZ Image_type.XYZ x;
/* convert XYZ colourspace to Yxy colourspace
*/
Yxy x = _colour_conv Image_type.XYZ Image_type.YXY x;
/* convert XYZ colourspace to Lab colourspace
*/
Lab x = _colour_conv Image_type.XYZ Image_type.LAB x;
/* convert XYZ colourspace to LCh colourspace
*/
LCh x = _colour_conv Image_type.XYZ Image_type.LCH x;
/* convert XYZ colourspace to UCS colourspace
*/
UCS x = _colour_conv Image_type.XYZ Image_type.UCS x;
/* convert XYZ colourspace to RGB colourspace
*/
RGB x = _colour_conv Image_type.XYZ Image_type.RGB x;
/* convert XYZ colourspace to sRGB colourspace
*/
sRGB x = _colour_conv Image_type.XYZ Image_type.sRGB x;
/* convert XYZ colourspace to LabQ colourspace
*/
LabQ x = _colour_conv Image_type.XYZ Image_type.LABQ x;
/* convert XYZ colourspace to LabS colourspace
*/
LabS x = _colour_conv Image_type.XYZ Image_type.LABS x;
}
/* convert Yxy to various formats
*/
Yxy_to = class {
/* convert Yxy colourspace to mono colourspace
*/
Mono x = _colour_conv Image_type.YXY Image_type.B_W x;
/* convert Yxy colourspace to XYZ colourspace
*/
XYZ x = _colour_conv Image_type.YXY Image_type.XYZ x;
/* convert Yxy colourspace to Yxy colourspace
*/
Yxy x = _colour_conv Image_type.YXY Image_type.YXY x;
/* convert Yxy colourspace to Lab colourspace
*/
Lab x = _colour_conv Image_type.YXY Image_type.LAB x;
/* convert Yxy colourspace to LCh colourspace
*/
LCh x = _colour_conv Image_type.YXY Image_type.LCH x;
/* convert Yxy colourspace to UCS colourspace
*/
UCS x = _colour_conv Image_type.YXY Image_type.UCS x;
/* convert Yxy colourspace to RGB colourspace
*/
RGB x = _colour_conv Image_type.YXY Image_type.RGB x;
/* convert Yxy colourspace to sRGB colourspace
*/
sRGB x = _colour_conv Image_type.YXY Image_type.sRGB x;
/* convert Yxy colourspace to LabQ colourspace
*/
LabQ x = _colour_conv Image_type.YXY Image_type.LABQ x;
/* convert Yxy colourspace to LabS colourspace
*/
LabS x = _colour_conv Image_type.YXY Image_type.LABS x;
}
/* convert Lab to various formats
*/
Lab_to = class {
/* convert Lab colourspace to mono colourspace
*/
Mono x = _colour_conv Image_type.LAB Image_type.B_W x;
/* convert Lab colourspace to XYZ colourspace
*/
XYZ x = _colour_conv Image_type.LAB Image_type.XYZ x;
/* convert Lab colourspace to Yxy colourspace
*/
Yxy x = _colour_conv Image_type.LAB Image_type.YXY x;
/* convert Lab colourspace to Lab colourspace
*/
Lab x = _colour_conv Image_type.LAB Image_type.LAB x;
/* convert Lab colourspace to LCh colourspace
*/
LCh x = _colour_conv Image_type.LAB Image_type.LCH x;
/* convert Lab colourspace to UCS colourspace
*/
UCS x = _colour_conv Image_type.LAB Image_type.UCS x;
/* convert Lab colourspace to RGB colourspace
*/
RGB x = _colour_conv Image_type.LAB Image_type.RGB x;
/* convert Lab colourspace to sRGB colourspace
*/
sRGB x = _colour_conv Image_type.LAB Image_type.sRGB x;
/* convert Lab colourspace to LabQ colourspace
*/
LabQ x = _colour_conv Image_type.LAB Image_type.LABQ x;
/* convert Lab colourspace to LabS colourspace
*/
LabS x = _colour_conv Image_type.LAB Image_type.LABS x;
}
/* convert LCh to various formats
*/
LCh_to = class {
/* convert LCh colourspace to mono colourspace
*/
Mono x = _colour_conv Image_type.LCH Image_type.B_W x;
/* convert LCh colourspace to XYZ colourspace
*/
XYZ x = _colour_conv Image_type.LCH Image_type.XYZ x;
/* convert LCh colourspace to Yxy colourspace
*/
Yxy x = _colour_conv Image_type.LCH Image_type.YXY x;
/* convert LCh colourspace to Lab colourspace
*/
Lab x = _colour_conv Image_type.LCH Image_type.LAB x;
/* convert LCh colourspace to LCh colourspace
*/
LCh x = _colour_conv Image_type.LCH Image_type.LCH x;
/* convert LCh colourspace to UCS colourspace
*/
UCS x = _colour_conv Image_type.LCH Image_type.UCS x;
/* convert LCh colourspace to RGB colourspace
*/
RGB x = _colour_conv Image_type.LCH Image_type.RGB x;
/* convert LCh colourspace to sRGB colourspace
*/
sRGB x = _colour_conv Image_type.LCH Image_type.sRGB x;
/* convert LCh colourspace to LabQ colourspace
*/
LabQ x = _colour_conv Image_type.LCH Image_type.LABQ x;
/* convert LCh colourspace to LabS colourspace
*/
LabS x = _colour_conv Image_type.LCH Image_type.LABS x;
}
/* convert UCS to various formats
*/
UCS_to = class {
/* convert UCS colourspace to mono colourspace
*/
Mono x = _colour_conv Image_type.UCS Image_type.B_W x;
/* convert UCS colourspace to XYZ colourspace
*/
XYZ x = _colour_conv Image_type.UCS Image_type.XYZ x;
/* convert UCS colourspace to Yxy colourspace
*/
Yxy x = _colour_conv Image_type.UCS Image_type.YXY x;
/* convert UCS colourspace to Lab colourspace
*/
Lab x = _colour_conv Image_type.UCS Image_type.LAB x;
/* convert UCS colourspace to LCh colourspace
*/
LCh x = _colour_conv Image_type.UCS Image_type.LCH x;
/* convert UCS colourspace to UCS colourspace
*/
UCS x = _colour_conv Image_type.UCS Image_type.UCS x;
/* convert UCS colourspace to RGB colourspace
*/
RGB x = _colour_conv Image_type.UCS Image_type.RGB x;
/* convert UCS colourspace to sRGB colourspace
*/
sRGB x = _colour_conv Image_type.UCS Image_type.sRGB x;
/* convert UCS colourspace to LabQ colourspace
*/
LabQ x = _colour_conv Image_type.UCS Image_type.LABQ x;
/* convert UCS colourspace to LabS colourspace
*/
LabS x = _colour_conv Image_type.UCS Image_type.LABS x;
}
/* convert RGB to various formats
*/
RGB_to = class {
/* convert RGB colourspace to mono colourspace
*/
Mono x = _colour_conv Image_type.RGB Image_type.B_W x;
/* convert RGB colourspace to XYZ colourspace
*/
XYZ x = _colour_conv Image_type.RGB Image_type.XYZ x;
/* convert RGB colourspace to Yxy colourspace
*/
Yxy x = _colour_conv Image_type.RGB Image_type.YXY x;
/* convert RGB colourspace to Lab colourspace
*/
Lab x = _colour_conv Image_type.RGB Image_type.LAB x;
/* convert RGB colourspace to LCh colourspace
*/
LCh x = _colour_conv Image_type.RGB Image_type.LCH x;
/* convert RGB colourspace to UCS colourspace
*/
UCS x = _colour_conv Image_type.RGB Image_type.UCS x;
/* convert RGB colourspace to RGB colourspace
*/
RGB x = _colour_conv Image_type.RGB Image_type.RGB x;
/* convert RGB colourspace to sRGB colourspace
*/
sRGB x = _colour_conv Image_type.RGB Image_type.sRGB x;
/* convert RGB colourspace to LabQ colourspace
*/
LabQ x = _colour_conv Image_type.RGB Image_type.LABQ x;
/* convert RGB colourspace to LabS colourspace
*/
LabS x = _colour_conv Image_type.RGB Image_type.LABS x;
}
/* convert sRGB to various formats
*/
sRGB_to = class {
/* convert sRGB colourspace to mono colourspace
*/
Mono x = _colour_conv Image_type.sRGB Image_type.B_W x;
/* convert sRGB colourspace to XYZ colourspace
*/
XYZ x = _colour_conv Image_type.sRGB Image_type.XYZ x;
/* convert sRGB colourspace to Yxy colourspace
*/
Yxy x = _colour_conv Image_type.sRGB Image_type.YXY x;
/* convert sRGB colourspace to Lab colourspace
*/
Lab x = _colour_conv Image_type.sRGB Image_type.LAB x;
/* convert sRGB colourspace to LCh colourspace
*/
LCh x = _colour_conv Image_type.sRGB Image_type.LCH x;
/* convert sRGB colourspace to UCS colourspace
*/
UCS x = _colour_conv Image_type.sRGB Image_type.UCS x;
/* convert sRGB colourspace to RGB colourspace
*/
RGB x = _colour_conv Image_type.sRGB Image_type.RGB x;
/* convert sRGB colourspace to sRGB colourspace
*/
sRGB x = _colour_conv Image_type.sRGB Image_type.sRGB x;
/* convert sRGB colourspace to LabQ colourspace
*/
LabQ x = _colour_conv Image_type.sRGB Image_type.LABQ x;
/* convert sRGB colourspace to LabS colourspace
*/
LabS x = _colour_conv Image_type.sRGB Image_type.LABS x;
}
/* convert LabQ to various formats
*/
LabQ_to = class {
/* convert LabQ colourspace to mono colourspace
*/
Mono x = _colour_conv Image_type.LABQ Image_type.B_W x;
/* convert LabQ colourspace to XYZ colourspace
*/
XYZ x = _colour_conv Image_type.LABQ Image_type.XYZ x;
/* convert LabQ colourspace to Yxy colourspace
*/
Yxy x = _colour_conv Image_type.LABQ Image_type.YXY x;
/* convert LabQ colourspace to Lab colourspace
*/
Lab x = _colour_conv Image_type.LABQ Image_type.LAB x;
/* convert LabQ colourspace to LCh colourspace
*/
LCh x = _colour_conv Image_type.LABQ Image_type.LCH x;
/* convert LabQ colourspace to UCS colourspace
*/
UCS x = _colour_conv Image_type.LABQ Image_type.UCS x;
/* convert LabQ colourspace to RGB colourspace
*/
RGB x = _colour_conv Image_type.LABQ Image_type.RGB x;
/* convert LabQ colourspace to sRGB colourspace
*/
sRGB x = _colour_conv Image_type.LABQ Image_type.sRGB x;
/* convert LabQ colourspace to LabQ colourspace
*/
LabQ x = _colour_conv Image_type.LABQ Image_type.LABQ x;
/* convert LabQ colourspace to LabS colourspace
*/
LabS x = _colour_conv Image_type.LABQ Image_type.LABS x;
}
/* convert LabS to various formats
*/
LabS_to = class {
/* convert LabS colourspace to mono colourspace
*/
Mono x = _colour_conv Image_type.LABS Image_type.B_W x;
/* convert LabS colourspace to XYZ colourspace
*/
XYZ x = _colour_conv Image_type.LABS Image_type.XYZ x;
/* convert LabS colourspace to Yxy colourspace
*/
Yxy x = _colour_conv Image_type.LABS Image_type.YXY x;
/* convert LabS colourspace to Lab colourspace
*/
Lab x = _colour_conv Image_type.LABS Image_type.LAB x;
/* convert LabS colourspace to LCh colourspace
*/
LCh x = _colour_conv Image_type.LABS Image_type.LCH x;
/* convert LabS colourspace to UCS colourspace
*/
UCS x = _colour_conv Image_type.LABS Image_type.UCS x;
/* convert LabS colourspace to RGB colourspace
*/
RGB x = _colour_conv Image_type.LABS Image_type.RGB x;
/* convert LabS colourspace to sRGB colourspace
*/
sRGB x = _colour_conv Image_type.LABS Image_type.sRGB x;
/* convert LabS colourspace to LabQ colourspace
*/
LabQ x = _colour_conv Image_type.LABS Image_type.LABQ x;
/* convert LabS colourspace to LabS colourspace
*/
LabS x = _colour_conv Image_type.LABS Image_type.LABS x;
}
#separator
/* recombine image bands with an editable matrix
*/
Colour_recombination in
= map_unary widget in
{
widget image = class
Image value {
_check_args = [
[image, "image", check_Image]
] ++ super._check_args;
_vislevel = 3;
matrix = Matrix_rec (identity_matrix image.bands);
value = recomb matrix image.value;
}
}
/* colour temperature conversions
*/
Colour_temperature = class {
/* convert XYZ from D65 to D50 ... use the Bradford approximation
*/
D65XYZ_to_D50XYZ in = map_unary (colour_unary im_D652D50) in;
/* convert XYZ from D50 to D65 ... use the Bradford approximation
*/
D50XYZ_to_D65XYZ in = map_unary (colour_unary im_D502D65) in;
}
/* various colour difference metrics
*/
dE_ = class {
/* Apply a converter to an object ... convert image or colour (since
* we can guess the colour space we're converting from), don't convert
* matrix or vector (since we can't tell ... assume it's in the right
* space already).
*/
_apply_cvt cvt x
= cvt x,
is_instanceof "Image" x || is_instanceof "Colour" x ||
is_image x
= x;
_diff cvt in1 in2 = abs_vec (_apply_cvt cvt in1 - _apply_cvt cvt in2);
/* Converter to LAB.
*/
_lab_cvt = colour_transform_to Image_type.LAB;
/* Converter to UCS ... plain UCS is Ch form, so we go LAB again after
* to make sure we get a rectangular coord system.
*/
_ucs_cvt = colour_transform Image_type.LCH Image_type.LAB @
colour_transform_to Image_type.UCS;
/* calculate delta-E CIE76 for two objects
*/
CIE76 in1 in2 = map_binary (_diff _lab_cvt) in1 in2;
/* calculate delta-E00 (CIEDE2000) for two objects
*/
CIE00 in1 in2 = map_binary
(colour_binary "im_dE00_fromLab" im_dE00_fromLab) in1 in2;
/* calculate delta-E CMC(1:1) for two objects
*/
UCS in1 in2 = map_binary (_diff _ucs_cvt) in1 in2;
}
#separator
/* apply a coloured tint to a monochrome image
*/
Tint_mono_image in
= map_unary apply_tint in
{
apply_tint in = class
Image value {
_check_args = [
[in, "in", check_Image]
] ++ super._check_args;
_vislevel = 3;
tint = Colour "Lab" [50, 0, 0];
value = image_set_type Image_type.LAB
(fancytint inp l_tint a_tint b_tint)
{
// input image ... to L only
inp_lab = colour_transform_to Image_type.LAB in.value;
inp = inp_lab?0;
// make sure tint is LAB (might be edited)
lab_tint = colour_transform_to Image_type.LAB tint;
// selected lab
l_tint = lab_tint.value?0;
a_tint = lab_tint.value?1;
b_tint = lab_tint.value?2;
// fancy tint function ... don't tint black and white
fancytint im l a b
= im ++ ima ++ imb
{
mod
= (100 - im) / (100 - l), im > l
= im / l;
backgr = image_new in.width in.height 1
Image_format.FLOAT
Image_coding.NOCODING
Image_type.B_W 0 0 0;
ima = mod * (backgr + a);
imb = mod * (backgr + b);
}
}
}
}
/* displace neutral axis in LAB colourspace
*/
Adjust_cast image
= map_unary widget image
{
widget image = class
Image value {
_check_args = [
[image, "Image", check_Image]
] ++ super._check_args;
_vislevel = 3;
green_red = Slider (-20) 20 0;
blue_yellow = Slider (-20) 20 0;
value
= (colour_transform_to (get_type image) image'').value
{
image' = colour_transform_to Image_type.LAB image;
image'' = image' +
Vector [0, green_red.value, blue_yellow.value];
}
}
}
/* displace h, scale LC in LCh colourspace
*/
Adjust_hue_saturation_brightness image
= map_unary widget image
{
widget image = class
Image value {
_check_args = [
[image, "Image", check_Image]
] ++ super._check_args;
_vislevel = 3;
hue = Slider 0 360 0;
saturation = Slider 0.01 5 1;
brightness = Slider 0.01 5 1;
value
= (colour_transform_to (get_type image) image'').value
{
image' = colour_transform_to Image_type.LCH image;
image'' =
image' * Vector [bv, sv, 1] + Vector [0, 0, hv];
bv = brightness.value;
sv = saturation.value;
hv = hue.value;
}
}
}
/* find pixels with a similar colour
*/
Similar_colour image
= map_unary match image
{
match image = class
Image value {
_check_args = [
[image, "Image", check_Image]
] ++ super._check_args;
_vislevel = 3;
target_patch = Region image
(20 - image.xoffset)
(20 - image.yoffset)
10 10;
target_colour = Colour_from_image target_patch;
dE_threshold = Slider 0 100 10;
value = (dE_.CIE76 image target_colour < dE_threshold).value;
}
}
/* plot an ab scatter histogram
*/
Plot_ab_scatter image
= map_unary widget image
{
widget image = class
Image value {
_check_args = [
[image, "Image", check_Image]
] ++ super._check_args;
_vislevel = 3;
bins = 8;
value
= bg * (((90 / mx) * hist) ++ blk)
{
lab = colour_transform_to Image_type.LAB image.value;
ab = (unsigned char) ((lab?1 ++ lab?2) + 128);
hist = hist_find_nD bins ab;
mx = max hist;
bg = lab_slice bins 1;
blk = 1 + im_black bins bins 2;
}
}
}
|