Example:
----------------------------------
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "iostream"
using namespace cv;
using namespace std;
int main( )
{
Mat src1;
src1 = imread("lena.jpg", CV_LOAD_IMAGE_COLOR);
namedWindow( "Original image", CV_WINDOW_AUTOSIZE );
imshow( "Original image", src1 );
Mat gray;
cvtColor(src1, gray, CV_BGR2GRAY);
namedWindow( "Result window", CV_WINDOW_AUTOSIZE );
imshow( "Result window", gray );
// Use the copy constructor
Mat src2(src1);
namedWindow( "window2", CV_WINDOW_AUTOSIZE );
imshow( "window2", src2 );
// Assignment operator
Mat src3;
src3 = src2;
namedWindow( "window3", CV_WINDOW_AUTOSIZE );
imshow( "window3", src3 );
// Selecting a region of interest using a rectangle
Mat src4 (src1, Rect(50, 50, 150, 150) );
namedWindow( "window4", CV_WINDOW_AUTOSIZE );
imshow( "window4", src4 );
// Another way of doing same
Rect r(10, 10, 100, 100);
Mat src41 = src1(r);
namedWindow( "window4.1", CV_WINDOW_AUTOSIZE );
imshow( "window4.1", src41 );
// clone() function
Mat src5 = src1.clone();
namedWindow( "window5", CV_WINDOW_AUTOSIZE );
imshow( "window5", src5 );
// copyTo() function
Mat src6;
src1.copyTo(src6);
namedWindow( "window6", CV_WINDOW_AUTOSIZE );
imshow( "window6", src6 );
// Using Range()
Mat P;
src6.rowRange(1,2).copyTo(P);
cout << "P = " << endl << " " << P(Range::all(),Range::all()) << endl << endl ;
// Range::all() - “the whole sequence”
// Range(a,b) - "[start , end]
// Copy {row : 0 to 4} and {col : 5 to 9} to matrix Q
Mat Q; Q = gray(Range(0,5),Range(5,10));
cout<< Q << endl << endl;
//make a black image from an existing image
src1 = Scalar(0);
namedWindow( "window7", CV_WINDOW_AUTOSIZE );
imshow( "window7", src1 );
// Create a header for an already existing IplImage pointer
IplImage* img = cvLoadImage("lena.jpg", 1);
Mat mtx(img); // convert IplImage* -> Mat
namedWindow( "window8", CV_WINDOW_AUTOSIZE );
imshow( "window8", mtx );
// Mat() Constructor
Mat M(2,2, CV_8UC3, Scalar(0,0,255));
cout << "M = " << endl << " " << M << endl << endl;
// Use C\C++ arrays and initialize via constructor
// Create a matrix with more than two dimensions
int sz[3] = {4,2,3};
Mat L(3,sz, CV_8UC(1), Scalar::all(0));
// Create() function
Mat N;
N.create(4,4, CV_8UC(2));
cout << "N = "<< endl << " " << N << endl << endl;
// initializer: zeros(), ones(), :eyes(). Specify size and data type to use
Mat E = Mat::eye(4, 4, CV_64F);
cout << "E = " << endl << " " << E << endl << endl;
Mat O = Mat::ones(2, 2, CV_32F);
cout << "O = " << endl << " " << O << endl << endl;
Mat Z = Mat::zeros(3,3, CV_8UC1);
cout << "Z = " << endl << " " << Z << endl << endl;
// For small matrices you may use comma separated initializers:
Mat C = (Mat_<double>(3,3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
cout << "C = " << endl << " " << C << endl << endl;
Mat RowClone = C.row(1).clone();
cout << "RowClone = " << endl << " " << RowClone << endl << endl;
// Fill out a matrix with random values using the randu() function.
// You need to give the lower and upper value for the random values:
Mat R = Mat(3, 2, CV_8UC3);
randu(R, Scalar::all(0), Scalar::all(255));
cout << "R = " << endl << " " << R << endl << endl;
// allocates a 30x40 floating-point matrix
Mat A(30, 40, DataType<float>::type);
Mat B = Mat_<std::complex<double> >(3, 3);
// the statement below will print 6, 2 /*, that is depth == CV_64F, channels == 2 */
cout << B.depth() << ", " << B.channels() << endl;
waitKey(0);
return 0;
}
----------------------------------
good one..really helpful
ReplyDeleteLearn Opencv By Examples: Creating Matrix In Different Ways >>>>> Download Now
Delete>>>>> Download Full
Learn Opencv By Examples: Creating Matrix In Different Ways >>>>> Download LINK
>>>>> Download Now
Learn Opencv By Examples: Creating Matrix In Different Ways >>>>> Download Full
>>>>> Download LINK b3
Very much Helpful....
ReplyDeletecsharp example codes for beginners
ReplyDeletedon't follow this fucking site otherwise you probably forget all about opencv
ReplyDeletePython is a general-purpose interpreted, interactive, object-oriented and high-level programming language. Currently Python is the most popular Language in IT.
ReplyDeletepython training in bangalore
aws training in bangalore
artificial intelligence training in bangalore
data science training in bangalore
machine learning training in bangalore
hadoop training in bangalore
devops training in bangalore
Very useful details provided by you. I hope it would be useful for many of the seekers. Thank you for sharing details here with us.
ReplyDeleteHome tutors are provided by TheTuitionTeacher in Delhi.
Home Tutors in Delhi | Home Tutors Delhi
very informative blog and useful article thank you for sharing with us , keep posting learn more AngularJS Online Training Hyderabad
ReplyDeleteHere is the link of best BSc Cardiac Care Technology Colleges In Bangalore. If you need to get the list of best colleges, just click on the following link.
ReplyDeleteBSc Cardiac Care Technology Colleges In Bangalore
python training in bangalore | python online training
ReplyDeleteartificial intelligence training in bangalore | artificial intelligence online training
data science training in bangalore | data science online training
machine learning training in bangalore | machine learning online training
Python is a general-purpose interpreted, interactive, object-oriented and high-level programming language.
ReplyDeleteslotmandiri888.com
slotmandiri888.com
slotmandiri888.com
ReplyDeletePretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.sap fico training institute in Hyderabad
ReplyDeleteThat is nice article from you , this is informative stuff . Hope more articles from you . I also want to share some information about Pet Vaccination in vizag
Learn Opencv By Examples: Creating Matrix In Different Ways >>>>> Download Now
ReplyDelete>>>>> Download Full
Learn Opencv By Examples: Creating Matrix In Different Ways >>>>> Download LINK
>>>>> Download Now
Learn Opencv By Examples: Creating Matrix In Different Ways >>>>> Download Full
>>>>> Download LINK
ค่ายเกมสล็อตออนไลน์ที่อยู่คู่กับนักเดิมพันมาอย่างยาวนาน slotxo ค่ายสล็อตยอดนิยม มีเกมยอดฮิตให้เลือกเล่นมากมาย เกมสล็อตระดับคุณภาพ เล่นได้ทุกเกม เกมสล็อตลิขสิทธิ์เเท้ ส่งตรงจากต่างประเทศ สมัคร slotxo รับเครดิตฟรีไม่อั้น โปรโมชั่นเพียบ ฝาก-ถอนอัตโนมัติ 24 ชั่วโมง ไม่มีขั้นต่ำ ผู้เล่นสามารถดาวน์โหลด slotxo เล่นผ่านเว็บได้ทันที.
ReplyDeletemardin
ReplyDeleteerzincan
kars
antep
çorum
WWGH8
yurtdışı kargo
ReplyDeleteresimli magnet
instagram takipçi satın al
yurtdışı kargo
sms onay
dijital kartvizit
dijital kartvizit
https://nobetci-eczane.org/
SMB
salt likit
ReplyDeletesalt likit
dr mood likit
big boss likit
dl likit
dark likit
P048D
شركة تسليك مجاري بالدمام RgwoqiR68M
ReplyDelete