@@ -223,8 +223,7 @@ 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 !=
227
- 1 ) {
226
+ if (samplesPerPixel !=1 ) {
228
227
cerr << " Not a depthmap, expecting just 1 channel" << endl;
229
228
TIFFClose (inTiff);
230
229
return false ;
@@ -425,7 +424,6 @@ bool Depthmap::loadMask(const char *tifPath){
425
424
return false ;
426
425
}
427
426
428
-
429
427
return true ;
430
428
431
429
}
@@ -471,8 +469,8 @@ void Depthmap::saveTiff(const char *mask_path, vector<float> &values, uint32_t &
471
469
return ;
472
470
}
473
471
474
- TIFFSetField (maskTiff, TIFFTAG_IMAGEWIDTH, & w);
475
- TIFFSetField (maskTiff, TIFFTAG_IMAGELENGTH, & h);
472
+ TIFFSetField (maskTiff, TIFFTAG_IMAGEWIDTH, w);
473
+ TIFFSetField (maskTiff, TIFFTAG_IMAGELENGTH, h);
476
474
TIFFSetField (maskTiff, TIFFTAG_SAMPLESPERPIXEL, 1 );
477
475
478
476
if (bitsPerSample == 32 ) {
@@ -513,31 +511,31 @@ void Depthmap::saveTiff(const char *mask_path, vector<float> &values, uint32_t &
513
511
if (bitsPerSample == 1 ) {
514
512
515
513
unsigned char * scanline= new unsigned char [scanLineSize];
516
- memset (scanline, 0 , scanLineSize);
517
514
518
- for ( uint32_t row = 0 ; row < h; ++row) {
519
- // write the current strip
520
- for (uint32_t col = 0 ; col < w; ++col) {
521
- uint32_t bytePos = col >> 3 ;
522
- uint32_t bitPos = 7 - (col & 7 );
523
- uint32_t dstIndex = row * w + col;
515
+ memset (scanline, 0 , scanLineSize);
516
+ // write the current strip
517
+ for (uint32_t col = 0 ; col < w; ++col) {
518
+ uint32_t bytePos = col >> 3 ;
519
+ uint32_t bitPos = 7 - (col & 7 );
520
+ uint32_t dstIndex = y * w + col;
524
521
525
- // values[dstIndex] = (scanline[bytePos] & (1 << bitPos)) != 0;
526
- if (values[dstIndex]){
527
- scanline[bytePos] |= (1 << bitPos);
528
- }
529
- }
530
- if (TIFFWriteScanline (maskTiff, scanline, y, 0 ) < 0 ) {
531
- cerr << " Error writing strip " << row << endl;
532
- TIFFClose (maskTiff);
533
- return ;
522
+ // values[dstIndex] = (scanline[bytePos] & (1 << bitPos)) != 0;
523
+ if (values[dstIndex] != 0 .0f ){
524
+ scanline[bytePos] |= (1 << bitPos);
534
525
}
535
526
}
527
+ if (TIFFWriteScanline (maskTiff, scanline, y, 0 ) < 0 ) {
528
+ cerr << " Error writing strip " << y << endl;
529
+ TIFFClose (maskTiff);
530
+ return ;
531
+ }
532
+
536
533
delete[] scanline;
537
534
}
538
- TIFFClose (maskTiff);
535
+
539
536
540
537
}
538
+ TIFFClose (maskTiff);
541
539
}
542
540
543
541
0 commit comments