Example #1
0
void idct_8x8(double **input, gray **output) {
    double temp[ NJPEG ][ NJPEG ];
    double temp1;
    int i;
    int j;
    int k;

/*  MatrixMultiply( temp, input, C ); */
    for ( i = 0 ; i < NJPEG ; i++ ) {
        for ( j = 0 ; j < NJPEG ; j++ ) {
            temp[ i ][ j ] = 0.0;
            for ( k = 0 ; k < NJPEG ; k++ )
                temp[ i ][ j ] += input[ i ][ k ] * C[ k ][ j ];
        }
    }

/*  MatrixMultiply( output, Ct, temp ); */
    for ( i = 0 ; i < NJPEG ; i++ ) {
        for ( j = 0 ; j < NJPEG ; j++ ) {
            temp1 = 0.0;
            for ( k = 0 ; k < NJPEG ; k++ )
                temp1 += Ct[ i ][ k ] * temp[ k ][ j ];
            temp1 += 128.0;
            output[i][j] = PIXELRANGE(ROUND(temp1));
        }
    }
}
Example #2
0
void idct_NxM(double **dcts, gray **pixels) {
  int x, y;
  int i, j;
  double cx0 = sqrt(1.0 / N);
  double cy0 = sqrt(1.0 / M);
  double t;

  for (x = 0; x < N; x++) {
    for (y = 0; y < M; y++) {

      t = cx0 * cy0 * dcts[0][0];

      for (i = 1; i < N; i++)
        t += cy0 * dcts[0][i] * dct_NxM_costable_x[x][i];

      for (j = 1; j < M; j++)
        t += cx0 * dcts[j][0] * dct_NxM_costable_y[y][j];

      for (i = 1; i < N; i++) {
        double s = 0.0;
        for (j = 1; j < M; j++) {
          s += dcts[j][i] * dct_NxM_costable_y[y][j];
        }
        t += s * dct_NxM_costable_x[x][i];
      }

      pixels[y][x] = PIXELRANGE((int) (t + 128.5));
    }
  }
}
Example #3
0
void idct_NxN(double **dcts, gray **pixels) {
 int u,v;
 double two_over_sqrtncolsnrows = 2.0/sqrt((double) N*M);

  double **tmp;

  tmp = alloc_coeffs(N, N);
  for (u=0;u<N;u++)
    for (v=0;v<M;v++)
      tmp[u][v] = dcts[u][v];

  for (u=0; u<=M-1; u++){
    ifct_noscale(tmp[u]);
  }
  for (v=0; v<=N-1; v++){
    for (u=0; u<=M-1; u++){
       dct_NxN_tmp[u] = tmp[u][v];
    }
    ifct_noscale(dct_NxN_tmp);
    for (u=0; u<=M-1; u++){
       tmp[u][v] = dct_NxN_tmp[u]*two_over_sqrtncolsnrows;
    }
  }

 for (u=0;u<N;u++)
    for (v=0;v<M;v++)
      pixels[u][v] = PIXELRANGE(tmp[u][v] + 128.5);
 free(tmp);
}
Example #4
0
void  image_to_gray(Image img_scaled, gray *pixels) {
	//image must be scaled by get_absolute_image_scaled()
	int i, j;
	for (i = 0; i < img_scaled->height; i++)
		for (j = 0; j < img_scaled->width; j++)
			pixels[j + (i*(img_scaled->width))] = PIXELRANGE((int)(get_pixel(img_scaled, j, i) + 0.5));
	
}
Example #5
0
void idwt_wp(Image_tree dwts, gray **pixels) {
  Image image;
  int i, j;

  image = inv_transform(dwts, dwt_filters, dwt_method + 1);

  for (i = 0; i < dwt_rows; i++)
    for (j = 0; j < dwt_cols; j++)
      pixels[i][j] = PIXELRANGE((int) (get_pixel(image, j, i) + 0.5));
  printf("idwt_wp(): working!!\n");
  free_image(image);
}
Example #6
0
void idwt(Image_tree dwts, gray *pixels) {
  Image image;
  int i, j;

  image = inv_transform(dwts, dwt_filters, dwt_method + 1);
  for (i = 0; i < dwt_rows; i++)
    for (j = 0; j < dwt_cols; j++)
    //  pixels[i][j] = PIXELRANGE((int) (get_pixel(image, j, i) + 0.5));
		pixels[j + (i*(image->width))] = PIXELRANGE((int) (get_pixel(image, j, i) + 0.5));
 // for (i = 0; i < (dwt_cols*dwt_rows); i++) pixels[i] = PIXELRANGE((int)(image->data[i] + 0.5));
 
  free_image(image);
  free_image_tree(dwts);
}