[vspline] 29/72: license change of pano_extract to GPL3, proper CL argument handling
Kay F. Jahnke
kfj-guest at moszumanska.debian.org
Sun Jul 2 09:02:40 UTC 2017
This is an automated email from the git hooks/post-receive script.
kfj-guest pushed a commit to branch master
in repository vspline.
commit 92a1b561b067897d46276615a0aff573845a948e
Author: Kay F. Jahnke <kfjahnke at gmail.com>
Date: Tue Jan 17 11:50:51 2017 +0100
license change of pano_extract to GPL3, proper CL argument handling
---
example/pano_extract.cc | 156 +++++++++++++++++++++++++++++-------------------
1 file changed, 94 insertions(+), 62 deletions(-)
diff --git a/example/pano_extract.cc b/example/pano_extract.cc
index ec02cb1..a6c7028 100644
--- a/example/pano_extract.cc
+++ b/example/pano_extract.cc
@@ -1,33 +1,23 @@
-/************************************************************************/
-/* */
-/* vspline - a set of generic tools for creation and evaluation */
-/* of uniform rational b-splines */
-/* */
-/* Copyright 2015, 2016 by Kay F. Jahnke */
-/* */
-/* Permission is hereby granted, free of charge, to any person */
-/* obtaining a copy of this software and associated documentation */
-/* files (the "Software"), to deal in the Software without */
-/* restriction, including without limitation the rights to use, */
-/* copy, modify, merge, publish, distribute, sublicense, and/or */
-/* sell copies of the Software, and to permit persons to whom the */
-/* Software is furnished to do so, subject to the following */
-/* conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the */
-/* Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
-/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
-/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
-/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
-/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
-/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
-/* OTHER DEALINGS IN THE SOFTWARE. */
-/* */
-/************************************************************************/
+/*************************************************************************/
+/* */
+/* pano_extract: demonstration of vspline's transformation-based remap */
+/* */
+/* Copyright 2016-2017 by Kay F. Jahnke */
+/* */
+/* pano_extract is free software: you can redistribute it and/or modify */
+/* it under the terms of the GNU General Public License as published */
+/* by the Free Software Foundation, either version 3 of the License, */
+/* or (at your option) any later version. */
+/* */
+/* pv is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU General Public License */
+/* along with pv. If not, see <http://www.gnu.org/licenses/>. */
+/* */
+/*************************************************************************/
/// \file pano_extract.cc
///
@@ -408,14 +398,16 @@ void r_v_to_l_rgb ( shape_range_type < 2 > range ,
/// linear interpolation (a b-spline of degree 1).
template < class rc_type >
-void process_image ( char * name ,
+void process_image ( const char * name ,
rc_type roll ,
rc_type pitch ,
rc_type yaw ,
int width ,
int height ,
rc_type hfov ,
- int spline_degree )
+ int spline_degree ,
+ const char * output
+ )
{
// first we have to read and preprocess the source data. The naive way of
// doing this would be to read the image into some buffer and then erect a
@@ -673,7 +665,8 @@ void process_image ( char * name ,
// data, resulting in slower operation. The one-argument form is only a crutch if vectorized
// code can't be had.
- vspline::transformation < pixel_type , rc_type , 2 , 2 >
+ vspline::transformation < rc_type , 2 , 2 ,
+ vspline::vector_traits < float > :: vsize >
tf ( tf_se , tf_se ) ;
#else
@@ -681,7 +674,7 @@ void process_image ( char * name ,
// ... or if Vc can't be used. In this case only the single-argument constructor
// can be used:
- vspline::transformation < pixel_type , rc_type , 2 , 2 >
+ vspline::transformation < rc_type , 2 , 2 >
tf ( tf_se ) ;
#endif
@@ -699,7 +692,7 @@ void process_image ( char * name ,
for ( int times = 0 ; times < 1 ; times++ )
{
- vspline::tf_remap < pixel_type , rc_type , eval_type , 2 , 2 >
+ vspline::tf_remap < eval_type , 2 , 2 >
( ev , tf , result ) ;
}
@@ -722,10 +715,11 @@ void process_image ( char * name ,
// instead of pixels of three RGB values
#ifdef USE_VC
- vspline::transformation < float , rc_type , 2 , 2 >
+ vspline::transformation < rc_type , 2 , 2 ,
+ vspline::vector_traits < float > :: vsize >
tf_alpha ( tf_se , tf_se ) ;
#else
- vspline::transformation < float , rc_type , 2 , 2 >
+ vspline::transformation < rc_type , 2 , 2 >
tf_alpha ( tf_se ) ;
#endif
@@ -734,7 +728,7 @@ void process_image ( char * name ,
alpha_ev_type ev_alpha ( bspl_alpha ) ;
// now we do a transformation-based remap of the alpha channel
- vspline::tf_remap < float , rc_type , alpha_ev_type , 2 , 2 >
+ vspline::tf_remap < alpha_ev_type , 2 , 2 >
( ev_alpha , tf_alpha , alpha_result ) ;
}
@@ -777,18 +771,18 @@ void process_image ( char * name ,
// brightness values to 0...max.
// TODO .setForcedRangeMapping is not in vigra documentation
- cout << "saving result to extract.tif" << endl ;
+ cout << "saving result to " << output << endl ;
if ( extra_bands )
vigra::exportImageAlpha ( result ,
alpha_result ,
- vigra::ImageExportInfo ( "extract.tif" )
+ vigra::ImageExportInfo ( output )
.setPixelType(input_pixel_type)
.setCompression("DEFLATE")
.setForcedRangeMapping ( rgb_min , rgb_max , rgb_min , rgb_max ) );
else
vigra::exportImage ( result ,
- vigra::ImageExportInfo ( "extract.tif" )
+ vigra::ImageExportInfo ( output )
.setPixelType(input_pixel_type)
.setCompression("DEFLATE")
.setForcedRangeMapping ( rgb_min , rgb_max , rgb_min , rgb_max ) );
@@ -799,38 +793,76 @@ void process_image ( char * name ,
int main ( int argc , char * argv[] )
{
- if ( argc < 9 )
+ // fill in any parameters gleaned from the command line
+ float r = 0.0f ;
+ float p = 0.0f ;
+ float y = 0.0f ;
+ int w = 2000 ;
+ int h = 2000 ;
+ int d = 3 ;
+ float hfov = 90.0f ;
+ const char * filename ;
+ const char * output = "extract.tif" ;
+
+ int opt ;
+ while ( ( opt = getopt ( argc , argv , "r:p:y:w:h:d:v:o:" ) ) != -1 )
{
- cout << std::string ( argv[0] ) << " - extract rectilinear section from spherical image" << endl ;
- cout << "parameters: spherical image, roll, pitch, yaw," << endl ;
- cout << "rectilinear image width, height, horizontal field of view, spline degree" << endl ;
- cout << "all angles in degrees" << endl ;
- cout << "example: pano_extract pano.tif 0.0 -90.0 0.0 2000 2000 60.0 3" << endl ;
- cout << "creates a 60 degree wide nadir image from pano.tif" << endl ;
- cout << "output is written to extract.tif" << endl ;
- cout << "It's assumed images are sRGB if pixels are UCHAR8 or UCHAR16" << endl ;
- cout << "or linear RGB if otherwise. Monochrome is not supported." << endl ;
- cout << "alpha channel will be honoured if present." << endl ;
- return 1 ;
+ switch (opt)
+ {
+ case 'r':
+ // roll of the view
+ r = atof ( optarg ) ;
+ break;
+ case 'p':
+ // pitch of the view
+ p = atof ( optarg ) ;
+ break;
+ case 'y':
+ // yaw of the view
+ y = atof ( optarg ) ;
+ break;
+ case 'w':
+ // width of the extracted image
+ w = atoi ( optarg ) ;
+ break;
+ case 'h':
+ // ditto for height
+ h = atoi ( optarg ) ;
+ break;
+ case 'd':
+ // degree of b-spline to use
+ d = atoi ( optarg ) ;
+ break;
+ case 'v':
+ // horizontal field of view of the view
+ hfov = atof ( optarg ) ;
+ break;
+ case 'o':
+ // output filename
+ output = optarg ;
+ break ;
+ default: // TODO incomplete
+ exit ( EXIT_FAILURE ) ;
+ }
}
+ if ( optind >= argc )
+ {
+ std::cerr << "please pass an image file name after the options" << std::endl ;
+ exit ( EXIT_FAILURE ) ;
+ }
+
+ filename = argv [ optind ] ;
+
cout << fixed << showpoint ;
- float r = atof ( argv[2] ) ;
- float p = atof ( argv[3] ) ;
- float y = atof ( argv[4] ) ;
- int w = atoi ( argv[5] ) ;
- int h = atoi ( argv[6] ) ;
- float hfov = atof ( argv[7] ) ;
- int d = atoi ( argv[8] ) ;
-
cout << "image " << std::string(argv[1]) << endl ;
cout << "roll " << r << " pitch " << p << " yaw " << y << endl ;
cout << "output width: " << w << " height: " << h << endl ;
cout << "output hfov: " << hfov << endl ;
cout << "spline degree: " << d << endl ;
- process_image<float> ( argv[1] , r , p , y , w , h , hfov , d ) ;
+ process_image<float> ( filename , r , p , y , w , h , hfov , d , output ) ;
return 0 ;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/vspline.git
More information about the debian-science-commits
mailing list