Changes to resolve jagged horizontal edge and blurred vertical edge issues.

1) Made the strip width and cross-fading parameters absolute pixel values.
2) Updated the above parameters to use thinner strips with lower cross-fading radius.
3) Added another parameter to limit the number of pyramid levels at which cross-fading is applied.

Bug: 5578488
Change-Id: I69161bfbb535dc5bfcd647cfa6d6e050b6ad0068
diff --git a/jni/feature_mos/src/mosaic/Blend.cpp b/jni/feature_mos/src/mosaic/Blend.cpp
index cce89ff..e37755d 100644
--- a/jni/feature_mos/src/mosaic/Blend.cpp
+++ b/jni/feature_mos/src/mosaic/Blend.cpp
@@ -445,7 +445,7 @@
         {
             // Set the number of pixels around the seam to cross-fade between
             // the two component images,
-            int tw = STRIP_CROSS_FADE_WIDTH * width;
+            int tw = STRIP_CROSS_FADE_WIDTH_PXLS;
 
             // Proceed with the image index calculation for cross-fading
             // only if the cross-fading width is larger than 0
@@ -498,7 +498,7 @@
         {
             // Set the number of pixels around the seam to cross-fade between
             // the two component images,
-            int tw = STRIP_CROSS_FADE_WIDTH * height;
+            int tw = STRIP_CROSS_FADE_WIDTH_PXLS;
 
             // Proceed with the image index calculation for cross-fading
             // only if the cross-fading width is larger than 0
@@ -941,7 +941,10 @@
                 {
                     if(inMask && imgMos.Y.ptr[jj][ii] != 255)
                     {
-                        if(imgMos.V.ptr[jj][ii] == 128) // Not on a seam
+                        // If not on a seam OR pyramid level exceeds
+                        // maximum level for cross-fading.
+                        if((imgMos.V.ptr[jj][ii] == 128) ||
+                            (dscale > STRIP_CROSS_FADE_MAX_PYR_LEVEL))
                         {
                             wt0 = 0.0;
                             wt1 = 1.0;
@@ -1216,8 +1219,8 @@
         double deltaY = currY - prevY;
         double center2centerDist = sqrt(deltaY * deltaY + deltaX * deltaX);
 
-        if (fabs(deltaX) > STRIP_SEPARATION_THRESHOLD * last->width ||
-                fabs(deltaY) > STRIP_SEPARATION_THRESHOLD * last->height)
+        if (fabs(deltaX) > STRIP_SEPARATION_THRESHOLD_PXLS ||
+                fabs(deltaY) > STRIP_SEPARATION_THRESHOLD_PXLS)
         {
             relevant_frames[relevant_frames_size] = mb;
             relevant_frames_size++;
diff --git a/jni/feature_mos/src/mosaic/Blend.h b/jni/feature_mos/src/mosaic/Blend.h
index ebb3bdc..6371fde 100644
--- a/jni/feature_mos/src/mosaic/Blend.h
+++ b/jni/feature_mos/src/mosaic/Blend.h
@@ -35,14 +35,18 @@
 
 // This threshold determines the minimum separation between the image centers
 // of the input image frames for them to be accepted for blending in the
-// STRIP_TYPE_WIDE mode. This threshold is specified as a fraction of the
-// input image frame width.
-const float STRIP_SEPARATION_THRESHOLD = 0.10;
+// STRIP_TYPE_WIDE mode.
+const float STRIP_SEPARATION_THRESHOLD_PXLS = 10;
 
 // This threshold determines the number of pixels on either side of the strip
-// to cross-fade using the images contributing to each seam. This threshold
-// is specified as a fraction of the input image frame width.
-const float STRIP_CROSS_FADE_WIDTH = 0.002;
+// to cross-fade using the images contributing to each seam.
+const float STRIP_CROSS_FADE_WIDTH_PXLS = 2;
+// This specifies the maximum pyramid level to which cross-fading is applied.
+// The original image resolution is Level-0, half of that size is Level-1 and
+// so on. BLEND_RANGE_DEFAULT specifies the number of pyramid levels used by
+// the blending algorithm.
+const int STRIP_CROSS_FADE_MAX_PYR_LEVEL = 2;
+
 /**
  *  Class for pyramid blending a mosaic.
  */