"cvtColor source code c++" Code Answer's
You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "cvtColor source code c++" answered properly. Developers are finding an appropriate answer about cvtColor source code c++ related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like cvtColor source code c++. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on cvtColor source code c++.
cvtColor source code c++
#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
void RGB2Gray(const cv::Mat& src, cv::Mat& dst)
{
CV_Assert(src.type() == CV_8UC3);
int rows = src.rows, cols = src.cols;
dst.create(src.size(), CV_8UC1);
if (src.isContinuous() && dst.isContinuous())
{
cols = rows * cols;
rows = 1;
}
for (int row = 0; row < rows; row++)
{
const uchar* src_ptr = src.ptr<uchar>(row);
uchar* dst_ptr = dst.ptr<uchar>(row);
for (int col = 0; col < cols; col++)
{
dst_ptr[col] = (uchar)(src_ptr[0] * 0.114f + src_ptr[1] * 0.587f + src_ptr[2] * 0.299f);
src_ptr += 3;
}
}
}
int main()
{
cv::Mat SrcImg = cv::imread("../data/lena.jpg");
cv::Mat DstImg;
RGB2Gray(SrcImg, DstImg);
imshow("gray", DstImg);
cv::waitKey();
return 0;
}
Source: answers.opencv.org
All those coders who are working on the C++ based application and are stuck on cvtColor source code c++ can get a collection of related answers to their query. Programmers need to enter their query on cvtColor source code c++ related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about cvtColor source code c++ for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of cvtColor source code c++ while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "cvtColor source code c++". Visit this developer's friendly online web community, CodeProZone, and get your queries like cvtColor source code c++ resolved professionally and stay updated to the latest C++ updates.