| Algorithm 1 Generation of a color palette | |
| Input: a sequence of n brain wave samples s1, s2, …, sn in a duration of 20 s with each si consisting of the two features of attention and meditation represented by variables ai and mi, respectively, i.e., si = (ai, mi). | |
| Output: a color palette H consisting of four strips of colors of blue, green, orange, and aubergine from left to right representing the emotion types of focusing, relaxation, calmness, and anxiety, respectively. | |
| Steps. | |
| Step 1: | //Initialization |
| 1.1 denote the four emotion types of focusing, relaxation, calmness, and anxiety by Fi, Ri, Ci, and Ai, respectively; | |
| 1.2 set up four counters Ftotal, Ttotal, Ctotal, and Atotal for Fi, Ri, Ci, and Ai, respectively. | |
| Step 2: | //Classifying the brain waves |
| for i = 1 to n do | |
| (a) classify si = (ai, mi) as one of Fi, Ri, Ci, and Ai according to rules specified by Equation (1), and denote the result by Xi; | |
| (b) increment the counters according to Xi in the following way: | //Computing sums |
| (i) if Xi = Fi, then set Ftotal = Ftotal + 1; | |
| end if; | //Ftotal = # blue samples |
| (ii) if Xi = Ri, then set Rtotal = Rtotal + 1; | |
| end if; | //Rtotal = # green samples |
| (iii) if Xi = Ci, then set Ctotal = Ctotal + 1; | |
| end if; | //Ctotal = # orange samples |
| (iv) if Xi = Ai, then set Atotal = Atotal + 1; | |
| end if; | //Atotal = # aubergine samples |
| end for. | |
| Step 3: | //Computing the color ratios and transforming them into 0~3 |
| compute the following integers as the color weights: | |
| f = ⎣(Ftotal/n) × 4⎦, r = ⎣(Rtotal/n) × 4⎦; c = ⎣(Ctotal/n) × 4⎦; and a = ⎣(Atotal/n) × 4⎦. | |
| Step 4: | //Creating the color palette |
| 4.1 create a rectangular shape H of size 4w × h pixels; | |
| //The unit width w and unit height h are pre-determined | |
| 4.2 fill H with blue-, green-, orange-, and aubergine-colored strips of the widths of f×w, r×w, c×w, and a×w pixels, respectively; | |
| 4.3 smear the boundary between every two different colors in H to create a color gradient effect within a distance of (1/3)×w from the boundary. | |
| //Making the created color palette look more natural | |
| Step 5: | //Ending |
| exit with H as the desired color palette. | |