# Automated Design of Salient Object Detection Algorithms with Brain Programming
## Appendix A
In the next three lines, we execute rescaling processes and grayscale conversions of the final mask (17-19). ```
**Purpose:** Create a population of individuals. Each individual is made up of a minimum of 4 functions. The GBVS+MCG uses these functions, and the fitness function uses their results to determine the best individual. **Input:**

* _num_gen_: Number of cycles/generations in the evolutionary process. * _pop_size_: Number of individuals in the population. **Variables:**

* _max_level_: Maximum number of levels any tree can have. * _max_trees_: Number of trees (genes) that an individual (chromosome) must have. * _prob_chrom_cross_: Probability of applying a chromosome crossover. * _prob_chrom_mut_: Probability of applying a chromosome mutation. * _pop_: An array with all individuals in the population. * _parents_chrom_: A structure that saves the selected individuals as parents. * _\(ofspring_{chrom}\)_: An array that holds one or two new individuals, the product of some genetic operator applied to selected members of the current population. * _new_pop_: An array containing the individuals of the new population generation. It is the same size as pop. * _parents_chrom_: An array of image pairs used for training. The first is an RGB image, and the second is a binary image representing the RGB image's proto-object. * _image_str_: An array of image pairs used for training. The first is an RGB image, and the second is a binary image representing the RGB image's proto-object. * _fitness_: An array that stores the average fitness values for each individual. * _fitness_: An array that stores the fitness values of a single individual. \(f_{O}\), \(f_{C}\), \(f_{S}\), \(f_{F1}\) : List of function sets regarding Orientation (O), Color (C), Shape (S), and Feature Integration (FI). * _data_base_train_: Number of cycles/generations in the evolutionary process. **Output**

* _best_ind_: Save the individual with the best fitness value. ```
1:max_level \(\leftarrow\) 9
2:max_trees \(\leftarrow\) 4
3:prob_chrom_cross \(\leftarrow\) 0.8
4:prob_chrom_mut \(\leftarrow\) 0.2
5:prob_gen_cross \(\leftarrow\) 0.8
6:prob_gen_mut \(\leftarrow\) 0.2
7:\(f_{O}\) \(\leftarrow\) [Orientation functions]
8:\(f_{C}\) \(\leftarrow\) [Color Features]
9:\(f_{S}\) \(\leftarrow\) [Form Functions]
10:\(f_{FI}\) \(\leftarrow\) [Feature Integration Functions]
11:\(f_{O}\) \(\leftarrow\) [Orientation Terminals]
12:\(l_{C}\) \(\leftarrow\) [Color Terminals]
13:\(l_{S}\) \(\leftarrow\) [Form Terminals]
14:\(l_{FI}\) \(\leftarrow\) [Feature Integration Terminals]
15:pop \(\leftarrow\) \(\textit{Init\_Pop}(f_{O},f_{C},f_{S},f_{FI},l_{O},t_{C},l_{S},t_{FI},pop\_size,max\_level,max\_trees)\)
16:\(images_{tr}\) \(\leftarrow\) Load(data_base_train)
17:for (gen \(\leftarrow\) 1 to num_gen) do
18:if\(\textbf{gen}\
eq\textbf{1}\)then
19:parents_chrom_Clear()
20:parents_chrom_\(\leftarrow\) Roulette(pop,fitness,pop.size)
21:\(offsetping_{chrom}\)_Clear()
22:while(\(offsetping_{chrom}\)_length \(<\)\(parents\_{chrom}\)_length) do
23: operator \(\leftarrow\) Roulette_Pop(prob_chrom_cross,prob_chrom_mut,prob_gen_cross,prob_gen_mut)
24:i \(\leftarrow\)\(offsetping_{chrom}\)_length
25:\(offsetping_{chrom}\)_Add(Apply_Gen_Op(operator,\(parents_{chrom}\),i))
26:endwhile
27:pop \(\leftarrow\)\(offsetping_{chrom}\)
28:pop.Add(best_ind)
29:endif
30:fitness \(\leftarrow\) 0
31:for (i \(\leftarrow\) 1 to pop_length) do
32:\(fitness_{chrom}\) \(\leftarrow\) 0
33:for (j \(\leftarrow\) 1 to \(images_{tr}\),length) do
34: proto \(\leftarrow\)\(\textit{sabol\_test\_img}(images_{tr}\)[j,1]pop[i])
35:\(fitness_{chrom}\)[j] \(\leftarrow\) Calc_Proto_fitness(pop[i], \(images_{tr}\)[j,2])
36:endfor
37:fitness[i] \(\leftarrow\) Mean(\(fitness_{chrom}\))
38:endfor
39:best_ind \(\leftarrow\) Get_Best(pop, fitness, best_ind)
40:endfor
41:return best_ind ```
**Algorithm A1** Evolving GBVS with BP
```
1:Purpose
2: Proto-object generation. 3:Input
4:\(\mathit{img}\): Image or image path. 5:\(\mathit{param}\): Contains parameters for the algorithm.