From f4c5d71b85f75cc73ac00ad506ec997794f75e78 Mon Sep 17 00:00:00 2001 From: David Mayerich Date: Mon, 20 Oct 2014 17:43:14 -0500 Subject: [PATCH] started working with masks --- envi/bil.h | 2 +- envi/binary.h | 3 ++- envi/bip.h | 2 +- envi/bsq.h | 2 +- envi/envi.h | 16 ++++++++-------- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/envi/bil.h b/envi/bil.h index a577252..344e4b9 100644 --- a/envi/bil.h +++ b/envi/bil.h @@ -669,7 +669,7 @@ public: } //create mask file - bool mask(unsigned char* p, double mask_band, double threshold){ + bool build_mask(double mask_band, double threshold, unsigned char* p){ T* temp = (T*)malloc(R[0] * R[1] * sizeof(T)); //allocate memory for the certain band band(temp, mask_band); diff --git a/envi/binary.h b/envi/binary.h index 12c81c2..2011bf3 100644 --- a/envi/binary.h +++ b/envi/binary.h @@ -20,6 +20,7 @@ protected: unsigned int R[D]; //resolution unsigned int header; //header size (in bytes) + unsigned char* mask; //pointer to a character array: 0 = background, 1 = foreground (or valid data) @@ -28,7 +29,7 @@ protected: void init(){ memset(R, 0, sizeof(unsigned int) * D); //initialize the resolution to zero header = 0; //initialize the header size to zero - + mask = NULL; } //returns the file size diff --git a/envi/bip.h b/envi/bip.h index 77f4212..bd75907 100644 --- a/envi/bip.h +++ b/envi/bip.h @@ -760,7 +760,7 @@ public: } //create mask file - bool mask(unsigned char* p, double mask_band, double threshold){ + bool build_mask(double mask_band, double threshold, unsigned char* p){ T* temp = (T*)malloc(R[0] * R[1] * sizeof(T)); //allocate memory for the certain band band(temp, mask_band); diff --git a/envi/bsq.h b/envi/bsq.h index 50c6cda..9a97291 100644 --- a/envi/bsq.h +++ b/envi/bsq.h @@ -596,7 +596,7 @@ public: } //create mask file - bool mask(unsigned char* p, double mask_band, double threshold){ + bool build_mask(double mask_band, double threshold, unsigned char* p = NULL){ T* temp = (T*)malloc(R[0] * R[1] * sizeof(T)); //allocate memory for the certain band band(temp, mask_band); diff --git a/envi/envi.h b/envi/envi.h index 29a23c5..78aeac0 100644 --- a/envi/envi.h +++ b/envi/envi.h @@ -273,32 +273,32 @@ public: } - //get the mask - bool mask(unsigned char* p, double mask_band, double threshold) { + //create a mask based on a band and threshold, save it to p (if p is not NULL) + bool build_mask(double mask_band, double threshold, unsigned char* p = NULL) { if(header.interleave == envi_header::BSQ){ //if the infile is bsq file if(header.data_type ==envi_header::float32) - return ((bsq*)file)->mask(p, mask_band, threshold); + return ((bsq*)file)->build_mask(mask_band, threshold, p); else if(header.data_type == envi_header::float64) - return ((bsq*)file)->mask(p, mask_band, threshold); + return ((bsq*)file)->build_mask(mask_band, threshold, p); else std::cout<<"ERROR: unidentified data type"<*)file)->mask(p, mask_band, threshold); + return ((bil*)file)->build_mask(mask_band, threshold, p); else if(header.data_type == envi_header::float64) - return ((bil*)file)->mask(p, mask_band, threshold); + return ((bil*)file)->build_mask(mask_band, threshold, p); else std::cout<<"ERROR: unidentified data type"<*)file)->mask(p, mask_band, threshold); + return ((bip*)file)->build_mask(mask_band, threshold, p); else if(header.data_type == envi_header::float64) - return ((bip*)file)->mask(p, mask_band, threshold); + return ((bip*)file)->build_mask(mask_band, threshold, p); else std::cout<<"ERROR: unidentified data type"<