Commit 9f489bb3a996315c4dd55998fa146a420b86e1fa

Authored by heziqi
1 parent bfe9c6db

Added load_mask and feature_matrix in envi class

Showing 1 changed file with 5 additions and 11 deletions   Show diff stats
envi/envi.h
... ... @@ -587,29 +587,23 @@ public:
587 587 }
588 588 return false;
589 589 }
590   - /*
  590 +
591 591 //load mask from maskfile and save it into memory
592 592 bool load_mask(unsigned char * mask, std::string maskname){
593 593 //open the mask file
594   - cimg_library::CImg<unsigned char> mask_image(maskname.c_str(),true);
  594 + cimg_library::CImg<unsigned char> mask_image(maskname.c_str());
595 595 //save mask file into memory
596   - for (unsigned i = 0; i < header.lines * header.samples; i++)
597   - mask[i] = mask_image.at(i); //how to copy value from cimg class?
  596 + memcpy(mask, mask_image.data(), mask_image.size());
598 597 //close mask file
599 598 mask_image.clear();
600 599 return true;
601   - }*/
  600 + }
602 601  
603 602 //p:start positon; N: number of pixels saved in X;
604   - bool feature_matrix(void * X, std::string maskname, unsigned char * mask, unsigned start, unsigned N)
  603 + bool feature_matrix(void * X, unsigned char * mask, unsigned start, unsigned N)
605 604 {
606   - cimg_library::CImg<unsigned char> mask_image(maskname.c_str());
607   - //save mask file into memory
608   - mask = mask_image.data();
609 605 //save pixels in X as floating numbers
610 606 float * p = (float *)malloc(header.bands * sizeof(float));
611   -
612   - //use mask to save valid pixel in X
613 607 unsigned bandnum = header.samples * header.lines; //calculate pixel numbers in a band
614 608 unsigned count = 0; //for counting use
615 609 unsigned j = 0; //memory the pointer location in X
... ...