Authored by heziqi
1 parent ed158acd

### added solve correlation coefficient matrix

Showing 4 changed files with 176 additions and 7 deletions
envi/bil.h

 ... ... @@ -754,6 +754,28 @@ public: 754 754 return true; 755 755 } 756 756 757 + //calculate the average number of every band 758 + bool avg_band(T*p){ 759 + unsigned long long XZ = R[0] * R[2]; 760 + unsigned long long XY = R[0] * R[1]; 761 + T* temp = (T*)malloc(sizeof(T) * XZ); 762 + for (unsigned j = 0; j < R[2]; j++){ 763 + p[j] = 0; 764 + } 765 + for (unsigned k = 0; k < R[1]; k++){ 766 + getY(temp, k); 767 + for (unsigned j = 0; j < R[2]; j++){ 768 + unsigned jx = j * R[0]; 769 + for (unsigned i = 0; i < R[0]; i++){ 770 + p[j] += temp[jx + i] / (T)XY; 771 + } 772 + } 773 + } 774 + free(temp); 775 + return true; 776 + } 777 + 778 + 757 779 //close the file 758 780 bool close(){ 759 781 file.close(); ... ...
envi/bip.h

 ... ... @@ -840,6 +840,26 @@ public: 840 840 return true; 841 841 } 842 842 843 + //calculate the average number of every band 844 + bool avg_band(T*p){ 845 + unsigned long long XY = R[0] * R[1]; 846 + T* temp = (T*)malloc(sizeof(T) * R[2]); 847 + //Iinitialize 848 + for (unsigned j = 0; j < R[2]; j++){ 849 + p[j] = 0; 850 + } 851 + 852 + for (unsigned i = 0; i < XY; i++){ 853 + pixel(temp, i); 854 + for (unsigned j = 0; j < R[2]; j++){ 855 + p[j] += temp[j] / (T)XY; 856 + } 857 + } 858 + free(temp); 859 + return true; 860 + } 861 + 862 + 843 863 //close the file 844 864 bool close(){ 845 865 file.close(); ... ...
envi/bsq.h

 ... ... @@ -683,6 +683,21 @@ public: 683 683 return true; 684 684 } 685 685 686 + //calculate the average number of every band 687 + bool avg_band(T*p){ 688 + unsigned long long XY = R[0] * R[1]; 689 + T* temp = (T*)malloc(sizeof(T) * XY); 690 + for (unsigned i = 0; i < R[2]; i++){ 691 + p[i] = 0; 692 + band_index(temp, i); 693 + for (unsigned j = 0; j < XY; j++){ 694 + p[i] += temp[j] / (T)XY; 695 + } 696 + } 697 + free(temp); 698 + return true; 699 + } 700 + 686 701 //close the file 687 702 bool close(){ 688 703 file.close(); ... ...
envi/envi.h