Commit 96c4558f authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Debugging fitting strategies, initial image parameter setup

parent f1c19f00
Loading
Loading
Loading
Loading
+34 −15
Original line number Original line Diff line number Diff line
@@ -2634,6 +2634,7 @@ if (MORE_BUTTONS) {
					parFilter,
					parFilter,
					""); //String defaultPath
					""); //String defaultPath
			if ((pathname==null) || (pathname=="")) return;
			if ((pathname==null) || (pathname=="")) return;
			System.out.println("*** Will not work with different size senspors !!!");
		    DISTORTION_CALIBRATION_DATA.setMaskFromImageStack(pathname);
		    DISTORTION_CALIBRATION_DATA.setMaskFromImageStack(pathname);
			if (LENS_DISTORTIONS!=null) LENS_DISTORTIONS.updateSensorMasks();
			if (LENS_DISTORTIONS!=null) LENS_DISTORTIONS.updateSensorMasks();
			return;
			return;
@@ -3642,8 +3643,8 @@ if (MORE_BUTTONS) {
				double threadPitch=0.35; // M1.6
				double threadPitch=0.35; // M1.6
				double dPx0=camPars.eyesisSubCameras[stationNumber][0].px0-(camPars.sensorWidth/2)-FOCUS_MEASUREMENT_PARAMETERS.centerDeltaX;
				double dPx0=camPars.eyesisSubCameras[stationNumber][0].px0-(camPars.getSensorWidth(0)/2)-FOCUS_MEASUREMENT_PARAMETERS.centerDeltaX;
				double dPy0=camPars.eyesisSubCameras[stationNumber][0].py0-(camPars.sensorHeight/2)-FOCUS_MEASUREMENT_PARAMETERS.centerDeltaY;
				double dPy0=camPars.eyesisSubCameras[stationNumber][0].py0-(camPars.getSensorHeight(0)/2)-FOCUS_MEASUREMENT_PARAMETERS.centerDeltaY;
			   	double psi=camPars.eyesisSubCameras[stationNumber][0].psi;     // degrees, rotation (of the sensor) around the optical axis. Positive if camera is rotated clockwise looking to the target
			   	double psi=camPars.eyesisSubCameras[stationNumber][0].psi;     // degrees, rotation (of the sensor) around the optical axis. Positive if camera is rotated clockwise looking to the target
			   	FOCUS_MEASUREMENT_PARAMETERS.result_PX0=camPars.eyesisSubCameras[stationNumber][0].px0;
			   	FOCUS_MEASUREMENT_PARAMETERS.result_PX0=camPars.eyesisSubCameras[stationNumber][0].px0;
@@ -5026,8 +5027,8 @@ if (MORE_BUTTONS) {
						if (DEBUG_LEVEL>2) System.out.println("sfeParameters["+numSFE+"].length="+sfeParameters[numSFE].length);
						if (DEBUG_LEVEL>2) System.out.println("sfeParameters["+numSFE+"].length="+sfeParameters[numSFE].length);
						if (DEBUG_LEVEL>2) System.out.println("sfeParameters["+numSFE+"]["+iLens+"].length="+sfeParameters[numSFE][iLens].length);
						if (DEBUG_LEVEL>2) System.out.println("sfeParameters["+numSFE+"]["+iLens+"].length="+sfeParameters[numSFE][iLens].length);
						sfeParameters[numSFE][iLens][iState]=FOCUS_MEASUREMENT_PARAMETERS.clone();
						sfeParameters[numSFE][iLens][iState]=FOCUS_MEASUREMENT_PARAMETERS.clone();
						sensorDimensions[numSFE][0]=EYESIS_CAMERA_PARAMETERS.sensorWidth; // should be the same for all lenses/states
						sensorDimensions[numSFE][0]=EYESIS_CAMERA_PARAMETERS.getSensorWidth(numSFE); // should be the same for all lenses/states
						sensorDimensions[numSFE][1]=EYESIS_CAMERA_PARAMETERS.sensorHeight;
						sensorDimensions[numSFE][1]=EYESIS_CAMERA_PARAMETERS.getSensorHeight(numSFE);
						iState++;
						iState++;
					}
					}
					iLens++;
					iLens++;
@@ -5492,12 +5493,12 @@ if (MORE_BUTTONS) {
				String path=dFile+Prefs.getFileSeparator()+lensPrefix+CAMERAS.getLastTimestampUnderscored()+
				String path=dFile+Prefs.getFileSeparator()+lensPrefix+CAMERAS.getLastTimestampUnderscored()+
				(modeAverage?"-summary.csv":"-tempscan.csv");
				(modeAverage?"-summary.csv":"-tempscan.csv");
				if (MASTER_DEBUG_LEVEL>0) System.out.println ((modeAverage?"Saving averaged measurements to ":"Saving temperature measurement log data to ")+path);
				if (MASTER_DEBUG_LEVEL>0) System.out.println ((modeAverage?"Saving averaged measurements to ":"Saving temperature measurement log data to ")+path);
				int sensorWidth=2992,sensorHeight=1936;
				int sensorWidth=2592,sensorHeight=1936;
				if ((LENS_DISTORTIONS!=null) && (LENS_DISTORTIONS.fittingStrategy!=null) && (LENS_DISTORTIONS.fittingStrategy!=null)&&
				if ((LENS_DISTORTIONS!=null) && (LENS_DISTORTIONS.fittingStrategy!=null) && (LENS_DISTORTIONS.fittingStrategy!=null)&&
						(LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData!=null) &&
						(LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData!=null) &&
						(LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.eyesisCameraParameters!=null)){
						(LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.eyesisCameraParameters!=null)){
					sensorWidth=LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.sensorWidth;
					sensorWidth=LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorWidth(0);
					sensorHeight=LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.sensorHeight;
					sensorHeight=LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorHeight(0);
				}
				}
				if (FOCUSING_FIELD!=null){
				if (FOCUSING_FIELD!=null){
					sensorWidth=FOCUSING_FIELD.sensorWidth;
					sensorWidth=FOCUSING_FIELD.sensorWidth;
@@ -5918,7 +5919,12 @@ if (MORE_BUTTONS) {
				IJ.showMessage("LENS_DISTORTION.fittingStrategy is not set");
				IJ.showMessage("LENS_DISTORTION.fittingStrategy is not set");
				return;
				return;
			}
			}
			LENS_DISTORTIONS.listImageSets();
			GenericDialog gd=new GenericDialog ("Select list mode");
    		gd.addNumericField("Mode 0 - old, 1 - shift/Rots", 0, 0);
    		gd.showDialog();
    		if (gd.wasCanceled()) return;
    		int listMode=          (int) gd.getNextNumber();
			LENS_DISTORTIONS.listImageSets(listMode);
			return;
			return;
		}
		}
/* ======================================================================== */
/* ======================================================================== */
@@ -8986,12 +8992,20 @@ if (MORE_BUTTONS) {
    	    	for (int nChn=0;nChn<masks.length;nChn++) if ((nChn<selectedChannels.length)&&!selectedChannels[nChn]) masks[nChn]=null;
    	    	for (int nChn=0;nChn<masks.length;nChn++) if ((nChn<selectedChannels.length)&&!selectedChannels[nChn]) masks[nChn]=null;
    	    }
    	    }
			if (showSensorMasks) this.SDFA_INSTANCE.showArrays( //java.lang.ArrayIndexOutOfBoundsException: 313632
    	    if (showSensorMasks) {
    	    	boolean same_size = true;
    	    	for (int i = 1; i < masks.length; i++) same_size &= (masks[i].length == masks[0].length);
    	    	if (same_size) {
    	    		this.SDFA_INSTANCE.showArrays( //java.lang.ArrayIndexOutOfBoundsException: 313632
    	    				masks,
    	    				masks,
					LENS_DISTORTIONS.pixelCorrectionWidth/ LENS_DISTORTIONS.pixelCorrectionDecimation,
    	    				LENS_DISTORTIONS.getSensorWidth(0)/ LENS_DISTORTIONS.getDecimateMasks(0),
					LENS_DISTORTIONS.pixelCorrectionHeight/LENS_DISTORTIONS.pixelCorrectionDecimation,
    	    				LENS_DISTORTIONS.getSensorHeight(0)/LENS_DISTORTIONS.getDecimateMasks(0),
    	    				true,
    	    				true,
    	    				"nonVinetting masks");
    	    				"nonVinetting masks");
    	    	} else {
    	    		System.out.println("**** Can't show sesnor masks for different size sesnors as a stack! ");
    	    	}
    	    }
			double [][][][] sensorGrids=LENS_DISTORTIONS.calculateGridFlatField(
			double [][][][] sensorGrids=LENS_DISTORTIONS.calculateGridFlatField(
					serNumber,
					serNumber,
					masks,
					masks,
@@ -9556,7 +9570,7 @@ if (MORE_BUTTONS) {
				true,                    // boolean read_grids
				true,                    // boolean read_grids
				MASTER_DEBUG_LEVEL);
				MASTER_DEBUG_LEVEL);
	    if (MASTER_DEBUG_LEVEL <100) return true;
///	    if (MASTER_DEBUG_LEVEL <100) return true;
	    // patterns are not yet read here!
	    // patterns are not yet read here!
/*
/*
@@ -9639,6 +9653,11 @@ if (MORE_BUTTONS) {
				path,
				path,
				PROCESS_PARAMETERS.useXML,
				PROCESS_PARAMETERS.useXML,
				null); // Properties properties
				null); // Properties properties
		if (LENS_DISTORTIONS==null) {
			System.out.println("Creating new LENS_DISTORTIONS");
			LENS_DISTORTIONS=new Distortions(LENS_DISTORTION_PARAMETERS,PATTERN_PARAMETERS,REFINE_PARAMETERS,this.SYNC_COMMAND.stopRequested);
		}
//		ABERRATIONS_PARAMETERS.selectCalibrationDirectory(true, ABERRATIONS_PARAMETERS.calibrationDirectory, true);
		return EYESIS_CAMERA_PARAMETERS.importSystem(
		return EYESIS_CAMERA_PARAMETERS.importSystem(
				properties,
				properties,
				prefix,
				prefix,
+670 −102

File changed.

Preview size limit exceeded, changes collapsed.

+185 −400

File changed.

Preview size limit exceeded, changes collapsed.

+63 −28
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@ import java.util.Set;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.XMLConfiguration;


import com.elphel.imagej.calibration.CalibrationFileManagement.MultipleExtensionsFileFilter;
import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.common.WindowTools;


import ij.IJ;
import ij.IJ;
@@ -1627,6 +1626,16 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
    				"Image sets, start from empty selection",         // 5
    				"Image sets, start from empty selection",         // 5
    				"Image sets, start from current selection"        // 6
    				"Image sets, start from current selection"        // 6
    				};
    				};
    		String help = "<html>"+
    				"<h2>Use of buttons in this dialog:</h2>"+
    				"<ul>"+
    				"<li><b>More</b> will re-open dialog after performin selection modification actions,"+
    				" in case of selecting individual images that may happen after multiple selection "+
    				"screens</li>"+
    				"<li><b>Cancel</b> - keep current selection that you do not want to modify further"+
    				" (e.g. if you wrongly pressed 'More' in this dialog earlier)</li>"+
    				"<li><b>OK</b> - perform selection modification once (same as 'More'...'Cancel')</li>"+
    				"</ul><br/>";
    		int numStations=this.distortionCalibrationData.eyesisCameraParameters.getNumStations();
    		int numStations=this.distortionCalibrationData.eyesisCameraParameters.getNumStations();
    		int numChannels=this.distortionCalibrationData.eyesisCameraParameters.getNumChannels(0); // for station 0
    		int numChannels=this.distortionCalibrationData.eyesisCameraParameters.getNumChannels(0); // for station 0
    		boolean [] selected=          this.selectedImages[numSeries];
    		boolean [] selected=          this.selectedImages[numSeries];
@@ -1833,6 +1842,11 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
    		//selectionType
    		//selectionType
//			gd.addCheckbox("Select images with estimated orientation", selectEstimated);
//			gd.addCheckbox("Select images with estimated orientation", selectEstimated);
//			gd.addCheckbox("Select new enabled images", selectNewEnabled);
//			gd.addCheckbox("Select new enabled images", selectNewEnabled);
			if (this.distortionCalibrationData.hasSmallSensors()) {
				gd.addMessage("=== Filter selection by High/Low resolution sensors (such as VNIR/LWIR)");
				gd.addCheckbox("Select high-res sensors", true);
				gd.addCheckbox("Select low-res sensors", true);
			}
    		gd.addMessage("=== Filter selection by the number of matched laser pointers ===");
    		gd.addMessage("=== Filter selection by the number of matched laser pointers ===");
    		for (int i=0;i<matchedPointersIndex.length;i++){
    		for (int i=0;i<matchedPointersIndex.length;i++){
    			gd.addCheckbox("Select images with "+matchedPointersIndex[i]+" pointers", requiredMatchedPointers[i]);
    			gd.addCheckbox("Select images with "+matchedPointersIndex[i]+" pointers", requiredMatchedPointers[i]);
@@ -1850,14 +1864,21 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
    			gd.addCheckbox("Select channel "+i, requiredChannels[i]);
    			gd.addCheckbox("Select channel "+i, requiredChannels[i]);
    		}
    		}
    		gd.enableYesNoCancel("OK", "More");
    		gd.enableYesNoCancel("OK", "More");
    		gd.addHelp(help);
			WindowTools.addScrollBars(gd);
			WindowTools.addScrollBars(gd);
			gd.showDialog();
			gd.showDialog();
			if (gd.wasCanceled()) return -1;
			if (gd.wasCanceled()) return -1;
			boolean more=!gd.wasOKed();
			boolean more=!gd.wasOKed();
			System.out.println("manageSelection(): more=!gd.wasOKed() = "+more);
			operIndex=gd.getNextChoiceIndex();
			operIndex=gd.getNextChoiceIndex();
			selectionTypeIndex=gd.getNextChoiceIndex(); // TODO:Implement!
			selectionTypeIndex=gd.getNextChoiceIndex(); // TODO:Implement!
//			selectEstimated=gd.getNextBoolean();

//			selectNewEnabled=gd.getNextBoolean();
			boolean [] selectHiLowRes = null;
			if (this.distortionCalibrationData.hasSmallSensors()) {
				selectHiLowRes = new boolean[2];
				selectHiLowRes[0] = gd.getNextBoolean(); //	gd.addCheckbox("Select high-res sensors", true);
				selectHiLowRes[1] = gd.getNextBoolean(); //	gd.addCheckbox("Select low-res sensors", true);
			}
    		for (int i=0;i<matchedPointersIndex.length;i++) requiredMatchedPointers[i]=gd.getNextBoolean();
    		for (int i=0;i<matchedPointersIndex.length;i++) requiredMatchedPointers[i]=gd.getNextBoolean();
    		for (int i=0;i<hintedMatchIndex.length;i++)     requiredHintedMatch[i]=    gd.getNextBoolean();
    		for (int i=0;i<hintedMatchIndex.length;i++)     requiredHintedMatch[i]=    gd.getNextBoolean();
    		for (int i=0;i<requiredStations.length;i++)     requiredStations[i]=gd.getNextBoolean();
    		for (int i=0;i<requiredStations.length;i++)     requiredStations[i]=gd.getNextBoolean();
@@ -1882,6 +1903,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
	    			false, // allImages,
	    			false, // allImages,
	    			0, // star iIndex
	    			0, // star iIndex
	    			500)) return -1; //perPage))
	    			500)) return -1; //perPage))
    			break;
    		case 6: // start from current selection
    		case 6: // start from current selection
    			selection=selected.clone();
    			selection=selected.clone();
    			break;
    			break;
@@ -1899,9 +1921,19 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
			for (int i=0;i<selection.length;i++) if (imageStations[i]>=0) selection[i] &= requiredStations[imageStations[i]];
			for (int i=0;i<selection.length;i++) if (imageStations[i]>=0) selection[i] &= requiredStations[imageStations[i]];
			else selection[i] = false;
			else selection[i] = false;


			if (selectHiLowRes != null) {
				boolean [] lowres_channel = this.distortionCalibrationData.getSmallSensors();
				for (int i =0; i < requiredChannels.length;i++) {
					if ((lowres_channel[i] && !selectHiLowRes[1]) ||(!lowres_channel[i] && !selectHiLowRes[0])) {
						requiredChannels[i] = false;
					}
				}
			}

			for (int i=0;i<selection.length;i++) if (imageChannels[i]>=0) selection[i] &= requiredChannels[imageChannels[i]];
			for (int i=0;i<selection.length;i++) if (imageChannels[i]>=0) selection[i] &= requiredChannels[imageChannels[i]];
			else selection[i] = false;
			else selection[i] = false;



			// now combine new/old selections
			// now combine new/old selections
			switch (operIndex){
			switch (operIndex){
			case 0: // keep new selection
			case 0: // keep new selection
@@ -1926,6 +1958,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
			for (int i=0;i<selection.length;i++) selection[i] &= enabled[i];
			for (int i=0;i<selection.length;i++) selection[i] &= enabled[i];
			// replace current selection
			// replace current selection
			this.selectedImages[numSeries]=selection;
			this.selectedImages[numSeries]=selection;
			System.out.println("manageSelection(): on exit more = "+more);
			return more?0:1;
			return more?0:1;
    	}
    	}
       	/**
       	/**
@@ -1936,21 +1969,8 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
   	 * @param useParameters Select parameters for this series
   	 * @param useParameters Select parameters for this series
   	 * @param askNextSeries Ask for next series number
   	 * @param askNextSeries Ask for next series number
   	 * @param zeroAndOther use 2 channels 0 and "other", propagate settings for channel 1 to all the rest
   	 * @param zeroAndOther use 2 channels 0 and "other", propagate settings for channel 1 to all the rest
   	 * For low/high res (LWIR/VNIR) - use first /other for each class
   	 * @return -2 - cancel, -1, done, otherwise - number of step to edit
   	 * @return -2 - cancel, -1, done, otherwise - number of step to edit
   	public int selectStrategyStep(
   			int numSeries,
   			boolean useImages,
				int [] fromToImages,
   			boolean allImages,
   			boolean useParameters,
   			boolean askLambdas,
   			boolean askNextSeries,
   			boolean zeroAndOther
   			){
			GenericDialog gd = new GenericDialog("Fitting Strategy Step Configuration, step "+numSeries+
					                             " number of enabled images="+this.distortionCalibrationData.getNumEnabled());
			gd.addStringField  ("Comment",   this.strategyComment[numSeries],80);

   	 */
   	 */


    	public void listStrategies() {
    	public void listStrategies() {
@@ -2117,9 +2137,15 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
			for (int i=0;i<constrainByStation.length;i++) constrainByStation[i]=true;
			for (int i=0;i<constrainByStation.length;i++) constrainByStation[i]=true;
			if (this.distortionCalibrationData.eyesisCameraParameters.numStations>1){
			if (this.distortionCalibrationData.eyesisCameraParameters.numStations>1){
				gd.addMessage("Constrain by stations");
				gd.addMessage("Constrain by stations");
//				gd.addCheckbox("Remove images of unselected stations below", true);
				for (int i=0;i<this.distortionCalibrationData.eyesisCameraParameters.numStations;i++) 	gd.addCheckbox("Station "+i, constrainByStation[i]);
				for (int i=0;i<this.distortionCalibrationData.eyesisCameraParameters.numStations;i++) 	gd.addCheckbox("Station "+i, constrainByStation[i]);
			}
			}
			if (this.distortionCalibrationData.hasSmallSensors()) {
				gd.addMessage("Constrain by High/Low resolution sensors (such as VNIR/LWIR)");
				gd.addCheckbox("Select high-res sensors", true);
				gd.addCheckbox("Select low-res sensors", true);
			}




			if (useImages) {
			if (useImages) {
	    		gd.addNumericField("Image selection range, from", fromToImages[0], 0);
	    		gd.addNumericField("Image selection range, from", fromToImages[0], 0);
@@ -2141,7 +2167,6 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit


			}
			}
			if (useParameters) {
			if (useParameters) {
//				choice_offsets = new int [this.parameterEnable.length];
				gd.addMessage("Select parameters to fit");
				gd.addMessage("Select parameters to fit");
				for (int i =0; i<this.parameterEnable.length;i++) if (this.parameterEnable[i] &&
				for (int i =0; i<this.parameterEnable.length;i++) if (this.parameterEnable[i] &&
						(!zeroAndOther || (this.parameterList[i][0] <= 1) || (this.parameterList[i][0] ==24))){ // in "zeroAndOther" mode do not show other subcameras
						(!zeroAndOther || (this.parameterList[i][0] <= 1) || (this.parameterList[i][0] ==24))){ // in "zeroAndOther" mode do not show other subcameras
@@ -2159,18 +2184,14 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
									) { // both subcameras are "other" subcameras
									) { // both subcameras are "other" subcameras
								double parValue=this.distortionCalibrationData.getParameterValue(imgNumber,parIndex);
								double parValue=this.distortionCalibrationData.getParameterValue(imgNumber,parIndex);
								if (!defined) {
								if (!defined) {
//									min=this.distortionCalibrationData.pars[imgNumber][parIndex];
									min=parValue;
									min=parValue;
									max=min;
									max=min;
									defined=true;
									defined=true;
								}
								}
//								if (this.distortionCalibrationData.pars[imgNumber][parIndex]<min) min=this.distortionCalibrationData.pars[imgNumber][parIndex];
//								if (this.distortionCalibrationData.pars[imgNumber][parIndex]>max) max=this.distortionCalibrationData.pars[imgNumber][parIndex];
								if (parValue<min) min=parValue;
								if (parValue<min) min=parValue;
								if (parValue>max) max=parValue;
								if (parValue>max) max=parValue;
							}
							}
						}
						}
//					System.out.println(i+": "+parIndex+":"+subCam+"defined="+defined+" min="+min+" max="+max);
					// undefined, min, max
					// undefined, min, max
					String sValue=(defined)?((min==max)?(min+""):(min+"..."+max)):"undefined";
					String sValue=(defined)?((min==max)?(min+""):(min+"..."+max)):"undefined";
					String sChn=(zeroAndOther && (subCam>=1)&& (subCam<24))?"-head-other":
					String sChn=(zeroAndOther && (subCam>=1)&& (subCam<24))?"-head-other":
@@ -2263,8 +2284,9 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
			showAdvancedImageSelection=gd.getNextBoolean();
			showAdvancedImageSelection=gd.getNextBoolean();
			if (showAdvancedImageSelection){
			if (showAdvancedImageSelection){
				int rslt=0;
				int rslt=0;
				while (rslt==0) rslt=manageSelection(numSeries);
				while (rslt==0) {
//				return (rslt<0)?-2:numSeries;
					rslt=manageSelection(numSeries);
				}
				return numSeries; // cancel from manageSelection will just exit that mode with no changes
				return numSeries; // cancel from manageSelection will just exit that mode with no changes
			}
			}
			boolean copyFromPrevious=gd.getNextBoolean();
			boolean copyFromPrevious=gd.getNextBoolean();
@@ -2276,9 +2298,15 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
			boolean selectNewEnabled=false;
			boolean selectNewEnabled=false;
			if (numNewEnabled>0) selectNewEnabled=gd.getNextBoolean();
			if (numNewEnabled>0) selectNewEnabled=gd.getNextBoolean();
			if (this.distortionCalibrationData.eyesisCameraParameters.numStations>1){
			if (this.distortionCalibrationData.eyesisCameraParameters.numStations>1){
//				boolean removeUnselectedStations=gd.getNextBoolean();
				for (int i=0;i<constrainByStation.length; i++) constrainByStation[i]=gd.getNextBoolean();
				for (int i=0;i<constrainByStation.length; i++) constrainByStation[i]=gd.getNextBoolean();
			}
			}
			boolean [] selectHiLowRes = null;
			if (this.distortionCalibrationData.hasSmallSensors()) {
				selectHiLowRes = new boolean[2];
				selectHiLowRes[0] = gd.getNextBoolean(); //	gd.addCheckbox("Select high-res sensors", true);
				selectHiLowRes[1] = gd.getNextBoolean(); //	gd.addCheckbox("Select low-res sensors", true);
			}

			if (selectNewEnabled) {
			if (selectNewEnabled) {
				this.selectedImages[numSeries]=this.distortionCalibrationData.selectNewEnabled();
				this.selectedImages[numSeries]=this.distortionCalibrationData.selectNewEnabled();
				for (int i =0; i<this.distortionCalibrationData.getNumImages();i++){
				for (int i =0; i<this.distortionCalibrationData.getNumImages();i++){
@@ -2308,9 +2336,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
				return numSeries; // caller will repeat with the same series
				return numSeries; // caller will repeat with the same series
			}
			}
			if (removeAllImages || selectAllImages) {
			if (removeAllImages || selectAllImages) {
//
				for (int i =0; i<this.distortionCalibrationData.getNumImages();i++){
				for (int i =0; i<this.distortionCalibrationData.getNumImages();i++){
//					this.selectedImages[numSeries][i]=false; // invalidate - all, regardless of .enabled
					this.selectedImages[numSeries][i]=selectAllImages || ((i==0) && removeAllImages); // invalidate - all, regardless of .enabled
					this.selectedImages[numSeries][i]=selectAllImages || ((i==0) && removeAllImages); // invalidate - all, regardless of .enabled
					this.selectedImages[numSeries][i]&=constrainByStation[this.distortionCalibrationData.gIP[i].getStationNumber()];
					this.selectedImages[numSeries][i]&=constrainByStation[this.distortionCalibrationData.gIP[i].getStationNumber()];
				}
				}
@@ -2329,6 +2355,15 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
				if (this.masterImages[numSeries]<0)this.masterImages[numSeries]=0;
				if (this.masterImages[numSeries]<0)this.masterImages[numSeries]=0;
				if (this.masterImages[numSeries]>=this.selectedImages[numSeries].length)this.masterImages[numSeries]=this.selectedImages[numSeries].length;
				if (this.masterImages[numSeries]>=this.selectedImages[numSeries].length)this.masterImages[numSeries]=this.selectedImages[numSeries].length;
			}
			}
			if (selectHiLowRes != null) {
				for (int i =0; i<this.distortionCalibrationData.getNumImages();i++) {
					boolean low_res = this.distortionCalibrationData.isSmallSensor(i);
					if ((low_res && !selectHiLowRes[1]) && (!low_res && !selectHiLowRes[0])){
						this.selectedImages[numSeries][i]= false;
					}
				}
			}

			if (useParameters) {
			if (useParameters) {
				int [] lastGroups=null;
				int [] lastGroups=null;
				for (int i =0; i<this.parameterEnable.length;i++) if (this.parameterEnable[i] &&
				for (int i =0; i<this.parameterEnable.length;i++) if (this.parameterEnable[i] &&
+74 −51
Original line number Original line Diff line number Diff line
package com.elphel.imagej.calibration;
package com.elphel.imagej.calibration;
import java.awt.Rectangle;
import java.util.Properties;

import com.elphel.imagej.jp4.JP46_Reader_camera;

/*
/*
 **
 **
 ** PatternParameters.java
 ** PatternParameters.java
@@ -28,12 +33,6 @@ import ij.ImageStack;
import ij.gui.GenericDialog;
import ij.gui.GenericDialog;
import ij.io.FileSaver;
import ij.io.FileSaver;
import ij.io.Opener;
import ij.io.Opener;

import java.awt.Rectangle;
import java.util.Properties;

import com.elphel.imagej.calibration.CalibrationFileManagement.MultipleExtensionsFileFilter;
import com.elphel.imagej.jp4.JP46_Reader_camera;
	/* gridGeometry:
	/* gridGeometry:
	 * [v][u][0] - x(mm) of the node(u,v), right (looking to the wall) - positive
	 * [v][u][0] - x(mm) of the node(u,v), right (looking to the wall) - positive
	 * [v][u][1] - y(mm) of the node(u,v), down - positive
	 * [v][u][1] - y(mm) of the node(u,v), down - positive
@@ -260,6 +259,7 @@ import com.elphel.imagej.jp4.JP46_Reader_camera;
			setPhotometric(viewMap);
			setPhotometric(viewMap);
			calculateGridGeometryAndPhotometric(true);
			calculateGridGeometryAndPhotometric(true);
		}
		}
		@Override
		public PatternParameters clone() {
		public PatternParameters clone() {
			PatternParameters patternParameters= new PatternParameters(
			PatternParameters patternParameters= new PatternParameters(
					this.viewMap,
					this.viewMap,
@@ -609,13 +609,15 @@ import com.elphel.imagej.jp4.JP46_Reader_camera;
			GenericDialog gd = new GenericDialog("Initial Wall pattern parameters");
			GenericDialog gd = new GenericDialog("Initial Wall pattern parameters");
			gd.addNumericField("Pattern full width",                  this.patternWidth, 1,6,"mm"); // pattern full width in mm
			gd.addNumericField("Pattern full width",                  this.patternWidth, 1,6,"mm"); // pattern full width in mm
			gd.addNumericField("Pattern full height",                 this.patternHeight, 1,6,"mm"); // pattern full width in mm
			gd.addNumericField("Pattern full height",                 this.patternHeight, 1,6,"mm"); // pattern full width in mm
			gd.addNumericField("Distance between opposite sign nodes",this.patternHalfPeriod, 4,8,"mm"); // istance between opposite sign nodes in mm
			gd.addNumericField("Distance between opposite sign nodes",this.patternHalfPeriod, 4,8,"mm"); // distance between opposite sign nodes in mm
			gd.addNumericField("Pattern tilt (clockwise)",            this.patternTilt, 1,5,"degrees"); //  pattern tilt (degrees) - U clockwise from X-right (V clockwise from Y-down)
			gd.addNumericField("Pattern tilt (clockwise)",            this.patternTilt, 3,8,"degrees"); //  pattern tilt (degrees) - U clockwise from X-right (V clockwise from Y-down)
			gd.addNumericField("Average grid RED   (1.0 for white)",  this.averageRGB[0], 3,5,"x"); //
			gd.addNumericField("Average grid RED   (1.0 for white)",  this.averageRGB[0], 3,5,"x"); //
			gd.addNumericField("Average grid GREEN (1.0 for white)",  this.averageRGB[1], 3,5,"x"); //
			gd.addNumericField("Average grid GREEN (1.0 for white)",  this.averageRGB[1], 3,5,"x"); //
			gd.addNumericField("Average grid BLUE  (1.0 for white)",  this.averageRGB[2], 3,5,"x"); //
			gd.addNumericField("Average grid BLUE  (1.0 for white)",  this.averageRGB[2], 3,5,"x"); //


			gd.addNumericField("Number of sensors (>24 - two groups, 0 - do not change)",this.defaultNumberOfChannels,0); //
			gd.addNumericField("Number of sensors (>24 - two groups, 0 - do not change)",this.defaultNumberOfChannels,0); //
			gd.addCheckbox("Reset to standard fine pitch pattern" ,   false);
			gd.addCheckbox("Reset to standard LWIR pattern" ,         false);


			gd.addMessage("Pressing OK will recalculate grid and clear current grid calibration");
			gd.addMessage("Pressing OK will recalculate grid and clear current grid calibration");
			gd.showDialog();
			gd.showDialog();
@@ -628,6 +630,27 @@ import com.elphel.imagej.jp4.JP46_Reader_camera;
			this.averageRGB[1]=        gd.getNextNumber();
			this.averageRGB[1]=        gd.getNextNumber();
			this.averageRGB[2]=        gd.getNextNumber();
			this.averageRGB[2]=        gd.getNextNumber();
			int numberOfChannels= (int)gd.getNextNumber();
			int numberOfChannels= (int)gd.getNextNumber();
			boolean use_fine_pattern = gd.getNextBoolean();
			boolean use_lwir_pattern = gd.getNextBoolean();

			if (use_fine_pattern) {
				this.patternWidth=         7010.0;
				this.patternHeight=        3073.0;
				this.patternHalfPeriod=      41.57;
				this.patternTilt=             5.0;
				this.averageRGB[0]=           1.0;
				this.averageRGB[1]=           1.0;
				this.averageRGB[2]=           1.0;

			} else if (use_lwir_pattern) {
				this.patternWidth=         7010.0; // 7192.0
				this.patternHeight=        2997.2;
				this.patternHalfPeriod=     178.65;
				this.patternTilt=             14.036;
				this.averageRGB[0]=           1.0;
				this.averageRGB[1]=           1.0;
				this.averageRGB[2]=           1.0;
			}


			if (numberOfChannels>0){
			if (numberOfChannels>0){
				initDefaultChannels(numberOfChannels);
				initDefaultChannels(numberOfChannels);
Loading