-
Notifications
You must be signed in to change notification settings - Fork 0
/
neudist
executable file
·1013 lines (952 loc) · 34.6 KB
/
neudist
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
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /bin/sh
# This is basically what displaycal would do for me before python 2.7 was
# killed. It's a helper script around various Argyll CMS utilities.
# for now, it's a bit hacky, because I mainly wrote it for my system. But
# overall, apart from a couple hardcoded paths and defaults for my laptop,
# I think it's pretty good. Use --help for help.
# Should work in any Bourne shell, I believe.
# change this if you want to change the default corrections file/path.
# example: CORRECTIONS='-X/path/to/ccmx-or-ccss-file'.
INVOCATION="$@" # save this before we start shifting
CORRECTIONS=''
PROGNAME="$(echo "$0" | sed 's!^.*/!!')"
# Program defaults are defined here.
# An empty string means that the option is not passed to dispwin,
# dispread, etc..
SKIP_ADJUST='' # '-m'
TEMPERATURE='-w0.3127,0.329' # d65 srgb white point
GAMMA_RAMP=''
if [ "$NEUDIST_BLACK_POINT_HACK" ]; then
BLACK_POINT_HACK='-b'
else
BLACK_POINT_HACK='' # -b to enable for dispcal and collink operations
fi
COLLINK_3DLUT_TYPE='-3c' # for --3dlut mode only
COLLINK_3DLUT_TARGET=''
COLLINK_INTENT='-ip' # output intent. perceptual.
COLLINK_RES='-r65' # resolution of 3D LUT (65x65x65)
# FIXME: hardcoded path
# adobe rgb 1998 == ClayRGB1998
COLLINK_INPUT_PROFILE='/usr/share/color/argyll/ref/ClayRGB1998.icm'
# COLLINK_INPUT_PROFILE='/usr/share/color/argyll/ref/sRGB.icm'
colprof_get_input_prof() {
echo "$COLPROF_GET_INPUT_PROFILE"
}
COLPROF_ALGORITHM='-aX' # XYZ CLUT. The default (-al) is great except that some browsers hate it.
COLPROF_QUALITY='-qh'
COLPROF_INTENT='-tp' # output intent. perceptual.
COLPROF_INTENT_SAT='-Ts'
COLPROF_SRC_GAMUT_PROFILE='-S'''
BRIGHTNESS=''
COLORANT='-d3'
AUTOBRIGHT='true'
DRIFT='' # -Ib, -Iw, -Ibw - black level and white level drift compensation
PROFNAME=''
# DISPLAY='-d 1'
DISPLAYNO=''
DISPLAYTYPE=''
DEVICE='-c1'
WINDOWSIZE='1.33'
WINDOWRECT='-P0.5,0.5,'"$WINDOWSIZE"
VERBOSE='-v2'
TESTCHART_PATCHES='-f836' # this is the targen default, but 500 might be ample.
INTERACTIVE='' # -Yp to not prompt for enter key
NO_CORRECTIONS='' # We need this so we can not prompt if --no-corrections
# passed
MODE='all' # name of function to run before exiting; defaults to
# calibrating and profiling
if [ "$NEUDIST_MODE_OVERRIDE" ]; then
MODE="$NEUDIST_MODE_OVERRIDE"
fi
# can't set variables within while loops?
yesno() { # returns true (0) or false (1) based on yes/no prompt
ynprompt=''
while true; do
if [ "$1" ]; then
printf "$1"': '
fi
read -r ynprompt
case "$ynprompt" in
[Yy][Ee][Ss]|[Yy])
return 0
;;
[Nn][Oo]|[Nn])
return 1
;;
*)
echo "Invalid response. Please answer 'yes' or 'no'."
;;
esac
done
}
usage() {
echo 'Usage:'
echo ' '"$PROGNAME"' [options] output_profile_name'
echo
cat << EOF
Options:
--all Perform all profiling, calibration, test chart generation,
and .icc profile generation, all in one shot. This
is the default behavior when no mode is specified.
Specifically, this option performs the following actions:
1. Clear (actually reset) the video card gamma
correction table (VCGT/VGCT/RAMDAC) with
'dispwin -c'.
2. Perform initial calibration with 'dispcal'
(creates a .cal file with VCGT values).
(--calib)
3. Generate a testchart (.ti1) using targen
(--testchart)
4. Profile and create a .ti3 file using dispread
(--calc)
5. Calculate a final .ICC/.ICM profile using colprof
6. Check the profile's accuracy using profcheck
--3dlut Switches to 3D LUT creation mode. Uses an already
existing ICC profile to create a 3D lookup table.
The output format for the LUT will be will be IRIDAS
(.cube); to change this, use --3dlut-type.
--3dlut-icc Specify the .icc profile to use as a destination profile
<value> for 3D LUT creation.
--3dlut-res <value> Specify the resolution of the generated 3D LUT
(will be cubed).
(default: 65)
--3dlut-type Create a 3D lookup table of type <value>. Implies --3dlut.
<value> "Type" can be one of:
c = IRIDAS (.cube) (default)
e = eeColor (.txt)
m = MadVR (.3dlut)
An output profile name should still be specified, and
the LUT file will have the same name (sans .icc) as
the output profile file.
-a, --algorithm Algorithm type override
l = Lab cLUT (Argyll preferred),
x = XYZ cLUT,
X = display XYZ cLUT + matrix (Neudist default),
Y = display XYZ cLUT + debug matrix,
g = gamma+matrix,
s = shaper+matrix,
m = matrix only,
G = single gamma+matrix,
S = single shaper+matrix
If it weren't for problems in some browsers, I would
recommend -a 'l'. As it is, though, you should
probably use 'X' for compatibility.
-b, --brightness <n> Specify a display brightness in nits (cd/m^2).
(default: auto-detect display brightness)
-c, --device <num> Specify a measuring device to use - 'spotread -h' can
display a list of all devices, if you don't know what
number yours is. (Default: 1)
--colorant <num> Choose a colorant combination. See the '-d' option of
'targen' for a full list. You likely want '3', which
is the normal choice for "Video RGB."
(default: 3)
--colortemp <num> Use a white point of 'num' degrees Kelvin.
controls the (White daylight locus target). If unset,
Argyll's 'dispcal' uses the screen's natural white
point to allow the highest depth of color possible. If
you want to set this, a commonly standardized value is
6500 degrees Kelvin.
If --whitepoint is also present, the later flag in the
command line will take priority.
See also: --whitepoint (which uses chromaticity
coordinates to adjust this white point instead),
--whitepoint-preset (which lets common illuminants
be specified non-numerically).
--correction <file> Choose a colorimeter corrections file (.ccss, .ccmx).
this is not necessary if you are using a spectrometer,
but will greatly improve results with a colorimeter.
--no-correction Do not use any colorimeter correction matrices (probably
desirable for a spectrometer - but I do not have one
of those, regrettably).
You can edit the lines near the very top of this
script to set a default corrections file path.
-d, --display <num> Specify your display number. 'dispcal -h' can show a list
of valid display numbers and their names.
(Default: 1)
--display-type <?> Specify a display type to be used. The options available
depend on your specific measuring instrument(s); see
https://www.argyllcms.com/doc/instruments.html to find
out what modes yours supports.
Example display types (for i1 Display Pro) are:
'n' - non-refresh display(s), like LCD's - screens
that do not work by re-illuminating their
faces on each draw, but have a constant
light source (like a backlight).
'r' - refresh-type Displays that 'flicker' or
repeatedly re-draw a picture by illuminating
an illuminant for a specific portion of the
screen. This includes CRTs, plasmas, and(?)
OLED's.
(Default is specific to each measurement device.)
--drift <b|w> If your display has an unstable black or white point
(or both), use this option to have 'dispcal' and
'dispread' account for that.
Examples of displays with unstable white points are
screens that automatically adjust brightness based
on the picture (ABL), and devices like CRT's and
many plasma screens. Some OLED displays also have
a similar behavior to slow aging.
I believe significant black level drift to be
somewhat rare, but can imagine it occurring on
some CRT's where the phosphors fade slowly or
where the tube is not sufficiently warmed up when
calibration/profiling begins. But if it's warmed
up, You probably don't even need it there.
To make use of both black and white level drift
compensation, use 'bw'.
-h, --help Display this help text.
-g, --gamma <value> Specifies a gamma ramp.
This takes lots of words to fully explain.
Please refer to:
https://www.argyllcms.com/doc/dispcal.html#g
if you need the full, detailed explanation.
Most people should probably use the default here.
(default: 2.4, unless on OS X 10.5 or earlier).
-G, --gamma-actual Use the actual, technical gamma value specified. You
<value> probably do not actually want this. See:
https://www.argyllcms.com/doc/dispcal.html#G
for more information about this flag.
For most people, you should use -g instead, or let the
default be used instead (-g s).
-i, --input-profile Specify a source gamut ICC/ICM profile. This is necessary
<value> to create saturation intents in color profiles and to
generate 3D LUT's.
EOF
echo ' (default: '"$COLLINK_INPUT_PROFILE"')'
cat << EOF
--intent <value> Specify an output gamut mapping for perceptual intent.
(default: perceptual, 'p')
'value' should be one of:
a = absolute colorimetric
(ICC Absolute Colorimetric),
aw = absolute, with scaling to fit white point,
aa = absolute appearance,
r = white point matched appearance
(ICC Relative Colorimetric),
la = luminance matched appearance,
p = perceptual
(ICC Perceptual),
pa = perceptual appearance,
lp = luminance preserving perceptual,
ms = saturation
s = enhanced saturation
(ICC Saturation),
al = absolute colorimetric (Lab),
rl = white point matched colorimetric (Lab)
--intent-sat <value> Specify an output gamut mapping for saturation intent.
Uses the same values as --intent.
Note that saturation intents are dependent on the
source gamut (--input-profile).
(default: enhanced saturation, 's')
-n, --noninteractive Do not prompt or wait for the user to place the
measurement device on the screen.
See also: The similar but distinct option
'--skip-adjust'.
--patches <num> When creating a test chart (--testchart), use 'num'
patches. Larger values mean a slower profiling stage,
but possibly better results. 500 might be an
acceptable number here, dependant on other factors.
Poor gamut displays might benefit from larger numbers
of patches.
Smaller numbers may be good for displays with erratic
responsivity or auto-dimming features.
(default: 836, which is the Argyll default.)
--patch-scale <num> Change the resolution of the patch window on the screen
For displays with Automatic brightness level
adjustments based on screen content (such as some
plasmas), this being small can be vital to getting
a dependable result.
This resolution takes effect as a multiplier value
passed to dispcal/dispread.
(default: 1.33)
--profile Perform only the profiling step on output_profile_name
and exit. Use this if you have already done a
calibration (--calib) and made a testchart
(--testchart), but need to create a '.ti3'.
'.ti3' files are needed to finally generate an ICC/ICM
file.
-q, --quality <lmhu> Final ICC profile (or 3D LUT file) Quality:
Low, Medium, High (default), or Ultra.
Higher levels take more time but might give better
results. The resulting profiles are also usually
significantly larger.
See Argyll's colprof for more information.
--skip-adjust Skip interactive display adjustment step
--srgb Shorthand for:
'--whitepoint-preset D65 --brightness 80 --gamma s'.
If used before a conflicting argument, the later
argument takes priority. For example, if you want
"sRGB, except 120 cd/m^2 brightness," the command
line would read '--srgb --brightness 120'.
--testchart Create a .ti1 testchart. This is required before the
profiling stage can be performed.
See also: --patches, which controls how many patches
this test chart uses.
-v, --verbose <num> Use a specified verbosity level, when supported in the
underlying Argyll programs. 'Num' is an optional
parameter specifying the specific level for 'dispcal,'
but for other programs with only one verbosity level
this can be omitted.
If num is omitted, 'dispcal' will default to -v 2.
A value of '0' will turn off verbosity.
-w, --whitepoint Use a white point specified in comma-separated
<x,y> chromaticity coordinates (x,y).
If --colortemp or --whitepoint-preset is also present,
the later flag on the command line will take priority.
See also: --colortemp, --whitepoint-preset.
(default: use display native white point)
--whitepoint-preset Use a "preset" standard illuminant whitepoint.
<name> One of:
- D50
- D55
- D65 (CIE standard illuminant, roughly 6500 deg. K.
Actually 6504 deg. K.)
D65 is also the standard for Rec. 709 HDTV.
Recommended.
- D75 (CIE standard illuminant, roughly 7500 deg. K)
- D93 (CIE standard illuminant, roughly 9300 deg. K)
- F2 (simulated fluorescent lamp: 4100 deg. K CRI 60)
- F7 (simulated fluorescent lamp: 6500 deg. K CRI 90)
- F11 (simulated narrow tri-band fluorescent lamp:
4000 deg. K CRI 83)
If you are not doing color grading, using the native
white point is recommended. The native white point is
chosen if no temperature or white point arguments are
provided.
--no-whitepoint This is only useful when doing something like '--srgb' but
when wanting the native white point. You probably
should not use this. Otherwise, an unspecified
whitepoint is the default (lets Argyll determine your
display's native point).
Note: Options valid for some operations may be ignored silently for others.
Usually, this is because the underlying tool does not accept the given
parameter. For instance, passing '--3dlut-type' when not creating a 3D LUT
(with --3dlut) will not cause an error, but calibration/profiling will be
done as if the parameter had not been passed.
This could be good or bad, depending on what you're trying to do, but the
upshot is that doing something like providing a correction matrix when you're
not sure if it's necessary for a given task is OK.
It also facilitates creating a shell alias for this script that contains
parameters like '--correction' that aren't necessary for all operation modes.
If you want an option that exists in Argyll, but can't find it here, please
open an issue or send a pull request.
EOF
}
helptext() {
# YAHTACM? nah. That's a dumb name.
# YADCA? Yet another DisplayCal Alternative?
# YAWDISC? Yet Another Wrapper for DispCal?
# YAWA? Yet Another Wrapper for Argyll cms?
# DCAS? DisplayCal Alternative script?
# Not Entirely Unlike Displaycal (NEUD?) Haha, I love it.
# NEUDPROF (Not-Entirely-Unlike-Displaycal PROFiler)
# NEUD-PROFILE: Not Entirely Unlike Displaycal PROFILEr
# Not Entirely Unusable Display Tester: NEUDIST
# NEUDIST-YAC: Not Entirely Unusable Display Tester: Yet Another Color manager
# PROFILE-NEUD: PROFILEr, Not Entirely Unlike Displaycal. Perfect.
# NEUDIST-COLONI-PROF : Not Entirely Unlike Displaycal: The COLOr NormalIzation PROFiler
# NEUDIST-COLONI-PROF : Not Entirely Unlike Displaycal: The COLOr NormalIzation PROFiler
# NEUDIST-PROF: Not Entirely Unlike Displaycal
# Not Entirely Useless Display Tester: NEUDIST
# 'Not Entirely Unlike a Display Tester: NEUDIST'
# NEUDIST is good enough. 'Not Entirely Unlike a Display Tester: NEUDIST' it is.
echo "$PROGNAME"':'
cat << EOF
neudist: Not Entirely Unlike a DISplay Tester.
Yet another a helper tool for Argyll color management.
My stand-in for displaycal, since it is currently inoperable without Python 2.7 and
WxWidgets bindings.
This program should be runnable with no arguments except for a profile name, but
options can also be customized at run-time.
If you want an option that exists in Argyll (or to an extent DisplayCal), but
that does not exist here, please make an issue or pull request at your earliest
convenience and I will try to get it in for you.
By default, calibration and profiling will be done to screen 1 with measuring
device 1, and will target sRGB as closely as I know how to get it.
If your device is not a generic, narrow gamut white LED backlit LCD,
you should at least provide a correction file (if using a colorimeter).
IMPORTANT NOTE:
Unlike Argyll's 'dispcal,' this program currently requires spaces between flags
and their assigned values (no equals signs). If this bothers you more than it
does me, please report an issue and i will try to change this behavior.
EOF
usage
}
if [ $# -eq 0 ]; then
1>&2 usage
exit 0
fi
# prompt for input until desired input is given
# while case "$ynprompt" in [Yy][Ee][Ss]|[Yy]|[Nn][Oo]|[Nn]) false;; *) read -r ynprompt;; esac do echo 'hi'; done
# Pass an argument for the title/dir name of the profile
# parse args until one that doesn't start with '-' is found
while case $1 in -*) true;; *) false;; esac; do
case $1 in
--all)
MODE='all' # this is also the default if no mode is requested
;;
-a|--algorithm)
COLPROF_ALGORITHM='-a'"$2"
shift 1
;;
-3|--3dlut)
MODE='threedeelut' #cant have a function name start with '3'
# 3c is already set as the type at top for COLLINK_3DLUT_TYPE,
# unless overridden
;;
--3dlut-target|--3dlut-icc)
COLLINK_3DLUT_TARGET="$2"
shift 1
;;
--3dlut-res)
COLLINK_3DLUT_RES='-r'"$2"
shift 1
;;
--3dlut-type)
COLLINK_3DLUT_TYPE='-3'"$2"
shift 1
;;
-b|--brightness|--bright|--nits|--cdm2)
# automatic brightness gets used unless this is passed
unset AUTOBRIGHT
BRIGHTNESS="$2"
shift 1
;;
--calibrate|--calib) # when passed, only perform calibration stage
MODE='calib' # name of appropriate function
;;
--calc) # when passed, only perform icc profile creation stage
MODE='profile_calc' # name of appropriate function
;;
-c|--dev|--device) # argyll colorimeter device number
DEVICE='-c'"$2"
shift 1
;;
--colorant)
COLORANT='-d3' # 3=Video RGB, see targen -h
;;
--correction|--cor|--corrections)
CORRECTIONS='-X'"$2"
shift 1
;;
--no-correction|--no-corrections)
NO_CORRECTIONS='1'
CORRECTIONS=''
;;
-d|--display)
DISPLAYNO='-d'"$2"
shift 1
;;
--display-type)
DISPLAYTYPE='-y'"$2"
shift 1
;;
--drift)
DRIFT='-I'"$2"
shift 1
;;
-h|--help)
helptext
exit 0
;;
-i|--input-profile)
COLLINK_INPUT_PROFILE="$2"
shift 1
;;
--intent)
COLPROF_INTENT='-t'"$2"
COLLINK_INTENT='-i'"$2"
shift 1
;;
--intent-sat)
COLPROF_INTENT_SAT='-T'"$2"
shift 1
;;
-g|--gamma)
# see https://www.argyllcms.com/doc/dispcal.html#g
GAMMA_RAMP='-g'"$2"
shift 1
;;
-G|--gamma-actual)
# see https://www.argyllcms.com/doc/dispcal.html#G
GAMMA_RAMP='-G'"$2"
shift 1
;;
-n|--noninteractive)
INTERACTIVE='-Yp'
;;
--patches)
TESTCHART_PATCHES='-f'"$2"
shift 1
;;
--profile)
MODE='profile'
;;
--patch-scale)
WINDOWSIZE="$2"
WINDOWRECT='-P0.5,0.5,'"$WINDOWSIZE"
shift 1
;;
-q|--quality)
level='h'
case "$2" in
[Ll]|[Ll][Oo][Ww])
level=l
;;
[Mm]|[Mm][Ee][Dd][Ii][Uu][Mm])
level=m
;;
[Hh]|[Hh][Ii][Gg][Hh])
level=h
;;
[Uu]|[Uu][Ll][Tt][Rr][Aa])
level=u
;;
*)
1>&2 echo 'Error: invalid quality level specified. Exiting.'
exit 1
;;
esac
COLPROF_QUALITY='-q'"$level"
shift 1
;;
--skip-adjust)
SKIP_ADJUST='-m'
;;
--srgb)
BRIGHTNESS='-b80'
GAMMA='-gs'
TEMPERATURE='-w0.3127,0.3290'
;;
--targen|--testchart)
MODE='testchart'
;;
-t|--temperature|--temp|--colortemp) # temperature
TEMPERATURE='-t'"$2"
shift 1
;;
-w|--whitepoint|--white-point) # whitepoint in coordinates
TEMPERATURE='-w'"$2"
shift 1
;;
--whitepoint-preset) # preset standard values
case "$2" in
'D50'|'d50')
TEMPERATURE='-w0.34567,0.35850'
;;
'D55'|'d55')
TEMPERATURE='-w0.33242,0.34743'
;;
'D65'|'d65')
TEMPERATURE='-w0.31271,0.32902'
;;
'D75'|'d75')
TEMPERATURE='-w0.29902,0.31485'
;;
'D93'|'d93')
TEMPERATURE='-w0.28315,0.29711'
;;
'F2'|'f2')
TEMPERATURE='-w0.37208,0.37529'
;;
'F7'|'f7')
TEMPERATURE='-w0.31292,0.32933'
;;
'F11'|'f11')
TEMPERATURE='-w0.38052,0.37713'
;;
*)
1>&2 echo 'Error: invalid whitepoint preset specified. Exiting.'
exit 1
;;
esac
shift 1
;;
--no-whitepoint)
TEMPERATURE=''
;;
--wyatt)
# secret mode that just sets the things I usually want
COLPROF_INTENT='-tp' # perceptual
# luminance preserving perceptual is a nice balance between clipping
# and loss of visibility of detail, although it reduces overall
# saturation slightly:
COLPROF_INTENT_SAT='-Tlp' # luminance preserving perceptual
COLLINK_INTENT='-ilp'
# TESTCHART_PATCHES=-f500 # default 836
;;
-v|--verbose) # verbosity
if [ "$#" -gt 1 ]; then
# fixme: need to check if expr fails (non-numeric value passed)
case "$(expr "$2" '+' 0)" in # this prevents breaking on numbers with leading zeroes
0)
VERBOSE='' # do not be verbose
shift 1
;;
[1-9]*) # hopefully this will be a real number.
VERBOSE='-v'"$2"
shift 1
;;
*)
if [ "$2" ]; then
VERBOSE='-v2'
fi
;;
esac;
fi
;;
*)
1>&2 echo "Error: Unknown parameter passed: ""$1" 1>&2
exit 1
;;
esac
shift 1
done
if [ "$#" -lt 1 ]; then
echo 'WARNING: No name was given for the output profile. If we continue,'
echo 'a default name ('"'profile'"') will be used.'
yesno 'Is that OK?'
if [ "$?" = '0' ]; then # continue
PROFNAME='profile'
else
exit 0
fi
else
PROFNAME="$1"
shift 1
fi
# if no corrections were provided, and --no-correction(s) was not passed
if ( [ "$MODE" = 'all' ] || [ "$MODE" = 'calib' ] ) && ( [ ! "$CORRECTIONS" ] && [ ! "$NO_CORRECTIONS" ] ); then
echo 'A colorimeter corrections matrix/spectral set (.ccmx/.ccss file) was'
echo 'not given.'
echo "If you meant to use one, please quit here and use '--correction <filename>'"
echo 'to provide an appropriate file.'
echo
echo 'If you are using a spectrometer, rather than a colorimeter, you do not'
echo "need one, and should answer yes to the following prompt."
echo "'--no-correction' can be used to disable this prompt in the future."
echo
yesno 'Continue without a colorimeter corrections matrix? (yes/no)'
if [ "$?" = '1' ]; then # break
echo 'Aborted per user request.'
exit 0
fi
fi
if [ "$AUTOBRIGHT" ]; then
BRIGHTNESS=''
else
if [ "$BRIGHTNESS" ]; then
BRIGHTNESS='-b'"$BRIGHTNESS"
else
1>&2 cat << EOF
Warning: condition that should be unreachable was reached in script while
setting the requested brightness value. Using automatic brightness instead.
EOF
# BRIGHTNESS=''
fi
fi
# info:
#
# v2: verbosity 2
# d1: display 1
# c1: device (colorimeter) 1
# yn: I have no idea at all.
# P: Test window position
# X: correction matrix
# qh: high quality (qm would be medium)
# m: skip adjustment of monitor controls
# w: set white point as chromaticity coordinates
# (t: set white point in degrees kelvin)
# b: brightness (nits)
# gs: srgb curve
# f1.0: idk but use it on lcd's with non absolute zero black point. probably what i was missing doing this before.
# k0: don't automatically set black point, make it zero artificially.
# A4.0: neutral to black point bending rate, 4.0 default
# b: "forces source 0,0,0 to map to destination 0,0,0. This may be useful with
# displays that have a very dark black point, and with an instrument is
# unable to measure it precisely, and where it is known in some other way
# that the display is very well behaved from black (i.e. that it has no
# "dead zone" above zero device input). Using this option with a display
# that is not well behaved, may result in a loss of shadow detail. This
# will override any -k factor."
calib() {
# $DISPLAY
# set -x
echo dispcal \
$VERBOSE \
$INTERACTIVE \
$DEVICE \
$DISPLAYNO \
$DISPLAYTYPE \
$SKIP_ADJUST \
-yn \
"$WINDOWRECT" \
"$CORRECTIONS" \
-qh \
$BLACK_POINT_HACK \
$TEMPERATURE \
$BRIGHTNESS \
$GAMMA_RAMP \
$DRIFT \
-f1.0 \
-k0 \
-A4.0 \
-b \
"$1"
dispcal \
$VERBOSE \
$INTERACTIVE \
$DEVICE \
$DISPLAYNO \
$DISPLAYTYPE \
$GAMMA_RAMP \
$SKIP_ADJUST \
-yn \
"$WINDOWRECT" \
"$CORRECTIONS" \
-qh \
$BLACK_POINT_HACK \
$TEMPERATURE \
$BRIGHTNESS \
$GAMMA_RAMP \
$DRIFT \
-f1.0 \
-k0 \
-A4.0 \
-b \
"$1"
}
# profile
profile() {
# dispread only has one verbosity level, unlike dispcal.
VERB_PROF=''
if [ "$VERBOSE" ]; then
VERB_PROF='-v'
fi
# k: load calibration into VGCT while reading
echo dispread \
$VERB_PROF \
$DEVICE \
$DISPLAYNO \
$DISPLAYTYPE \
$INTERACTIVE \
-c1 \
$DRIFT \
-yn \
"$WINDOWRECT" \
"$CORRECTIONS" \
-k"$1"'.cal' \
"$1"
dispread \
$VERB_PROF \
$DEVICE \
$DISPLAYNO \
$DISPLAYTYPE \
$INTERACTIVE \
-c1 \
$DRIFT \
-yn \
"$WINDOWRECT" \
"$CORRECTIONS" \
-k"$1"'.cal' \
"$1"
}
# actually make an icc profile from info from the .ti3
# v: verbose
# D: description
# aX: XYZLUT + matrixh
profile_calc() {
#colprof -v -D"$1"' - Argyll CMS' -qh -aX "$1"
# displaycal log: -v -qh -aX -bn -C 'copyright'
# OBSERVER "1931_2"
# USE_BLACK_POINT_COMPENSATION "NO"
# BLACK_POINT_CORRECTION "0.0"
# HIRES_B2A "YES"
# HIRES_B2A_SIZE "-1"
# SMOOTH_B2A "YES"
# PATCH_SEQUENCE "OPTIMIZE_DISPLAY_RESPONSE_DELAY"
if [ "$BLACK_POINT_HACK" ]; then
# doesn't actually work, even though documented?!?
# COLPROF_BLACKPT='-B0,0,0'
COLPROF_BLACKPT=''
else
COLPROF_BLACKPT=''
fi
set -x
colprof \
$COLPROF_ALGORITHM \
$COLPROF_QUALITY \
$COLPROF_BLACKPT \
-v \
$COLPROF_INTENT \
$COLPROF_INTENT_SAT \
'-S'"$COLLINK_INPUT_PROFILE" \
-D"$1"' - Argyll CMS' \
-qh "$1"
}
# need to use targen to make a .ti1 file
# d3: video rgb
# f500: 500 patches
testchart() {
echo targen $COLORANT $TESTCHART_PATCHES "$1"
targen $COLORANT $TESTCHART_PATCHES "$1"
}
profile_check() {
profcheck \
"$1"'.ti3' \
"$1"'.icc'
}
# make the actual .icc file containing profile-based lookup tables
create_plot() {
iccgamut \
-v \
-w \
-ir \
-ff \
-on \
-d10.00 \
"$1"'.icc'
}
# currently unused
view_gamuts_1() {
viewgam \
-cw \
-t0 \
-w /usr/share/DisplayCAL/ref/sRGB.gam \
-cn \
-t.3 \
-s "$1"'.gam' \
-i "$1"'.wrl'
}
# currently unused
view_gamuts_2() {
viewgam\
-cw \
-t0 \
-w /usr/share/DisplayCAL/ref/ClayRGB1998.gam \
-cn \
-t.3 \
-s"$1"'.gam' \
-i"$1"' vs ClayRGB1998.wrl'
}
# currently unused
view_gamuts_3() {
viewgam \
-cw \
-t0 \
-w /usr/share/DisplayCAL/ref/SMPTE431_P3.gam \
-cn \
-t.3 \
-s "$1"'.gam' \
-i "$1"' vs SMPTE431_P3.wrl'
}
all () {
main "$@"
}
main() {
# echo 'waiting ten seconds for the user to do whatever.'
# sleep 10
# xcalib -c # same as dispwin -c, but xcalib is not part of Argyll CMS
# reset "ramdac" color ramps
dispwin $DISPLAYNO -c # TODO: make it possible to specify which display to reset
calib "$@"
testchart "$1"
profile "$@"
profile_calc "$@"
profile_check "$1"
}
# debug
most() {
profile "$@"
profile_calc "$@"
profile_check "$1"
}
# colprof -v -S /usr/share/color/argyll/ref/sRGB.icm -D'4000k_10nit - Argyll CMS' -qh 4000k_10nit
# this is to make a 3dlut
threedeelut() {
# v: verbose
# qh: quality high
# G: gamut mapping mode using inverse outprofile A2B
# ip: Perceptual intent (default)
# alternatives:
# ia: absolute
# iaw: absolute with scaling to fit white point
# iaa: absolute appearance
# ilp: luminance preserving perceptual appearance (desaturated)
# ip: perceptual
# ipa: perceptual appearance
# ims: saturation
# is: enhanced saturation
# ial: absolute colorimetric lab
# irl: white point matched colorimetric lab
# r64: clut resolution 64x64x64
# n: Don't preserve device linearization curves in result
# (if using a RAMDAC/gamma ramps you want to keep this)
# 3: make a 3D LUT as well as devlink (IRIDAS cube)
# options:
# 3e: eeColor txt
# 3m: MadVR 3dlut
# 3c: IRIDAS cube
# en: video encode input as:
# en: normal
# et: 16-235/255 (TV RGB)
# (THERE ARE MORE I DIDN'T WRITE DOWN)
# En: video encode output as above^
# b: "Forces RGB source 0,0,0 to map to RGB destination 0,0,0.
# This may be useful for Video proofing/calibration purposes,
# where the source is a standard colorspace such as Rec709, and
# the display device is well behaved with black at 0,0,0, and
# forcing the black mapping avoids any slight raising of the black
# due to display profile tolerances. On the other hand, any "dead
# zone" above zero device input, won't be corrected."
# (black point hack)
# fixme: hardcoded icm file.
# fixme: catch if in 3dlut mode and --3dlut-target wasn't provided here.
LUTNAME="$1" # PROFNAME
shift 1
echo /usr/bin/collink \
-v \
"$COLPROF_QUALITY" \
-G \
"$COLLINK_INTENT" \
"$COLLINK_RES" \
"$BLACK_POINT_HACK" \
-n \
"$COLLINK_3DLUT_TYPE" \
-en \
-En \
"$COLLINK_INPUT_PROFILE" \
"$COLLINK_3DLUT_TARGET" \
"$LUTNAME".icc
/usr/bin/collink \
-v \
"$COLPROF_QUALITY" \
-G \
"$COLLINK_INTENT" \
"$COLLINK_RES" \
"$BLACK_POINT_HACK" \
-n \
"$COLLINK_3DLUT_TYPE" \
-en \
-En \
"$COLLINK_INPUT_PROFILE" \
"$COLLINK_3DLUT_TARGET" \
"$LUTNAME".icc
# need to run twice in order to get the calibration curves in the .icc
# iccvcgt -i
}
# todo: find a better solution for this.
echo 'Running in mode "'"$MODE"'".'