10 #ifndef CLASS_TORUSMIXER
11 #define CLASS_TORUSMIXER
33 int make(vector<DataType *> *list,
int width,
int height, vector<int> parameters,
int nParameters,
bool show_data){
48 int n = parameters[0];
49 int k = parameters[1];
50 unsigned int M[2][2], TorusMatrice[2][2];
53 TorusMatrice[0][0] = 1;
54 TorusMatrice[0][1] = 1;
55 TorusMatrice[1][0] = k;
56 TorusMatrice[1][1] = k+1;
59 for(
int count=1; count < n; count++)
61 M[0][0]=(TorusMatrice[0][0]+TorusMatrice[0][1]*k)%width;
62 M[0][1]=(TorusMatrice[0][0]+TorusMatrice[0][1]*(k+1))%width;
63 M[1][0]=(TorusMatrice[1][0]+TorusMatrice[1][1]*k)%width;
64 M[1][1]=(TorusMatrice[1][0]+TorusMatrice[1][1]*(k+1))%width;
66 TorusMatrice[0][0] = M[0][0];
67 TorusMatrice[0][1] = M[0][1];
68 TorusMatrice[1][0] = M[1][0];
69 TorusMatrice[1][1] = M[1][1];
74 file.open(
"files/torus.txt",ofstream::out| ofstream::trunc);
76 file << width*height <<
"\n";
77 for(
int i = 0; i < width; i++)
78 for(
int j = 0; j < width; j++)
80 int iPos = ((i*width)+j);
81 int ip = (TorusMatrice[0][0]*i + TorusMatrice[0][1]*j)%width;
82 int jp = (TorusMatrice[1][0]*i + TorusMatrice[1][1]*j)%width;
83 int fPos = ((ip*width)+jp);
85 list->at(fPos)=list->at(iPos);
87 file << iPos <<
"-" << fPos <<
"\n";
90 cout <<
"Torus Automorphisms Applied to Image\n";
100 int unmake(vector<DataType *> *list,
bool show_data){
105 vector<string> array;
107 string line, delimiter=
"-";
109 string path =
"files/torus.txt";
110 file.open(path.c_str());
113 int width = atoi(line.c_str());
114 for(
int x=0;x<width;x++){
116 array.push_back(line);
118 for(
int x=0;x<width;x++){
119 string s = array.back();
123 pos = s.find(delimiter);
124 token = s.substr(0, pos);
125 iPos = atoi(token.c_str());
126 s.erase(0, pos + delimiter.length());
127 pos = s.find(delimiter);
128 token = s.substr(0, pos);
129 fPos = atoi(token.c_str());
130 s.erase(0, pos + delimiter.length());
132 list->at(fPos)=list->at(iPos);
136 cout <<
"Torus Automorphisms undo to Image\n";
Clase abstracta que representa la estructura que debe tener todo procesamiento de imagen...
Clase que representa un tipo de dato que será paquetizado.
Clase que implementa el Método de Entrelazamiento usando Torus Automosphisms.
int unmake(vector< DataType * > *list, bool show_data)
int make(vector< DataType * > *list, int width, int height, vector< int > parameters, int nParameters, bool show_data)