@@ -223,7 +223,8 @@ bool Depthmap::loadTiff(const char *tiff, vector<float> &values, uint32_t &w, ui
223
223
224
224
uint16_t samplesPerPixel = 1 ;
225
225
TIFFGetField (inTiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel);
226
- if (samplesPerPixel != 1 ) {
226
+ if (samplesPerPixel !=
227
+ 1 ) {
227
228
cerr << " Not a depthmap, expecting just 1 channel" << endl;
228
229
TIFFClose (inTiff);
229
230
return false ;
@@ -245,6 +246,7 @@ bool Depthmap::loadTiff(const char *tiff, vector<float> &values, uint32_t &w, ui
245
246
return false ;
246
247
}
247
248
249
+
248
250
values.resize (w * h);
249
251
250
252
// Check if the TIFF is tiled
@@ -427,11 +429,11 @@ bool Depthmap::loadMask(const char *tifPath){
427
429
return true ;
428
430
429
431
}
432
+
430
433
// 1. scrivere la depth map e la masq fai tif .save con i nomi.
431
434
// 2. prendi la superficie dell rti e trovi la media delle due superfici della depth e della rti. sottraiamo la media del rti per vedere se hanno la stessa media.
432
435
// void Depthmap::
433
436
434
-
435
437
bool Depthmap::loadNormals (const char *normals_path){
436
438
437
439
QImage normalmap (normals_path);
@@ -469,13 +471,25 @@ void Depthmap::saveTiff(const char *mask_path, vector<float> &values, uint32_t &
469
471
return ;
470
472
}
471
473
472
- TIFFSetField (maskTiff, TIFFTAG_IMAGEWIDTH, w);
473
- TIFFSetField (maskTiff, TIFFTAG_IMAGELENGTH, h);
474
- // TIFFSetField(maskTiff, TIFFTAG_SAMPLESPERPIXEL, 1);
474
+ TIFFSetField (maskTiff, TIFFTAG_IMAGEWIDTH, &w);
475
+ TIFFSetField (maskTiff, TIFFTAG_IMAGELENGTH, &h);
476
+ TIFFSetField (maskTiff, TIFFTAG_SAMPLESPERPIXEL, 1 );
477
+
478
+ if (bitsPerSample == 32 ) {
479
+ TIFFSetField (maskTiff, TIFFTAG_BITSPERSAMPLE, bitsPerSample);
480
+ TIFFSetField (maskTiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
481
+ TIFFSetField (maskTiff, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
482
+ } else if (bitsPerSample == 1 ) {
483
+ TIFFSetField (maskTiff, TIFFTAG_BITSPERSAMPLE, 1 );
484
+ TIFFSetField (maskTiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
485
+ TIFFSetField (maskTiff, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
486
+ }
487
+
488
+
475
489
476
490
tsize_t scanLineSize = TIFFScanlineSize (maskTiff);
477
491
if (scanLineSize == 0 ) {
478
- cerr << " Error computing scanline size for 1-bit TIFF ." << endl;
492
+ cerr << " Error computing scanline size." << endl;
479
493
TIFFClose (maskTiff);
480
494
return ;
481
495
}
@@ -484,10 +498,6 @@ void Depthmap::saveTiff(const char *mask_path, vector<float> &values, uint32_t &
484
498
for (uint32_t y = 0 ; y < h; ++y) {
485
499
if (bitsPerSample == 32 ) {
486
500
487
- TIFFSetField (maskTiff, TIFFTAG_BITSPERSAMPLE, 32 );
488
- TIFFSetField (maskTiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
489
- TIFFSetField (maskTiff, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
490
-
491
501
std::vector<float > stripData (scanLineSize / sizeof (float ));
492
502
for (uint32_t x = 0 ; x < w; ++x) {
493
503
uint32_t index = y * w + x;
@@ -502,10 +512,6 @@ void Depthmap::saveTiff(const char *mask_path, vector<float> &values, uint32_t &
502
512
}
503
513
if (bitsPerSample == 1 ) {
504
514
505
- TIFFSetField (maskTiff, TIFFTAG_BITSPERSAMPLE, 1 );
506
- TIFFSetField (maskTiff, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
507
- TIFFSetField (maskTiff, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
508
-
509
515
unsigned char * scanline= new unsigned char [scanLineSize];
510
516
memset (scanline, 0 , scanLineSize);
511
517
@@ -529,12 +535,12 @@ void Depthmap::saveTiff(const char *mask_path, vector<float> &values, uint32_t &
529
535
}
530
536
delete[] scanline;
531
537
}
538
+ TIFFClose (maskTiff);
532
539
533
540
}
534
- TIFFClose (maskTiff);
535
-
536
541
}
537
542
543
+
538
544
void Depthmap::saveDepth (const char *depth_path){
539
545
saveTiff (depth_path, elevation, width, height, 32 );
540
546
}
@@ -693,7 +699,7 @@ void Depthmap::resizeNormals (int factorPowerOfTwo, int step) {
693
699
// depthIntegrateNormals();
694
700
695
701
}
696
- /* void Depthmap::sampleDepth() {
702
+ void Depthmap::sampleDepth () {
697
703
std::vector<float > sampledDepths;
698
704
float sum = 0 .0f ;
699
705
@@ -714,7 +720,7 @@ void Depthmap::resizeNormals (int factorPowerOfTwo, int step) {
714
720
for (int i = 0 ; i < sampledDepths.size (); i++) {
715
721
cout << " Sampled Depth[" << i << " ]: " << sampledDepths[i] << endl;
716
722
}
717
- }*/
723
+ }
718
724
719
725
// take the x=160,14 e y=140
720
726
// the coordinates of the pixel step 0.016 are in the depth map xml Z_num etc.
0 commit comments