Diff of /src/hugin_base/algorithms/basic/CalculateOptimalROI.cpp [10a514] .. [d2a914] Maximize Restore

  Switch to side-by-side view

--- a/src/hugin_base/algorithms/basic/CalculateOptimalROI.cpp
+++ b/src/hugin_base/algorithms/basic/CalculateOptimalROI.cpp
@@ -96,6 +96,7 @@
 {
     if(testedPixels[j*o_optimalSize.x+i]==0)
     {
+        bool inside = intersection; // start with true for intersection mode and with false for union mode
         //check that pixel at each place
         for(UIntSet::const_iterator it=activeImages.begin();it!=activeImages.end();it++)
         {
@@ -104,18 +105,26 @@
             {
                 if(o_panorama.getImage(*it).isInside(vigra::Point2D(xd,yd)))
                 {
-                    //if found in a single image, short cut out
-                    testedPixels[j*o_optimalSize.x+i]=1;
-                    pixels[j*o_optimalSize.x+i]=1;
-                    return true; 
+                    if (!intersection) {
+                        //if found in a single image, short cut out
+                        inside=true;
+                        break;
+                    }
                 }
-            }
-        }
-        
-        //if made it through the for loop without a success, mark as bad
+                else {
+                    if (intersection) {
+                        //outside of at least one image - return false
+                        inside=false;
+                        break;
+                    }
+                }
+            }
+        }
+
         testedPixels[j*o_optimalSize.x+i]=1;
-        pixels[j*o_optimalSize.x+i]=0;
-        return false;
+        pixels[j*o_optimalSize.x+i]=inside;
+        
+        return inside;
     }
     //else it is know if this pixel is covered by at least one image
     else