Exemplo n.º 1
0
 void init(int offset) {
   for(int j=offset;j<dstim->h;j++)
     for(int i=offset;i<dstim->w;i++) {
       int x = rand()%srcim->w;
       int y = rand()%srcim->h;
       dstz->p(i,j) = srcim->ij_to_idx(x,y);
       x = rand()%srcim->w;
       y = rand()%srcim->h;
       //dsto->p(i,j) = srcim->ij_to_idx(x,y);
       dstim->p(i,j) = srcim->p(x,y);
     }
 }
Exemplo n.º 2
0
  void analyze_srcimg()
  {
    printf("analyzing source img..."); fflush(stdout);
    srck = new Kcoherence<K>[srcim->w*srcim->h];
    int inset = srcwrap ? 0 : Nsize;
    for(int j=inset;j<srcim->h-inset;j++)
      for(int i=inset;i<srcim->w-inset;i++) {
        int idx = srcim->ij_to_idx(i,j);
        srck[idx] = ::nn_search(srcim, i,j, Nsize, srcwrap);
#if 0
        printf("%d: ", idx);
        for(int k=0;k<srck[idx].n;k++) {
          printf("%d(%d)%s", srck[idx]._idx[k], srck[idx]._err[k], k==K-1?"":",");
        }
        printf("\n");
#endif
      }
    printf("done\n");
  }
Exemplo n.º 3
0
 // nearest neighbor search, using a given coherence set
 void nn_search(Img *destim, int di, int dj, const Kcoherence<K> &kset,
                int offx, int offy,
                unsigned &bestdiff,unsigned &bestidx)
 {
   for(int k=0;k<kset.n;k++) {
     int i,j;
     srcim->idx_to_ij(kset[k],i,j);
     i = srcim->wrapw(i+offx);
     j = srcim->wraph(j+offy);
     if(!srcwrap && (i<Nsize || i>=srcim->w-Nsize))
       continue;
     if(!srcwrap && (j<Nsize || j>=srcim->h-Nsize))
       continue;
     unsigned diff = neighbor_diff(destim, srcim, di,dj, i,j, Nsize);
     if(diff < bestdiff) {
       bestdiff = diff;
       bestidx = srcim->ij_to_idx(i,j);
     }
   }
 }