Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[0628c3]: src / hugin_base / nona / Stitcher.h Maximize Restore History

Download this file

Stitcher.h    1252 lines (1092 with data), 46.5 kB

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
// -*- c-basic-offset: 4 -*-
/** @file nona/Stitcher.h
*
* Contains various routines used for stitching panoramas.
*
* @author Pablo d'Angelo <pablo.dangelo@web.de>
*
* $Id$
*
* This 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 2 of the License, or (at your option) any later version.
*
* This software 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _NONA_STITCHER_H
#define _NONA_STITCHER_H
// To avoid windows.h namespace pollution later on
#include <vigra/windows.h>
#include <sstream>
#include <iomanip>
#include <vector>
#include <utility>
#include <cctype>
#include <algorithm>
#include <vigra/stdimage.hxx>
#include <vigra/rgbvalue.hxx>
#include <vigra/tiff.hxx>
#include <vigra/impex.hxx>
#include <vigra_ext/impexalpha.hxx>
#include <vigra_ext/blend.h>
#include <vigra_ext/NearestFeatureTransform.h>
#include <vigra_ext/tiffUtils.h>
#include <vigra_ext/ImageTransforms.h>
#include <panodata/PanoramaData.h>
#include <algorithms/nona/ComputeImageROI.h>
#include <nona/RemappedPanoImage.h>
#include <nona/ImageRemapper.h>
// calculate distance image for multi file output
#define STITCHER_CALC_DIST_IMG 0
// somehow these are still
#undef DIFFERENCE
#undef min
#undef max
#undef MIN
#undef MAX
namespace HuginBase {
namespace Nona {
/** determine blending order (starting with image 0), and continue to
* stitch the image with the biggest overlap area with the real image..
* do everything on a low res version of the masks
*/
void estimateBlendingOrder(const PanoramaData & pano, UIntSet images,
std::vector<unsigned int> & blendOrder);
#if 0
/**
* remap a single image to a multiple/multilayer tiff files.
*
* If tiff already contains tiff files, append to the file
*/
template <typename ImageType, typename AlphaType>
bool remapToTiff(const PanoramaData & pano, const PanoramaOptions &opts,
unsigned imgNr, TIFF * tiff
AppBase::MultiProgressDisplay & progress)
{
bool saveRoi = opts.tiff_saveROI;
const PanoImage & img = pano.getImage(imgNr);
vigra::Diff2D srcSize;
srcSize.x = img.getWidth();
srcSize.y = img.getHeight();
// create transforms
// SpaceTransform t;
// SpaceTransform invT;
PTools::Transform transf;
PTools::Transform invTransf;
transf.createTransform(pano, imgNr, opts, srcSize);
invTransf.createInvTransform(pano, imgNr, opts, srcSize);
// calculate ROI for this image.
ImageOptions imgOpts = img.getOptions();
vigra::Rect2D imageRect;
vigra::BImage miniAlpha;
double alphaScale;
bool circCrop = pano.getLens(pano.getImage(imgNr).getLensNr()).getProjection() == Lens::CIRCULAR_FISHEYE;
estimateImageRect(Size2D(opts.width, opts.getHeight()), srcSize,
imgOpts.docrop, imgOpts.cropRect, circCrop,
transf,
imageRect, miniAlpha, alphaScale);
/** the scanlines */
ImageType img(;
AlphaType alpha;
// write TIFF header
if (saveRoi) {
vigra_ext::createTiffDirectory(tiff,
img.getFilename(),
m_basename,
opts.tiffCompression,
imgNr+1, nImg,
imageRect.upperLeft());
} else {
vigra_ext::createTiffDirectory(tiff,
img.getFilename(),
m_basename,
opts.tiffCompression,
imgNr+1, nImg,
vigra::Diff2D(0,0));
}
#endif
/** implements a stitching algorithm */
template <typename ImageType, typename AlphaType>
class Stitcher
{
public:
/** create a stitcher for the given panorama */
Stitcher(const PanoramaData & pano, AppBase::MultiProgressDisplay & prog)
: m_pano(pano), m_progress(prog)
{
}
virtual ~Stitcher() {};
/** Stitch some images into a panorama file.
*
* The filename can be specified with and without extension
*/
virtual void stitch(const PanoramaOptions & opts,
UIntSet & images, const std::string & file,
SingleImageRemapper<ImageType, AlphaType> & remapper)
{
m_images=images;
calcOutputROIS(opts, images);
};
virtual UIntSet getUsedImages()
{
UIntSet ret;
assert(m_rois.size() == m_images.size());
std::vector<vigra::Rect2D>::iterator itr = m_rois.begin();
for(UIntSet::iterator it = m_images.begin(); it != m_images.end(); ++it) {
if (! itr->isEmpty()) {
ret.insert(*it);
}
}
return ret;
}
// template<typename ImgIter, typename ImgAccessor>
//void stitch(const PanoramaOptions & opts, UIntSet & images, vigra::triple<ImgIter, ImgIter, ImgAccessor> output);
protected:
// calculate ROI's if not already known
virtual void calcOutputROIS(const PanoramaOptions & opts, const UIntSet & images)
{
m_rois = HuginBase::ComputeImageROI::computeROIS(m_pano, opts, images);
}
const PanoramaData & m_pano;
AppBase::MultiProgressDisplay & m_progress;
UIntSet m_images;
std::vector<vigra::Rect2D> m_rois;
};
/** remap a set of images, and store the individual remapped files. */
template <typename ImageType, typename AlphaType>
class MultiImageRemapper : public Stitcher<ImageType, AlphaType>
{
public:
typedef Stitcher<ImageType, AlphaType> Base;
MultiImageRemapper(const PanoramaData & pano,
AppBase::MultiProgressDisplay & progress)
: Stitcher<ImageType,AlphaType>(pano, progress)
{
}
virtual ~MultiImageRemapper()
{
}
virtual void stitch(const PanoramaOptions & opts, UIntSet & images,
const std::string & basename,
SingleImageRemapper<ImageType, AlphaType> & remapper)
{
Base::stitch(opts, images, basename, remapper);
DEBUG_ASSERT(opts.outputFormat == PanoramaOptions::TIFF_multilayer
|| opts.outputFormat == PanoramaOptions::TIFF_m
|| opts.outputFormat == PanoramaOptions::HDR_m
|| opts.outputFormat == PanoramaOptions::EXR_m);
m_basename = basename;
// setup the output.
prepareOutputFile(opts);
unsigned int nImg = images.size();
Base::m_progress.pushTask(AppBase::ProgressTask("Remapping", "", 1.0/(nImg)));
// remap each image and save
int i=0;
for (UIntSet::const_iterator it = images.begin();
it != images.end(); ++it)
{
// get a remapped image.
RemappedPanoImage<ImageType, AlphaType> *
remapped = remapper.getRemapped(Base::m_pano, opts, *it,
Base::m_rois[i], Base::m_progress);
try {
saveRemapped(*remapped, *it, Base::m_pano.getNrOfImages(), opts);
} catch (vigra::PreconditionViolation & e) {
// this can be thrown, if an image
// is completely out of the pano
std::cerr << e.what();
}
// free remapped image
remapper.release(remapped);
i++;
}
Base::m_progress.popTask();
finalizeOutputFile(opts);
}
/** prepare the output file (setup file structures etc.) */
virtual void prepareOutputFile(const PanoramaOptions & opts)
{
}
/** save a remapped image, or layer */
virtual void saveRemapped(RemappedPanoImage<ImageType, AlphaType> & remapped,
unsigned int imgNr, unsigned int nImg,
const PanoramaOptions & opts)
{
ImageType * final_img = 0;
AlphaType * alpha_img = 0;
ImageType complete;
vigra::BImage alpha;
if ( remapped.boundingBox().isEmpty() )
// do not save empty files...
// TODO: need to tell other parts (enblend etc.) about it too!
return;
if (opts.outputMode == PanoramaOptions::OUTPUT_HDR) {
// export alpha channel as gray channel (original pixel weights)
std::ostringstream greyname;
greyname << m_basename << std::setfill('0') << std::setw(4) << imgNr << "_gray.pgm";
vigra::ImageExportInfo exinfo1(greyname.str().c_str());
if (! opts.tiff_saveROI) {
alpha.resize(opts.getROI().size());
vigra::Rect2D newOutRect = remapped.boundingBox() & opts.getROI();
vigra::Rect2D newOutArea(newOutRect);
newOutRect.moveBy(-opts.getROI().upperLeft());
vigra::copyImage(vigra_ext::applyRect(newOutArea,
vigra_ext::srcMaskRange(remapped)),
vigra_ext::applyRect(newOutRect,
destImage(alpha)));
vigra::exportImage(srcImageRange(alpha), exinfo1);
} else {
exinfo1.setPosition(remapped.boundingBox().upperLeft());
exinfo1.setCanvasSize(vigra::Size2D(opts.getWidth(), opts.getHeight()));
vigra::Rect2D rect=remapped.boundingBox();
if(rect.right() > opts.getROI().right()) {
rect&=opts.getROI();
rect.moveBy(-rect.upperLeft());
vigra::exportImage(srcImageRange(remapped.m_mask, rect), exinfo1);
} else {
vigra::exportImage(srcImageRange(remapped.m_mask), exinfo1);
};
}
// calculate real alpha for saving with the image
Base::m_progress.setMessage("Calculating mask");
remapped.calcAlpha();
}
vigra::Rect2D subImage;
if (! opts.tiff_saveROI) {
// FIXME: this is stupid. Should not require space for full image...
// but this would need a lower level interface in vigra impex
complete.resize(opts.getROI().size());
alpha.resize(opts.getROI().size());
vigra::Rect2D newOutRect = remapped.boundingBox() & opts.getROI();
vigra::Rect2D newOutArea(newOutRect);
newOutRect.moveBy(-opts.getROI().upperLeft());
vigra::copyImage(vigra_ext::applyRect(newOutArea,
vigra_ext::srcImageRange(remapped)),
vigra_ext::applyRect(newOutRect,
destImage(complete)));
vigra::copyImage(vigra_ext::applyRect(newOutArea,
vigra_ext::srcMaskRange(remapped)),
vigra_ext::applyRect(newOutRect,
destImage(alpha)));
final_img = & complete;
alpha_img = & alpha;
} else {
final_img = &remapped.m_image;
alpha_img = &remapped.m_mask;
if(remapped.boundingBox().right() > opts.getROI().right()) {
subImage=remapped.boundingBox() & opts.getROI();
subImage.moveBy(-subImage.upperLeft());
};
}
/*
std::string cext = hugin_utils::getExtension(m_basename);
std::transform(cext.begin(),cext.end(), cext.begin(), (int(*)(int))std::tolower);
// remove extension only if it specifies the same file type, otherwise
// its probably part of the filename.
if (cext == ext) {
m_basename = hugin_utils::stripExtension(m_basename);
}
*/
std::string ext = opts.getOutputExtension();
std::ostringstream filename;
filename << m_basename << std::setfill('0') << std::setw(4) << imgNr << "." + ext;
Base::m_progress.setMessage(std::string("saving ") +
hugin_utils::stripPath(filename.str()));
vigra::ImageExportInfo exinfo(filename.str().c_str());
exinfo.setXResolution(150);
exinfo.setYResolution(150);
exinfo.setICCProfile(remapped.m_ICCProfile);
if (opts.tiff_saveROI) {
exinfo.setPosition(remapped.boundingBox().upperLeft());
exinfo.setCanvasSize(vigra::Size2D(opts.getWidth(), opts.getHeight()));
} else {
exinfo.setPosition(opts.getROI().upperLeft());
exinfo.setCanvasSize(vigra::Size2D(opts.getWidth(), opts.getHeight()));
}
if (opts.outputPixelType.size() > 0) {
exinfo.setPixelType(opts.outputPixelType.c_str());
}
if (ext == "tif") {
exinfo.setCompression(opts.tiffCompression.c_str());
}
if(subImage.area()>0) {
vigra::exportImageAlpha(srcImageRange(*final_img, subImage), srcImage(*alpha_img), exinfo);
} else {
vigra::exportImageAlpha(srcImageRange(*final_img), srcImage(*alpha_img), exinfo);
};
if (opts.saveCoordImgs) {
vigra::UInt16Image xImg;
vigra::UInt16Image yImg;
Base::m_progress.setMessage("creating coordinate images");
remapped.calcSrcCoordImgs(xImg, yImg);
vigra::UInt16Image dist;
if (! opts.tiff_saveROI) {
dist.resize(opts.getWidth(), opts.getHeight());
vigra::copyImage(srcImageRange(xImg),
vigra_ext::applyRect(remapped.boundingBox(),
destImage(dist)));
std::ostringstream filename2;
filename2 << m_basename << std::setfill('0') << std::setw(4) << imgNr << "_x.tif";
vigra::ImageExportInfo exinfo(filename2.str().c_str());
exinfo.setXResolution(150);
exinfo.setYResolution(150);
exinfo.setCompression(opts.tiffCompression.c_str());
vigra::exportImage(srcImageRange(dist), exinfo);
vigra::copyImage(srcImageRange(yImg),
vigra_ext::applyRect(remapped.boundingBox(),
destImage(dist)));
std::ostringstream filename3;
filename3 << m_basename << std::setfill('0') << std::setw(4) << imgNr << "_y.tif";
vigra::ImageExportInfo exinfo2(filename3.str().c_str());
exinfo2.setXResolution(150);
exinfo2.setYResolution(150);
exinfo2.setCompression(opts.tiffCompression.c_str());
vigra::exportImage(srcImageRange(dist), exinfo2);
} else {
std::ostringstream filename2;
filename2 << m_basename << std::setfill('0') << std::setw(4) << imgNr << "_x.tif";
vigra::ImageExportInfo exinfo(filename2.str().c_str());
exinfo.setXResolution(150);
exinfo.setYResolution(150);
exinfo.setCompression(opts.tiffCompression.c_str());
vigra::exportImage(srcImageRange(xImg), exinfo);
std::ostringstream filename3;
filename3 << m_basename << std::setfill('0') << std::setw(4) << imgNr << "_y.tif";
vigra::ImageExportInfo exinfo2(filename3.str().c_str());
exinfo2.setXResolution(150);
exinfo2.setYResolution(150);
exinfo2.setCompression(opts.tiffCompression.c_str());
vigra::exportImage(srcImageRange(yImg), exinfo2);
}
}
}
virtual void finalizeOutputFile(const PanoramaOptions & opts)
{
}
protected:
std::string m_basename;
};
/** stitch multilayer */
template <typename ImageType, typename AlphaImageType>
class TiffMultiLayerRemapper : public MultiImageRemapper<ImageType, AlphaImageType>
{
public:
typedef MultiImageRemapper<ImageType, AlphaImageType> Base;
TiffMultiLayerRemapper(const PanoramaData & pano,
AppBase::MultiProgressDisplay & progress)
: MultiImageRemapper<ImageType, AlphaImageType> (pano, progress)
{
}
virtual ~TiffMultiLayerRemapper()
{
}
virtual void prepareOutputFile(const PanoramaOptions & opts)
{
std::string filename = Base::m_basename + ".tif";
DEBUG_DEBUG("Layering image into a multi image tif file " << filename);
m_tiff = TIFFOpen(filename.c_str(), "w");
DEBUG_ASSERT(m_tiff && "could not open tiff output file");
}
/** save the remapped image in a partial tiff layer */
virtual void saveRemapped(RemappedPanoImage<ImageType, AlphaImageType> & remapped,
unsigned int imgNr, unsigned int nImg,
const PanoramaOptions & opts)
{
if (remapped.boundingBox().isEmpty())
return;
DEBUG_DEBUG("Saving TIFF ROI");
vigra_ext::createTiffDirectory(m_tiff,
Base::m_pano.getImage(imgNr).getFilename(),
Base::m_basename,
opts.tiffCompression,
imgNr+1, nImg, remapped.boundingBox().upperLeft(),
opts.getROI().size(),
remapped.m_ICCProfile);
vigra_ext::createAlphaTiffImage(vigra::srcImageRange(remapped.m_image),
vigra::maskImage(remapped.m_mask),
m_tiff);
TIFFFlush(m_tiff);
}
/** close the tiff file */
virtual void finalizeOutputFile(const PanoramaOptions & opts)
{
TIFFClose(m_tiff);
}
protected:
vigra::TiffImage * m_tiff;
};
typedef std::vector<std::pair<float, unsigned int> > AlphaVector;
/** functor to calculate the union of two images. also calculates the
* size of the union
*/
struct CalcMaskUnion
{
CalcMaskUnion()
: count(0)
{ }
template<typename PIXEL>
PIXEL operator()(PIXEL const & img1, PIXEL const & img2)
{
if (img1 > vigra::NumericTraits<PIXEL>::zero() && img2 > vigra::NumericTraits<PIXEL>::zero()) {
count++;
return img1;
} else {
return vigra::NumericTraits<PIXEL>::zero();
}
}
int count;
};
template <typename ImageType, typename AlphaType>
class WeightedStitcher : public Stitcher<ImageType, AlphaType>
{
public:
typedef Stitcher<ImageType, AlphaType> Base;
WeightedStitcher(const PanoramaData & pano,
AppBase::MultiProgressDisplay & progress)
: Stitcher<ImageType, AlphaType>(pano, progress)
{
}
virtual ~WeightedStitcher() {};
template<class ImgIter, class ImgAccessor,
class AlphaIter, class AlphaAccessor>
void stitch(const PanoramaOptions & opts, UIntSet & imgSet,
vigra::triple<ImgIter, ImgIter, ImgAccessor> pano,
std::pair<AlphaIter, AlphaAccessor> alpha,
SingleImageRemapper<ImageType, AlphaType> & remapper)
{
std::vector<unsigned int> images;
// calculate stitching order
estimateBlendingOrder(Base::m_pano, imgSet, images);
unsigned int nImg = images.size();
Base::m_progress.pushTask(AppBase::ProgressTask("Stitching", "", 1.0/(nImg)));
// empty ROI
vigra::Rect2D panoROI;
int i=0;
// remap each image and blend into main pano image
for (UIntVector::const_iterator it = images.begin();
it != images.end(); ++it)
{
// get a remapped image.
DEBUG_DEBUG("remapping image: " << *it);
RemappedPanoImage<ImageType, AlphaType> *
remapped = remapper.getRemapped(Base::m_pano, opts, *it,
Base::m_rois[i], Base::m_progress);
if(iccProfile.size()==0)
{
iccProfile=remapped->m_ICCProfile;
};
Base::m_progress.setMessage("blending");
// add image to pano and panoalpha, adjusts panoROI as well.
try {
vigra_ext::blend(*remapped, pano, alpha, panoROI,
Base::m_progress);
// update bounding box of the panorama
panoROI = panoROI | remapped->boundingBox();
} catch (vigra::PreconditionViolation & e) {
DEBUG_ERROR("exception during stitching" << e.what());
// this can be thrown, if an image
// is completely out of the pano
}
// free remapped image
remapper.release(remapped);
i++;
}
}
void stitch(const PanoramaOptions & opts, UIntSet & imgSet,
const std::string & filename,
SingleImageRemapper<ImageType, AlphaType> & remapper)
{
Base::stitch(opts, imgSet, filename, remapper);
std::string basename = filename;
// create panorama canvas
ImageType pano(opts.getWidth(), opts.getHeight());
AlphaType panoMask(opts.getWidth(), opts.getHeight());
stitch(opts, imgSet, vigra::destImageRange(pano), vigra::destImage(panoMask), remapper);
std::string ext = opts.getOutputExtension();
std::string cext = hugin_utils::tolower(hugin_utils::getExtension(basename));
std::transform(cext.begin(),cext.end(), cext.begin(), (int(*)(int))std::tolower);
// remove extension only if it specifies the same file type, otherwise
// its probably part of the filename.
if (cext == ext) {
basename = hugin_utils::stripExtension(basename);
}
std::string outputfile = basename + "." + ext;
// save the remapped image
Base::m_progress.setMessage("saving result: " + hugin_utils::stripPath(outputfile));
DEBUG_DEBUG("Saving panorama: " << outputfile);
vigra::ImageExportInfo exinfo(outputfile.c_str());
exinfo.setXResolution(150);
exinfo.setYResolution(150);
exinfo.setICCProfile(iccProfile);
if (opts.outputPixelType.size() > 0) {
exinfo.setPixelType(opts.outputPixelType.c_str());
}
// set compression quality for jpeg images.
if (opts.outputFormat == PanoramaOptions::JPEG) {
char jpgCompr[4];
snprintf(jpgCompr,4,"%d", opts.quality);
exinfo.setCompression(jpgCompr);
vigra::exportImage(srcImageRange(pano), exinfo);
} else if (opts.outputFormat == PanoramaOptions::TIFF) {
exinfo.setCompression(opts.tiffCompression.c_str());
vigra::exportImageAlpha(srcImageRange(pano),
srcImage(panoMask), exinfo);
} else if (opts.outputFormat == PanoramaOptions::HDR) {
exinfo.setPixelType("FLOAT");
vigra::exportImage(srcImageRange(pano), exinfo);
} else {
vigra::exportImageAlpha(srcImageRange(pano),
srcImage(panoMask), exinfo);
}
/*
#ifdef DEBUG
vigra::exportImage(srcImageRange(panoMask), vigra::ImageExportInfo("pano_alpha.tif"));
#endif
*/
Base::m_progress.popTask();
}
protected:
vigra::ImageImportInfo::ICCProfile iccProfile;
};
/** Difference reduce functor */
template<class VALUETYPE>
struct ReduceToDifferenceFunctor
{
typedef VALUETYPE argument_type;
typedef VALUETYPE result_type;
typedef typename vigra::NumericTraits<argument_type> Traits;
typedef typename Traits::RealPromote float_type;
ReduceToDifferenceFunctor()
{
reset();
}
void reset()
{
sum = vigra::NumericTraits<float_type>::zero();
values.clear();
}
template<class T, class M>
void operator() (T const &v, M const &a)
{
if (a) {
values.push_back(v);
sum = sum + v;
}
}
/** return the result */
float_type operator()() const
{
typedef typename std::vector<float_type>::const_iterator Iter;
if (values.size() > 1) {
float_type mean = sum / values.size();
float_type error = vigra::NumericTraits<float_type>::zero();
for (Iter it= values.begin(); it != values.end(); ++it) {
error += vigra::abs(*it-mean);
}
return error;
} else {
return sum;
}
}
std::vector<float_type> values;
float_type sum;
};
/** create a panorama using the reduce operation on all overlapping
* pixels. WARNING: this version is very memory hungry for large
* panoramas (> 3 images ;-)
*/
template <typename ImageType, typename AlphaType>
class ReduceStitcher : public Stitcher<ImageType, AlphaType>
{
typedef Stitcher<ImageType, AlphaType> Base;
public:
ReduceStitcher(const PanoramaData & pano,
AppBase::MultiProgressDisplay & progress)
: Stitcher<ImageType, AlphaType>(pano, progress)
{
}
virtual ~ReduceStitcher()
{
}
template <class FUNCTOR>
void stitch(const PanoramaOptions & opts, UIntSet & imgSet,
const std::string & filename,
SingleImageRemapper<ImageType, AlphaType> & remapper,
FUNCTOR & reduce)
{
Base::stitch(opts, imgSet, filename, remapper);
std::string basename = filename;
// create panorama canvas
ImageType pano(opts.getWidth(), opts.getHeight());
AlphaType panoMask(opts.getWidth(), opts.getHeight());
stitch(opts, imgSet, vigra::destImageRange(pano), vigra::destImage(panoMask),
remapper, reduce);
std::string ext = opts.getOutputExtension();
std::string cext = hugin_utils::tolower(hugin_utils::getExtension(basename));
// remove extension only if it specifies the same file type, otherwise
// its probably part of the filename.
if (cext == ext) {
basename = hugin_utils::stripExtension(basename);
}
std::string outputfile = basename + "." + ext;
// Base::m_progress.setMessage("saving result: " + hugin_utils::stripPath(outputfile));
DEBUG_DEBUG("Saving panorama: " << outputfile);
vigra::ImageExportInfo exinfo(outputfile.c_str());
if (opts.outputPixelType.size() > 0) {
exinfo.setPixelType(opts.outputPixelType.c_str());
}
exinfo.setXResolution(150);
exinfo.setYResolution(150);
exinfo.setICCProfile(iccProfile);
// set compression quality for jpeg images.
if (opts.outputFormat == PanoramaOptions::JPEG) {
char jpgCompr[4];
snprintf(jpgCompr,4,"%d", opts.quality);
exinfo.setCompression(jpgCompr);
vigra::exportImage(srcImageRange(pano), exinfo);
} else if (opts.outputFormat == PanoramaOptions::TIFF) {
exinfo.setCompression(opts.tiffCompression.c_str());
vigra::exportImageAlpha(srcImageRange(pano),
srcImage(panoMask), exinfo);
} else if (opts.outputFormat == PanoramaOptions::HDR) {
vigra::exportImage(srcImageRange(pano), exinfo);
} else {
vigra::exportImageAlpha(srcImageRange(pano),
srcImage(panoMask), exinfo);
}
/*
#ifdef DEBUG
vigra::exportImage(srcImageRange(panoMask), vigra::ImageExportInfo("pano_alpha.tif"));
#endif
*/
}
template<class ImgIter, class ImgAccessor,
class AlphaIter, class AlphaAccessor,
class FUNCTOR>
void stitch(const PanoramaOptions & opts, UIntSet & imgSet,
vigra::triple<ImgIter, ImgIter, ImgAccessor> pano,
std::pair<AlphaIter, AlphaAccessor> alpha,
SingleImageRemapper<ImageType, AlphaType> & remapper,
FUNCTOR & reduce)
{
typedef typename
vigra::NumericTraits<typename ImageType::value_type> Traits;
typedef typename
Traits::RealPromote RealImgType;
typedef typename ImageType::value_type ImgType;
typedef typename AlphaAccessor::value_type MaskType;
Base::stitch(opts, imgSet, "dummy", remapper);
// remap all images..
typedef std::vector<RemappedPanoImage<ImageType, AlphaType> *> RemappedVector;
unsigned int nImg = imgSet.size();
Base::m_progress.pushTask(AppBase::ProgressTask("Stitching", "", 1.0/(nImg)));
// empty ROI
// vigra::Rect2D panoROI;
// remap all images..
RemappedVector remapped(nImg);
int i=0;
// remap each image and blend into main pano image
for (UIntSet::const_iterator it = imgSet.begin();
it != imgSet.end(); ++it)
{
// get a copy of the remapped image.
// not very good, keeps all images in memory,
// but should be enought for the preview.
remapped[i] = remapper.getRemapped(Base::m_pano, opts, *it,
Base::m_rois[i], Base::m_progress);
if(iccProfile.size()==0)
{
iccProfile=remapped[i]->m_ICCProfile;
};
i++;
}
vigra::Diff2D size = pano.second - pano.first;
ImgIter output = pano.first;
// iterate over the whole image...
// calculate something on the pixels that belong together..
for (int y=0; y < size.y; y++) {
for (int x=0; x < size.x; x++) {
reduce.reset();
MaskType maskRes=0;
for (unsigned int i=0; i< nImg; i++) {
MaskType a = remapped[i]->getMask(x,y);
if (a) {
maskRes = vigra_ext::LUTTraits<MaskType>::max();
reduce(remapped[i]->operator()(x,y), a);
}
}
pano.third.set(Traits::fromRealPromote(reduce()), output, vigra::Diff2D(x,y));
alpha.second.set(maskRes, alpha.first, vigra::Diff2D(x,y));
}
}
Base::m_progress.popTask();
for (typename RemappedVector::iterator it=remapped.begin();
it != remapped.end(); ++it)
{
remapper.release(*it);
}
}
protected:
vigra::ImageImportInfo::ICCProfile iccProfile;
};
/** A stitcher without seaming, just copies the images over each other
*/
template <typename ImageType, typename AlphaType>
class SimpleStitcher : public Stitcher<ImageType, AlphaType>
{
typedef Stitcher<ImageType, AlphaType> Base;
public:
SimpleStitcher(const PanoramaData & pano,
AppBase::MultiProgressDisplay & progress)
: Stitcher<ImageType, AlphaType>(pano, progress)
{
}
virtual ~SimpleStitcher()
{
}
template<class ImgIter, class ImgAccessor,
class AlphaIter, class AlphaAccessor,
class BlendFunctor>
void stitch(const PanoramaOptions & opts, UIntSet & imgSet,
vigra::triple<ImgIter, ImgIter, ImgAccessor> pano,
std::pair<AlphaIter, AlphaAccessor> alpha,
SingleImageRemapper<ImageType, AlphaType> & remapper,
BlendFunctor & blend)
{
Base::m_images=imgSet;
Base::calcOutputROIS(opts, imgSet);
unsigned int nImg = imgSet.size();
Base::m_progress.pushTask(AppBase::ProgressTask("Stitching", "", 1.0/(nImg)));
// empty ROI
vigra::Rect2D panoROI;
unsigned i=0;
// remap each image and blend into main pano image
for (UIntSet::reverse_iterator it = imgSet.rbegin();
it != imgSet.rend(); ++it)
{
// get a remapped image.
RemappedPanoImage<ImageType, AlphaType> *
remapped = remapper.getRemapped(Base::m_pano, opts, *it,
Base::m_rois[i], Base::m_progress);
if (iccProfile.size() == 0) {
// try to extract icc profile.
iccProfile = remapped->m_ICCProfile;
}
Base::m_progress.setMessage("blending");
// add image to pano and panoalpha, adjusts panoROI as well.
try {
blend(*remapped, pano, alpha, panoROI);
// update bounding box of the panorama
panoROI = panoROI | remapped->boundingBox();
} catch (vigra::PreconditionViolation & e) {
// this can be thrown, if an image
// is completely out of the pano
std::cerr << e.what();
}
// free remapped image
remapper.release(remapped);
i++;
}
Base::m_progress.popTask();
}
template <class BlendFunctor>
void stitch(const PanoramaOptions & opts, UIntSet & imgSet,
const std::string & filename,
SingleImageRemapper<ImageType, AlphaType> & remapper,
BlendFunctor & blend)
{
std::string basename = filename;
// create panorama canvas
ImageType pano(opts.getWidth(), opts.getHeight());
AlphaType panoMask(opts.getWidth(), opts.getHeight());
stitch(opts, imgSet, vigra::destImageRange(pano), vigra::destImage(panoMask), remapper, blend);
std::string ext = opts.getOutputExtension();
std::string cext = hugin_utils::tolower(hugin_utils::getExtension(basename));
// remove extension only if it specifies the same file type, otherwise
// its probably part of the filename.
if (cext == ext) {
basename = hugin_utils::stripExtension(basename);
}
std::string outputfile = basename + "." + ext;
Base::m_progress.setMessage("saving result: " + hugin_utils::stripPath(outputfile));
DEBUG_DEBUG("Saving panorama: " << outputfile);
vigra::ImageExportInfo exinfo(outputfile.c_str());
exinfo.setXResolution(150);
exinfo.setYResolution(150);
exinfo.setICCProfile(iccProfile);
// set compression quality for jpeg images.
if (opts.outputFormat == PanoramaOptions::JPEG) {
char jpgCompr[4];
snprintf(jpgCompr,4,"%d", opts.quality);
exinfo.setCompression(jpgCompr);
vigra::exportImage(srcImageRange(pano), exinfo);
} else if (opts.outputFormat == PanoramaOptions::TIFF) {
exinfo.setCompression("DEFLATE");
vigra::exportImageAlpha(srcImageRange(pano),
srcImage(panoMask), exinfo);
} else {
vigra::exportImageAlpha(srcImageRange(pano),
srcImage(panoMask), exinfo);
}
/*
#ifdef DEBUG
vigra::exportImage(srcImageRange(panoMask), vigra::ImageExportInfo("pano_alpha.tif"));
#endif
*/
Base::m_progress.popTask();
}
protected:
vigra::ImageExportInfo::ICCProfile iccProfile;
};
/** blend images, by simply stacking them, without soft blending or
* boundary calculation
*/
struct StackingBlender
{
public:
/** blend \p img into \p pano, using \p alpha mask and \p panoROI
*
* updates \p pano, \p alpha and \p panoROI
*/
template <typename ImageType, typename AlphaType,
typename PanoIter, typename PanoAccessor,
typename AlphaIter, typename AlphaAccessor>
void operator()(RemappedPanoImage<ImageType, AlphaType> & img,
vigra::triple<PanoIter, PanoIter, PanoAccessor> pano,
std::pair<AlphaIter, AlphaAccessor> alpha,
const vigra::Rect2D & panoROI)
{
using namespace vigra_ext;
DEBUG_DEBUG("pano roi: " << panoROI << " img roi: " << img.boundingBox());
typedef typename AlphaIter::value_type AlphaValue;
// DEBUG_DEBUG("no overlap, copying upper area. imgroi " << img.roi());
// DEBUG_DEBUG("pano roi: " << panoROI.upperLeft() << " -> " << panoROI.lowerRight());
DEBUG_DEBUG("size of panorama: " << pano.second - pano.first);
// check if bounding box of image is outside of panorama...
vigra::Rect2D fullPano(vigra::Size2D(pano.second-pano.first));
// blend only the intersection (which is inside the pano..)
vigra::Rect2D overlap = fullPano & img.boundingBox();
vigra::copyImageIf(applyRect(overlap, vigra_ext::srcImageRange(img)),
applyRect(overlap, vigra_ext::srcMask(img)),
applyRect(overlap, std::make_pair(pano.first, pano.third)));
// copy mask
vigra::copyImageIf(applyRect(overlap, srcMaskRange(img)),
applyRect(overlap, srcMask(img)),
applyRect(overlap, alpha));
}
};
/** seam blender. */
struct SeamBlender
{
public:
/** blend \p img into \p pano, using \p alpha mask and \p panoROI
*
* updates \p pano, \p alpha and \p panoROI
*/
template <typename ImageType, typename AlphaType,
typename PanoIter, typename PanoAccessor,
typename AlphaIter, typename AlphaAccessor>
void operator()(RemappedPanoImage<ImageType, AlphaType> & img,
vigra::triple<PanoIter, PanoIter, PanoAccessor> pano,
std::pair<AlphaIter, AlphaAccessor> alpha,
const vigra::Rect2D & panoROI)
{
DEBUG_DEBUG("pano roi: " << panoROI << " img roi: " << img.boundingBox());
AppBase::MultiProgressDisplay dummy;
vigra_ext::blend(img, pano, alpha, panoROI, dummy);
}
};
/** blend by difference */
struct DifferenceBlender
{
public:
/** blend \p img into \p pano, using \p alpha mask and \p panoROI
*
* updates \p pano, \p alpha and \p panoROI
*/
template <typename ImageType, typename AlphaType,
typename PanoIter, typename PanoAccessor,
typename AlphaIter, typename AlphaAccessor>
void operator()(RemappedPanoImage<ImageType, AlphaType> & img,
vigra::triple<PanoIter, PanoIter, PanoAccessor> pano,
std::pair<AlphaIter, AlphaAccessor> alpha,
const vigra::Rect2D & panoROI)
{
DEBUG_DEBUG("pano roi: " << panoROI << " img roi: " << img.boundingBox());
typedef typename AlphaIter::value_type AlphaValue;
// check if bounding box of image is outside of panorama...
vigra::Rect2D fullPano(vigra::Size2D(pano.second-pano.first));
// blend only the intersection (which is inside the pano..)
vigra::Rect2D overlap = fullPano & img.boundingBox();
vigra::combineTwoImagesIf(applyRect(overlap, vigra_ext::srcImageRange(img)),
applyRect(overlap, std::make_pair(pano.first, pano.third)),
applyRect(overlap, vigra_ext::srcMask(img)),
applyRect(overlap, std::make_pair(pano.first, pano.third)),
abs(vigra::functor::Arg1()-vigra::functor::Arg2()));
// copy mask
vigra::copyImageIf(applyRect(overlap, srcMaskRange(img)),
applyRect(overlap, srcMask(img)),
applyRect(overlap, alpha));
}
};
/*
template <typename ImageType, typename AlphaImageType>
class MultiResStitcher : public WeightedSticher<ImageType, AlphaImageType>
{
public:
MultiResStitcher(const PanoramaData & pano,
AppBase::MultiProgressDisplay & progress)
: WeightedStitcher(pano, progress)
{
}
template <typename PanoIter, typename PanoAccessor,
typename MaskIter, typename MaskAccessor>
virtual void blendOverlap(vigra::triple<PanoIter, PanoIter, PanoAccessor> image,
std::pair<MaskIter, MaskAccessor> imageMask,
std::pair<PanoIter, PanoAccessor> pano,
std::pair<MaskIter, MaskAccessor> panoMask)
{
vigra::Diff2D size = image.second - image.first;
// create new blending masks
vigra::BasicImage<typename MaskIter::value_type> blendPanoMask(size);
vigra::BasicImage<typename MaskIter::value_type> blendImageMask(size);
// calculate the stitching masks.
vigra_ext::nearestFeatureTransform(srcIterRange(panoMask.first, panoMask.first + size),
imageMask,
destImage(blendPanoMask),
destImage(blendImageMask),
m_progress);
// calculate the a number of
// copy the image into the panorama
vigra::copyImageIf(image, maskImage(blendImageMask), pano);
// copy mask
vigra::copyImageIf(srcImageRange(blendImageMask), maskImage(blendImageMask), panoMask);
}
private:
};
*/
#if 0
/** small convinience function to remap and stitch a HDR image
* Warning, this requires tons of memory, since everything is
* hold on disk.
*/
template <typename Remapper, typename OutputImage, typename Mask>
void stitchToHDR(Remapper & remappers, OutputImage & panoImg, Mask & mask,
AppBase::MultiProgressDisplay & progress)
{
std::vector<RemappedPanoImage<OutputImage, Mask> *> remapped;
// get all remapped images
for (UIntSet::const_iterator it = displayedImages.begin();
it != displayedImages.end(); ++it)
{
remapped.push_back(remapper.getRemapped(pano, opts, *it, progress));
}
ReduceToHDRFunctor<RGBValue<float> > hdrmerge;
reduceROIImages(remapped,
destImageRange(panoImg), destImage(alpha),
hdrmerge);
#endif
template<typename ImageType, typename AlphaType>
static void stitchPanoIntern(const PanoramaData & pano,
const PanoramaOptions & opts,
AppBase::MultiProgressDisplay & progress,
const std::string & basename,
UIntSet imgs)
{
using namespace vigra_ext;
// typedef
// vigra::NumericTraits<typename OutputImageType::Accessor::value_type> DestTraits;
FileRemapper<ImageType, AlphaType> m;
// determine stitching output
switch (opts.outputFormat) {
case PanoramaOptions::JPEG:
case PanoramaOptions::PNG:
case PanoramaOptions::TIFF:
case PanoramaOptions::HDR:
case PanoramaOptions::EXR:
{
if (opts.outputMode == PanoramaOptions::OUTPUT_HDR) {
ReduceToHDRFunctor<typename ImageType::value_type> hdrmerge;
ReduceStitcher<ImageType, AlphaType> stitcher(pano, progress);
stitcher.stitch(opts, imgs, basename, m, hdrmerge);
} else {
WeightedStitcher<ImageType, AlphaType> stitcher(pano, progress);
stitcher.stitch(opts, imgs, basename,
m);
}
break;
}
case PanoramaOptions::TIFF_m:
case PanoramaOptions::HDR_m:
case PanoramaOptions::EXR_m:
{
MultiImageRemapper<ImageType, AlphaType> stitcher(pano, progress);
stitcher.stitch(opts, imgs, basename,
m);
break;
}
case PanoramaOptions::TIFF_multilayer:
{
TiffMultiLayerRemapper<ImageType, AlphaType> stitcher(pano, progress);
stitcher.stitch(opts, imgs, basename,
m);
break;
}
case PanoramaOptions::TIFF_mask:
case PanoramaOptions::TIFF_multilayer_mask:
DEBUG_ERROR("multi mask stitching not implemented!");
break;
default:
DEBUG_ERROR("output format " << opts.getFormatName(opts.outputFormat) << "not supported");
break;
}
}
/** stitch a panorama
*
* @todo vignetting correction
* @todo do not keep complete output image in memory
*
*/
IMPEX void stitchPanorama(const PanoramaData & pano,
const PanoramaOptions & opts,
AppBase::MultiProgressDisplay & progress,
const std::string & basename,
const UIntSet & usedImgs);
// the instantiations of the stitching functions have been divided into two .cpp
// files, because g++ will use too much memory otherwise (> 1.5 GB)
void stitchPanoGray_8_16(const PanoramaData & pano,
const PanoramaOptions & opts,
AppBase::MultiProgressDisplay & progress,
const std::string & basename,
const UIntSet & usedImgs,
const char * pixelType);
void stitchPanoGray_32_float(const PanoramaData & pano,
const PanoramaOptions & opts,
AppBase::MultiProgressDisplay & progress,
const std::string & basename,
const UIntSet & usedImgs,
const char * pixelType);
void stitchPanoRGB_8_16(const PanoramaData & pano,
const PanoramaOptions & opts,
AppBase::MultiProgressDisplay & progress,
const std::string & basename,
const UIntSet & usedImgs,
const char * pixelType);
void stitchPanoRGB_32_float(const PanoramaData & pano,
const PanoramaOptions & opts,
AppBase::MultiProgressDisplay & progress,
const std::string & basename,
const UIntSet & usedImgs,
const char * pixelType);
} // namespace
} // namespace
#endif // _H