Commit a6cd306e authored by Andrey Filippov's avatar Andrey Filippov

more on pattern detection

parent 4ffb8a32
......@@ -9262,7 +9262,8 @@ dbgThis=true;
" numOfNeib="+numOfNeib+" (distortionParameters.correlationAverageOnRefine="+distortionParameters.correlationAverageOnRefine);
}
double [][] modelCorrs=new double[numOfNeib][];
double [][] modelCorrs= new double[numOfNeib][];
double [][] modelCorrs_new= new double[numOfNeib][];
double [][] debugGreens=new double[numOfNeib][0];
for (numNeib=0;numNeib<numOfNeib;numNeib++) {
neibCenter[0]=diffBeforeXY[0]+0.5*(greenNeib[numNeib][0]+greenNeib[numNeib][1]);
......@@ -9309,14 +9310,24 @@ dbgThis=true;
debugGreens[numNeib]=simGreensCentered.clone();
// testing if phase reversal would exactly inverse result pattern - tested, perfect
double [] simGreensCenteredClone = simGreensCentered.clone();
modelCorrs[numNeib]=fht_instance.correlate (greens.clone(), // measured pixel array
// modelCorr=fht_instance.correlate (greens, // measured pixel array
simGreensCentered, // simulated (model) pixel array)
// distortionParameters.correlationHighPassSigma);
distortionParameters.correlationHighPassSigma,
fast?distortionParameters.correlationLowPassSigma:0.0,// moved to decimation via FFT
distortionParameters.phaseCorrelationFraction);
(fast ? distortionParameters.correlationLowPassSigma : 0.0),// moved to decimation via FFT
distortionParameters.phaseCorrelationFraction);
modelCorrs_new[numNeib]=fht_instance.phaseCorrelate (
greens.clone(),
simGreensCenteredClone,
patternDetectParameters.phaseCoeff,
0,// distortionParameters.correlationHighPassSigma,
patternDetectParameters.lowpass_sigma, // (fast?distortionParameters.correlationLowPassSigma:0.0),// moved to decimation via FFT
null,
null);
if (dbgStr!=null) {
double dbgSumWindow=0.0;
for (double[] dbgSlice:modelCorrs) for (double dbgD:dbgSlice) dbgSumWindow+=dbgD;
......@@ -9333,6 +9344,7 @@ dbgThis=true;
if (debug_level > (debug_threshold + 0)){
System.out.println(">=========Showing modelCorrs, passNumber="+passNumber);
SDFA_INSTANCE.showArrays(modelCorrs, true, "modelCorrs:"+numOfNeib);
SDFA_INSTANCE.showArrays(modelCorrs_new, true, "modelCorrs_new:"+numOfNeib);
}
// combine 4 correlations into the double resolution, same output size (so half input size) array
......
......@@ -303,7 +303,7 @@ public class DoubleFHT {
else return phaseCorrelate (first, second, phaseCoeff,filter);
}
//asymmetrical - will divide by squared second amplitude (pattern to match)
public double [] phaseCorrelate (
public double [] phaseCorrelate ( // old
double [] first,
double [] second,
double phaseCoeff,
......@@ -371,6 +371,56 @@ public class DoubleFHT {
swapQuadrants(first);
return first;
}
public double [] phaseCorrelate (
double [] first,
double [] second,
double phaseCoeff,
double highPassSigma,
double lowPassSigma,
double [] first_save,
double [] second_save ){ //null-OK
updateMaxN(first);
double [] filter = null;
if ((highPassSigma >0) || (lowPassSigma > 0)) {
filter = createFrequencyFilter(highPassSigma, lowPassSigma);
}
return phaseCorrelate (
first,
second,
phaseCoeff,
filter, // high/low pass filtering
first_save,
second_save );
}
public double [] phaseCorrelate ( // new
double [] first,
double [] second,
double phaseCoeff,
double [] filter, // high/low pass filtering
double [] first_save,
double [] second_save ){ //null-OK
if (first.length!=second.length) {
IJ.showMessage("Error","Correlation arrays should be the same size");
return null;
}
updateMaxN(first);
swapQuadrants(first);
swapQuadrants(second);
if (!transform(first,false)) return null; // direct FHT
if (!transform(second,false)) return null; // direct FHT
if (first_save != null) System.arraycopy(first, 0, first_save, 0, first.length);
if (second_save != null) System.arraycopy(second, 0, second_save, 0, second.length);
first= phaseMultiplyNorm(first, second, phaseCoeff); // correlation, not convolution
if (filter!=null) multiplyByReal(first, filter);
transform(first,true) ; // inverse transform
swapQuadrants(first);
return first;
}
//
public double [] applyFreqFilter(
double [] first,
......
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