You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

105 lines
3.1 KiB

/*
This file is part of "Interface Fractures III - Silicon".
Copyright (c) 2015 Luka Prinčič, All rights reserved.
This program is free software distributed under
GNU General Public Licence. See COPYING for more info.
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
getLinesData.pde - process spectral lines
*/
ArrayList<FloatList> getLinesData() {
float[][] colors = { // these are taken from http://astro.u-strasbg.fr/~koppen/discharge/discharge.html
{ 3800.0, 0, 0, 0},
{ 4000.0, 150, 0, 150},
{ 4400.0, 120, 0, 255}, // violet
{ 4500.0, 0, 0, 255}, // blue
{ 4800.0, 0, 255, 255}, // cyan
{ 5200.0, 0, 255, 0}, // green
{ 5800.0, 255, 255, 0}, // yellow
{ 6500.0, 255, 0, 0}, // red
{ 7000.0, 80, 0, 0},
{ 7300.0, 0, 0, 0} };
String[] siLinesData;
int threshold = 400;
siLinesData = loadStrings(dataPath(sketchPath + "/silicon_lines.txt"));
ArrayList<FloatList> siLinesList = new ArrayList<FloatList>();
for (String lineData : siLinesData ) {
String[] datatemp = split(lineData, " ");
FloatList data_x;
data_x = new FloatList();
for (int i = 0; i < datatemp.length; i++) {
if (!datatemp[i].equals("")) { // if not empty (spaces):
data_x.append(float(datatemp[i]));
}
}
// process data - add rgb values
//println(data_x.get(0));
float wavelength = data_x.get(0);
for (int i = 0; i < colors.length; i++){
float thisboundary = colors[i][0];
if (i+1 < colors.length){
float nextboundary = colors[i+1][0];
if(wavelength > thisboundary && wavelength < nextboundary) {
int red = round(colors[i][1] + ( ( (colors[i+1][1] - colors[i][1]) / (colors[i+1][0] - colors[i][0]) )
* (wavelength - colors[i][0]) ));
int green = round(colors[i][2] + ( ( (colors[i+1][2] - colors[i][2]) / (colors[i+1][0] - colors[i][0]) )
* (wavelength - colors[i][0]) ));
int blue = round(colors[i][3] + ( ( (colors[i+1][3] - colors[i][3]) / (colors[i+1][0] - colors[i][0]) )
* (wavelength - colors[i][0]) ));
data_x.append(red);
data_x.append(green);
data_x.append(blue);
}
}
}
printArray(data_x);
siLinesList.add(data_x);
}
// for(int i = 0; i < siLinesList.size(); i ++) {
// //println(siLinesList.get(i).get(0));
// float wavelength = siLinesList.get(i).get(0);
// float intensity = siLinesList.get(i).get(1);
// if(intensity > threshold && wavelength < 6741 && wavelength > 3950) {
// // (item[1].asInt > threshold) && (item[0].asInt < 6741) && (item[0].asInt > 3950), {
// println(wavelength + " " + intensity);
// }
// }
//printArray(siLinesList);
return siLinesList;
}