Commit ada64adb authored by Andrey Filippov's avatar Andrey Filippov
Browse files

implementing non-radial corrections to lens polynomial model

parent ab077ab1
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -403,7 +403,9 @@ public static MatchSimulatedPattern.DistortionParameters DISTORTION =new MatchSi
    		2360,// double distance// distance from the lens input pupil to the pattern plane along the camera axis, mm 
    		1296.0, // double px0     // lens axis from sensor, horizontal, from left (pixels)
    		968.0, // double py0     // lens axis from sensor, vertical, from top (pixels)
    		true//  boolean flipVertical // acquired image is mirrored vertically (mirror used)
    		true, //  boolean flipVertical // acquired image is mirrored vertically (mirror used)
    		null, //  double [][] r_xy,
    		null  //  double [][] r_od
    		);
//    public static double [] defaultGoniometerPosition={0.0, 0.0, 2360};
    public static EyesisCameraParameters EYESIS_CAMERA_PARAMETERS=new EyesisCameraParameters(
+45 −5
Original line number Diff line number Diff line
@@ -264,7 +264,7 @@ import org.apache.commons.configuration.XMLConfiguration;
        	}
    	}
    	public class GridImageSet{
    		private int numPars=27;
    		private int numPars=53; // 27;
    		private int thisParsStartIndex=6;

    		public int         stationNumber=0; // changes when camera/goniometer is moved to new position
@@ -465,12 +465,48 @@ import org.apache.commons.configuration.XMLConfiguration;
    			{"subcamDistortionA5",   "Distortion A5(r^5)","relative","S","I"},                                                              //23 (21)
    			{"subcamDistortionA",    "Distortion A (r^4)","relative","S","I"},                                                              //24 (22)
    			{"subcamDistortionB",    "Distortion B (r^3)","relative","S","I"},                                                              //25 (23)
    			{"subcamDistortionC",    "Distortion C (r^2)","relative","S","I"}                                                               //26 (24)
    			{"subcamDistortionC",    "Distortion C (r^2)","relative","S","I"},                                                               //26 (24)
    			
        		{"subcamElong_C_o",      "Orthogonal elongation for r^2","relative","S","I"},     // 27 39 (37)
        		{"subcamElong_C_d",      "Diagonal   elongation for r^2","relative","S","I"},     // 28 40 (38)

        		{"subcamEccen_B_x",      "Distortion center shift X for r^3","relative","S","I"}, // 29 27 (25)
        		{"subcamEccen_B_y",      "Distortion center shift Y for r^3","relative","S","I"}, // 30 28 (26)
        		{"subcamElong_B_o",      "Orthogonal elongation for r^3","relative","S","I"},     // 31 41 (39)
        		{"subcamElong_B_d",      "Diagonal   elongation for r^3","relative","S","I"},     // 32 42 (40)

        		{"subcamEccen_A_x",      "Distortion center shift X for r^4","relative","S","I"}, // 33 29 (27)
        		{"subcamEccen_A_y",      "Distortion center shift Y for r^4","relative","S","I"}, // 34 30 (28)
        		{"subcamElong_A_o",      "Orthogonal elongation for r^4","relative","S","I"},     // 35 43 (41)
        		{"subcamElong_A_d",      "Diagonal   elongation for r^4","relative","S","I"},     // 36 44 (42)

        		{"subcamEccen_A5_x",     "Distortion center shift X for r^5","relative","S","I"}, // 37 31 (29)
        		{"subcamEccen_A5_y",     "Distortion center shift Y for r^5","relative","S","I"}, // 38 32 (30)
        		{"subcamElong_A5_o",     "Orthogonal elongation for r^5","relative","S","I"},     // 39 45 (43)
        		{"subcamElong_A5_d",     "Diagonal   elongation for r^5","relative","S","I"},     // 40 46 (44)

        		{"subcamEccen_A6_x",     "Distortion center shift X for r^6","relative","S","I"}, // 41 33 (31)
        		{"subcamEccen_A6_y",     "Distortion center shift Y for r^6","relative","S","I"}, // 42 34 (32)
        		{"subcamElong_A6_o",     "Orthogonal elongation for r^6","relative","S","I"},     // 43 47 (45)
        		{"subcamElong_A6_d",     "Diagonal   elongation for r^6","relative","S","I"},     // 44 48 (46)

        		{"subcamEccen_A7_x",     "Distortion center shift X for r^7","relative","S","I"}, // 45 35 (33)
        		{"subcamEccen_A7_y",     "Distortion center shift Y for r^7","relative","S","I"}, // 46 36 (34)
        		{"subcamElong_A7_o",     "Orthogonal elongation for r^7","relative","S","I"},     // 47 49 (47)
        		{"subcamElong_A7_d",     "Diagonal   elongation for r^7","relative","S","I"},     // 48 50 (48)

        		{"subcamEccen_A8_x",     "Distortion center shift X for r^8","relative","S","I"}, // 49 37 (35)
        		{"subcamEccen_A8_y",     "Distortion center shift Y for r^8","relative","S","I"}, // 50 38 (36)
        		{"subcamElong_A8_o",     "Orthogonal elongation for r^8","relative","S","I"},     // 51 51 (49)
        		{"subcamElong_A8_d",     "Diagonal   elongation for r^8","relative","S","I"}      // 52 52 (50)
        };
        public String [] channelSuffixes={ // natural order (same as array indices, may be modified to camera/subcamera
        		"00","01","02","03","04","05","06","07","08","09",
        		"10","11","12","13","14","15","16","17","18","19",
        		"20","21","22","23","24","25","26","27","28","29"};
        public boolean isNonRadial(int index){
        	return parameterDescriptions[index][0].startsWith("subcamEccen_") || parameterDescriptions[index][0].startsWith("subcamElong_");
        }
        public int getParameterIndexByName(String name){
        	for (int i=0;i<this.parameterDescriptions.length;i++) if (this.parameterDescriptions[i][0].equals(name)){
        		return i;
@@ -1550,7 +1586,7 @@ import org.apache.commons.configuration.XMLConfiguration;
                	int minIndex=       this.gIS[index].getMinIndex();
                	int maxIndexPlusOne=this.gIS[index].getMaxIndexPlusOne();
                	for (int j=minIndex;j<maxIndexPlusOne;j++) if (sub.getString(parameterDescriptions[j][0])!=null) {
                		this.gIS[index].setParameterValue(j,Double.parseDouble((sub.getString(parameterDescriptions[j][0]))), false);
                		this.gIS[index].setParameterValue(j,Double.parseDouble(sub.getString(parameterDescriptions[j][0])), false);
                	}
            		if (sub.getString("orientationEstimated")!=null) {
            			this.gIS[i].orientationEstimated=Boolean.parseBoolean(sub.getString("orientationEstimated"));
@@ -1590,9 +1626,13 @@ import org.apache.commons.configuration.XMLConfiguration;
        			if (sub.getString(parameterDescriptions[j][0])!=null)
        				this.pars[i][j] = Double.parseDouble(sub.getString(parameterDescriptions[j][0]));
        			else
        				if (isNonRadial(j)){
        					this.pars[i][j] = 0.0; // old calibration files without non-radial parameters
        				} else {
        					this.pars[i][j] = Double.NaN;
        				}
        		}
        	}
        	if (this.gIS!=null){
            	System.out.println("Using stored image set data");
        		for (int is=0;is<this.gIS.length;is++){
+65 −13
Original line number Diff line number Diff line
@@ -30,8 +30,10 @@ import ij.io.Opener;
import ij.process.FloatProcessor;
import ij.process.ImageProcessor;
import ij.text.TextWindow;

import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.util.Arrays;
//import java.io.StringWriter;
import java.util.List;
import java.util.ArrayList;
@@ -3299,7 +3301,7 @@ For each point in the image
		double [] vectorFX=new double[doubleNumAllPoints];
//		this.fX=new double[doubleNumAllPoints];
		if (this.debugLevel>2) {
			System.out.println("calculateFxAndJacobian(), calcJacobian="+calcJacobian);
			System.out.println("calculateFxAndJacobian(), calcJacobian="+calcJacobian+" D3304 + this.debugLevel="+this.debugLevel);
			if (vector!=null) {
			  for (int ii=0;ii<vector.length;ii++) System.out.println(ii+": "+vector[ii]);
			} else {
@@ -3331,8 +3333,9 @@ For each point in the image
// and this.interParameterDerivatives
//			if (this.debugLevel>1) {
			if (this.debugLevel>2) {
				System.out.println("calculateFxAndJacobian(), imgNum="+imgNum+" calcInterParamers():");
				System.out.println("calculateFxAndJacobian(), imgNum="+imgNum+" calcInterParamers(): (D3336)");
			}
			this.lensDistortionParameters.debugLevel=this.debugLevel;
			this.lensDistortionParameters.lensCalcInterParamers(
					this.lensDistortionParameters,
					this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod,
@@ -3359,7 +3362,7 @@ For each point in the image
	    					IJ.d2s(targetXYZ[fullIndex][1],2)+","+
	    					IJ.d2s(targetXYZ[fullIndex][2],2)+" ("+calcJacobian+") -> "+
	    					IJ.d2s(derivatives15[0][0],2)+"/"+IJ.d2s(derivatives15[0][1],2));
	    			String all="derivatives15:";
	    			String all="derivatives15: D3365";
	    			for (int ii=0;ii<derivatives15.length;ii++) all+=" "+ii+":"+IJ.d2s(derivatives15[ii][0],3)+"/"+IJ.d2s(derivatives15[ii][1],3);
	    			System.out.println(all);
	    		}
@@ -3470,7 +3473,7 @@ For each point in the image
						IJ.d2s(patternXYZ[fullIndex][1],2)+","+
						IJ.d2s(patternXYZ[fullIndex][2],2)+" ("+calcJacobian+") -> "+
						IJ.d2s(derivatives15[0][0],2)+"/"+IJ.d2s(derivatives15[0][1],2));
				String all="derivatives15:";
				String all="derivatives15: D3476";
				for (int ii=0;ii<derivatives15.length;ii++) all+=" "+ii+":"+IJ.d2s(derivatives15[ii][0],3)+"/"+IJ.d2s(derivatives15[ii][1],3);
				System.out.println(all);
			}
@@ -3557,7 +3560,7 @@ For each point in the image
									IJ.d2s(targetXYZ[fullIndex][1],2)+","+
									IJ.d2s(targetXYZ[fullIndex][2],2)+" -> "+
									IJ.d2s(derivatives15[0][0],2)+"/"+IJ.d2s(derivatives15[0][1],2));
							String all="derivatives15:";
							String all="derivatives15: D3563";
							for (int ii=0;ii<derivatives15.length;ii++) all+=" "+ii+":"+IJ.d2s(derivatives15[ii][0],3)+"/"+IJ.d2s(derivatives15[ii][1],3);
							System.out.println(all);
						}
@@ -5916,6 +5919,14 @@ List calibration
    	imp.setProperty("comment_entrancePupilForward",  "entrance pupil distance from the azimuth/radius/height, outwards in mm");
    	imp.setProperty("entrancePupilForward",  ""+entrancePupilForward); // currently global, decoders will use per-sensor
       	imp.setProperty("comment_defects", "Sensor hot/cold pixels list as x:y:difference");
		for (int i=0;i<subCam.r_xy.length;i++){
			imp.setProperty("r_xy_"+i+"_x",subCam.r_xy[i][0]+"");
			imp.setProperty("r_xy_"+i+"_y",subCam.r_xy[i][1]+"");
		}
		for (int i=0;i<subCam.r_od.length;i++){
			imp.setProperty("r_od_"+i+"_o",subCam.r_od[i][0]+"");
			imp.setProperty("r_od_"+i+"_d",subCam.r_od[i][1]+"");
		}
       	if (subCam.defectsXY!=null){
    		StringBuffer sb = new StringBuffer();
    		for (int i=0;i<subCam.defectsXY.length;i++){
@@ -6076,6 +6087,16 @@ List calibration
        		subCam.defectsXY=null;
        		subCam.defectsDiff=null;
        	}
 // non-radial
        	subCam.setDefaultNonRadial();
			for (int i=0;i<subCam.r_xy.length;i++) {
				if (imp.getProperty("r_xy_"+i+"_x")  !=null) subCam.r_xy[i][0]= Double.parseDouble((String) imp.getProperty("r_xy_"+i+"_x"));
				if (imp.getProperty("r_xy_"+i+"_y")  !=null) subCam.r_xy[i][1]= Double.parseDouble((String) imp.getProperty("r_xy_"+i+"_y"));
			}
			for (int i=0;i<subCam.r_od.length;i++) {
				if (imp.getProperty("r_od_"+i+"_o")  !=null) subCam.r_od[i][0]= Double.parseDouble((String) imp.getProperty("r_od_"+i+"_o"));
				if (imp.getProperty("r_od_"+i+"_d")  !=null) subCam.r_od[i][1]= Double.parseDouble((String) imp.getProperty("r_od_"+i+"_d"));
			}
        }
        for (int imgNum=0;imgNum<fittingStrategy.distortionCalibrationData.getNumImages();imgNum++){
        	int imageSubCam=  fittingStrategy.distortionCalibrationData.getImageSubcamera(imgNum);
@@ -9289,7 +9310,7 @@ M * V = B
			gd.addNumericField("Select parameter number (0.."+(parameterNames.length-1)+") from above", 0, 0);

	    }
		if (debugDerivatives) gd.addNumericField("Select delta to increment selected parameter", .01, 5);
		if (debugDerivatives) gd.addNumericField("Select delta to increment selected parameter", .001, 5);
		if (debugDerivatives) gd.addCheckbox("Show inter-parameter derivatives matrix", true);
	    gd.showDialog();
	    if (gd.wasCanceled()) return;
@@ -9304,7 +9325,7 @@ M * V = B
	    String title;
	    if (useActualParameters) {
	    	this_currentfX=calculateFxAndJacobian(this.currentVector, true); // is it always true here (this.jacobian==null)
	    	d_derivative=this.jacobian[selectedParameter].clone();
	    	d_derivative=this.jacobian[selectedParameter].clone(); //  wrong?
	    	if (debugDerivatives) {
	    		double[] modVector=this.currentVector.clone();
	    		modVector[selectedParameter]+=delta;
@@ -9354,13 +9375,17 @@ M * V = B
	 * @return rms 
	 */
	public double showCompareDerivatives(int imgNumber, double [] d_derivative, double [] d_delta, boolean applySensorMask, String title ){
		String [] titlesDebug={"dX-derivative","dY-derivative","abs-derivative","diff-X (should be 0)","diff-Y (should be 0)","dX-delta/delta","dY-delta/delta"};
		String [] titlesDebug={"dX-derivative","dY-derivative","abs-derivative","diff-X (should be 0)","diff-Y (should be 0)","dX-delta/delta","dY-delta/delta","dX-delta","dY-delta"};
		String [] titlesNoDebug={"dX-derivative","dY-derivative","abs-derivative"};
		String [] titles= (d_delta==null)? titlesNoDebug:titlesDebug;
		double [] d_diff=new double [d_derivative.length];
		double [] r_diff=new double [d_derivative.length];
		double [] aDeriv=new double [d_derivative.length/2];
		
		if (d_delta!=null) for (int i=0;i<d_diff.length;i++) d_diff[i]=d_derivative[i]-d_delta[i];
		if (d_delta!=null) for (int i=0;i<d_diff.length;i++){
			d_diff[i]=d_derivative[i]-d_delta[i];
			r_diff[i]=d_diff[i]/d_delta[i];
		}
// find data range for the selected image
		int index=0;
		int numImg=fittingStrategy.distortionCalibrationData.getNumImages();
@@ -9396,8 +9421,10 @@ M * V = B
			if (d_delta!=null) {
				imgData[3][vu]=   d_diff[2*(index+i)];
				imgData[4][vu]=   d_diff[2*(index+i)+1];
				imgData[5][vu]=   d_delta[2*(index+i)];
				imgData[6][vu]=   d_delta[2*(index+i)+1];
				imgData[5][vu]=   r_diff[2*(index+i)];
				imgData[6][vu]=   r_diff[2*(index+i)+1];
				imgData[7][vu]=   d_delta[2*(index+i)];
				imgData[8][vu]=   d_delta[2*(index+i)+1];
			}
		}
		this.SDFA_INSTANCE.showArrays(imgData, width, getGridHeight(),  true, title, titles);
@@ -9456,6 +9483,14 @@ M * V = B
        	System.out.println("this.lensDistortionParameters.distortionA="+IJ.d2s(this.lensDistortionParameters.distortionA, 5));
        	System.out.println("this.lensDistortionParameters.distortionB="+IJ.d2s(this.lensDistortionParameters.distortionB, 5));
        	System.out.println("this.lensDistortionParameters.distortionC="+IJ.d2s(this.lensDistortionParameters.distortionC, 5));
        	for (int i=0;i<this.lensDistortionParameters.r_xy.length;i++){
            	System.out.println("this.lensDistortionParameters.r_xy["+i+"][0]="+IJ.d2s(this.lensDistortionParameters.r_xy[i][0], 5));
            	System.out.println("this.lensDistortionParameters.r_xy["+i+"][1]="+IJ.d2s(this.lensDistortionParameters.r_xy[i][1], 5));
        	}
        	for (int i=0;i<this.lensDistortionParameters.r_od.length;i++){
            	System.out.println("this.lensDistortionParameters.r_od["+i+"][0]="+IJ.d2s(this.lensDistortionParameters.r_od[i][0], 5));
            	System.out.println("this.lensDistortionParameters.r_od["+i+"][1]="+IJ.d2s(this.lensDistortionParameters.r_od[i][1], 5));
        	}
        }
        LensDistortionParameters ldp=this.lensDistortionParameters.clone();
//		public void setLensDistortionParameters(LensDistortionParameters ldp
@@ -9612,6 +9647,7 @@ M * V = B
    		DistortionCalibrationData distortionCalibrationData,
    		EyesisCameraParameters eyesisCameraParameters
    ){
    	boolean resetParametersToZero=false;
    	boolean [] parameterMask= new boolean[distortionCalibrationData.getNumParameters()];
    	boolean [] channelMask=   new boolean[distortionCalibrationData.getNumSubCameras()];
    	boolean [] stationMask=   new boolean[distortionCalibrationData.getNumStations()];
@@ -9619,7 +9655,9 @@ M * V = B
    	for (int i=0;i<channelMask.length;i++)   channelMask[i]=  true;
    	for (int i=0;i<stationMask.length;i++)   stationMask[i]=  true;
    	GenericDialog gd=new GenericDialog("Update (new) image settings from known data");
    	gd.addMessage("Select which individual image parameters to be updated from the camera parameters");
    	//
    	gd.addCheckbox("Reset selected parameters to zero (false - update from camera parameters)", resetParametersToZero);
    	gd.addMessage("Select which individual image parameters to be updated from the camera parameters (or reset to 0)");
    	for (int i=0;i<parameterMask.length;i++) gd.addCheckbox(i+": "+distortionCalibrationData.getParameterName(i), parameterMask[i]);
    	gd.addMessage("----------");
    	gd.addMessage("Select which channels (sub-cameras) to update");
@@ -9637,6 +9675,7 @@ M * V = B
	    WindowTools.addScrollBars(gd);
    	gd.showDialog();
    	if (gd.wasCanceled()) return false;
    	resetParametersToZero=gd.getNextBoolean();
    	for (int i=0;i<parameterMask.length;i++) parameterMask[i]= gd.getNextBoolean();
    	for (int i=0;i<channelMask.length;i++)   channelMask[i]=   gd.getNextBoolean();
    	if (stationMask.length>1) {
@@ -9653,6 +9692,7 @@ M * V = B
		
//		boolean updateDisabled=       gd.getNextBoolean();
    	updateImageSetFromCamera(
    			resetParametersToZero,
    			distortionCalibrationData,
    			eyesisCameraParameters,
    			parameterMask, //boolean [] parameterMask,
@@ -9741,6 +9781,7 @@ M * V = B
    	}
    	
    	if (updateFromCamera) updateImageSetFromCamera(
    			false, //resetParametersToZero
    			distortionCalibrationData,
    			eyesisCameraParameters,
    			parameterMask, //boolean [] parameterMask,
@@ -9771,6 +9812,7 @@ M * V = B
     * @param copyOrientation copy 2 goniometer angles, normally should be false
     */
    public void updateImageSetFromCamera(
    		boolean resetParametersToZero, // reset to 0 instead of camera parameters
    		DistortionCalibrationData distortionCalibrationData,
    		EyesisCameraParameters eyesisCameraParameters,
    		boolean [] parameterMask,
@@ -9785,7 +9827,17 @@ M * V = B
    		if ((stationMask!=null) && !stationMask[stationNumber]) continue;
    		double [] oldVector=distortionCalibrationData.getParameters(i);
    		double [] newVector=eyesisCameraParameters.getParametersVector(stationNumber,subCam);
    		for (int j=0;j<oldVector.length;j++) if (parameterMask[j]) oldVector[j]=newVector[j];
    		for (int j=0;j<oldVector.length;j++) if (parameterMask[j]){
    			if (resetParametersToZero) newVector[j]=0.0;
    			oldVector[j]=newVector[j];
    		}
    		if (resetParametersToZero){
    			eyesisCameraParameters.setParametersVector(
    					newVector,
    					parameterMask,
    					stationNumber,
    					subCam);
    		}
    		distortionCalibrationData.setParameters(oldVector, i);
    		this.lensDistortionParameters.pixelSize=eyesisCameraParameters.getPixelSize(subCam);
    		this.lensDistortionParameters.distortionRadius=eyesisCameraParameters.getDistortionRadius(subCam);
+136 −5

File changed.

Preview size limit exceeded, changes collapsed.

+54 −3
Original line number Diff line number Diff line
@@ -47,6 +47,24 @@ import java.util.Properties;
		public double channelWeightCurrent=1.0;
		public int [][] defectsXY=null; // pixel defects coordinates list (starting with worst)
		public double [] defectsDiff=null; // pixel defects value (diff from average of neighbors), matching defectsXY
		
		final private double [][] r_xy_dflt={{0.0,0.0},{0.0,0.0},{0.0,0.0},{0.0,0.0},{0.0,0.0},{0.0,0.0}}; // only 6, as for the first term delta x, delta y ==0  
		final private double [][] r_od_dflt=   {{0.0,0.0},{0.0,0.0},{0.0,0.0},{0.0,0.0},{0.0,0.0},{0.0,0.0},{0.0,0.0}}; // ortho
		
		public double [][] r_xy=null; // only 6, as for the first term delta x, delta y ==0  
		public double [][] r_od=null; // ortho
		/*
		 Modifying to accommodate for eccentricity of different terms (2 parameters per term) and elliptical shape (another 2 terms). When all are
		 zeroes, the old parameters are in effect:
				Rdist/R=A8*R^7+A7*R^6+A6*R^5+A5*R^4+A*R^3+B*R^2+C*R+(1-A6-A7-A6-A5-A-B-C)");
				Rdist/R=A8*R6^7+A7*R5^6+A6*R4^5+A5*R3^4+A*R2^3+B*R1^2+C*R0+(1-A6-A7-A6-A5-A-B-C)");
				R[i] depends on px,py and r_xy[i][], r_o[i] (positive - "landscape", negative - "portrait"), r_d (positive - along y=x, negative - along y=-x)
				R[i] = r0[i]*(1+  (r_od[i][0]*(y[i]**2-x[i]**2)+ 2*r_od[i][1]*x[i]*y[i])/r0[i]**2;
				r0[i]=sqrt(x[i]**2+y[2]**2)
				x[i]=pixel_x-px0-((i>0)?r_xy[i-1][0]:0) 
				y[i]=pixel_y-py0-((i>0)?r_xy[i-1][1]:0)
		*/		
		
    	public EyesisSubCameraParameters(
    			double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
    			double radius,  // mm, distance from the rotation axis
@@ -66,6 +84,8 @@ import java.util.Properties;
    			double distortionC, // r^2
    			double px0,           // center of the lens on the sensor, pixels
    			double py0,           // center of the lens on the sensor, pixels
				double [][] r_xy,     // eccentricity for b,a,a5,a6,a7,a8
				double [][] r_od,     // elongation for c,b,a,a5,a6,a7,a8
    			double channelWeightDefault
    	){
    		this.azimuth=azimuth;
@@ -86,6 +106,12 @@ import java.util.Properties;
    		this.distortionC=distortionC; // r^2
    		this.px0=px0;
    		this.py0=py0;
			if (r_xy==null) r_xy=r_xy_dflt;
			if (r_od==null) r_od=r_od_dflt;
			this.r_xy=new double [r_xy.length][2];
			for (int i=0;i<r_xy.length;i++)this.r_xy[i]=r_xy[i].clone();
			this.r_od=new double [r_od.length][2];
			for (int i=0;i<r_od.length;i++)this.r_od[i]=r_od[i].clone();
    		this.channelWeightDefault=channelWeightDefault;
    		this.channelWeightCurrent=this.channelWeightDefault;
    		this.defectsXY=null; // pixel defects coordinates list (starting with worst)
@@ -113,10 +139,18 @@ import java.util.Properties;
    	    		this.distortionC,
    	    		this.px0,
    	    		this.py0,
    				this.r_xy,
    				this.r_od,
    	    		this.channelWeightDefault
    				);
    	}

    	public void setDefaultNonRadial(){
			r_od=new double [r_od_dflt.length][2];
			for (int i=0;i<r_od.length;i++) r_od[i]=r_od_dflt[i].clone();
			r_xy=new double [r_xy_dflt.length][2];
			for (int i=0;i<r_xy.length;i++) r_xy[i]=r_xy_dflt[i].clone();
    	}
// TODO: add/restore new properties
    	public void setProperties(String prefix,Properties properties){
    		properties.setProperty(prefix+"azimuth",this.azimuth+"");
    		properties.setProperty(prefix+"radius",this.radius+"");
@@ -136,6 +170,14 @@ import java.util.Properties;
			properties.setProperty(prefix+"distortionC",this.distortionC+"");
			properties.setProperty(prefix+"px0",this.px0+"");
			properties.setProperty(prefix+"py0",this.py0+"");
			for (int i=0;i<this.r_xy.length;i++){
				properties.setProperty(prefix+"r_xy_"+i+"_x",this.r_xy[i][0]+"");
				properties.setProperty(prefix+"r_xy_"+i+"_y",this.r_xy[i][1]+"");
			}
			for (int i=0;i<this.r_od.length;i++){
				properties.setProperty(prefix+"r_od_"+i+"_o",this.r_od[i][0]+"");
				properties.setProperty(prefix+"r_od_"+i+"_d",this.r_od[i][1]+"");
			}
			properties.setProperty(prefix+"channelWeightDefault",this.channelWeightDefault+"");
    	}
    	public void getProperties(String prefix,Properties properties){
@@ -175,6 +217,16 @@ import java.util.Properties;
				this.px0=Double.parseDouble(properties.getProperty(prefix+"px0"));
			if (properties.getProperty(prefix+"py0")!=null)
				this.py0=Double.parseDouble(properties.getProperty(prefix+"py0"));
			setDefaultNonRadial();
			for (int i=0;i<this.r_xy.length;i++){
				if (properties.getProperty(prefix+"r_xy_"+i+"_x")!=null) this.r_xy[i][0]=Double.parseDouble(properties.getProperty(prefix+"r_xy_"+i+"_x"));
				if (properties.getProperty(prefix+"r_xy_"+i+"_y")!=null) this.r_xy[i][1]=Double.parseDouble(properties.getProperty(prefix+"r_xy_"+i+"_y"));
			}
			for (int i=0;i<this.r_od.length;i++){
				if (properties.getProperty(prefix+"r_od_"+i+"_o")!=null) this.r_od[i][0]=Double.parseDouble(properties.getProperty(prefix+"r_od_"+i+"_o"));
				if (properties.getProperty(prefix+"r_od_"+i+"_d")!=null) this.r_od[i][1]=Double.parseDouble(properties.getProperty(prefix+"r_od_"+i+"_d"));
			}

			if (properties.getProperty(prefix+"channelWeightDefault")!=null) {
				this.channelWeightDefault=Double.parseDouble(properties.getProperty(prefix+"channelWeightDefault"));
				this.channelWeightCurrent=this.channelWeightDefault;
@@ -190,5 +242,4 @@ import java.util.Properties;
    	public double getChannelWeightDefault(){
    		return this.channelWeightDefault;
    	}

    }
Loading