# Revision history [back]

I followed both approaches as mentioned in the comments above. First I generate a LineIterator for every single line. Then I get the magnitude values out of the magnitude Mat. After that it is possible to calculate the sum/normalized sum etc. Thanks for the help.

Here is the code:

void computeStrengthOfEdges(Mat magn, vector<Vec4f> lines) {

vector<float> magnitude_of_line;
vector<float> strength;

for (size_t i = 0; i < lines.size(); i++) {

// Generate a LineIterator for every line
LineIterator line_iterator(magn, Point2f(lines[i], lines[i]), Point2f(lines[i], lines[i]), 8, true);

for (int j = 0; j < line_iterator.count; j++, ++line_iterator) {
// Get all values the line hits (8 way-connection) in the magnitude image
float magnitude_value = magn.at<float>(line_iterator.pos());
magnitude_of_line.push_back(magnitude_value);
}
// Calculate the sum all values
float sum = accumulate(magnitude_of_line.begin(), magnitude_of_line.end(), 0.0);
strength.push_back(sum);
magnitude_of_line.clear();
}
}


I followed both approaches as mentioned in the comments above. First I generate a LineIterator for every single line. Then I get the magnitude values out of the magnitude Mat. After that it is possible to calculate the sum/normalized sum etc. Thanks for the help.

Here is the code:

void computeStrengthOfEdges(Mat magn, vector<Vec4f> lines) {

vector<float> magnitude_of_line;
vector<float> strength;

for (size_t i = 0; i < lines.size(); i++) {

// Generate a LineIterator for every line
LineIterator line_iterator(magn, Point2f(lines[i], lines[i]), Point2f(lines[i], lines[i]), 8, true);

for (int j = 0; j < line_iterator.count; j++, ++line_iterator) {
// Get all values the line hits (8 way-connection) in the magnitude image
float magnitude_value = magn.at<float>(line_iterator.pos());
magnitude_of_line.push_back(magnitude_value);
}
// Calculate the sum all values
float sum = accumulate(magnitude_of_line.begin(), magnitude_of_line.end(), 0.0);
strength.push_back(sum);
magnitude_of_line.clear();
}
}