0
I have a project where there is a need to analyze the intensity of the pixels of a certain column or row, that is, my function will be Intensity(cv::Mat m, int ref, Std::string "lico") with a vector-type sadide with the data of the desired column. I’m new to opencv and c++. I’ve been using the following code:
.hpp
class fooTools
{
public:
static std::vector<int> intensity(cv::Mat src, int ref, std::string lico);
};
.cpp
int footools::intensity(cv::Mat src, int ref, std::string lico)
{
//condicional para linha ou coluna
if (lico == "linha") {
for (int col = 0; col < (src.cols); col++)
{
std::cout << src.at<uchar>(ref,col);
}
}
else if (lico == "coluna") {
for (int row = 0; row < (src.rows); row++)
{
std::cout << src.at<uchar>(row, ref);
}
}
return intensity;
}
main
int main() {
//load img
std::string path = "C:/foo/";
std::string name = "foo.bmp";
cv::Mat src = cv::imread(path + name, cv::IMREAD_GRAYSCALE);
fooTools::intensity(src, 44, "linha");
}
I haven’t had a way out, and I’ve tried a lot, someone can help me have an idea for this situation.
friend, format your code that you posted, that I even tried to format, but it’s hard to understand
– FourZeroFive
I believe it has improved, the intention is to pass the idea, I have not been able to implement this idea, still, obg by the attention!
– Hyury
What would be the ref variable?
– FourZeroFive
ref is the row or column that I want to access the pixels, for example intesity(cv:Mat m, 185, "line"); therefore, I would access all pixels of line 185 of the image m. In this case, I would switch to Intensity(cv:Mat m, 185,"column"); I would access all pixels of column 185.
– Hyury