Commit f4c5d71b85f75cc73ac00ad506ec997794f75e78

Authored by David Mayerich
1 parent ee4dea28

started working with masks

envi/bil.h
... ... @@ -669,7 +669,7 @@ public:
669 669 }
670 670  
671 671 //create mask file
672   - bool mask(unsigned char* p, double mask_band, double threshold){
  672 + bool build_mask(double mask_band, double threshold, unsigned char* p){
673 673  
674 674 T* temp = (T*)malloc(R[0] * R[1] * sizeof(T)); //allocate memory for the certain band
675 675 band(temp, mask_band);
... ...
envi/binary.h
... ... @@ -20,6 +20,7 @@ protected:
20 20  
21 21 unsigned int R[D]; //resolution
22 22 unsigned int header; //header size (in bytes)
  23 + unsigned char* mask; //pointer to a character array: 0 = background, 1 = foreground (or valid data)
23 24  
24 25  
25 26  
... ... @@ -28,7 +29,7 @@ protected:
28 29 void init(){
29 30 memset(R, 0, sizeof(unsigned int) * D); //initialize the resolution to zero
30 31 header = 0; //initialize the header size to zero
31   -
  32 + mask = NULL;
32 33 }
33 34  
34 35 //returns the file size
... ...
envi/bip.h
... ... @@ -760,7 +760,7 @@ public:
760 760 }
761 761  
762 762 //create mask file
763   - bool mask(unsigned char* p, double mask_band, double threshold){
  763 + bool build_mask(double mask_band, double threshold, unsigned char* p){
764 764  
765 765 T* temp = (T*)malloc(R[0] * R[1] * sizeof(T)); //allocate memory for the certain band
766 766 band(temp, mask_band);
... ...
envi/bsq.h
... ... @@ -596,7 +596,7 @@ public:
596 596 }
597 597  
598 598 //create mask file
599   - bool mask(unsigned char* p, double mask_band, double threshold){
  599 + bool build_mask(double mask_band, double threshold, unsigned char* p = NULL){
600 600  
601 601 T* temp = (T*)malloc(R[0] * R[1] * sizeof(T)); //allocate memory for the certain band
602 602 band(temp, mask_band);
... ...
envi/envi.h
... ... @@ -273,32 +273,32 @@ public:
273 273  
274 274 }
275 275  
276   - //get the mask
277   - bool mask(unsigned char* p, double mask_band, double threshold) {
  276 + //create a mask based on a band and threshold, save it to p (if p is not NULL)
  277 + bool build_mask(double mask_band, double threshold, unsigned char* p = NULL) {
278 278  
279 279 if(header.interleave == envi_header::BSQ){ //if the infile is bsq file
280 280 if(header.data_type ==envi_header::float32)
281   - return ((bsq<float>*)file)->mask(p, mask_band, threshold);
  281 + return ((bsq<float>*)file)->build_mask(mask_band, threshold, p);
282 282 else if(header.data_type == envi_header::float64)
283   - return ((bsq<double>*)file)->mask(p, mask_band, threshold);
  283 + return ((bsq<double>*)file)->build_mask(mask_band, threshold, p);
284 284 else
285 285 std::cout<<"ERROR: unidentified data type"<<std::endl;
286 286 }
287 287  
288 288 else if(header.interleave == envi_header::BIL){ //if the infile is bil file
289 289 if(header.data_type ==envi_header::float32)
290   - return ((bil<float>*)file)->mask(p, mask_band, threshold);
  290 + return ((bil<float>*)file)->build_mask(mask_band, threshold, p);
291 291 else if(header.data_type == envi_header::float64)
292   - return ((bil<double>*)file)->mask(p, mask_band, threshold);
  292 + return ((bil<double>*)file)->build_mask(mask_band, threshold, p);
293 293 else
294 294 std::cout<<"ERROR: unidentified data type"<<std::endl;
295 295 }
296 296  
297 297 else if(header.interleave == envi_header::BIP){ //if the infile is bip file
298 298 if(header.data_type ==envi_header::float32)
299   - return ((bip<float>*)file)->mask(p, mask_band, threshold);
  299 + return ((bip<float>*)file)->build_mask(mask_band, threshold, p);
300 300 else if(header.data_type == envi_header::float64)
301   - return ((bip<double>*)file)->mask(p, mask_band, threshold);
  301 + return ((bip<double>*)file)->build_mask(mask_band, threshold, p);
302 302 else
303 303 std::cout<<"ERROR: unidentified data type"<<std::endl;
304 304 }
... ...