Hi Thomas,

here is the patch of the changes I made.

-- Torsten

Am Mittwoch, 8. Juni 2016 00:15:55 UTC+2 schrieb Torsten Stremlau:
>
> I recently started using Hugin to create 360° panoramas of HDR images.
> The images I am trying to stitch together are in OpenEXR format.
>
> I noticed that cpfind hardly finds any control points on these HDR images.
> If I convert the images to LDR first, then cpfind actually finds quite a 
> few control points.
>
> I poked around in cpfind and found out that this is probably because the 
> HDR images are first mapped
> to [0,255] before any features are detected. As this is done using a 
> linear mapping the images end up being
> mostly black with only the brightest parts in the image visible. (Usually 
> the sun...)
>
> When I switched the mapping in cpfind to logarithmic in the source code, 
> the results became much better and
> more control points were found.
>
> Is this a known issue, or am I doing something wrong?
>
> I am using hugin on ubuntu 16.04 64bit.
> I built hugin myself from hg 
> revision:674a88cfacb6468ac185c8e12392ba9c206a7113
>
> -- Torsten
>

-- 
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
--- 
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/eb3c004d-6cd2-4bd7-9431-3ee96607c967%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# HG changeset patch
# User Torsten Stremlau
# Date 1465333447 -7200
#      Tue Jun 07 23:04:07 2016 +0200
# Node ID 3219144b685b0dc9ea87c34260441742083d716b
# Parent  674a88cfacb6468ac185c8e12392ba9c206a7113
Allow logarithmic mapping of float images in cpfind.
This is mostly useful for images with very high dynamic range.

diff -r 674a88cfacb6 -r 3219144b685b src/hugin1/icpfind/default.unix
--- a/src/hugin1/icpfind/default.unix	Tue Jun 07 18:01:29 2016 +0200
+++ b/src/hugin1/icpfind/default.unix	Tue Jun 07 23:04:07 2016 +0200
@@ -1,5 +1,5 @@
 [AutoPano]
-AutoPanoCount=10
+AutoPanoCount=11
 Default=0
 
 [AutoPano/AutoPano_0]
@@ -79,3 +79,8 @@
 ArgumentsMatcher=
 Option=1
 
+[AutoPano/AutoPano_10]
+Type=1
+Description=Hugin's CPFind (logarithmic float mapping)
+Program=cpfind
+Arguments=--floatmapping log --multirow -o %o %s
diff -r 674a88cfacb6 -r 3219144b685b src/hugin_cpfind/cpfind/PanoDetector.cpp
--- a/src/hugin_cpfind/cpfind/PanoDetector.cpp	Tue Jun 07 18:01:29 2016 +0200
+++ b/src/hugin_cpfind/cpfind/PanoDetector.cpp	Tue Jun 07 23:04:07 2016 +0200
@@ -106,7 +106,7 @@
     _sieve2Width(5), _sieve2Height(5), _sieve2Size(1),
     _matchingStrategy(ALLPAIRS), _linearMatchLen(1),
     _test(false), _cores(0), _downscale(true), _cache(false), _cleanup(false),
-    _celeste(false), _celesteThreshold(0.5), _celesteRadius(20), 
+    _celeste(false), _celesteThreshold(0.5), _celesteRadius(20), _floatmapping(0),
     _keypath(""), _outputFile("default.pto"), _outputGiven(false), svmModel(NULL)
 {
     _panoramaInfo = new HuginBase::Panorama();
diff -r 674a88cfacb6 -r 3219144b685b src/hugin_cpfind/cpfind/PanoDetector.h
--- a/src/hugin_cpfind/cpfind/PanoDetector.h	Tue Jun 07 18:01:29 2016 +0200
+++ b/src/hugin_cpfind/cpfind/PanoDetector.h	Tue Jun 07 23:04:07 2016 +0200
@@ -309,6 +309,14 @@
     {
         _cores = iCores;
     }
+    inline void setFloatmapping(int iFloatmapping)
+    {
+        _floatmapping = iFloatmapping;
+    }
+    inline int getFloatmapping() const
+    {
+        return _floatmapping;
+    }
 
     // predeclaration
     struct ImgData;
@@ -355,6 +363,7 @@
     int         _celesteRadius;
     std::string _keypath;
     std::string _prefix;
+    int         _floatmapping;
 
     //	bool						_stereoRemap;
 
diff -r 674a88cfacb6 -r 3219144b685b src/hugin_cpfind/cpfind/PanoDetectorLogic.cpp
--- a/src/hugin_cpfind/cpfind/PanoDetectorLogic.cpp	Tue Jun 07 18:01:29 2016 +0200
+++ b/src/hugin_cpfind/cpfind/PanoDetectorLogic.cpp	Tue Jun 07 23:04:07 2016 +0200
@@ -561,7 +561,7 @@
                                 TRACE_IMG("Rescale range...");
                                 if (!range255)
                                 {
-                                    vigra_ext::applyMapping(vigra::srcImageRange(*rgbImage), vigra::destImage(*rgbImage), minVal, maxVal, 0);
+                                    vigra_ext::applyMapping(vigra::srcImageRange(*rgbImage), vigra::destImage(*rgbImage), minVal, maxVal, iPanoDetector.getFloatmapping());
                                 };
                                 range255 = true;
                             }
diff -r 674a88cfacb6 -r 3219144b685b src/hugin_cpfind/cpfind/main.cpp
--- a/src/hugin_cpfind/cpfind/main.cpp	Tue Jun 07 18:01:29 2016 +0200
+++ b/src/hugin_cpfind/cpfind/main.cpp	Tue Jun 07 23:04:07 2016 +0200
@@ -28,6 +28,15 @@
 
 #include "PanoDetector.h"
 
+
+namespace { // anonymous namespace
+
+static const int LINEAR_MAPPING = 0;
+static const int LOG_MAPPING = 1;
+static const int GAMMA_MAPPING = 2;
+
+}
+
 void printVersion()
 {
     std::cout << "Hugin's cpfind " << hugin_utils::GetHuginVersion() << std::endl;
@@ -85,7 +94,10 @@
         << "                  Celeste can be fine tuned with the following parameters" << std::endl
         << "      --celestethreshold=<int>  Threshold for celeste (default 0.5)" << std::endl
         << "      --celesteradius=<int>     Radius for celeste (in pixels, default 20)" << std::endl
-        << "  --ncores=<int>  Number of threads to use (default: autodetect number of cores)" << std::endl;
+        << "  --ncores=<int>  Number of threads to use (default: autodetect number of cores)" << std::endl
+        << "  --floatmapping=<string>  Method to be used to map float values to [0,255]." << std::endl
+        << "                           Possible values: linear, log, gamma" << std::endl
+        << "                           (default: linear)" << std::endl;
 };
 
 bool parseOptions(int argc, char** argv, PanoDetector& ioPanoDetector)
@@ -113,7 +125,8 @@
         CELESTE,
         CELESTETHRESHOLD,
         CELESTERADIUS,
-        CPFINDVERSION
+        CPFINDVERSION,
+        FLOATMAPPING,
     };
     const char* optstring = "qvftn:o:k:cp:h";
     static struct option longOptions[] =
@@ -150,6 +163,7 @@
         {"celesteradius", required_argument, NULL, CELESTERADIUS},
         {"version", no_argument, NULL, CPFINDVERSION},
         {"help", no_argument, NULL, 'h'},
+        {"floatmapping", required_argument, NULL, FLOATMAPPING},
         0
     };
 
@@ -162,6 +176,7 @@
     int doLinearMatch=0;
     int doMultirow=0;
     int doPrealign=0;
+    int floatMapping = LINEAR_MAPPING;
     while ((c = getopt_long (argc, argv, optstring, longOptions,&optionIndex)) != -1)
     {
         switch (c)
@@ -375,6 +390,29 @@
                 std::cerr <<"Option " << longOptions[optionIndex].name << " requires an argument" << std::endl;
                 return false;
                 break;
+            case FLOATMAPPING:
+            {
+                std::string floatMappingString = optarg;
+                floatMappingString = hugin_utils::tolower(floatMappingString);
+                std::cout << "floatmapping: " << floatMappingString << std::endl;
+                if(floatMappingString == "linear")
+                {
+                    floatMapping = LINEAR_MAPPING;
+                }
+                else if (floatMappingString == "log")
+                {
+                    floatMapping = LOG_MAPPING;
+                }
+                else if (floatMappingString == "gamma")
+                {
+                    floatMapping = GAMMA_MAPPING;
+                }
+                else
+                {
+                    std::cout << "Warning: Invalid parameter in --floatmapping." << std::endl;
+                }
+            }
+                break;
             case '?':
             default:
                 break;
@@ -387,6 +425,7 @@
         return false;
     };
     ioPanoDetector.setInputFile(argv[optind]);
+    ioPanoDetector.setFloatmapping(floatMapping);
     if(doLinearMatch + doMultirow + doPrealign>1)
     {
         std::cout << "Error: The arguments --linearmatch, --multirow and --prealigned are" << std::endl

Reply via email to