Commit 3a3d388e authored by Karel Štěpka's avatar Karel Štěpka
Browse files

Fixed a bug that sometimes resulted in fiducial registration returning a rotation angle 180° off.

parent 3625f597
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -378,11 +378,11 @@ function findRegisteringTransform(xFixed, yFixed, xMoving, yMoving) {
	angleInFixed = atan2(yFixed[0] - yFixed[1], xFixed[1] - xFixed[0]);
	angleInMoving = atan2(yMoving[0] - yMoving[1], xMoving[1] - xMoving[0]);
	rotation = angleInMoving - angleInFixed;	
	// We are not trying to find out which of the moving points corresponds to which of the fixed points. Instead, we will simply take that rotation whose absolute value is below 180°.
	while (rotation > PI) {
	// We are not trying to find out which of the moving points corresponds to which of the fixed points. Instead, we will simply take that 180° rotation whose absolute value is below 90°.
	while (rotation > PI/2) {
		rotation -= PI;
	}
	while (rotation <= -PI) {
	while (rotation <= -PI/2) {
		rotation += PI;
	}
	
@@ -858,7 +858,7 @@ function processImage(imageIndex, imageToAnalyzeTitle) {
	if ((currentImageEmptyRegionsROIIndex > -1) && (currentImageLimitingROIIndex > -1)) {
		roiManager("select", newArray(currentImageEmptyRegionsROIIndex, currentImageLimitingROIIndex));
//waitForUser("selected ROIs to intersect");	
		roiManager("AND");  // TODO: It seems intersecting with "Empty Regions Between Fiducials From First Image" can yield shifted results, resulting in significantly incorrect are measurements later.
		roiManager("AND");  // TODO: BUG: It seems intersecting with "Empty Regions Between Fiducials From First Image" can yield shifted results, resulting in significantly incorrect area measurements later.
		if (selectionType > -1) {
			setSelectionName(imageToAnalyzeTitle + " Empty Regions Between Fiducials");
			roiManager("Add");