Commit f25142a1 authored by Andrey Filippov's avatar Andrey Filippov

Fixing sensor geometric corrections

parent 484ec936
...@@ -4042,7 +4042,7 @@ public class ImageDtt { ...@@ -4042,7 +4042,7 @@ public class ImageDtt {
public double data_y = 0.0; // kernel data is relative to this displacement Y (0.5 pixel increments) public double data_y = 0.0; // kernel data is relative to this displacement Y (0.5 pixel increments)
public double center_x = 0.0; // actual center X (use to find derivatives) public double center_x = 0.0; // actual center X (use to find derivatives)
public double center_y = 0.0; // actual center X (use to find derivatives) public double center_y = 0.0; // actual center X (use to find derivatives)
public double dxc_dx = 0.0; // add this to data_x per each pixel X-shift relative to the kernel centger location public double dxc_dx = 0.0; // add this to data_x per each pixel X-shift relative to the kernel center location
public double dxc_dy = 0.0; // same per each Y-shift pixel public double dxc_dy = 0.0; // same per each Y-shift pixel
public double dyc_dx = 0.0; public double dyc_dx = 0.0;
public double dyc_dy = 0.0; public double dyc_dy = 0.0;
...@@ -4075,6 +4075,17 @@ public class ImageDtt { ...@@ -4075,6 +4075,17 @@ public class ImageDtt {
} }
} }
public void offsetKernelSensor(
double [][] clt_tile, // clt tile, including [4] - metadata
double dx,
double dy) {
CltExtra ce = new CltExtra (clt_tile[4]);
ce.center_x += dx;
ce.center_y += dy;
ce.data_x += dx;
ce.data_y += dy;
clt_tile[4] = ce.getArray();
}
public void clt_fill_coord_corr( public void clt_fill_coord_corr(
final int kern_step, // distance between kernel centers, in pixels. final int kern_step, // distance between kernel centers, in pixels.
final double [][][][][] clt_data, final double [][][][][] clt_data,
...@@ -4201,6 +4212,8 @@ public class ImageDtt { ...@@ -4201,6 +4212,8 @@ public class ImageDtt {
// same with extra shift // same with extra shift
px = centerX - transform_size - (ce.data_x + ce.dxc_dx * kdx + ce.dxc_dy * kdy) ; // fractional left corner px = centerX - transform_size - (ce.data_x + ce.dxc_dx * kdx + ce.dxc_dy * kdy) ; // fractional left corner
py = centerY - transform_size - (ce.data_y + ce.dyc_dx * kdx + ce.dyc_dy * kdy) ; // fractional top corner py = centerY - transform_size - (ce.data_y + ce.dyc_dx * kdx + ce.dyc_dy * kdy) ; // fractional top corner
}else {
System.out.println("Skipping kernels!!!");
} }
if (bdebug0){ if (bdebug0){
System.out.print(px+"\t"+py+"\t"); System.out.print(px+"\t"+py+"\t");
......
This diff is collapsed.
...@@ -250,6 +250,7 @@ public class QuadCLT { ...@@ -250,6 +250,7 @@ public class QuadCLT {
//GeometryCorrection //GeometryCorrection
public double [][][][][] calculateCLTKernel ( // per color/per tileY/ per tileX/per quadrant (plus offset as 5-th)/per pixel public double [][][][][] calculateCLTKernel ( // per color/per tileY/ per tileX/per quadrant (plus offset as 5-th)/per pixel
final PixelMapping.SensorData sensor, // to calculate extra shift
final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels
final int kernelSize, // 64 final int kernelSize, // 64
final EyesisCorrectionParameters.CLTParameters clt_parameters, final EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -294,6 +295,7 @@ public class QuadCLT { ...@@ -294,6 +295,7 @@ public class QuadCLT {
System.out.println("calculateCLTKernel():numberOfKernels="+numberOfKernels); System.out.println("calculateCLTKernel():numberOfKernels="+numberOfKernels);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
float [] kernelPixels= null; // will be initialized at first use NOT yet? float [] kernelPixels= null; // will be initialized at first use NOT yet?
double [] kernel= new double[kernelSize*kernelSize]; double [] kernel= new double[kernelSize*kernelSize];
...@@ -328,7 +330,7 @@ public class QuadCLT { ...@@ -328,7 +330,7 @@ public class QuadCLT {
double s =0.0; double s =0.0;
for (int i=0;i<kernel.length;i++) s+=kernel[i]; for (int i=0;i<kernel.length;i++) s+=kernel[i];
System.out.println("calculateCLTKernel(): sum(kernel_raw)="+s); System.out.println("calculateCLTKernel(): sum(kernel_raw)="+s);
sdfa_instance.showArrays( if (globalDebugLevel > 1) sdfa_instance.showArrays(
kernel, kernel,
size, size,
size, size,
...@@ -350,7 +352,7 @@ public class QuadCLT { ...@@ -350,7 +352,7 @@ public class QuadCLT {
int klen = (2*dtt_size-1) * (2*dtt_size-1); int klen = (2*dtt_size-1) * (2*dtt_size-1);
for (int i = 0; i < klen; i++) s += kernel_centered[i]; for (int i = 0; i < klen; i++) s += kernel_centered[i];
System.out.println("calculateCLTKernel(): sum(kernel_centered)="+s); System.out.println("calculateCLTKernel(): sum(kernel_centered)="+s);
sdfa_instance.showArrays( if (globalDebugLevel > 1) sdfa_instance.showArrays(
kernel_centered, kernel_centered,
size, size,
size, size,
...@@ -370,7 +372,7 @@ public class QuadCLT { ...@@ -370,7 +372,7 @@ public class QuadCLT {
int klen = (2*dtt_size-1) * (2*dtt_size-1); int klen = (2*dtt_size-1) * (2*dtt_size-1);
for (int i = 0; i < klen; i++) s += kernel_centered[i]; for (int i = 0; i < klen; i++) s += kernel_centered[i];
System.out.println("calculateCLTKernel(): sum(kernel_normalized)="+s); System.out.println("calculateCLTKernel(): sum(kernel_normalized)="+s);
sdfa_instance.showArrays( if (globalDebugLevel > 1) sdfa_instance.showArrays(
kernel_centered, kernel_centered,
size, size,
size, size,
...@@ -394,7 +396,7 @@ public class QuadCLT { ...@@ -394,7 +396,7 @@ public class QuadCLT {
String [] titles = {"CC", "SC", "CS", "SS"}; String [] titles = {"CC", "SC", "CS", "SS"};
int length=dbg_clt[0].length; int length=dbg_clt[0].length;
int size=(int) Math.sqrt(length); int size=(int) Math.sqrt(length);
sdfa_instance.showArrays( if (globalDebugLevel > 1) sdfa_instance.showArrays(
dbg_clt, dbg_clt,
size, size,
size, size,
...@@ -406,6 +408,43 @@ public class QuadCLT { ...@@ -406,6 +408,43 @@ public class QuadCLT {
clt_kernels[chn][tileY][tileX], // double [][] kernels, // set of 4 SS, AS, SA, AA kdernels, each dtt_size * dtt_size (may have 5-th with center shift clt_kernels[chn][tileY][tileX], // double [][] kernels, // set of 4 SS, AS, SA, AA kdernels, each dtt_size * dtt_size (may have 5-th with center shift
dtt_size, // 8 dtt_size, // 8
dtt); dtt);
if ((globalDebugLevel > 0) && (tileY == clt_parameters.tileY/2) && (tileX == clt_parameters.tileX/2)) {
System.out.println("calculateCLTKernel() - before corr: chn="+chn+" "+
"tileX = "+clt_parameters.tileX+" ("+(clt_parameters.tileX/2)+") "+
"tileY = "+clt_parameters.tileY+" ("+(clt_parameters.tileY/2)+") "+
"center_x = "+clt_kernels[chn][tileY][tileX][4][0]+", "+
"center_y = "+clt_kernels[chn][tileY][tileX][4][1]+", "+
"full_dx = "+clt_kernels[chn][tileY][tileX][4][2]+", "+
"full_dy = "+clt_kernels[chn][tileY][tileX][4][3]);
}
// Add sensor geometry correction (optional?)
// Kernel center in pixels
double kpx0 = (tileX -1 +0.5) * clt_parameters.kernel_step;
double kpy0 = (tileY -1 +0.5) * clt_parameters.kernel_step;
double [] corrPxPy = sensor.interpolateCorrectionVector(false, kpx0, kpy0);
image_dtt.offsetKernelSensor(
clt_kernels[chn][tileY][tileX], // double [][] clt_tile, // clt tile, including [4] - metadata
// (corrPxPy[0] - kpx0), // double dx,
// (corrPxPy[1] - kpy0)); // double dy)
-corrPxPy[0], // double dx,
-corrPxPy[1]); // double dy)
if ((globalDebugLevel > 0) && (tileY == clt_parameters.tileY/2) && (tileX == clt_parameters.tileX/2)) {
System.out.println("calculateCLTKernel() - after corr: chn="+chn+" "+
"tileX = "+clt_parameters.tileX+" ("+(clt_parameters.tileX/2)+") "+
"tileY = "+clt_parameters.tileY+" ("+(clt_parameters.tileY/2)+") "+
"center_x = "+clt_kernels[chn][tileY][tileX][4][0]+", "+
"center_y = "+clt_kernels[chn][tileY][tileX][4][1]+", "+
"full_dx = "+clt_kernels[chn][tileY][tileX][4][2]+", "+
"full_dy = "+clt_kernels[chn][tileY][tileX][4][3]);
System.out.println("calculateCLTKernel() - after corr: chn="+chn+" "+
"kpx0 = "+kpx0+
"kpy0 = "+kpy0+
"corrPxPy[0] = "+corrPxPy[0]+
"corrPxPy[1] = "+corrPxPy[1]);
}
if ((globalDebugLevel > 0) && (tileY == clt_parameters.tileY/2) && (tileX == clt_parameters.tileX/2)) { if ((globalDebugLevel > 0) && (tileY == clt_parameters.tileY/2) && (tileX == clt_parameters.tileX/2)) {
double [][] dbg_clt = { double [][] dbg_clt = {
clt_kernels[chn][tileY][tileX][0], clt_kernels[chn][tileY][tileX][0],
...@@ -415,7 +454,7 @@ public class QuadCLT { ...@@ -415,7 +454,7 @@ public class QuadCLT {
String [] titles = {"CC", "SC", "CS", "SS"}; String [] titles = {"CC", "SC", "CS", "SS"};
int length=dbg_clt[0].length; int length=dbg_clt[0].length;
int size=(int) Math.sqrt(length); int size=(int) Math.sqrt(length);
sdfa_instance.showArrays( if (globalDebugLevel > 1) sdfa_instance.showArrays(
dbg_clt, dbg_clt,
size, size,
size, size,
...@@ -474,6 +513,7 @@ public class QuadCLT { ...@@ -474,6 +513,7 @@ public class QuadCLT {
System.out.println("flattenCLTKernels():numberOfKernels="+numberOfKernels); System.out.println("flattenCLTKernels():numberOfKernels="+numberOfKernels);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
int chn,tileY,tileX; int chn,tileY,tileX;
for (int nTile = ai.getAndIncrement(); nTile < numberOfKernels; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < numberOfKernels; nTile = ai.getAndIncrement()) {
...@@ -604,6 +644,7 @@ public class QuadCLT { ...@@ -604,6 +644,7 @@ public class QuadCLT {
System.out.println("flattenCLTKernels():numberOfKernels="+numberOfKernels); System.out.println("flattenCLTKernels():numberOfKernels="+numberOfKernels);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override
public void run() { public void run() {
int chn,tileY,tileX; int chn,tileY,tileX;
for (int nTile = ai.getAndIncrement(); nTile < numberOfKernels; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < numberOfKernels; nTile = ai.getAndIncrement()) {
...@@ -642,6 +683,9 @@ public class QuadCLT { ...@@ -642,6 +683,9 @@ public class QuadCLT {
boolean updateStatus, boolean updateStatus,
int debugLevel int debugLevel
){ ){
// get sensor geometry correction to apply to kernels as extra shifts
PixelMapping.SensorData [] sensors = eyesisCorrections.pixelMapping.sensors;
String [] sharpKernelPaths= correctionsParameters.selectKernelChannelFiles( String [] sharpKernelPaths= correctionsParameters.selectKernelChannelFiles(
0, // 0 - sharp, 1 - smooth 0, // 0 - sharp, 1 - smooth
eyesisCorrections.usedChannels.length, // numChannels, // number of channels eyesisCorrections.usedChannels.length, // numChannels, // number of channels
...@@ -671,6 +715,7 @@ public class QuadCLT { ...@@ -671,6 +715,7 @@ public class QuadCLT {
" kernel_sharp_stack.getHeight() = "+kernel_sharp_stack.getHeight()); " kernel_sharp_stack.getHeight() = "+kernel_sharp_stack.getHeight());
double [][][][][] kernels = calculateCLTKernel ( // per color/per tileY/ per tileX/per quadrant (plus offset as 5-th)/per pixel double [][][][][] kernels = calculateCLTKernel ( // per color/per tileY/ per tileX/per quadrant (plus offset as 5-th)/per pixel
sensors[chn], // to calculate extra shift (kernels are centered around green)
kernel_sharp_stack, // final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels kernel_sharp_stack, // final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels
srcKernelSize, // final int kernelSize, // 64 srcKernelSize, // final int kernelSize, // 64
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
......
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