Created
October 30, 2016 22:16
-
-
Save Seanmatthews/704eec1b62c49271f1e84c8d5e4bf1e8 to your computer and use it in GitHub Desktop.
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
cv::Mat createLOGKernel1D(int ksize, float sigma) | |
{ | |
using namespace cv; | |
float std2 = sigma * sigma; | |
std::vector<float> seq(ksize); | |
std::iota(begin(seq), end(seq), -(ksize-1)/2); | |
Mat_<float> kSeq(1, ksize, seq.data()); | |
Mat XX; | |
multiply(kSeq, kSeq, XX); | |
Mat H = -(XX / (2.*std2)); | |
exp(H, H); | |
double minVal, maxVal; | |
minMaxIdx(H, &minVal, &maxVal); | |
Mat mask = H < std::numeric_limits<float>::epsilon()*maxVal; | |
H.setTo(0, mask); | |
float sumh = sum(H)[0]; | |
if (sumh != 0) H /= sumh; | |
Mat H1; | |
multiply(H, (XX - 2.*std2)/(std2 * std2), H1); | |
H = H1 - sum(H1)[0] / ksize; | |
return H; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment