Commit 1c62dfa5 authored by Andrey Filippov's avatar Andrey Filippov

Creating kernel and matching images from different altitude

parent 2a60dccc
......@@ -346,7 +346,7 @@ public class DoubleFHT {
return phaseCorrelate(first, phaseCoeff, filter,fht_save);
}
public double [] phaseCorrelate (
public double [] phaseCorrelate ( // never
double [] first,
double phaseCoeff,
double [] filter) { // high/low pass filtering
......@@ -561,7 +561,7 @@ public class DoubleFHT {
if (debug) ShowDoubleFloatArrays.showArrays(this.translateFHT, "translateFHT-"+IJ.d2s(dx,3)+":"+IJ.d2s(dy,3));
}
private boolean updateMaxN(double [] data){
public boolean updateMaxN(double [] data){ // was private
if (data==null) return false; // do nothing
if (!powerOf2Size(data)) {
String msg="Image is not power of 2 size";
......@@ -2146,6 +2146,41 @@ public class DoubleFHT {
return result;
}
public double [] divide(double [] h1, double [] h2, double fat_zero) {
int rowMod, colMod;
double mag, h2e, h2o;
double fz2=fat_zero*fat_zero;
double[] result = new double[maxN*maxN];
for (int r=0; r<maxN; r++) {
rowMod = (maxN - r) % maxN;
for (int c=0; c<maxN; c++) {
colMod = (maxN - c) % maxN;
mag =h2[r*maxN+c] * h2[r*maxN+c] + h2[rowMod*maxN+colMod] * h2[rowMod*maxN+colMod]+fz2;
if (mag<1e-20)
mag = 1e-20;
h2e = (h2[r*maxN+c] + h2[rowMod*maxN+colMod]);
h2o = (h2[r*maxN+c] - h2[rowMod*maxN+colMod]);
double tmp = (h1[r*maxN+c] * h2e - h1[rowMod*maxN+colMod] * h2o);
result[r*maxN+c] = tmp/mag;
}
}
return result;
}
public double [] setReal (double [] amp) { // only first half used
double[] result = new double[maxN*maxN];
int rowMod, colMod;
for (int r=0; r<maxN/2; r++) {
rowMod = (maxN - r) % maxN;
for (int c=0; c<maxN; c++) {
colMod = (maxN - c) % maxN;
result[r*maxN+c] = amp[r*maxN+c];
result[rowMod*maxN+colMod] = amp[r*maxN+c];
}
}
return result;
}
public double [] calculateAmplitude(double [] fht) {
int size=(int) Math.sqrt(fht.length);
......@@ -2156,6 +2191,31 @@ public class DoubleFHT {
swapQuadrants(amp);
return amp;
}
public double [] calculateAmplitudeNoSwap(double [] fht) {
int size=(int) Math.sqrt(fht.length);
double[] amp = new double[size*size];
for (int row=0; row<size; row++) {
amplitude(row, size, fht, amp);
}
return amp;
}
public static double [] calculatePhaseNoSwap(double [] fht) {
int size=(int) Math.sqrt(fht.length);
double[] phs = new double[size*size];
for (int row=0; row<size; row++) {
phase(row, size, fht, phs);
}
return phs;
}
public double [] calculatePhase(double [] fht) {
int size=(int) Math.sqrt(fht.length);
double[] phs = new double[size*size];
for (int row=0; row<size; row++) {
phase(row, size, fht, phs);
}
swapQuadrants(phs);
return phs;
}
public double [] calculateAmplitudeHalf(double [] fht) {
int size=(int) Math.sqrt(fht.length);
......@@ -2186,6 +2246,19 @@ public class DoubleFHT {
}
}
static void phase(int row, int size, double[] fht, double[] phase) {
int base = row*size;
int l;
for (int c=0; c<size; c++) {
l = ((size-row)%size) * size + (size-c)%size;
double re=0.5*(fht[base+c]+fht[l]);
double im=0.5*(fht[base+c]-fht[l]);
phase[base+c] = Math.atan2(im,re);;
}
}
/* Squared amplitude of one row from 2D Hartley Transform. */
void amplitude2(int row, int size, double[] fht, double[] amplitude) {
int base = row*size;
......
......@@ -849,6 +849,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
addButton("Read Tiff", panelLWIRWorld, color_process);
addButton("Set pair GPS", panelLWIRWorld, color_process);
addButton("Test video", panelLWIRWorld, color_process);
addButton("Deconvolve Slices", panelLWIRWorld, color_process);
plugInFrame.add(panelLWIRWorld);
}
......@@ -5733,8 +5734,22 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
return;
}
OrthoMap.testVideo(imp_sel);
} else if (label.equals("Deconvolve Slices")) {
ImagePlus imp_sel = WindowManager.getCurrentImage();
if (imp_sel == null) {
IJ.showMessage("Error", "No images selected");
return;
}
OrthoMap.testDeconvolveSlices(
imp_sel, // ImagePlus imp,
512, // int [] slices,
new int [] {1,2}, // int [] slices, deconvolve slice 2 with slice1
4, // int kernel_radius,
true, // boolean hor_sym,
true, // boolean vert_sym,
true, // false, // boolean all_sym,
DEBUG_LEVEL); // int debugLevel) { // >0
}
}
public boolean debugInitOneScene() {
......
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