Tutorial by Examples

Given a non-empty cv::Mat img of some size, we can fill it to a solid color in several ways: img = cv::Scalar(blueVal,greenVal,redVal); or, the more general, mask supporting, cv::Mat::setTo(): img.setTo(cv::Scalar(blueVal,greenVal,redVal)); If you are using the older OpenCV C API with IplIma...
In OpenCV, images can be RGB/BGR, HSV, grayscaled, black-white and so on. It is crucial to know the data type before dealing with images. The image data types are mainly CV_8UC3 (Matrix of uchar with 3 channels) and CV_8U (Matrix of uchar with 1 channel), however, the conversion to other types such...
#include opencv2/opencv.hpp> #include vector> using namespace std; using namespace cv; int main() { Mat3b img = imread("test.jpg"); imshow("Original", img); // Cluster int K = 8; int n = img.rows * img.cols; Mat data = img.reshape(1, n); data.convertTo(data, CV_32F); ...

Page 1 of 1