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");
......
...@@ -37,9 +37,6 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -37,9 +37,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import loci.common.services.DependencyException;
import loci.common.services.ServiceException;
import loci.formats.FormatException;
import Jama.Matrix; import Jama.Matrix;
import ij.IJ; import ij.IJ;
import ij.ImagePlus; import ij.ImagePlus;
...@@ -50,6 +47,9 @@ import ij.io.FileSaver; ...@@ -50,6 +47,9 @@ import ij.io.FileSaver;
import ij.io.Opener; import ij.io.Opener;
import ij.process.ColorProcessor; import ij.process.ColorProcessor;
import ij.text.TextWindow; import ij.text.TextWindow;
import loci.common.services.DependencyException;
import loci.common.services.ServiceException;
import loci.formats.FormatException;
public class PixelMapping { public class PixelMapping {
...@@ -494,6 +494,7 @@ public class PixelMapping { ...@@ -494,6 +494,7 @@ public class PixelMapping {
IJ.showStatus("Warping image channel "+channel); IJ.showStatus("Warping image channel "+channel);
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() {
for (int opy=opyAtomic.getAndIncrement(); opy<erm.mapWOI.height;opy=opyAtomic.getAndIncrement()){ for (int opy=opyAtomic.getAndIncrement(); opy<erm.mapWOI.height;opy=opyAtomic.getAndIncrement()){
...@@ -561,6 +562,7 @@ public class PixelMapping { ...@@ -561,6 +562,7 @@ public class PixelMapping {
final int numFinished=opyDoneAtomic.getAndIncrement(); final int numFinished=opyDoneAtomic.getAndIncrement();
// IJ.showProgress(progressValues[numFinished]); // IJ.showProgress(progressValues[numFinished]);
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
// Here, we can safely update the GUI // Here, we can safely update the GUI
// because we'll be called from the // because we'll be called from the
...@@ -618,6 +620,7 @@ public class PixelMapping { ...@@ -618,6 +620,7 @@ public class PixelMapping {
IJ.showStatus("Warping image channel "+channel); IJ.showStatus("Warping image channel "+channel);
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() {
for (int opy=opyAtomic.getAndIncrement(); opy<erm.mapWOI.height;opy=opyAtomic.getAndIncrement()){ for (int opy=opyAtomic.getAndIncrement(); opy<erm.mapWOI.height;opy=opyAtomic.getAndIncrement()){
...@@ -666,6 +669,7 @@ public class PixelMapping { ...@@ -666,6 +669,7 @@ public class PixelMapping {
final int numFinished=opyDoneAtomic.getAndIncrement(); final int numFinished=opyDoneAtomic.getAndIncrement();
// IJ.showProgress(progressValues[numFinished]); // IJ.showProgress(progressValues[numFinished]);
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
// Here, we can safely update the GUI // Here, we can safely update the GUI
// because we'll be called from the // because we'll be called from the
...@@ -2499,6 +2503,7 @@ public class PixelMapping { ...@@ -2499,6 +2503,7 @@ public class PixelMapping {
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() {
DoubleFHT doubleFHT=new DoubleFHT(); DoubleFHT doubleFHT=new DoubleFHT();
for (int row=rowNum.getAndIncrement(); row<numTileRows;row=rowNum.getAndIncrement()) { for (int row=rowNum.getAndIncrement(); row<numTileRows;row=rowNum.getAndIncrement()) {
...@@ -2523,6 +2528,7 @@ public class PixelMapping { ...@@ -2523,6 +2528,7 @@ public class PixelMapping {
debugLevel); debugLevel);
final int numFinished=rowsFinished.getAndIncrement(); final int numFinished=rowsFinished.getAndIncrement();
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
IJ.showProgress(numFinished,numTileRows); IJ.showProgress(numFinished,numTileRows);
} }
...@@ -3649,6 +3655,7 @@ public class PixelMapping { ...@@ -3649,6 +3655,7 @@ public class PixelMapping {
final AtomicInteger numNonEmpty = new AtomicInteger(0); final AtomicInteger numNonEmpty = new AtomicInteger(0);
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() {
DoubleFHT doubleFHT=new DoubleFHT(); DoubleFHT doubleFHT=new DoubleFHT();
double [] tilePlot; double [] tilePlot;
...@@ -3706,6 +3713,7 @@ public class PixelMapping { ...@@ -3706,6 +3713,7 @@ public class PixelMapping {
} }
final int numFinished=tilesFinished.getAndIncrement(); final int numFinished=tilesFinished.getAndIncrement();
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
IJ.showProgress(numFinished,numTiles); IJ.showProgress(numFinished,numTiles);
} }
...@@ -3951,6 +3959,7 @@ public class PixelMapping { ...@@ -3951,6 +3959,7 @@ public class PixelMapping {
final double [][][] result=new double[numTileRows][numTileColumns][]; final double [][][] result=new double[numTileRows][numTileColumns][];
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() {
DoubleFHT doubleFHT=new DoubleFHT(); DoubleFHT doubleFHT=new DoubleFHT();
for (int tile=tileNum.getAndIncrement(); tile<numTiles;tile=tileNum.getAndIncrement()) { for (int tile=tileNum.getAndIncrement(); tile<numTiles;tile=tileNum.getAndIncrement()) {
...@@ -3980,6 +3989,7 @@ public class PixelMapping { ...@@ -3980,6 +3989,7 @@ public class PixelMapping {
debugLevel); debugLevel);
final int numFinished=tilesFinished.getAndIncrement(); final int numFinished=tilesFinished.getAndIncrement();
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
IJ.showProgress(numFinished,numTiles); IJ.showProgress(numFinished,numTiles);
} }
...@@ -5206,6 +5216,7 @@ public class PixelMapping { ...@@ -5206,6 +5216,7 @@ public class PixelMapping {
if (showProgress) IJ.showStatus("Centering correlation data..."); if (showProgress) IJ.showStatus("Centering correlation data...");
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() {
// common for the tread // common for the tread
double [][] partial=new double [imagePairIndices.length][]; double [][] partial=new double [imagePairIndices.length][];
...@@ -5254,6 +5265,7 @@ public class PixelMapping { ...@@ -5254,6 +5265,7 @@ public class PixelMapping {
if (showProgress){ if (showProgress){
final int fTile=tile; final int fTile=tile;
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
// Here, we can safely update the GUI // Here, we can safely update the GUI
// because we'll be called from the // because we'll be called from the
...@@ -5313,6 +5325,7 @@ public class PixelMapping { ...@@ -5313,6 +5325,7 @@ public class PixelMapping {
if (showProgress) IJ.showStatus("Re-centering correlation data..."); if (showProgress) IJ.showStatus("Re-centering correlation data...");
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() {
for (int tile=tileIndexAtomic.getAndIncrement(); tile<tiles;tile=tileIndexAtomic.getAndIncrement()){ for (int tile=tileIndexAtomic.getAndIncrement(); tile<tiles;tile=tileIndexAtomic.getAndIncrement()){
int nImage=tile/tilesPerImage; int nImage=tile/tilesPerImage;
...@@ -5342,6 +5355,7 @@ public class PixelMapping { ...@@ -5342,6 +5355,7 @@ public class PixelMapping {
if (showProgress){ if (showProgress){
final int fTile=tile; final int fTile=tile;
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
// Here, we can safely update the GUI // Here, we can safely update the GUI
// because we'll be called from the // because we'll be called from the
...@@ -5765,6 +5779,7 @@ public class PixelMapping { ...@@ -5765,6 +5779,7 @@ public class PixelMapping {
final AtomicInteger numberUpdated = new AtomicInteger(0); final AtomicInteger numberUpdated = new AtomicInteger(0);
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() {
for (int tile=tileIndexAtomic.getAndIncrement(); tile<tiles;tile=tileIndexAtomic.getAndIncrement()){ for (int tile=tileIndexAtomic.getAndIncrement(); tile<tiles;tile=tileIndexAtomic.getAndIncrement()){
if (fillForegroundTile( if (fillForegroundTile(
...@@ -5778,6 +5793,7 @@ public class PixelMapping { ...@@ -5778,6 +5793,7 @@ public class PixelMapping {
if (showProgress){ if (showProgress){
final int finalTile=tile; final int finalTile=tile;
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
IJ.showProgress(finalTile,tiles); IJ.showProgress(finalTile,tiles);
} }
...@@ -5938,6 +5954,7 @@ public class PixelMapping { ...@@ -5938,6 +5954,7 @@ public class PixelMapping {
refineWindow[0]=Double.NaN; refineWindow[0]=Double.NaN;
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() {
DoubleFHT doubleFHT = new DoubleFHT(); DoubleFHT doubleFHT = new DoubleFHT();
DoubleFHT refineFHT= new DoubleFHT(); DoubleFHT refineFHT= new DoubleFHT();
...@@ -5980,6 +5997,7 @@ public class PixelMapping { ...@@ -5980,6 +5997,7 @@ public class PixelMapping {
if (showProgress){ if (showProgress){
final int finalTile=tile; final int finalTile=tile;
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
IJ.showProgress(finalTile,tiles); IJ.showProgress(finalTile,tiles);
} }
...@@ -6613,6 +6631,7 @@ public class PixelMapping { ...@@ -6613,6 +6631,7 @@ public class PixelMapping {
refineWindow[0]=Double.NaN; refineWindow[0]=Double.NaN;
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() {
DoubleFHT doubleFHT = new DoubleFHT(); DoubleFHT doubleFHT = new DoubleFHT();
DoubleFHT refineFHT= new DoubleFHT(); DoubleFHT refineFHT= new DoubleFHT();
...@@ -6654,6 +6673,7 @@ public class PixelMapping { ...@@ -6654,6 +6673,7 @@ public class PixelMapping {
if (showProgress){ if (showProgress){
final int finalTile=tile; final int finalTile=tile;
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
IJ.showProgress(finalTile,tiles); IJ.showProgress(finalTile,tiles);
} }
...@@ -7052,6 +7072,7 @@ public class PixelMapping { ...@@ -7052,6 +7072,7 @@ public class PixelMapping {
final int size=2*this.overlapStep; final int size=2*this.overlapStep;
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() {
DoubleFHT doubleFHT = new DoubleFHT(); DoubleFHT doubleFHT = new DoubleFHT();
final double [] window=new double [size*size]; final double [] window=new double [size*size];
...@@ -7106,6 +7127,7 @@ public class PixelMapping { ...@@ -7106,6 +7127,7 @@ public class PixelMapping {
if (showProgress){ if (showProgress){
final int finalTile=tile; final int finalTile=tile;
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
IJ.showProgress(finalTile,tiles); IJ.showProgress(finalTile,tiles);
} }
...@@ -7706,6 +7728,7 @@ public class PixelMapping { ...@@ -7706,6 +7728,7 @@ public class PixelMapping {
final int size=2*this.overlapStep; final int size=2*this.overlapStep;
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() {
DoubleFHT doubleFHT = new DoubleFHT(); DoubleFHT doubleFHT = new DoubleFHT();
final double [] window=new double [size*size]; final double [] window=new double [size*size];
...@@ -7766,6 +7789,7 @@ public class PixelMapping { ...@@ -7766,6 +7789,7 @@ public class PixelMapping {
if (showProgress){ if (showProgress){
final int finalTile=tile; final int finalTile=tile;
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
IJ.showProgress(finalTile,tiles); IJ.showProgress(finalTile,tiles);
} }
...@@ -9147,7 +9171,7 @@ public class PixelMapping { ...@@ -9147,7 +9171,7 @@ public class PixelMapping {
if (debugLevel>2) System.out.println("setupZMap() zMapWOI.x="+zMapWOI.x+" zMapWOI.y="+zMapWOI.y+ if (debugLevel>2) System.out.println("setupZMap() zMapWOI.x="+zMapWOI.x+" zMapWOI.y="+zMapWOI.y+
" zMapWOI.width="+zMapWOI.width+" zMapWOI.height="+zMapWOI.height); " zMapWOI.width="+zMapWOI.width+" zMapWOI.height="+zMapWOI.height);
this.paddedSize=this.overlapStep+2*overlap; this.paddedSize=this.overlapStep+2*overlap;
this.innerMask=(BitSet) new BitSet(this.paddedSize*this.paddedSize); this.innerMask=new BitSet(this.paddedSize*this.paddedSize);
for (int i=0;i<this.overlapStep;i++) for (int j=0;j<this.overlapStep;j++){ for (int i=0;i<this.overlapStep;i++) for (int j=0;j<this.overlapStep;j++){
this.innerMask.set((overlap+i)*this.paddedSize+overlap+j); this.innerMask.set((overlap+i)*this.paddedSize+overlap+j);
} }
...@@ -9165,6 +9189,7 @@ public class PixelMapping { ...@@ -9165,6 +9189,7 @@ public class PixelMapping {
if (showProgress) IJ.showStatus("Setting up zMap for image "+nImg+" ("+(nImg+1)+" of "+this.disparityScales.length+") ..."); if (showProgress) IJ.showStatus("Setting up zMap for image "+nImg+" ("+(nImg+1)+" of "+this.disparityScales.length+") ...");
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() {
for (int tile=tileIndexAtomic.getAndIncrement(); tile<tiles;tile=tileIndexAtomic.getAndIncrement()){ for (int tile=tileIndexAtomic.getAndIncrement(); tile<tiles;tile=tileIndexAtomic.getAndIncrement()){
setupZMapTile( setupZMapTile(
...@@ -9183,6 +9208,7 @@ public class PixelMapping { ...@@ -9183,6 +9208,7 @@ public class PixelMapping {
if (showProgress){ if (showProgress){
final int finalTile=tile; final int finalTile=tile;
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
IJ.showProgress(finalTile,tiles); IJ.showProgress(finalTile,tiles);
} }
...@@ -10502,6 +10528,7 @@ public class PixelMapping { ...@@ -10502,6 +10528,7 @@ public class PixelMapping {
final AtomicInteger rsltTileAtomic = new AtomicInteger(0); final AtomicInteger rsltTileAtomic = new AtomicInteger(0);
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() {
DoubleFHT doubleFHT=new DoubleFHT(); DoubleFHT doubleFHT=new DoubleFHT();
DoubleFHT interpolationFHT=null; // will be initialized if needed DoubleFHT interpolationFHT=null; // will be initialized if needed
...@@ -10959,6 +10986,7 @@ public class PixelMapping { ...@@ -10959,6 +10986,7 @@ public class PixelMapping {
final AtomicInteger tileXAtomic = new AtomicInteger(tileXMin); final AtomicInteger tileXAtomic = new AtomicInteger(tileXMin);
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() {
double [] alphaSlice=new double[length]; double [] alphaSlice=new double[length];
double [] channelSlice=new double[length]; double [] channelSlice=new double[length];
...@@ -12533,14 +12561,14 @@ public class PixelMapping { ...@@ -12533,14 +12561,14 @@ public class PixelMapping {
int index=pixelX[i]+pixelY[i]*imageWidth; int index=pixelX[i]+pixelY[i]*imageWidth;
dbgImage[0][index]=(float) speed[i]; // same as source image, just masked dbgImage[0][index]=(float) speed[i]; // same as source image, just masked
dbgImage[1][index]=(float) timeToReach[i]; // dbgImage[1][index]=(float) timeToReach[i]; //
dbgImage[2][index]=(float) pathArea[i]; // dbgImage[2][index]=pathArea[i]; //
dbgImage[3][index]=(float) pathLength[i]; // dbgImage[3][index]=pathLength[i]; //
if (node[i]!=null){ if (node[i]!=null){
int numParents=0; int numParents=0;
for (int dir=0;dir<8;dir++) if ((parents[i]& (1<<dir))!=0) numParents++; for (int dir=0;dir<8;dir++) if ((parents[i]& (1<<dir))!=0) numParents++;
dbgImage[4][index]=numParents; dbgImage[4][index]=numParents;
} }
dbgImage[6][index]=(float) parents[i]; // dbgImage[6][index]=parents[i]; //
} }
...@@ -15498,6 +15526,7 @@ public class PixelMapping { ...@@ -15498,6 +15526,7 @@ public class PixelMapping {
IJ.showStatus("Warping image channel "+channel); IJ.showStatus("Warping image channel "+channel);
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() {
for (int opy=opyAtomic.getAndIncrement(); opy<mapHeight;opy=opyAtomic.getAndIncrement()){ for (int opy=opyAtomic.getAndIncrement(); opy<mapHeight;opy=opyAtomic.getAndIncrement()){
...@@ -15546,6 +15575,7 @@ public class PixelMapping { ...@@ -15546,6 +15575,7 @@ public class PixelMapping {
final int numFinished=opyDoneAtomic.getAndIncrement(); final int numFinished=opyDoneAtomic.getAndIncrement();
// IJ.showProgress(progressValues[numFinished]); // IJ.showProgress(progressValues[numFinished]);
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
// Here, we can safely update the GUI // Here, we can safely update the GUI
// because we'll be called from the // because we'll be called from the
...@@ -15805,6 +15835,7 @@ public class PixelMapping { ...@@ -15805,6 +15835,7 @@ public class PixelMapping {
/** /**
* Interpolate (bi-linear) X/Y corrections and flat-field data for the sensor * Interpolate (bi-linear) X/Y corrections and flat-field data for the sensor
* @param rgbOnly - only flat field, no geometry
* @param px - pixel X coordinate (non-decimated) * @param px - pixel X coordinate (non-decimated)
* @param py - pixel Y coordinate (non-decimated) * @param py - pixel Y coordinate (non-decimated)
* @return - vector of {corrX, corrY, alpha, flatfield_red, flatfield_green, flatfield_blue} * @return - vector of {corrX, corrY, alpha, flatfield_red, flatfield_green, flatfield_blue}
...@@ -16540,6 +16571,7 @@ public class PixelMapping { ...@@ -16540,6 +16571,7 @@ public class PixelMapping {
// for (int iLat=0;iLat<equirectangularMap.pixelsVertical;iLat++){ // for (int iLat=0;iLat<equirectangularMap.pixelsVertical;iLat++){
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() {
for (int iLat=ipLatAtomic.getAndIncrement(); iLat<equirectangularMap.pixelsVertical;iLat=ipLatAtomic.getAndIncrement()){ for (int iLat=ipLatAtomic.getAndIncrement(); iLat<equirectangularMap.pixelsVertical;iLat=ipLatAtomic.getAndIncrement()){
double [] a={distortionC,distortionB,distortionA,distortionA5,distortionA6,distortionA7,distortionA8}; double [] a={distortionC,distortionB,distortionA,distortionA5,distortionA6,distortionA7,distortionA8};
...@@ -16657,6 +16689,7 @@ public class PixelMapping { ...@@ -16657,6 +16689,7 @@ public class PixelMapping {
final int numFinished=ipLatDoneAtomic.getAndIncrement(); final int numFinished=ipLatDoneAtomic.getAndIncrement();
// IJ.showProgress(progressValues[numFinished]); // IJ.showProgress(progressValues[numFinished]);
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
// Here, we can safely update the GUI // Here, we can safely update the GUI
// because we'll be called from the // because we'll be called from the
...@@ -16734,6 +16767,7 @@ public class PixelMapping { ...@@ -16734,6 +16767,7 @@ public class PixelMapping {
// for (int iLat=0;iLat<equirectangularMap.pixelsVertical;iLat++){ // for (int iLat=0;iLat<equirectangularMap.pixelsVertical;iLat++){
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() {
for (int iLat=ipLatAtomic.getAndIncrement(); iLat<equirectangularMap.pixelsVertical;iLat=ipLatAtomic.getAndIncrement()){ for (int iLat=ipLatAtomic.getAndIncrement(); iLat<equirectangularMap.pixelsVertical;iLat=ipLatAtomic.getAndIncrement()){
...@@ -16826,6 +16860,7 @@ public class PixelMapping { ...@@ -16826,6 +16860,7 @@ public class PixelMapping {
final int numFinished=ipLatDoneAtomic.getAndIncrement(); final int numFinished=ipLatDoneAtomic.getAndIncrement();
// IJ.showProgress(progressValues[numFinished]); // IJ.showProgress(progressValues[numFinished]);
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
// Here, we can safely update the GUI // Here, we can safely update the GUI
// because we'll be called from the // because we'll be called from the
......
...@@ -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