Loading src/main/java/EyesisCorrectionParameters.java +14 −9 Original line number Diff line number Diff line Loading @@ -1797,6 +1797,7 @@ public class EyesisCorrectionParameters { public int kernel_chn = -1; //camera channel calibration to use for aberration correction ( < 0 - no correction) public boolean normalize = true; //normalize both sym and asym kernels (asym to have sum==1, sym to have sum = dct_size public boolean skip_sym = false; // do not apply symmetrical correction public boolean convolve_direct = false; // do not apply symmetrical correction public DCTParameters( int dct_size, Loading Loading @@ -1846,6 +1847,7 @@ public class EyesisCorrectionParameters { properties.setProperty(prefix+"kernel_chn", this.kernel_chn+""); properties.setProperty(prefix+"normalize", this.normalize+""); properties.setProperty(prefix+"skip_sym", this.skip_sym+""); properties.setProperty(prefix+"convolve_direct", this.convolve_direct+""); } public void getProperties(String prefix,Properties properties){ Loading Loading @@ -1878,6 +1880,7 @@ public class EyesisCorrectionParameters { if (properties.getProperty(prefix+"kernel_chn")!=null) this.kernel_chn=Integer.parseInt(properties.getProperty(prefix+"kernel_chn")); if (properties.getProperty(prefix+"normalize")!=null) this.normalize=Boolean.parseBoolean(properties.getProperty(prefix+"normalize")); if (properties.getProperty(prefix+"skip_sym")!=null) this.skip_sym=Boolean.parseBoolean(properties.getProperty(prefix+"skip_sym")); if (properties.getProperty(prefix+"convolve_direct")!=null) this.convolve_direct=Boolean.parseBoolean(properties.getProperty(prefix+"convolve_direct")); } public boolean showDialog() { Loading Loading @@ -1911,6 +1914,7 @@ public class EyesisCorrectionParameters { gd.addNumericField("Calibration channel to use for aberration ( <0 - no correction)",this.kernel_chn, 0); gd.addCheckbox ("Normalize both sym and asym kernels ", this.normalize); gd.addCheckbox ("Do not apply symmetrical (DCT) correction ", this.skip_sym); gd.addCheckbox ("Convolve directly with symmetrical kernel (debug feature) ", this.convolve_direct); gd.showDialog(); Loading Loading @@ -1944,6 +1948,7 @@ public class EyesisCorrectionParameters { this.kernel_chn= (int) gd.getNextNumber(); this.normalize= gd.getNextBoolean(); this.skip_sym= gd.getNextBoolean(); this.convolve_direct= gd.getNextBoolean(); // MASTER_DEBUG_LEVEL= (int) gd.getNextNumber(); return true; } Loading src/main/java/EyesisDCT.java +53 −6 Original line number Diff line number Diff line Loading @@ -56,8 +56,10 @@ public class EyesisDCT { public int asym_size = 15; // asymmetrical convolution limits, odd public int asym_nonzero = 4; // maximal number of non-zero elements in the asymmetrical kernels public double [][] sym_kernels = null; // per-color channel, DCT kernels in linescan order public double [][] sym_direct = null; // per-color channel, DCT kernels in linescan order (direct, not dct-iii transformed) - debug feature public double [][] asym_kernels = null; // per-color channel, asymmetrical kernels (all but asym_nonzero elements are strictly 0) public double [][][][] st_kernels = null; // [color][tileY][tileX][pixel] public double [][][][] st_direct = null; // [color][tileY][tileX][pixel] - direct, not converted with DCT-III - debug feature public double [][][][] asym_val = null; // [color][tileY][tileX][index] // value - asym kernel for elements public int [][][][] asym_indx = null; // [color][tileY][tileX][index] // value - index of non-zero elements in the list } Loading Loading @@ -204,6 +206,18 @@ public class EyesisDCT { dct_parameters.decimateSigma, gb); } if (dct_parameters.normalize) { double s =0.0; for (int i = 0; i <target_kernel.length; i++){ s+=target_kernel[i]; } for (int i = 0; i <target_kernel.length; i++){ target_kernel[i]/=s; } if (globalDebugLevel>0){ System.out.println(tileX+"/"+tileY+ " s="+s); } } // int numAsym = factorConvKernel.calcKernels( target_kernel, Loading Loading @@ -603,10 +617,8 @@ public class EyesisDCT { // sdfa_instance.showArrays(kernels[chn].asym_kernels, asym_width, asym_height, true, asymKernelPaths[chn]); int numHor = kernels[chn].numHor; int numVert = kernels[chn].sym_kernels[0].length / (dct_size * dct_size * numHor); // public double [][][][] st_kernels = null; // [color][tileY][tileX][pixel] // public double [][][][] asym_val = null; // [color][tileY][tileX][index] // value - asym kernel for elements // public int [][][][] asym_indx = null; // [color][tileY][tileX][index] // value - index of non-zero elements in the list kernels[chn].st_kernels = new double [nColors][numVert][numHor][dct_size * dct_size]; kernels[chn].st_direct = new double [nColors][numVert][numHor][dct_size * dct_size]; kernels[chn].asym_val = new double [nColors][numVert][numHor][asym_nonzero]; kernels[chn].asym_indx = new int [nColors][numVert][numHor][asym_nonzero]; int sym_kernel_inc_index = numHor * dct_size; Loading Loading @@ -637,19 +649,37 @@ public class EyesisDCT { double sum = 0.0; for (int i=0; i < dct_size;i++) { for (int j=0; j < dct_size;j++) { double d = kernels[chn].st_kernels[nc][tileY][tileX][i]; double d = kernels[chn].st_kernels[nc][tileY][tileX][i*dct_size+j]; if (i > 0) d *= 2.0; if (j > 0) d *= 2.0; sum += d; } } scale /= sum; if ((tileY == ((dct_parameters.tileY+1)/2)) && (tileX ==((dct_parameters.tileX+1)/2)) && (nc == 2)) { System.out.println("(kernel) tileY="+tileY+"(kernel) tileX="+tileX+" sum="+sum + " scale="+scale); } kernels[chn].st_kernels[nc][tileY][tileX]= dtt.dttt_iii(kernels[chn].st_kernels[nc][tileY][tileX]); } for (int i=0; i < kernels[chn].st_kernels[nc][tileY][tileX].length;i++) { kernels[chn].st_kernels[nc][tileY][tileX][i] *= scale; } // Make a copy of direct kernels (debug feature, may be removed later) for (int i = 0; i < dct_size;i++){ System.arraycopy( // copy one kernel line kernels[chn].st_kernels[nc][tileY][tileX], i * dct_size, kernels[chn].st_direct[nc][tileY][tileX], i * dct_size, dct_size); } // scale st_direct back to ~original for (int i=0; i < kernels[chn].st_kernels[nc][tileY][tileX].length;i++) { kernels[chn].st_direct[nc][tileY][tileX][i] /= dct_size; } kernels[chn].st_kernels[nc][tileY][tileX]= dtt.dttt_iii(kernels[chn].st_kernels[nc][tileY][tileX]); // extract asymmetrical kernel and convert it to list of values and indices (as arrays as the length is known) int asym_kernel_start_index = (asym_kernel_inc_index * tileY + tileX)* asym_size; Loading Loading @@ -731,6 +761,9 @@ public class EyesisDCT { int asym_width = numHor * kernels[chn].asym_size; int asym_height = numVert * kernels[chn].asym_size; kernels[chn].sym_kernels = new double [nColors][sym_width*sym_height]; if (kernels[chn].st_direct != null) { kernels[chn].sym_direct = new double [nColors][sym_width*sym_height]; } kernels[chn].asym_kernels = new double [nColors][asym_width*asym_height]; int sym_kernel_inc_index = numHor * dct_size; int asym_kernel_inc_index = numHor * asym_size; Loading @@ -748,6 +781,16 @@ public class EyesisDCT { sym_kernel_start_index + i * sym_kernel_inc_index, dct_size); } if (kernels[chn].st_direct != null){ for (int i = 0; i < dct_size;i++){ System.arraycopy( // copy one kernel line kernels[chn].st_direct[nc][tileY][tileX], i * dct_size, kernels[chn].sym_direct[nc], sym_kernel_start_index + i * sym_kernel_inc_index, dct_size); } } // set asymmetrical kernel from the list of values and indices double [] asym_kernel = new double[asym_size*asym_size]; Loading Loading @@ -780,7 +823,11 @@ public class EyesisDCT { System.out.println("kernels["+chn+"][0].asym_kernels.length="+kernels[chn].asym_kernels[0].length); sdfa_instance.showArrays(kernels[chn].sym_kernels, sym_width, sym_height, true, "restored-sym-"+chn); sdfa_instance.showArrays(kernels[chn].asym_kernels, asym_width, asym_height, true, "restored-asym-"+chn); if (kernels[chn].st_direct != null){ sdfa_instance.showArrays(kernels[chn].sym_direct, sym_width, sym_height, true, "restored-direct-"+chn); } kernels[chn].sym_kernels = null; // not needed anymore kernels[chn].asym_kernels = null; // not needed anymore kernels[chn].sym_direct = null; // not needed anymore } } src/main/java/ImageDtt.java +105 −3 Original line number Diff line number Diff line Loading @@ -235,6 +235,9 @@ public class ImageDtt { chn, dct_kernels, dctParameters.skip_sym, dctParameters.convolve_direct, dctParameters.tileX, dctParameters.tileY, threadsMax, // maximal number of threads to launch debugLevel); } Loading @@ -252,6 +255,9 @@ public class ImageDtt { final int color, final EyesisDCT.DCTKernels dct_kernels, final boolean skip_sym, final boolean convolve_direct, // test feature - convolve directly with the symmetrical kernel final int debug_tileX, final int debug_tileY, final int threadsMax, // maximal number of threads to launch final int globalDebugLevel) { Loading @@ -276,11 +282,18 @@ public class ImageDtt { DttRad2 dtt = new DttRad2(dct_size); dtt.set_window(window_type); double [] tile_in = new double[4*dct_size * dct_size]; double [] sym_conv= null; if ((dct_kernels != null) && convolve_direct){ // debug feature - directly convolve with symmetrical kernel sym_conv = new double[4*dct_size * dct_size]; } double [] tile_folded; double [] tile_out; // = new double[dct_size * dct_size]; int tileY,tileX; int n2 = dct_size * 2; double dc; showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging? for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { tileY = nTile/tilesX; tileX = nTile - tileY * tilesX; Loading @@ -291,7 +304,7 @@ public class ImageDtt { int asym_center = dct_kernels.asym_size/2; // 7 for 15 kernelTileY = kernel_margin + (tileY * dct_size) / dct_kernels.img_step; kernelTileX = kernel_margin + (tileX * dct_size) / dct_kernels.img_step; if ((tileY <2) && (tileX <2) && (color ==0)) { if ((tileY == debug_tileY) && (tileX == debug_tileX) && (color == 2)) { System.out.println("kernelTileY="+kernelTileY+" kernelTileX="+kernelTileX+" width="+width); } for (int i = 0; i < n2; i++){ Loading @@ -302,7 +315,7 @@ public class ImageDtt { double [] asym_val = dct_kernels.asym_val[color][kernelTileY][kernelTileX]; for (int indx = 0; indx < asym_indx.length; indx++){ int xy = asym_indx[indx]; if ((tileY <2) && (tileX <2) && (color ==0)) { if ((tileY == debug_tileY) && (tileX == debug_tileX) && (color == 2)) { System.out.println("i="+i+" j="+j+" indx="+indx+" xy="+xy); } if (xy >= 0) { Loading @@ -315,7 +328,7 @@ public class ImageDtt { if (y >= height) y = (height - 2) + (y & 1); if (x >= width) x = (width - 2) + (x & 1); tile_in[i*n2 + j] += asym_val[indx] * dpixels[ y * width + x]; if ((tileY <2) && (tileX <2) && (color ==0)) { if ((tileY == debug_tileY) && (tileX == debug_tileX) && (color == 2)) { System.out.println("dy= "+dy+" dx="+dx+" x = "+x+" y="+y+" y*width + x="+(y*width + x)); System.out.println("asym_val["+indx+"]="+asym_val[indx]+ " dpixels["+(y * width + x)+"]="+ dpixels[ y * width + x]+ Loading @@ -325,6 +338,95 @@ public class ImageDtt { } } } // directly convolve with symmetrical kernel (debug feature if ((dct_kernels != null) && convolve_direct){ double [] dir_sym = dct_kernels.st_direct[color][kernelTileY][kernelTileX]; double s0 = 0; for (int i = 0; i < n2; i++){ for (int j = 0; j < n2; j++){ int indx = i*n2+j; sym_conv[indx] = 0.0; // dir_sym[0]* tile_in[indx]; for (int dy = -dct_size +1; dy < dct_size; dy++){ int ady = (dy>=0)?dy:-dy; int sgny = 1; int y = i - dy; if (y < 0){ y = -1 -y; sgny = -sgny; if (y < 0) { y = 0; sgny = 0; } } if (y >= n2){ y = 2*n2 - y; sgny = -sgny; if (y >= n2) { y = n2-1; sgny = 0; } } for (int dx = -dct_size +1; dx < dct_size; dx++){ int adx = (dx >= 0)? dx:-dx; int sgn = sgny; int x = j - dx; if (x < 0){ x = -1 -x; sgn = -sgn; if (x <0) { x = 0; sgn = 0; } } if (x >= n2){ x = 2*n2 - x; sgn = -sgn; if (x >= n2) { x = n2-1; sgn = 0; } } sym_conv[indx] += sgn*dir_sym[ady * dct_size + adx] * tile_in[y * n2 + x]; s0+=dir_sym[ady * dct_size + adx]; if ((tileY == debug_tileY) && (tileX == debug_tileX) && (color == 2) && (i == dct_size) && (j== dct_size)) { System.out.println("i="+i+" j="+j+" dy="+dy+" dx="+dx+" ady="+ady+" adx="+adx+ " y="+y+" x="+x+" sgny="+sgny+" sgn="+sgn+ "sym_conv["+indx+"] += "+sgn+"* dir_sym["+(ady * dct_size + adx)+"] * tile_in["+(y * n2 + x)+"] +="+ sgn+"* "+ dir_sym[ady * dct_size + adx]+" * "+tile_in[y * n2 + x]+" +="+ (sgn*dir_sym[ady * dct_size + adx] * tile_in[y * n2 + x])+" ="+sym_conv[indx]); } } } } } if ((tileY == debug_tileY) && (tileX == debug_tileX) && (color == 2)) { // if ((tileY == debug_tileY) && (tileX == debug_tileX)) { double [][] pair = {tile_in, sym_conv}; sdfa_instance.showArrays(pair, n2, n2, true, "dconv-X"+tileX+"Y"+tileY+"C"+color); sdfa_instance.showArrays(dir_sym, dct_size, dct_size, "dk-X"+tileX+"Y"+tileY+"C"+color); double s1=0,s2=0; for (int i = 0; i<tile_in.length; i++){ s1 +=tile_in[i]; s2 +=sym_conv[i]; } double s3 = 0.0; for (int i=0; i<dct_size;i++){ for (int j=0; j<dct_size;j++){ double d = dir_sym[i*dct_size+j]; if (i > 0) d*=2; if (j > 0) d*=2; s3+=d; } } System.out.println("s1="+s1+" s2="+s2+" s1/s2="+(s1/s2)+" s0="+s0+" s3="+s3); } // tile_in = sym_conv.clone(); System.arraycopy(sym_conv, 0, tile_in, 0, n2*n2); } } else { // no aberration correction, just copy data for (int i = 0; i < n2;i++){ System.arraycopy(dpixels, (tileY*width+tileX)*dct_size + i*width, tile_in, i*n2, n2); Loading Loading
src/main/java/EyesisCorrectionParameters.java +14 −9 Original line number Diff line number Diff line Loading @@ -1797,6 +1797,7 @@ public class EyesisCorrectionParameters { public int kernel_chn = -1; //camera channel calibration to use for aberration correction ( < 0 - no correction) public boolean normalize = true; //normalize both sym and asym kernels (asym to have sum==1, sym to have sum = dct_size public boolean skip_sym = false; // do not apply symmetrical correction public boolean convolve_direct = false; // do not apply symmetrical correction public DCTParameters( int dct_size, Loading Loading @@ -1846,6 +1847,7 @@ public class EyesisCorrectionParameters { properties.setProperty(prefix+"kernel_chn", this.kernel_chn+""); properties.setProperty(prefix+"normalize", this.normalize+""); properties.setProperty(prefix+"skip_sym", this.skip_sym+""); properties.setProperty(prefix+"convolve_direct", this.convolve_direct+""); } public void getProperties(String prefix,Properties properties){ Loading Loading @@ -1878,6 +1880,7 @@ public class EyesisCorrectionParameters { if (properties.getProperty(prefix+"kernel_chn")!=null) this.kernel_chn=Integer.parseInt(properties.getProperty(prefix+"kernel_chn")); if (properties.getProperty(prefix+"normalize")!=null) this.normalize=Boolean.parseBoolean(properties.getProperty(prefix+"normalize")); if (properties.getProperty(prefix+"skip_sym")!=null) this.skip_sym=Boolean.parseBoolean(properties.getProperty(prefix+"skip_sym")); if (properties.getProperty(prefix+"convolve_direct")!=null) this.convolve_direct=Boolean.parseBoolean(properties.getProperty(prefix+"convolve_direct")); } public boolean showDialog() { Loading Loading @@ -1911,6 +1914,7 @@ public class EyesisCorrectionParameters { gd.addNumericField("Calibration channel to use for aberration ( <0 - no correction)",this.kernel_chn, 0); gd.addCheckbox ("Normalize both sym and asym kernels ", this.normalize); gd.addCheckbox ("Do not apply symmetrical (DCT) correction ", this.skip_sym); gd.addCheckbox ("Convolve directly with symmetrical kernel (debug feature) ", this.convolve_direct); gd.showDialog(); Loading Loading @@ -1944,6 +1948,7 @@ public class EyesisCorrectionParameters { this.kernel_chn= (int) gd.getNextNumber(); this.normalize= gd.getNextBoolean(); this.skip_sym= gd.getNextBoolean(); this.convolve_direct= gd.getNextBoolean(); // MASTER_DEBUG_LEVEL= (int) gd.getNextNumber(); return true; } Loading
src/main/java/EyesisDCT.java +53 −6 Original line number Diff line number Diff line Loading @@ -56,8 +56,10 @@ public class EyesisDCT { public int asym_size = 15; // asymmetrical convolution limits, odd public int asym_nonzero = 4; // maximal number of non-zero elements in the asymmetrical kernels public double [][] sym_kernels = null; // per-color channel, DCT kernels in linescan order public double [][] sym_direct = null; // per-color channel, DCT kernels in linescan order (direct, not dct-iii transformed) - debug feature public double [][] asym_kernels = null; // per-color channel, asymmetrical kernels (all but asym_nonzero elements are strictly 0) public double [][][][] st_kernels = null; // [color][tileY][tileX][pixel] public double [][][][] st_direct = null; // [color][tileY][tileX][pixel] - direct, not converted with DCT-III - debug feature public double [][][][] asym_val = null; // [color][tileY][tileX][index] // value - asym kernel for elements public int [][][][] asym_indx = null; // [color][tileY][tileX][index] // value - index of non-zero elements in the list } Loading Loading @@ -204,6 +206,18 @@ public class EyesisDCT { dct_parameters.decimateSigma, gb); } if (dct_parameters.normalize) { double s =0.0; for (int i = 0; i <target_kernel.length; i++){ s+=target_kernel[i]; } for (int i = 0; i <target_kernel.length; i++){ target_kernel[i]/=s; } if (globalDebugLevel>0){ System.out.println(tileX+"/"+tileY+ " s="+s); } } // int numAsym = factorConvKernel.calcKernels( target_kernel, Loading Loading @@ -603,10 +617,8 @@ public class EyesisDCT { // sdfa_instance.showArrays(kernels[chn].asym_kernels, asym_width, asym_height, true, asymKernelPaths[chn]); int numHor = kernels[chn].numHor; int numVert = kernels[chn].sym_kernels[0].length / (dct_size * dct_size * numHor); // public double [][][][] st_kernels = null; // [color][tileY][tileX][pixel] // public double [][][][] asym_val = null; // [color][tileY][tileX][index] // value - asym kernel for elements // public int [][][][] asym_indx = null; // [color][tileY][tileX][index] // value - index of non-zero elements in the list kernels[chn].st_kernels = new double [nColors][numVert][numHor][dct_size * dct_size]; kernels[chn].st_direct = new double [nColors][numVert][numHor][dct_size * dct_size]; kernels[chn].asym_val = new double [nColors][numVert][numHor][asym_nonzero]; kernels[chn].asym_indx = new int [nColors][numVert][numHor][asym_nonzero]; int sym_kernel_inc_index = numHor * dct_size; Loading Loading @@ -637,19 +649,37 @@ public class EyesisDCT { double sum = 0.0; for (int i=0; i < dct_size;i++) { for (int j=0; j < dct_size;j++) { double d = kernels[chn].st_kernels[nc][tileY][tileX][i]; double d = kernels[chn].st_kernels[nc][tileY][tileX][i*dct_size+j]; if (i > 0) d *= 2.0; if (j > 0) d *= 2.0; sum += d; } } scale /= sum; if ((tileY == ((dct_parameters.tileY+1)/2)) && (tileX ==((dct_parameters.tileX+1)/2)) && (nc == 2)) { System.out.println("(kernel) tileY="+tileY+"(kernel) tileX="+tileX+" sum="+sum + " scale="+scale); } kernels[chn].st_kernels[nc][tileY][tileX]= dtt.dttt_iii(kernels[chn].st_kernels[nc][tileY][tileX]); } for (int i=0; i < kernels[chn].st_kernels[nc][tileY][tileX].length;i++) { kernels[chn].st_kernels[nc][tileY][tileX][i] *= scale; } // Make a copy of direct kernels (debug feature, may be removed later) for (int i = 0; i < dct_size;i++){ System.arraycopy( // copy one kernel line kernels[chn].st_kernels[nc][tileY][tileX], i * dct_size, kernels[chn].st_direct[nc][tileY][tileX], i * dct_size, dct_size); } // scale st_direct back to ~original for (int i=0; i < kernels[chn].st_kernels[nc][tileY][tileX].length;i++) { kernels[chn].st_direct[nc][tileY][tileX][i] /= dct_size; } kernels[chn].st_kernels[nc][tileY][tileX]= dtt.dttt_iii(kernels[chn].st_kernels[nc][tileY][tileX]); // extract asymmetrical kernel and convert it to list of values and indices (as arrays as the length is known) int asym_kernel_start_index = (asym_kernel_inc_index * tileY + tileX)* asym_size; Loading Loading @@ -731,6 +761,9 @@ public class EyesisDCT { int asym_width = numHor * kernels[chn].asym_size; int asym_height = numVert * kernels[chn].asym_size; kernels[chn].sym_kernels = new double [nColors][sym_width*sym_height]; if (kernels[chn].st_direct != null) { kernels[chn].sym_direct = new double [nColors][sym_width*sym_height]; } kernels[chn].asym_kernels = new double [nColors][asym_width*asym_height]; int sym_kernel_inc_index = numHor * dct_size; int asym_kernel_inc_index = numHor * asym_size; Loading @@ -748,6 +781,16 @@ public class EyesisDCT { sym_kernel_start_index + i * sym_kernel_inc_index, dct_size); } if (kernels[chn].st_direct != null){ for (int i = 0; i < dct_size;i++){ System.arraycopy( // copy one kernel line kernels[chn].st_direct[nc][tileY][tileX], i * dct_size, kernels[chn].sym_direct[nc], sym_kernel_start_index + i * sym_kernel_inc_index, dct_size); } } // set asymmetrical kernel from the list of values and indices double [] asym_kernel = new double[asym_size*asym_size]; Loading Loading @@ -780,7 +823,11 @@ public class EyesisDCT { System.out.println("kernels["+chn+"][0].asym_kernels.length="+kernels[chn].asym_kernels[0].length); sdfa_instance.showArrays(kernels[chn].sym_kernels, sym_width, sym_height, true, "restored-sym-"+chn); sdfa_instance.showArrays(kernels[chn].asym_kernels, asym_width, asym_height, true, "restored-asym-"+chn); if (kernels[chn].st_direct != null){ sdfa_instance.showArrays(kernels[chn].sym_direct, sym_width, sym_height, true, "restored-direct-"+chn); } kernels[chn].sym_kernels = null; // not needed anymore kernels[chn].asym_kernels = null; // not needed anymore kernels[chn].sym_direct = null; // not needed anymore } }
src/main/java/ImageDtt.java +105 −3 Original line number Diff line number Diff line Loading @@ -235,6 +235,9 @@ public class ImageDtt { chn, dct_kernels, dctParameters.skip_sym, dctParameters.convolve_direct, dctParameters.tileX, dctParameters.tileY, threadsMax, // maximal number of threads to launch debugLevel); } Loading @@ -252,6 +255,9 @@ public class ImageDtt { final int color, final EyesisDCT.DCTKernels dct_kernels, final boolean skip_sym, final boolean convolve_direct, // test feature - convolve directly with the symmetrical kernel final int debug_tileX, final int debug_tileY, final int threadsMax, // maximal number of threads to launch final int globalDebugLevel) { Loading @@ -276,11 +282,18 @@ public class ImageDtt { DttRad2 dtt = new DttRad2(dct_size); dtt.set_window(window_type); double [] tile_in = new double[4*dct_size * dct_size]; double [] sym_conv= null; if ((dct_kernels != null) && convolve_direct){ // debug feature - directly convolve with symmetrical kernel sym_conv = new double[4*dct_size * dct_size]; } double [] tile_folded; double [] tile_out; // = new double[dct_size * dct_size]; int tileY,tileX; int n2 = dct_size * 2; double dc; showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging? for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) { tileY = nTile/tilesX; tileX = nTile - tileY * tilesX; Loading @@ -291,7 +304,7 @@ public class ImageDtt { int asym_center = dct_kernels.asym_size/2; // 7 for 15 kernelTileY = kernel_margin + (tileY * dct_size) / dct_kernels.img_step; kernelTileX = kernel_margin + (tileX * dct_size) / dct_kernels.img_step; if ((tileY <2) && (tileX <2) && (color ==0)) { if ((tileY == debug_tileY) && (tileX == debug_tileX) && (color == 2)) { System.out.println("kernelTileY="+kernelTileY+" kernelTileX="+kernelTileX+" width="+width); } for (int i = 0; i < n2; i++){ Loading @@ -302,7 +315,7 @@ public class ImageDtt { double [] asym_val = dct_kernels.asym_val[color][kernelTileY][kernelTileX]; for (int indx = 0; indx < asym_indx.length; indx++){ int xy = asym_indx[indx]; if ((tileY <2) && (tileX <2) && (color ==0)) { if ((tileY == debug_tileY) && (tileX == debug_tileX) && (color == 2)) { System.out.println("i="+i+" j="+j+" indx="+indx+" xy="+xy); } if (xy >= 0) { Loading @@ -315,7 +328,7 @@ public class ImageDtt { if (y >= height) y = (height - 2) + (y & 1); if (x >= width) x = (width - 2) + (x & 1); tile_in[i*n2 + j] += asym_val[indx] * dpixels[ y * width + x]; if ((tileY <2) && (tileX <2) && (color ==0)) { if ((tileY == debug_tileY) && (tileX == debug_tileX) && (color == 2)) { System.out.println("dy= "+dy+" dx="+dx+" x = "+x+" y="+y+" y*width + x="+(y*width + x)); System.out.println("asym_val["+indx+"]="+asym_val[indx]+ " dpixels["+(y * width + x)+"]="+ dpixels[ y * width + x]+ Loading @@ -325,6 +338,95 @@ public class ImageDtt { } } } // directly convolve with symmetrical kernel (debug feature if ((dct_kernels != null) && convolve_direct){ double [] dir_sym = dct_kernels.st_direct[color][kernelTileY][kernelTileX]; double s0 = 0; for (int i = 0; i < n2; i++){ for (int j = 0; j < n2; j++){ int indx = i*n2+j; sym_conv[indx] = 0.0; // dir_sym[0]* tile_in[indx]; for (int dy = -dct_size +1; dy < dct_size; dy++){ int ady = (dy>=0)?dy:-dy; int sgny = 1; int y = i - dy; if (y < 0){ y = -1 -y; sgny = -sgny; if (y < 0) { y = 0; sgny = 0; } } if (y >= n2){ y = 2*n2 - y; sgny = -sgny; if (y >= n2) { y = n2-1; sgny = 0; } } for (int dx = -dct_size +1; dx < dct_size; dx++){ int adx = (dx >= 0)? dx:-dx; int sgn = sgny; int x = j - dx; if (x < 0){ x = -1 -x; sgn = -sgn; if (x <0) { x = 0; sgn = 0; } } if (x >= n2){ x = 2*n2 - x; sgn = -sgn; if (x >= n2) { x = n2-1; sgn = 0; } } sym_conv[indx] += sgn*dir_sym[ady * dct_size + adx] * tile_in[y * n2 + x]; s0+=dir_sym[ady * dct_size + adx]; if ((tileY == debug_tileY) && (tileX == debug_tileX) && (color == 2) && (i == dct_size) && (j== dct_size)) { System.out.println("i="+i+" j="+j+" dy="+dy+" dx="+dx+" ady="+ady+" adx="+adx+ " y="+y+" x="+x+" sgny="+sgny+" sgn="+sgn+ "sym_conv["+indx+"] += "+sgn+"* dir_sym["+(ady * dct_size + adx)+"] * tile_in["+(y * n2 + x)+"] +="+ sgn+"* "+ dir_sym[ady * dct_size + adx]+" * "+tile_in[y * n2 + x]+" +="+ (sgn*dir_sym[ady * dct_size + adx] * tile_in[y * n2 + x])+" ="+sym_conv[indx]); } } } } } if ((tileY == debug_tileY) && (tileX == debug_tileX) && (color == 2)) { // if ((tileY == debug_tileY) && (tileX == debug_tileX)) { double [][] pair = {tile_in, sym_conv}; sdfa_instance.showArrays(pair, n2, n2, true, "dconv-X"+tileX+"Y"+tileY+"C"+color); sdfa_instance.showArrays(dir_sym, dct_size, dct_size, "dk-X"+tileX+"Y"+tileY+"C"+color); double s1=0,s2=0; for (int i = 0; i<tile_in.length; i++){ s1 +=tile_in[i]; s2 +=sym_conv[i]; } double s3 = 0.0; for (int i=0; i<dct_size;i++){ for (int j=0; j<dct_size;j++){ double d = dir_sym[i*dct_size+j]; if (i > 0) d*=2; if (j > 0) d*=2; s3+=d; } } System.out.println("s1="+s1+" s2="+s2+" s1/s2="+(s1/s2)+" s0="+s0+" s3="+s3); } // tile_in = sym_conv.clone(); System.arraycopy(sym_conv, 0, tile_in, 0, n2*n2); } } else { // no aberration correction, just copy data for (int i = 0; i < n2;i++){ System.arraycopy(dpixels, (tileY*width+tileX)*dct_size + i*width, tile_in, i*n2, n2); Loading