11 #ifndef CLASS_REBUILDERAVERAGEOPTIMIZED
12 #define CLASS_REBUILDERAVERAGEOPTIMIZED
14 #define max(a, b) ((a) > (b) ? (a) : (b))
15 #define min(a, b) ((a) < (b) ? (a) : (b))
40 int amount_channels = img->getType();
43 int w = img->getWidth()/img->getWidthBlock();
44 int h = img->getHeight()/img->getHeightBlock();
46 for(
int i = 0; i < h; i++){
47 for(
int j = 0; j < w; j++){
48 if((!matrix[i][j].isValid()) && amountNeighbors(img,i,j)>=neighbors)
50 vector<int> add(amount_channels);
51 for(
int x=0;x<amount_channels;x++)
55 for(
int iBlock = max((
int)i-1,0); iBlock <= min(i+1,h-1) ; iBlock++)
56 for(
int jBlock = max((
int)j-1,0); jBlock <= min(j+1,w-1); jBlock++)
57 if((i != iBlock) || (j != jBlock))
58 if(matrix[iBlock][jBlock].isValid())
60 vector<Pixel> *e = (vector<Pixel>*)matrix[iBlock][jBlock].getExtras();
61 for(
int r=0;r<img->getHeightBlock();r++){
62 for(
int c=0;c<img->getWidthBlock();c++){
63 vector<int> chnls = e->at((r*img->getWidthBlock())+c).getChannels();
64 for(
int x=0;x<amount_channels;x++){
73 for(
int x=0;x<amount_channels;x++){
74 add[x]=(int)(add[x]/count);
78 DataBlock* px =
new DataBlock(amount_channels,add,img->getWidthBlock(),img->getHeightBlock());
85 }
while(neighbors>=0 && isLossBlock(img));
87 cout <<
"The Image has been restored\n";
92 int amountNeighbors(
Images* img,
int i,
int j){
100 int w = img->getWidth()/img->getWidthBlock();
101 int h = img->getHeight()/img->getHeightBlock();
104 for(
int iBlock = max((
int)i-1,0); iBlock <= min(i+1,h-1) ; iBlock++)
105 for(
int jBlock = max((
int)j-1,0); jBlock <= min(j+1,w-1); jBlock++)
106 if((i != iBlock) || (j != jBlock))
107 if(matrix[iBlock][jBlock].isValid())
115 bool isLossBlock(
Images* img){
123 int w=img->getWidth()/img->getWidthBlock();
124 int h=img->getHeight()/img->getHeightBlock();
125 for (
int i = 0; i < h; ++i)
127 for (
int j = 0; j < w; ++j)
129 if(!matrix[i][j].isValid())
Clase que representa un Bloque de Píxeles.
virtual void hidden(Images *img, bool show_data)
Clase que implementa un método de ocultamiento de errores utilizando el promedio de sus vecinos más c...
Clase que representa una Imagen.
Clase Abstracta que indica la forma que debe tener todo método de Ocultamiento de errores en Imágenes...