diff options
Diffstat (limited to 'spectro')
-rw-r--r-- | spectro/conv.c | 5 | ||||
-rw-r--r-- | spectro/disptechs.c | 109 | ||||
-rw-r--r-- | spectro/disptechs.h | 3 | ||||
-rw-r--r-- | spectro/inst.c | 43 | ||||
-rw-r--r-- | spectro/inst.h | 1 | ||||
-rw-r--r-- | spectro/linear.cal | 272 | ||||
-rw-r--r-- | spectro/spec2cie.c | 163 | ||||
-rw-r--r-- | spectro/strange.cal | 272 |
8 files changed, 731 insertions, 137 deletions
diff --git a/spectro/conv.c b/spectro/conv.c index 1f4d102..1a8c78b 100644 --- a/spectro/conv.c +++ b/spectro/conv.c @@ -130,11 +130,11 @@ int next_con_char(void) { return c; } -/* Horrible hack to poll stdin when we're not interactive */ +/* Horrible hack to poll stdin when we're not interactive. */ /* This has the drawback that the char and returm must be */ /* written in one operation for the character to be recognised - */ /* trying to do this manually typically doesn't work unless you are */ -/* very fast an lucky. */ +/* very fast and lucky. */ static int th_read_char(void *pp) { char *rp = (char *)pp; HANDLE stdinh; @@ -166,6 +166,7 @@ int poll_con_char(void) { /* any of MSWin's async file read functions, because we */ /* have no way of ensuring that the STD_INPUT_HANDLE has been */ /* opened with FILE_FLAG_OVERLAPPED. Used a thread instead... */ + /* ReOpenFile() would fix this, but it's not available in WinXP, only Visa+ :-( */ if ((getch_thread = new_athread(th_read_char, &c)) != NULL) { HANDLE stdinh; diff --git a/spectro/disptechs.c b/spectro/disptechs.c index d44519c..70e150f 100644 --- a/spectro/disptechs.c +++ b/spectro/disptechs.c @@ -56,7 +56,7 @@ /* We deliberately duplicate the selection characters, */ /* because it's not usual to offer the whole list, just */ -/* a sub-set, which may not clash. */ +/* a sub-set which may not clash. */ /* disptechs_set_sel() should be used to present */ /* unique selectors. */ static disptech_info disptech_info_array[] = { @@ -387,52 +387,72 @@ disptech_info *disptech_get_strid(char *strid) { so we need to do three passes through all the selections. */ -/* Set the selection characters. */ -/* Return NZ if we have not set all selectors */ -/* If a selector is set, its index will be set in usels[], */ -/* and any remaining selection characters deleted. */ -/* If flag == 0, set from just first suggested selector */ -/* If flag == 1, set from just suggested selector */ +/* Append the selection characters. */ +/* If a selector is set, its index will be set in usels[]. */ +/* Remove any used selectors from isel[]. */ +/* If flag == 0, set from just first suggested selector. */ +/* If flag == 1, set from just suggested selectors. */ /* If flag == 2, set from suggested and fallback selectors */ -/* If flag == 3, set from suggested and fallback selectors, and set unset to nul */ -int disptechs_set_sel( +/* If flag == 3, append from suggested selectors */ +void disptechs_set_sel( int flag, /* See above */ int ix, /* Index of entry being set */ - char *sel, /* Pointer to string list of suggested selectors, */ - /* return a single unique selector in string. */ + char *osel, /* Append unique selectors to this string. */ + char *isel, /* Pointer to string list of suggested selectors, */ char *usels, /* char[256] initially -1, to track used selector entry index */ int *k, /* Index of next available selector in asels */ char *asels /* String list of fallback selectors to choose from, in order. */ ) { - char *d, *s, i; + char *iisel = isel, i; -//a1logd(g_log, 1,"disptechs_set_sel: flag %d, ix %d, sel '%s', k %d\n",flag, ix,sel,*k); +//a1logd(g_log, 1,"disptechs_set_sel: flag %d, ix %d, osel '%s', isel '%s', k %d\n",flag, ix,osel,isel,*k); - /* See if this has already been allocated */ - if (usels[*sel] == ix) { -//a1logd(g_log, 1," set OK\n"); - return 0; /* Nothing to do */ + if (flag != 3) { + /* See if we already have a selecor character */ + if (osel[0] != '\000') { +//a1logd(g_log, 1," already set OK\n"); + return; + } + } else { + if (isel[0] == '\000') { +//a1logd(g_log, 1," nothing to set from\n"); + return; /* Nothing to set from */ + } + + /* Get ready to append */ + osel += strlen(osel); } - /* Set from the suggested selectors */ - for (i = 0, s = sel; *s != '\000'; s++, i++) { + /* Set or add from the first unsed suggested selectors */ + for (i = 0; *isel != '\000'; isel++, i++) { if (flag == 0 && i > 0) { //a1logd(g_log, 1," run out of primaries\n"); break; /* Looked at primary */ } - if (usels[*s] == ((char)-1)) { /* If this selector is not currently used */ -//a1logd(g_log, 1," set to '%c' at %d\n", *s, i); - sel[0] = *s; /* Use it */ - sel[1] = '\000'; - usels[*s] = ix; - return 0; + if (usels[*isel] == ((char)-1)) { /* If this selector is not currently used */ +//a1logd(g_log, 1," added to '%c' from %d\n", *isel, i); + osel[0] = *isel; /* Use it */ + osel[1] = '\000'; + usels[osel[0]] = ix; + + /* Remove all used/discarded from isel, in case we are called again. */ + for (isel++; ;isel++, iisel++) { + *iisel = *isel; + if (*isel == '\000') + break; + } + return; } -//a1logd(g_log, 1," sel '%c' at %d is used by ix %d\n", *s, i, usels[*s]); +//a1logd(g_log, 1," sel '%c' at %d is used by ix %d\n", *isel, i, usels[*isel]); } - if (flag <= 2) { -//a1logd(g_log, 1," returning unset\n"); - return 1; + /* If we get here, we haven't managed to add anything from the remaining */ + /* selectors, so mark the candidate list as empty: */ + iisel[0] = '\000'; + + if (flag != 2) { +//a1logd(g_log, 1," returning without add\n"); + return; } /* Get the next unused char in fallback list */ @@ -442,22 +462,16 @@ int disptechs_set_sel( } if (asels[*k] != '\000') { //a1logd(g_log, 1," set int to fallback '%c' at %d\n", asels[*k], *k); - sel[0] = asels[*k]; - sel[1] = '\000'; - usels[sel[0]] = ix; + osel[0] = asels[*k]; + osel[1] = '\000'; + usels[osel[0]] = ix; (*k)++; - return 0; - } - - /* Set any unset to nul */ - if (flag >= 3) { -//a1logd(g_log, 1," clearing\n"); - sel[0] = '\000'; + return; } -//a1logd(g_log, 1," failed\n"); - /* If we got here, we failed */ - return 1; +//a1logd(g_log, 1," returning after fallback without add\n"); + /* If we got here, we failed to add a selector */ + return; } /* Return the display tech list with unique lsel lectors */ @@ -474,18 +488,19 @@ disptech_info *disptech_get_list() { /* Add entries from the static list and their primary selectors */ for (i = 0; list[i].dtech != disptech_end; i++) { -//a1logd(1,"tech[%d] '%s' sels = '%s'\n",i,list[i].desc,list[i].sel); - strcpy(list[i].lsel, list[i].sel); - disptechs_set_sel(0, i, list[i].lsel, usels, &k, asels); +//a1logd(g_log,1,"tech[%d] '%s' sels = '%s'\n",i,list[i].desc,list[i].sel); + strcpy(list[i].isel, list[i].sel); + list[i].lsel[0] = '\000'; + disptechs_set_sel(0, i, list[i].lsel, list[i].isel, usels, &k, asels); } /* Set selectors from secondary */ for (i = 0; list[i].dtech != disptech_end; i++) - disptechs_set_sel(1, i, list[i].lsel, usels, &k, asels); + disptechs_set_sel(1, i, list[i].lsel, list[i].isel, usels, &k, asels); /* Set remainder from fallback */ for (i = 0; list[i].dtech != disptech_end; i++) - disptechs_set_sel(3, i, list[i].lsel, usels, &k, asels); + disptechs_set_sel(2, i, list[i].lsel, list[i].isel, usels, &k, asels); return list; } diff --git a/spectro/disptechs.h b/spectro/disptechs.h index 68245cf..9860eac 100644 --- a/spectro/disptechs.h +++ b/spectro/disptechs.h @@ -114,6 +114,7 @@ struct _disptech_info { /* Private: */ char lsel[10]; /* Unique list selector for ui */ + char isel[10]; /* Candidate selectors */ }; typedef struct _disptech_info disptech_info; @@ -137,7 +138,7 @@ disptech_info *disptech_select(disptech_info *list, char c); /* utility function, used by disptech_get_list & inst_creat_disptype_list() */ /* See disptechs.c for parameter description. */ -int disptechs_set_sel(int flag, int ix, char *sel, char *usels, int *k, char *asels); +void disptechs_set_sel(int flag, int ix, char *osel, char *isel, char *usels, int *k, char *asels); /* - - - - - - - - - - */ /* Display settling time model */ diff --git a/spectro/inst.c b/spectro/inst.c index ba12f9d..949e34f 100644 --- a/spectro/inst.c +++ b/spectro/inst.c @@ -875,9 +875,11 @@ int doccmx /* Add matching installed ccmx files */ usels[i] = ((char)-1); k = 0; /* Next selector index */ + /* First create a list of calibrations and their desired selectors: */ + /* Add entries from the static list and their primary selectors */ /* (We're currently assuming that calibrations that the instrument */ - /* returns are not custom) */ + /* returns are not custom.) */ /* Count the number in the static list. */ for (i = 0; !(sdtlist[i].flags & inst_dtflags_end); i++) { @@ -966,25 +968,52 @@ int doccmx /* Add matching installed ccmx files */ } } + /* Copy candidate selectors to private isel[] list */ + for (i = 0; i < nlist; i++) { + strcpy(list[i].isel, list[i].sel); + list[i].sel[0] = '\000'; + } + + /* Then allocate a slector for each calibration: */ + /* Set selectors from primary for cbid or custom first */ for (i = 0; i < nlist; i++) { if (list[i].cbid > 0 || (list[i].flags & inst_dtflags_custom) != 0) { - disptechs_set_sel(0, i, list[i].sel, usels, &k, asels); + disptechs_set_sel(0, i, list[i].sel, list[i].isel, usels, &k, asels); } } /* Set selectors from primary for rest */ for (i = 0; i < nlist; i++) - disptechs_set_sel(0, i, list[i].sel, usels, &k, asels); + disptechs_set_sel(0, i, list[i].sel, list[i].isel, usels, &k, asels); - /* Set remaining selectors from secondaries */ + /* Set remaining selectors from primaries or secondaries */ for (i = 0; i < nlist; i++) - disptechs_set_sel(1, i, list[i].sel, usels, &k, asels); + disptechs_set_sel(1, i, list[i].sel, list[i].isel, usels, &k, asels); - /* Set remaining from fallback (or give up and set to null) */ + /* Set remaining from fallback */ for (i = 0; i < nlist; i++) { - fail = disptechs_set_sel(3, i, list[i].sel, usels, &k, asels); + disptechs_set_sel(2, i, list[i].sel, list[i].isel, usels, &k, asels); + if (list[i].sel[0] == '\000') + fail = 1; + } + + /* Any calibrations that failed to find a character will be left as a nul string */ + + /* Add alternate selectors if they are free. */ + for (;;) { + int more = 0; + for (i = 0; i < nlist; i++) { + /* Add unused secondaries */ + disptechs_set_sel(3, i, list[i].sel, list[i].isel, usels, &k, asels); + + if (list[i].isel[0] != '\000') { /* Still more secondaries available */ + more = 1; + } + } + if (!more) + break; } if (pndtlist != NULL) diff --git a/spectro/inst.h b/spectro/inst.h index 00dd9b3..d47f7ea 100644 --- a/spectro/inst.h +++ b/spectro/inst.h @@ -390,6 +390,7 @@ typedef struct _inst_disptypesel { /* Private: */ int ix; /* Internal index, */ + char isel[INST_DTYPE_SEL_LEN]; /* String of potential selector characters */ // Stuff for ccss & ccmx char *path; /* Path to ccss or ccmx. NULL if not valid */ diff --git a/spectro/linear.cal b/spectro/linear.cal new file mode 100644 index 0000000..96cad93 --- /dev/null +++ b/spectro/linear.cal @@ -0,0 +1,272 @@ +CAL + +DESCRIPTOR "Argyll Device Calibration Curves" +ORIGINATOR "Argyll synthcal" +CREATED "Mon Sep 07 03:37:56 2015" +DEVICE_CLASS "DISPLAY" +COLOR_REP "RGB" + +NUMBER_OF_FIELDS 4 +BEGIN_DATA_FORMAT +RGB_I RGB_R RGB_G RGB_B +END_DATA_FORMAT + +NUMBER_OF_SETS 256 +BEGIN_DATA +0.00000 0.00000 0.00000 0.00000 +0.00392157 0.00392157 0.00392157 0.00392157 +0.00784314 0.00784314 0.00784314 0.00784314 +0.0117647 0.0117647 0.0117647 0.0117647 +0.0156863 0.0156863 0.0156863 0.0156863 +0.0196078 0.0196078 0.0196078 0.0196078 +0.0235294 0.0235294 0.0235294 0.0235294 +0.0274510 0.0274510 0.0274510 0.0274510 +0.0313725 0.0313725 0.0313725 0.0313725 +0.0352941 0.0352941 0.0352941 0.0352941 +0.0392157 0.0392157 0.0392157 0.0392157 +0.0431373 0.0431373 0.0431373 0.0431373 +0.0470588 0.0470588 0.0470588 0.0470588 +0.0509804 0.0509804 0.0509804 0.0509804 +0.0549020 0.0549020 0.0549020 0.0549020 +0.0588235 0.0588235 0.0588235 0.0588235 +0.0627451 0.0627451 0.0627451 0.0627451 +0.0666667 0.0666667 0.0666667 0.0666667 +0.0705882 0.0705882 0.0705882 0.0705882 +0.0745098 0.0745098 0.0745098 0.0745098 +0.0784314 0.0784314 0.0784314 0.0784314 +0.0823529 0.0823529 0.0823529 0.0823529 +0.0862745 0.0862745 0.0862745 0.0862745 +0.0901961 0.0901961 0.0901961 0.0901961 +0.0941176 0.0941176 0.0941176 0.0941176 +0.0980392 0.0980392 0.0980392 0.0980392 +0.101961 0.101961 0.101961 0.101961 +0.105882 0.105882 0.105882 0.105882 +0.109804 0.109804 0.109804 0.109804 +0.113725 0.113725 0.113725 0.113725 +0.117647 0.117647 0.117647 0.117647 +0.121569 0.121569 0.121569 0.121569 +0.125490 0.125490 0.125490 0.125490 +0.129412 0.129412 0.129412 0.129412 +0.133333 0.133333 0.133333 0.133333 +0.137255 0.137255 0.137255 0.137255 +0.141176 0.141176 0.141176 0.141176 +0.145098 0.145098 0.145098 0.145098 +0.149020 0.149020 0.149020 0.149020 +0.152941 0.152941 0.152941 0.152941 +0.156863 0.156863 0.156863 0.156863 +0.160784 0.160784 0.160784 0.160784 +0.164706 0.164706 0.164706 0.164706 +0.168627 0.168627 0.168627 0.168627 +0.172549 0.172549 0.172549 0.172549 +0.176471 0.176471 0.176471 0.176471 +0.180392 0.180392 0.180392 0.180392 +0.184314 0.184314 0.184314 0.184314 +0.188235 0.188235 0.188235 0.188235 +0.192157 0.192157 0.192157 0.192157 +0.196078 0.196078 0.196078 0.196078 +0.200000 0.200000 0.200000 0.200000 +0.203922 0.203922 0.203922 0.203922 +0.207843 0.207843 0.207843 0.207843 +0.211765 0.211765 0.211765 0.211765 +0.215686 0.215686 0.215686 0.215686 +0.219608 0.219608 0.219608 0.219608 +0.223529 0.223529 0.223529 0.223529 +0.227451 0.227451 0.227451 0.227451 +0.231373 0.231373 0.231373 0.231373 +0.235294 0.235294 0.235294 0.235294 +0.239216 0.239216 0.239216 0.239216 +0.243137 0.243137 0.243137 0.243137 +0.247059 0.247059 0.247059 0.247059 +0.250980 0.250980 0.250980 0.250980 +0.254902 0.254902 0.254902 0.254902 +0.258824 0.258824 0.258824 0.258824 +0.262745 0.262745 0.262745 0.262745 +0.266667 0.266667 0.266667 0.266667 +0.270588 0.270588 0.270588 0.270588 +0.274510 0.274510 0.274510 0.274510 +0.278431 0.278431 0.278431 0.278431 +0.282353 0.282353 0.282353 0.282353 +0.286275 0.286275 0.286275 0.286275 +0.290196 0.290196 0.290196 0.290196 +0.294118 0.294118 0.294118 0.294118 +0.298039 0.298039 0.298039 0.298039 +0.301961 0.301961 0.301961 0.301961 +0.305882 0.305882 0.305882 0.305882 +0.309804 0.309804 0.309804 0.309804 +0.313725 0.313725 0.313725 0.313725 +0.317647 0.317647 0.317647 0.317647 +0.321569 0.321569 0.321569 0.321569 +0.325490 0.325490 0.325490 0.325490 +0.329412 0.329412 0.329412 0.329412 +0.333333 0.333333 0.333333 0.333333 +0.337255 0.337255 0.337255 0.337255 +0.341176 0.341176 0.341176 0.341176 +0.345098 0.345098 0.345098 0.345098 +0.349020 0.349020 0.349020 0.349020 +0.352941 0.352941 0.352941 0.352941 +0.356863 0.356863 0.356863 0.356863 +0.360784 0.360784 0.360784 0.360784 +0.364706 0.364706 0.364706 0.364706 +0.368627 0.368627 0.368627 0.368627 +0.372549 0.372549 0.372549 0.372549 +0.376471 0.376471 0.376471 0.376471 +0.380392 0.380392 0.380392 0.380392 +0.384314 0.384314 0.384314 0.384314 +0.388235 0.388235 0.388235 0.388235 +0.392157 0.392157 0.392157 0.392157 +0.396078 0.396078 0.396078 0.396078 +0.400000 0.400000 0.400000 0.400000 +0.403922 0.403922 0.403922 0.403922 +0.407843 0.407843 0.407843 0.407843 +0.411765 0.411765 0.411765 0.411765 +0.415686 0.415686 0.415686 0.415686 +0.419608 0.419608 0.419608 0.419608 +0.423529 0.423529 0.423529 0.423529 +0.427451 0.427451 0.427451 0.427451 +0.431373 0.431373 0.431373 0.431373 +0.435294 0.435294 0.435294 0.435294 +0.439216 0.439216 0.439216 0.439216 +0.443137 0.443137 0.443137 0.443137 +0.447059 0.447059 0.447059 0.447059 +0.450980 0.450980 0.450980 0.450980 +0.454902 0.454902 0.454902 0.454902 +0.458824 0.458824 0.458824 0.458824 +0.462745 0.462745 0.462745 0.462745 +0.466667 0.466667 0.466667 0.466667 +0.470588 0.470588 0.470588 0.470588 +0.474510 0.474510 0.474510 0.474510 +0.478431 0.478431 0.478431 0.478431 +0.482353 0.482353 0.482353 0.482353 +0.486275 0.486275 0.486275 0.486275 +0.490196 0.490196 0.490196 0.490196 +0.494118 0.494118 0.494118 0.494118 +0.498039 0.498039 0.498039 0.498039 +0.501961 0.501961 0.501961 0.501961 +0.505882 0.505882 0.505882 0.505882 +0.509804 0.509804 0.509804 0.509804 +0.513725 0.513725 0.513725 0.513725 +0.517647 0.517647 0.517647 0.517647 +0.521569 0.521569 0.521569 0.521569 +0.525490 0.525490 0.525490 0.525490 +0.529412 0.529412 0.529412 0.529412 +0.533333 0.533333 0.533333 0.533333 +0.537255 0.537255 0.537255 0.537255 +0.541176 0.541176 0.541176 0.541176 +0.545098 0.545098 0.545098 0.545098 +0.549020 0.549020 0.549020 0.549020 +0.552941 0.552941 0.552941 0.552941 +0.556863 0.556863 0.556863 0.556863 +0.560784 0.560784 0.560784 0.560784 +0.564706 0.564706 0.564706 0.564706 +0.568627 0.568627 0.568627 0.568627 +0.572549 0.572549 0.572549 0.572549 +0.576471 0.576471 0.576471 0.576471 +0.580392 0.580392 0.580392 0.580392 +0.584314 0.584314 0.584314 0.584314 +0.588235 0.588235 0.588235 0.588235 +0.592157 0.592157 0.592157 0.592157 +0.596078 0.596078 0.596078 0.596078 +0.600000 0.600000 0.600000 0.600000 +0.603922 0.603922 0.603922 0.603922 +0.607843 0.607843 0.607843 0.607843 +0.611765 0.611765 0.611765 0.611765 +0.615686 0.615686 0.615686 0.615686 +0.619608 0.619608 0.619608 0.619608 +0.623529 0.623529 0.623529 0.623529 +0.627451 0.627451 0.627451 0.627451 +0.631373 0.631373 0.631373 0.631373 +0.635294 0.635294 0.635294 0.635294 +0.639216 0.639216 0.639216 0.639216 +0.643137 0.643137 0.643137 0.643137 +0.647059 0.647059 0.647059 0.647059 +0.650980 0.650980 0.650980 0.650980 +0.654902 0.654902 0.654902 0.654902 +0.658824 0.658824 0.658824 0.658824 +0.662745 0.662745 0.662745 0.662745 +0.666667 0.666667 0.666667 0.666667 +0.670588 0.670588 0.670588 0.670588 +0.674510 0.674510 0.674510 0.674510 +0.678431 0.678431 0.678431 0.678431 +0.682353 0.682353 0.682353 0.682353 +0.686275 0.686275 0.686275 0.686275 +0.690196 0.690196 0.690196 0.690196 +0.694118 0.694118 0.694118 0.694118 +0.698039 0.698039 0.698039 0.698039 +0.701961 0.701961 0.701961 0.701961 +0.705882 0.705882 0.705882 0.705882 +0.709804 0.709804 0.709804 0.709804 +0.713725 0.713725 0.713725 0.713725 +0.717647 0.717647 0.717647 0.717647 +0.721569 0.721569 0.721569 0.721569 +0.725490 0.725490 0.725490 0.725490 +0.729412 0.729412 0.729412 0.729412 +0.733333 0.733333 0.733333 0.733333 +0.737255 0.737255 0.737255 0.737255 +0.741176 0.741176 0.741176 0.741176 +0.745098 0.745098 0.745098 0.745098 +0.749020 0.749020 0.749020 0.749020 +0.752941 0.752941 0.752941 0.752941 +0.756863 0.756863 0.756863 0.756863 +0.760784 0.760784 0.760784 0.760784 +0.764706 0.764706 0.764706 0.764706 +0.768627 0.768627 0.768627 0.768627 +0.772549 0.772549 0.772549 0.772549 +0.776471 0.776471 0.776471 0.776471 +0.780392 0.780392 0.780392 0.780392 +0.784314 0.784314 0.784314 0.784314 +0.788235 0.788235 0.788235 0.788235 +0.792157 0.792157 0.792157 0.792157 +0.796078 0.796078 0.796078 0.796078 +0.800000 0.800000 0.800000 0.800000 +0.803922 0.803922 0.803922 0.803922 +0.807843 0.807843 0.807843 0.807843 +0.811765 0.811765 0.811765 0.811765 +0.815686 0.815686 0.815686 0.815686 +0.819608 0.819608 0.819608 0.819608 +0.823529 0.823529 0.823529 0.823529 +0.827451 0.827451 0.827451 0.827451 +0.831373 0.831373 0.831373 0.831373 +0.835294 0.835294 0.835294 0.835294 +0.839216 0.839216 0.839216 0.839216 +0.843137 0.843137 0.843137 0.843137 +0.847059 0.847059 0.847059 0.847059 +0.850980 0.850980 0.850980 0.850980 +0.854902 0.854902 0.854902 0.854902 +0.858824 0.858824 0.858824 0.858824 +0.862745 0.862745 0.862745 0.862745 +0.866667 0.866667 0.866667 0.866667 +0.870588 0.870588 0.870588 0.870588 +0.874510 0.874510 0.874510 0.874510 +0.878431 0.878431 0.878431 0.878431 +0.882353 0.882353 0.882353 0.882353 +0.886275 0.886275 0.886275 0.886275 +0.890196 0.890196 0.890196 0.890196 +0.894118 0.894118 0.894118 0.894118 +0.898039 0.898039 0.898039 0.898039 +0.901961 0.901961 0.901961 0.901961 +0.905882 0.905882 0.905882 0.905882 +0.909804 0.909804 0.909804 0.909804 +0.913725 0.913725 0.913725 0.913725 +0.917647 0.917647 0.917647 0.917647 +0.921569 0.921569 0.921569 0.921569 +0.925490 0.925490 0.925490 0.925490 +0.929412 0.929412 0.929412 0.929412 +0.933333 0.933333 0.933333 0.933333 +0.937255 0.937255 0.937255 0.937255 +0.941176 0.941176 0.941176 0.941176 +0.945098 0.945098 0.945098 0.945098 +0.949020 0.949020 0.949020 0.949020 +0.952941 0.952941 0.952941 0.952941 +0.956863 0.956863 0.956863 0.956863 +0.960784 0.960784 0.960784 0.960784 +0.964706 0.964706 0.964706 0.964706 +0.968627 0.968627 0.968627 0.968627 +0.972549 0.972549 0.972549 0.972549 +0.976471 0.976471 0.976471 0.976471 +0.980392 0.980392 0.980392 0.980392 +0.984314 0.984314 0.984314 0.984314 +0.988235 0.988235 0.988235 0.988235 +0.992157 0.992157 0.992157 0.992157 +0.996078 0.996078 0.996078 0.996078 +1.000000 1.000000 1.000000 1.000000 +END_DATA diff --git a/spectro/spec2cie.c b/spectro/spec2cie.c index c9e570c..aa91ebb 100644 --- a/spectro/spec2cie.c +++ b/spectro/spec2cie.c @@ -514,8 +514,10 @@ main(int argc, char *argv[]) { int sidx; /* Sample ID index */ - int ti, ii, Xi, Yi, Zi, Li, ai, bi; + int ti, ii; + int Xi, Yi, Zi, Li, ai, bi; /* CGATS indexes for each field */ int spi[XSPECT_MAX_BANDS]; /* CGATS indexes for each wavelength */ + int oXi, oYi, oZi, oLi, oai, obi; /* CGATS indexes for each ouput field */ xsp2cie *sp2cie; /* Spectral conversion object */ xspect sp; double XYZ[3]; @@ -572,13 +574,17 @@ main(int argc, char *argv[]) /* copy fields to output file (except spectral if nospec) */ for (i = 0; i < icg->t[0].nfields; i++) { - /* See if this is a input spectral field */ - for (j = 0; nospec && j < sp.spec_n; j++) { - if (spi[j] == i) - break; /* Yes it is */ + + if (nospec) { + for (j = 0; nospec && j < sp.spec_n; j++) { + if (spi[j] == i) { + break; /* Yes it is */ + } + } + if (j < sp.spec_n) + continue; /* Skip it */ } - if (nospec == 0 || j >= sp.spec_n) - ocg->add_field (ocg, 0, icg->t[0].fsym[i], icg->t[0].ftype[i]); + ocg->add_field (ocg, 0, icg->t[0].fsym[i], icg->t[0].ftype[i]); } /* create field for XYZ and Lab if not present */ @@ -607,6 +613,13 @@ main(int argc, char *argv[]) if ((bi = ocg->add_field(ocg, 0, "LAB_B", r_t)) < 0) error ("Cannot add field to table"); + oXi = Xi; + oYi = Yi; + oZi = Zi; + oLi = Li; + oai = ai; + obi = bi; + /* allocate elements */ if ((elems = (cgats_set_elem *) @@ -746,25 +759,40 @@ main(int argc, char *argv[]) xspect corr_sp; /* copy all input colums to output (except spectral if nospec) */ - for (jj = j = 0; j < icg->t[0].nfields; j++) { - for (k = 0; nospec && k < sp.spec_n; k++) { - if (spi[k] == j) - break; - } - if (nospec == 0 || k >= sp.spec_n) { - switch (icg->t[0].ftype[j]) { - case r_t: - elems[jj].d = *((double *) icg->t[0].fdata[i][j]); - break; - case i_t: - elems[jj].i = *((int *) icg->t[0].fdata[i][j]); + + if (nospec) { + /* See if this is a spectral field */ + for (k = 0; nospec && k < sp.spec_n; k++) { + if (spi[k] == j) break; - default: - elems[jj].c = (char *) icg->t[0].fdata[i][j]; } - jj++; + + /* It is a spectral field */ + if (k < sp.spec_n) { + continue; /* Skip it */ + } } + + /* Correct the other fields location in output */ + if (j == Xi) oXi = jj; + if (j == Yi) oYi = jj; + if (j == Zi) oZi = jj; + if (j == Li) oLi = jj; + if (j == ai) oai = jj; + if (j == bi) obi = jj; + + switch (icg->t[0].ftype[j]) { + case r_t: + elems[jj].d = *((double *) icg->t[0].fdata[i][j]); + break; + case i_t: + elems[jj].i = *((int *) icg->t[0].fdata[i][j]); + break; + default: + elems[jj].c = (char *) icg->t[0].fdata[i][j]; + } + jj++; } /* Read the spectral values for this patch */ @@ -781,63 +809,16 @@ main(int argc, char *argv[]) /* Write the corrected spectral values for this patch */ if (nospec == 0) { for (j = 0; j < sp.spec_n; j++) { - elems[spi[j]].d = corr_sp.spec[j]; + elems[spi[j]].d = sp.spec[j] = corr_sp.spec[j]; } } -#ifdef ALLOW_PLOT - if (doplot) { - int ii; - double xx[XRES]; - double y1[XRES]; - double y2[XRES]; - double lab[3]; - - icmXYZ2Lab(&icmD50, lab, XYZ); - printf("Patch %d, XYZ = %f %f %f, Lab = %f %f %f\n",i, - XYZ[0], XYZ[1], XYZ[2], lab[0], lab[1], lab[2]); - - /* Plot spectrum out */ - for (ii = 0; ii < XRES; ii++) { - double ww; - - ww = (sp.spec_wl_long - sp.spec_wl_short) - * ((double)ii/(XRES-1.0)) + sp.spec_wl_short; - - xx[ii] = ww; - y1[ii] = value_xspect(&sp, ww); - y2[ii] = 100.0 * value_xspect(&corr_sp, ww); - } - do_plot(xx,y1,y2,NULL,ii); - } -#endif } + + /* No FWA comp */ else { /* Convert it to CIE space */ sp2cie->convert (sp2cie, XYZ, &sp); -#ifdef ALLOW_PLOT - if (doplot) { - int ii; - double xx[XRES]; - double y1[XRES]; - double lab[3]; - - icmXYZ2Lab(&icmD50, lab, XYZ); - printf("Patch %d, XYZ = %f %f %f, Lab = %f %f %f\n",i, - XYZ[0], XYZ[1], XYZ[2], lab[0], lab[1], lab[2]); - - /* Plot spectrum out */ - for (ii = 0; ii < XRES; ii++) { - double ww; - - ww = (sp.spec_wl_long - sp.spec_wl_short) - * ((double)ii/(XRES-1.0)) + sp.spec_wl_short; - - xx[ii] = ww; - y1[ii] = value_xspect(&sp, ww); - } - do_plot(xx,y1,NULL,NULL,ii); - } -#endif + } /* Could use sp2cie->get_cie_il() to get CIE white point */ @@ -846,13 +827,35 @@ main(int argc, char *argv[]) /* This won't work for emmisive though, since get_cie_il() will return 'E' */ icmXYZ2Lab(&icmD50, Lab, XYZ); - elems[Xi].d = XYZ[0] * 100.0; - elems[Yi].d = XYZ[1] * 100.0; - elems[Zi].d = XYZ[2] * 100.0; +#ifdef ALLOW_PLOT + if (doplot) { + int ii; + double xx[XRES]; + double y1[XRES]; + + printf("Patch %d, XYZ = %f %f %f, Lab = %f %f %f\n",i, + XYZ[0], XYZ[1], XYZ[2], Lab[0], Lab[1], Lab[2]); + + /* Plot spectrum out */ + for (ii = 0; ii < XRES; ii++) { + double ww; + + ww = (sp.spec_wl_long - sp.spec_wl_short) + * ((double)ii/(XRES-1.0)) + sp.spec_wl_short; + + xx[ii] = ww; + y1[ii] = value_xspect(&sp, ww); + } + do_plot(xx,y1,NULL,NULL,ii); + } +#endif + elems[oXi].d = XYZ[0] * 100.0; + elems[oYi].d = XYZ[1] * 100.0; + elems[oZi].d = XYZ[2] * 100.0; - elems[Li].d = Lab[0]; - elems[ai].d = Lab[1]; - elems[bi].d = Lab[2]; + elems[oLi].d = Lab[0]; + elems[oai].d = Lab[1]; + elems[obi].d = Lab[2]; ocg->add_setarr(ocg, 0, elems); } @@ -866,7 +869,7 @@ main(int argc, char *argv[]) ocg->del (ocg); /* Clean up */ icg->del (icg); /* Clean up */ - free (elems); + free (elems); } return 0; diff --git a/spectro/strange.cal b/spectro/strange.cal new file mode 100644 index 0000000..406fba4 --- /dev/null +++ b/spectro/strange.cal @@ -0,0 +1,272 @@ +CAL + +DESCRIPTOR "Argyll Device Calibration Curves" +ORIGINATOR "Argyll synthcal" +CREATED "Mon Sep 07 03:37:56 2015" +DEVICE_CLASS "DISPLAY" +COLOR_REP "RGB" + +NUMBER_OF_FIELDS 4 +BEGIN_DATA_FORMAT +RGB_I RGB_R RGB_G RGB_B +END_DATA_FORMAT + +NUMBER_OF_SETS 256 +BEGIN_DATA +0.00000 0.00000 0.00000 0.00000 +0.00392157 0.0000567518 0.0118787 0.0186065 +0.00784314 0.000184387 0.0206820 0.0302263 +0.0117647 0.000367355 0.0286065 0.0401466 +0.0156863 0.000599076 0.0360094 0.0491028 +0.0196078 0.000875445 0.0430471 0.0574042 +0.0235294 0.00119354 0.0498068 0.0652184 +0.0274510 0.00155112 0.0563438 0.0726496 +0.0313725 0.00194640 0.0626960 0.0797678 +0.0352941 0.00237789 0.0688909 0.0866232 +0.0392157 0.00284433 0.0749493 0.0932533 +0.0431373 0.00334462 0.0808876 0.0996872 +0.0470588 0.00387782 0.0867187 0.105948 +0.0509804 0.00444307 0.0924533 0.112053 +0.0549020 0.00503962 0.0981003 0.118020 +0.0588235 0.00566676 0.103667 0.123859 +0.0627451 0.00632388 0.109160 0.129583 +0.0666667 0.00701040 0.114585 0.135201 +0.0705882 0.00772579 0.119946 0.140720 +0.0745098 0.00846956 0.125248 0.146148 +0.0784314 0.00924125 0.130494 0.151490 +0.0823529 0.0100404 0.135689 0.156754 +0.0862745 0.0108667 0.140834 0.161942 +0.0901961 0.0117197 0.145932 0.167061 +0.0941176 0.0125991 0.150986 0.172112 +0.0980392 0.0135045 0.155998 0.177102 +0.101961 0.0144356 0.160971 0.182031 +0.105882 0.0153921 0.165905 0.186904 +0.109804 0.0163738 0.170803 0.191723 +0.113725 0.0173803 0.175665 0.196491 +0.117647 0.0184114 0.180495 0.201210 +0.121569 0.0194668 0.185292 0.205882 +0.125490 0.0205464 0.190059 0.210508 +0.129412 0.0216498 0.194796 0.215092 +0.133333 0.0227769 0.199504 0.219634 +0.137255 0.0239274 0.204184 0.224136 +0.141176 0.0251012 0.208838 0.228600 +0.145098 0.0262980 0.213466 0.233027 +0.149020 0.0275177 0.218069 0.237418 +0.152941 0.0287600 0.222648 0.241774 +0.156863 0.0300249 0.227204 0.246097 +0.160784 0.0313121 0.231737 0.250388 +0.164706 0.0326215 0.236248 0.254647 +0.168627 0.0339528 0.240737 0.258876 +0.172549 0.0353061 0.245205 0.263076 +0.176471 0.0366810 0.249654 0.267247 +0.180392 0.0380775 0.254082 0.271391 +0.184314 0.0394954 0.258491 0.275507 +0.188235 0.0409345 0.262882 0.279597 +0.192157 0.0423948 0.267254 0.283662 +0.196078 0.0438762 0.271609 0.287702 +0.200000 0.0453784 0.275946 0.291718 +0.203922 0.0469014 0.280266 0.295710 +0.207843 0.0484450 0.284570 0.299680 +0.211765 0.0500091 0.288857 0.303627 +0.215686 0.0515937 0.293128 0.307552 +0.219608 0.0531985 0.297384 0.311455 +0.223529 0.0548235 0.301625 0.315338 +0.227451 0.0564686 0.305851 0.319201 +0.231373 0.0581337 0.310063 0.323043 +0.235294 0.0598187 0.314260 0.326866 +0.239216 0.0615234 0.318443 0.330670 +0.243137 0.0632478 0.322613 0.334456 +0.247059 0.0649918 0.326769 0.338223 +0.250980 0.0667553 0.330911 0.341972 +0.254902 0.0685382 0.335041 0.345703 +0.258824 0.0703403 0.339159 0.349418 +0.262745 0.0721617 0.343264 0.353115 +0.266667 0.0740022 0.347356 0.356797 +0.270588 0.0758618 0.351437 0.360461 +0.274510 0.0777403 0.355505 0.364110 +0.278431 0.0796377 0.359563 0.367744 +0.282353 0.0815539 0.363608 0.371362 +0.286275 0.0834889 0.367643 0.374965 +0.290196 0.0854424 0.371666 0.378553 +0.294118 0.0874146 0.375679 0.382127 +0.298039 0.0894052 0.379681 0.385686 +0.301961 0.0914143 0.383672 0.389231 +0.305882 0.0934417 0.387653 0.392763 +0.309804 0.0954873 0.391624 0.396281 +0.313725 0.0975512 0.395585 0.399786 +0.317647 0.0996332 0.399536 0.403277 +0.321569 0.101733 0.403477 0.406756 +0.325490 0.103851 0.407409 0.410222 +0.329412 0.105987 0.411331 0.413676 +0.333333 0.108141 0.415244 0.417117 +0.337255 0.110313 0.419147 0.420546 +0.341176 0.112503 0.423042 0.423963 +0.345098 0.114710 0.426927 0.427368 +0.349020 0.116935 0.430804 0.430762 +0.352941 0.119177 0.434672 0.434144 +0.356863 0.121437 0.438532 0.437515 +0.360784 0.123714 0.442383 0.440875 +0.364706 0.126009 0.446225 0.444224 +0.368627 0.128321 0.450060 0.447563 +0.372549 0.130650 0.453886 0.450890 +0.376471 0.132997 0.457704 0.454207 +0.380392 0.135360 0.461514 0.457514 +0.384314 0.137741 0.465317 0.460811 +0.388235 0.140139 0.469111 0.464097 +0.392157 0.142554 0.472898 0.467374 +0.396078 0.144986 0.476678 0.470641 +0.400000 0.147435 0.480450 0.473898 +0.403922 0.149900 0.484214 0.477145 +0.407843 0.152383 0.487972 0.480383 +0.411765 0.154882 0.491722 0.483612 +0.415686 0.157398 0.495465 0.486831 +0.419608 0.159931 0.499200 0.490042 +0.423529 0.162480 0.502929 0.493243 +0.427451 0.165046 0.506651 0.496436 +0.431373 0.167628 0.510366 0.499619 +0.435294 0.170227 0.514075 0.502794 +0.439216 0.172842 0.517776 0.505961 +0.443137 0.175474 0.521472 0.509119 +0.447059 0.178122 0.525160 0.512269 +0.450980 0.180787 0.528842 0.515410 +0.454902 0.183467 0.532518 0.518543 +0.458824 0.186164 0.536187 0.521668 +0.462745 0.188877 0.539850 0.524785 +0.466667 0.191606 0.543507 0.527895 +0.470588 0.194351 0.547158 0.530996 +0.474510 0.197113 0.550803 0.534090 +0.478431 0.199890 0.554441 0.537176 +0.482353 0.202684 0.558074 0.540254 +0.486275 0.205493 0.561701 0.543325 +0.490196 0.208318 0.565322 0.546388 +0.494118 0.211159 0.568937 0.549444 +0.498039 0.214016 0.572547 0.552493 +0.501961 0.216889 0.576150 0.555535 +0.505882 0.219777 0.579748 0.558569 +0.509804 0.222681 0.583341 0.561597 +0.513725 0.225601 0.586928 0.564617 +0.517647 0.228536 0.590510 0.567631 +0.521569 0.231487 0.594086 0.570638 +0.525490 0.234454 0.597657 0.573638 +0.529412 0.237436 0.601222 0.576631 +0.533333 0.240434 0.604782 0.579618 +0.537255 0.243447 0.608337 0.582598 +0.541176 0.246476 0.611887 0.585571 +0.545098 0.249520 0.615431 0.588538 +0.549020 0.252579 0.618971 0.591499 +0.552941 0.255654 0.622505 0.594453 +0.556863 0.258744 0.626035 0.597401 +0.560784 0.261849 0.629559 0.600343 +0.564706 0.264970 0.633079 0.603279 +0.568627 0.268105 0.636594 0.606208 +0.572549 0.271256 0.640103 0.609132 +0.576471 0.274422 0.643608 0.612049 +0.580392 0.277603 0.647109 0.614961 +0.584314 0.280800 0.650604 0.617867 +0.588235 0.284011 0.654095 0.620766 +0.592157 0.287237 0.657581 0.623661 +0.596078 0.290478 0.661063 0.626549 +0.600000 0.293735 0.664540 0.629431 +0.603922 0.297006 0.668012 0.632308 +0.607843 0.300292 0.671480 0.635180 +0.611765 0.303593 0.674944 0.638045 +0.615686 0.306909 0.678403 0.640906 +0.619608 0.310239 0.681857 0.643761 +0.623529 0.313585 0.685308 0.646610 +0.627451 0.316945 0.688754 0.649454 +0.631373 0.320320 0.692195 0.652293 +0.635294 0.323709 0.695633 0.655126 +0.639216 0.327114 0.699066 0.657954 +0.643137 0.330533 0.702495 0.660777 +0.647059 0.333966 0.705919 0.663595 +0.650980 0.337414 0.709340 0.666408 +0.654902 0.340877 0.712756 0.669215 +0.658824 0.344354 0.716169 0.672018 +0.662745 0.347846 0.719577 0.674816 +0.666667 0.351352 0.722981 0.677608 +0.670588 0.354873 0.726381 0.680396 +0.674510 0.358408 0.729778 0.683179 +0.678431 0.361958 0.733170 0.685957 +0.682353 0.365522 0.736559 0.688730 +0.686275 0.369100 0.739943 0.691498 +0.690196 0.372693 0.743324 0.694262 +0.694118 0.376300 0.746701 0.697021 +0.698039 0.379921 0.750074 0.699775 +0.701961 0.383557 0.753443 0.702525 +0.705882 0.387207 0.756808 0.705270 +0.709804 0.390871 0.760170 0.708010 +0.713725 0.394549 0.763528 0.710746 +0.717647 0.398242 0.766882 0.713477 +0.721569 0.401948 0.770233 0.716204 +0.725490 0.405669 0.773580 0.718927 +0.729412 0.409404 0.776923 0.721645 +0.733333 0.413153 0.780263 0.724358 +0.737255 0.416916 0.783599 0.727068 +0.741176 0.420693 0.786932 0.729773 +0.745098 0.424484 0.790261 0.732473 +0.749020 0.428289 0.793587 0.735170 +0.752941 0.432108 0.796909 0.737862 +0.756863 0.435940 0.800228 0.740550 +0.760784 0.439787 0.803543 0.743234 +0.764706 0.443648 0.806855 0.745914 +0.768627 0.447523 0.810164 0.748589 +0.772549 0.451411 0.813469 0.751261 +0.776471 0.455314 0.816770 0.753928 +0.780392 0.459230 0.820069 0.756592 +0.784314 0.463160 0.823364 0.759251 +0.788235 0.467103 0.826656 0.761906 +0.792157 0.471061 0.829944 0.764558 +0.796078 0.475032 0.833230 0.767205 +0.800000 0.479017 0.836512 0.769849 +0.803922 0.483016 0.839790 0.772489 +0.807843 0.487028 0.843066 0.775124 +0.811765 0.491054 0.846339 0.777756 +0.815686 0.495094 0.849608 0.780385 +0.819608 0.499147 0.852874 0.783009 +0.823529 0.503214 0.856137 0.785630 +0.827451 0.507294 0.859397 0.788247 +0.831373 0.511388 0.862654 0.790860 +0.835294 0.515496 0.865908 0.793469 +0.839216 0.519617 0.869158 0.796075 +0.843137 0.523751 0.872406 0.798677 +0.847059 0.527899 0.875651 0.801276 +0.850980 0.532061 0.878892 0.803871 +0.854902 0.536236 0.882131 0.806462 +0.858824 0.540424 0.885367 0.809050 +0.862745 0.544626 0.888599 0.811634 +0.866667 0.548841 0.891829 0.814215 +0.870588 0.553070 0.895056 0.816792 +0.874510 0.557311 0.898280 0.819366 +0.878431 0.561567 0.901501 0.821936 +0.882353 0.565835 0.904719 0.824503 +0.886275 0.570117 0.907935 0.827066 +0.890196 0.574412 0.911147 0.829626 +0.894118 0.578721 0.914357 0.832183 +0.898039 0.583042 0.917564 0.834736 +0.901961 0.587377 0.920768 0.837286 +0.905882 0.591725 0.923969 0.839833 +0.909804 0.596087 0.927168 0.842376 +0.913725 0.600461 0.930363 0.844916 +0.917647 0.604849 0.933556 0.847453 +0.921569 0.609249 0.936747 0.849986 +0.925490 0.613663 0.939934 0.852516 +0.929412 0.618090 0.943119 0.855044 +0.933333 0.622530 0.946301 0.857567 +0.937255 0.626984 0.949481 0.860088 +0.941176 0.631450 0.952658 0.862606 +0.945098 0.635929 0.955832 0.865120 +0.949020 0.640421 0.959003 0.867631 +0.952941 0.644927 0.962172 0.870139 +0.956863 0.649445 0.965339 0.872644 +0.960784 0.653976 0.968502 0.875146 +0.964706 0.658521 0.971664 0.877645 +0.968627 0.663078 0.974822 0.880141 +0.972549 0.667648 0.977978 0.882634 +0.976471 0.672231 0.981132 0.885124 +0.980392 0.676827 0.984283 0.887610 +0.984314 0.681436 0.987431 0.890094 +0.988235 0.686058 0.990577 0.892575 +0.992157 0.690692 0.993721 0.895053 +0.996078 0.695340 0.996862 0.897528 +1.000000 0.700000 1.000000 0.900000 +END_DATA |