Wednesday, 12 March 2014

#3a. Create your own image Matrix


#include
#include
#include
using namespace std;
using namespace cv;
int main()
{
 Mat img=Mat(5,5,CV_32FC3,Scalar(300,400,500));
 namedWindow("Image");
 imshow("Image",img);
 while(char(waitKey(0))!='q'){}
 return 0;
}

Expanation:
'Mat' is basically a structure definition in OpenCV.

Mat img=Mat(5,5,CV_32FC3,Scalar(300,400,500));

So, now, this command creates a 5x5 matrix image.

CV_32FC3 : tells that each pixel has 3 Channel(e.g. R,G,B) and each channel is of 32 bits(e.g 010100...) and each of 32 bits represents a Floating Character.

32FC: 32bit Floating Character
8UC: 8bit Unsigned Character etc.

__FC1: 1 channel
__FC 5: 5 channels etc.

Look here for more explanation.

No comments:

Post a Comment