Commit 09416a86 authored by Andrey Filippov's avatar Andrey Filippov

working with actual images

parent 91616de2
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
public class DttRad2 { public class DttRad2 {
int N = 0; int N = 0;
double [][][] CII=null; double [][][] CII= null;
double [][][] CIV=null; double [][][] CIV= null;
double [][][] SIV=null; double [][][] SIV= null;
double [][] CN1=null; double [][] CN1=null;
double [][] SN1=null; double [][] SN1=null;
double COSPI_1_8_SQRT2 = Math.cos(Math.PI/8)*Math.sqrt(2.0); double COSPI_1_8_SQRT2 = Math.cos(Math.PI/8)*Math.sqrt(2.0);
...@@ -137,7 +137,7 @@ public class DttRad2 { ...@@ -137,7 +137,7 @@ public class DttRad2 {
} }
} }
} }
if (n < 16) { if (n < 8) {
for (int i = 0; i < n; i++ ){ for (int i = 0; i < n; i++ ){
fi = get_fold_indices(i,n); fi = get_fold_indices(i,n);
System.out.println(i+"->"+String.format("[%2d % 2d % 2d] [%2d %2d %2d] %f %f", System.out.println(i+"->"+String.format("[%2d % 2d % 2d] [%2d %2d %2d] %f %f",
...@@ -188,12 +188,12 @@ public class DttRad2 { ...@@ -188,12 +188,12 @@ public class DttRad2 {
unfold_index[n2*i+j]=(index_vert+index_hor); unfold_index[n2*i+j]=(index_vert+index_hor);
unfold_k[n2*i+j]=k_vert*k_hor; unfold_k[n2*i+j]=k_vert*k_hor;
if (n < 16) System.out.print(String.format("%4d", unfold_index[n2*i+j])); if (n < 8) System.out.print(String.format("%4d", unfold_index[n2*i+j]));
} }
if (n < 16) System.out.println(); if (n < 8) System.out.println();
} }
if (n < 16) { if (n < 8) {
for (int i = 0; i < 2*n; i++ ){ for (int i = 0; i < 2*n; i++ ){
System.out.println(i+"->"+get_unfold_index(i,n)); System.out.println(i+"->"+get_unfold_index(i,n));
} }
...@@ -226,7 +226,7 @@ public class DttRad2 { ...@@ -226,7 +226,7 @@ public class DttRad2 {
} }
public double [] dttt_ii(double [] x){ public double [] dttt_ii(double [] x){
return dttt_iv(x, 0, 1 << (ilog2(x.length)/2)); return dttt_ii(x, 1 << (ilog2(x.length)/2));
} }
public double [] dttt_ii(double [] x, int n){ public double [] dttt_ii(double [] x, int n){
...@@ -247,6 +247,29 @@ public class DttRad2 { ...@@ -247,6 +247,29 @@ public class DttRad2 {
return y; return y;
} }
public double [] dttt_iii(double [] x){
return dttt_iii(x, 1 << (ilog2(x.length)/2));
}
public double [] dttt_iii(double [] x, int n){
double [] y = new double [n*n];
double [] line = new double[n];
// first (horizontal) pass
for (int i = 0; i<n; i++){
System.arraycopy(x, n*i, line, 0, n);
line = dctiii_direct(line);
for (int j=0; j < n;j++) y[j*n+i] =line[j]; // transpose
}
// second (vertical) pass
for (int i = 0; i<n; i++){
System.arraycopy(y, n*i, line, 0, n);
line = dctiii_direct(line);
System.arraycopy(line, 0, y, n*i, n);
}
return y;
}
public void set_window(){ public void set_window(){
...@@ -259,15 +282,17 @@ public class DttRad2 { ...@@ -259,15 +282,17 @@ public class DttRad2 {
hwindow = new double[len]; hwindow = new double[len];
double f = Math.PI/(2.0*len); double f = Math.PI/(2.0*len);
double sqrt1_2=Math.sqrt(0.5); double sqrt1_2=Math.sqrt(0.5);
if (mode < 0) mode =0;
else if (mode > 2) mode = 2;
if (mode ==0){ if (mode ==0){
for (int i = 0; i < len; i++ ) hwindow[i] = sqrt1_2; for (int i = 0; i < len; i++ ) hwindow[i] = sqrt1_2;
} else if (mode ==1){ } else if (mode ==1){
for (int i = 0; i < len; i++ ) hwindow[i] = Math.sin(f*(i+0.5)); for (int i = 0; i < len; i++ ) hwindow[i] = Math.sin(f*(i+0.5));
} else { // add more types? } else if (mode ==2){
double s; double s;
for (int i = 0; i < len; i++ ) { for (int i = 0; i < len; i++ ) {
s = Math.sin(f*(i+0.5)); s = Math.sin(f*(i+0.5));
hwindow[i] = Math.sin(Math.PI*s*s); hwindow[i] = Math.sin(Math.PI*s*s/2);
} }
} }
set_fold_2d(len); set_fold_2d(len);
...@@ -317,6 +342,24 @@ public class DttRad2 { ...@@ -317,6 +342,24 @@ public class DttRad2 {
} }
return y; return y;
} }
public double [] dctiii_direct(double[] x){
// CIII=transp(CII)
int n = x.length;
int t = ilog2(n)-1;
if (CII==null){
setup_CII(N); // just full size
}
double [] y = new double[n];
for (int i = 0; i<n; i++) {
y[i] = 0.0;
for (int j = 0; j< n; j++){
y[i]+= CII[t][j][i]*x[j];
}
}
return y;
}
public double [] dctiv_direct(double[] x){ public double [] dctiv_direct(double[] x){
int n = x.length; int n = x.length;
...@@ -388,7 +431,7 @@ public class DttRad2 { ...@@ -388,7 +431,7 @@ public class DttRad2 {
} }
} }
} }
private void setup_CIV(int maxN){ private void setup_CIV(int maxN){
if (maxN > N) setup_arrays(maxN); if (maxN > N) setup_arrays(maxN);
int l = ilog2(N); int l = ilog2(N);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment