35 Images(vector<DataType *> list,
int nType,
int nwidth,
int nheight,
int nwblock,
int nhblock,
bool show_data){
48 if((w%wblock!=0 || h%hblock!=0) || wblock!=hblock){
53 for (
int i = 0; i < h/hblock; i=i+1)
56 for (
int j = 0; j < w/wblock; j=j+1)
58 int pos = (i*(int)(h/hblock))+j;
59 if(list.at(pos)!=NULL){
60 vector<Pixel> *e = (vector<Pixel>*)list.at(pos)->
getExtras();
61 vector<Pixel> lblock(wblock*hblock);
62 for(
int k=0;k<(wblock*hblock);k++){
63 int* content = e->at(k).getContent();
66 for(
int x=0;x<content[1];x++){
67 channels.push_back(content[2+x]);
69 Pixel transformed(channels, type);
70 lblock[k]=transformed;
74 lblock[k]=transformed;
77 DataBlock block(lblock, wblock,hblock,type);
83 cout <<
"Image Generated...\n";
86 Images(
string url,
int nwblock,
int nhblock,
bool show_data){
93 CImg<> img(url.c_str());
94 const CImg<unsigned char> R = img.get_shared_channel(0),
95 G = img.get_shared_channel(1),
96 B = img.get_shared_channel(2);
102 cout<<
"TIPO: "<<type<<
"\n";
105 if((w%wblock!=0 || h%hblock!=0) || wblock!=hblock){
111 for (
int i = 0; i < h/hblock; i=i+1)
114 matrix[i] =
new DataBlock[(int)w/wblock];
115 for (
int j = 0; j < w/wblock; j=j+1)
117 vector<Pixel> list(hblock*wblock);
118 for(
int f=0;f<hblock;f++){
119 for(
int c=0;c<wblock;c++){
120 vector<int> channels(type);
121 for(
int x=0;x<type;x++){
122 channels[x]=(int)img(((j*wblock)+c),((i*hblock)+f),0,x);
124 Pixel aux(channels,type);
125 list[(f*wblock)+c]=aux;
133 cout <<
"Image Loaded...\n";
143 int getHeightBlock(){
178 vector<DataType *> toList(){
182 vector<DataType *> list;
183 for (
int i = 0; i < h/hblock; i++)
185 for (
int j = 0; j < w/wblock; j++)
194 void save(
const char* destiny){
199 CImg<> img(w,h,1,type,0);
200 for (
int i = 0; i < h/hblock; i++){
201 for (
int j = 0; j < w/wblock; j++){
202 if(matrix[i][j].isValid()){
203 vector<Pixel> *e = (vector<Pixel>*)matrix[i][j].getExtras();
204 for(
int r=0;r<hblock;r++){
205 for(
int c=0;c<wblock;c++){
206 vector<int> v_rgb = (e->at((r*hblock)+c)).getChannels();
207 int* rgb = (
int*)malloc(
sizeof(
int)*v_rgb.size());
208 for(
int x=0;x<v_rgb.size();x++){
211 img.draw_point((j*wblock)+c,(i*hblock)+r,0,rgb);
217 img.normalize(0, 255);
222 vector<Pixel> getPixelPerBlock(CImg<> img,
int x,
int y){
229 vector<Pixel> list(hblock*wblock);
230 for(
int i=0;i<hblock;i++){
231 for(
int j=0;j<wblock;j++){
232 vector<int> channels(type);
233 for(
int c=0;c<type;c++){
234 channels[c]=(int)img(((y*wblock)+j),((x*hblock)+i),0,c);
236 Pixel aux(channels,type);
237 list[(i*wblock)+j]=aux;
Clase que representa un Bloque de Píxeles.
Clase que representa una Imagen.
Clase que representa un Pixel de una imagen.