Created
January 26, 2016 16:05
-
-
Save silgon/34271b10b874d9a56585 to your computer and use it in GitHub Desktop.
Eigen Find Peaks C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Eigen::ArrayXXb findPeaks(Eigen::ArrayXXd &M, unsigned int &footprint_size){ | |
Eigen::ArrayXXb result = Eigen::ArrayXXb::Zero(M.rows(), M.cols()); | |
bool tmp_max; | |
bool quit_for=false; | |
for(int i = footprint_size; i<M.rows()-footprint_size; ++i){ | |
for(int j = footprint_size; j<M.cols()-footprint_size; ++j){ | |
tmp_max=true; | |
for(int ii=i-footprint_size; ii<i+footprint_size;++ii){ | |
for(int jj=j-footprint_size; jj<j+footprint_size;++jj){ | |
if(ii==i && jj==j) | |
continue; | |
if(M(i,j)<M(ii,jj)){ | |
tmp_max=false; | |
quit_for=true; | |
break; | |
} | |
} | |
if(quit_for){ | |
quit_for=false; | |
break; | |
} | |
} | |
if(tmp_max) | |
result(i,j)=true; | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment