|
|
@ -7,6 +7,7 @@ byte[] colorByteValues = {0, 0, 0, 0, 0, 0, 0, 0}; |
|
|
|
int colorsN = colorValues.length; |
|
|
|
float colorsRange = float(100)/float(colorsN-2); |
|
|
|
|
|
|
|
|
|
|
|
void ephPercentage() { |
|
|
|
|
|
|
|
if (video.available()) { |
|
|
@ -36,11 +37,11 @@ void ephPercentage() { |
|
|
|
// if greater then 80% increace white counter, |
|
|
|
// if lower then 20% increace black counter, |
|
|
|
// otherwise increase color counters |
|
|
|
if(briVal > 20 && briVal < 80) { |
|
|
|
colorValues[constrain(int(hueVal/colorsRange),0,colorsN-3)]++; |
|
|
|
if(briVal > 20 && briVal < 99) { |
|
|
|
colorValues[hueCal(hueVal)]++; |
|
|
|
} else if(briVal <= 20) { |
|
|
|
colorValues[colorsN-2]++; |
|
|
|
} else if(briVal >= 80) { |
|
|
|
} else if(briVal >= 99) { |
|
|
|
colorValues[colorsN-1]++; |
|
|
|
} |
|
|
|
|
|
|
@ -66,3 +67,16 @@ void ephPercentage() { |
|
|
|
rect(0, 5*(colorsN-1)+5, map(colorValues[colorsN-1]/(cellN/100),0,100,0,width), 5); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int hueCal(float val){ |
|
|
|
int result = 0; |
|
|
|
if(val<11){result = 0;} |
|
|
|
if(val>=11 && val<22){result = 1;} |
|
|
|
if(val>=22 && val<44){result = 2;} |
|
|
|
if(val>=44 && val<56){result = 3;} |
|
|
|
if(val>=56 && val<80){result = 4;} |
|
|
|
if(val>=80){result = 5;} |
|
|
|
//if(val>=90){result = 0;} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |