Commit 1a55a328300dc8bae2d0576f3a8b8bb16e16c84c

Authored by David Mayerich
1 parent 72bc805b

Added comments for apply_mask for Brad

Showing 2 changed files with 21 additions and 20 deletions   Show diff stats
@@ -814,15 +814,16 @@ public: @@ -814,15 +814,16 @@ public:
814 814
815 std::ofstream target(outfile.c_str(), std::ios::binary); 815 std::ofstream target(outfile.c_str(), std::ios::binary);
816 816
817 - unsigned XZ = R[0] * R[2]; //calculate number of a band  
818 - unsigned L = XZ * sizeof(T); 817 + //I THINK THIS IS WRONG
  818 + unsigned XZ = R[0] * R[2]; //calculate the number of values in a page on disk
  819 + unsigned L = XZ * sizeof(T); //calculate the size of the page (in bytes)
819 820
820 - T * temp = (T*)malloc(L); 821 + T * temp = (T*)malloc(L); //allocate memory for a temporary page
821 822
822 - for (unsigned i = 0; i < R[1]; i++) 823 + for (unsigned i = 0; i < R[1]; i++) //for each value in R[1] (BIP should be X)
823 { 824 {
824 - getY(temp, i);  
825 - for ( unsigned j = 0; j < R[2]; j++) 825 + getY(temp, i); //retrieve an ZX slice, stored in temp
  826 + for ( unsigned j = 0; j < R[2]; j++) //for each R[2] (BIP should be Y)
826 { 827 {
827 for (unsigned k = 0; k < R[0]; k++) 828 for (unsigned k = 0; k < R[0]; k++)
828 { 829 {
@@ -905,29 +905,29 @@ public: @@ -905,29 +905,29 @@ public:
905 905
906 std::ofstream target(outfile.c_str(), std::ios::binary); 906 std::ofstream target(outfile.c_str(), std::ios::binary);
907 907
908 - unsigned ZX = R[2] * R[0]; //calculate number of a band  
909 - unsigned L = ZX * sizeof(T); 908 + unsigned ZX = R[2] * R[0]; //calculate the number of values in a page (XZ in BIP)
  909 + unsigned L = ZX * sizeof(T); //calculate the number of bytes in a page
910 910
911 - T * temp = (T*)malloc(L); 911 + T * temp = (T*)malloc(L); //allocate space for that page
912 912
913 - for (unsigned i = 0; i < R[1]; i++) 913 + for (unsigned i = 0; i < R[1]; i++) //for each page (Y in BIP)
914 { 914 {
915 - getY(temp, i);  
916 - for ( unsigned j = 0; j < R[0]; j++) 915 + getY(temp, i); //load that page (it's pointed to by temp)
  916 + for ( unsigned j = 0; j < R[0]; j++) //for each X value
917 { 917 {
918 - for (unsigned k = 0; k < R[2]; k++) 918 + for (unsigned k = 0; k < R[2]; k++) //for each B value (band)
919 { 919 {
920 - if(p[i * R[0] + k] == 0)  
921 - temp[j * R[2] + k] = 0;  
922 - else 920 + if(p[i * R[0] + k] == 0) //if the mask value is zero
  921 + temp[j * R[2] + k] = 0; //set the pixel value to zero
  922 + else //otherwise just continue
923 continue; 923 continue;
924 } 924 }
925 } 925 }
926 - target.write(reinterpret_cast<const char*>(temp), L); //write a band data into target file 926 + target.write(reinterpret_cast<const char*>(temp), L); //write the edited band data into target file
927 } 927 }
928 - target.close();  
929 - free(temp);  
930 - return true; 928 + target.close(); //close the target file
  929 + free(temp); //free allocated memory
  930 + return true; //return true
931 } 931 }
932 932
933 /// Calculate the mean band value (average along B) at each pixel location. 933 /// Calculate the mean band value (average along B) at each pixel location.