1 | initial version |
it's just a clever trick (maybe too clever, if it's hard to understand ...)
i guess, the context here is some dft analysis, which requires complex, float input.
normally, you would have to do:
Mat srcImage = imread("1.jpg", 0); // read the grayscale image. it's still uchar.
Mat realPart;
srcImage.convertTo(realPart, CV_32F); // manual conversion
Mat imPart = Mat::zeros(srcImage.size(), CV_32F);
Mat planes [] = { realPart, imPart };
merge(planes, 2, complexI);
the Mat_<float>(img)
constructor does an internal, automatic conversion to float (it obviously cannot hold any other data type). it's a shortcut, saving some lines of code, simply.
2 | No.2 Revision |
it's just a clever trick (maybe too clever, if it's hard to understand ...)
i guess, the context here is some dft analysis, which requires complex, float input.
normally, you would have to do:
Mat srcImage = imread("1.jpg", 0); // read the grayscale image. it's still uchar.
Mat realPart;
srcImage.convertTo(realPart, CV_32F); // manual conversion
Mat imPart = Mat::zeros(srcImage.size(), CV_32F);
Mat planes [] = { realPart, imPart };
merge(planes, 2, complexI);
the Mat_<float>(img)
constructor does an internal, automatic conversion to float (it (it's a template object, it's type is determined at compile time, so it obviously cannot hold any other data type). it's a shortcut, saving some lines of code, simply.
3 | No.3 Revision |
it's just a clever trick (maybe too clever, if it's hard to understand ...)
i guess, the context here is some dft analysis, which requires complex, float input.
normally, you would have to do:
Mat srcImage = imread("1.jpg", 0); // read the grayscale image. it's still uchar.
Mat realPart;
srcImage.convertTo(realPart, CV_32F); // manual conversion
Mat imPart = Mat::zeros(srcImage.size(), CV_32F);
Mat planes [] = { realPart, imPart };
merge(planes, 2, complexI);
the Mat_<float>(img)
constructor does an internal, automatic conversion to float (it's a template object, it's type is determined at compile time, so it obviously cannot hold any other data type). it's a shortcut, saving some lines of code, simply.
those template Mat's also have some other, interesting poroperties:
since the type is already handled in the constructor, you no more need at<type>
to access the elements, but can use a straightforward m(2,2)
then, it has an overloaded comma operator, so you can fill it like:
Mat_<float> T(3,3); T << .2, .2, .4, .1, .2, .1, .2, .1, .3;
(which is quite useful for setting up transformation Matrices, or filter kernels)
4 | No.4 Revision |
it's just a clever trick (maybe too clever, if it's hard to understand ...)
i guess, the context here is some dft analysis, which requires complex, float input.
normally, you would have to do:
Mat srcImage = imread("1.jpg", 0); // read the grayscale image. it's still uchar.
Mat realPart;
srcImage.convertTo(realPart, CV_32F); // manual conversion
Mat imPart = Mat::zeros(srcImage.size(), CV_32F);
Mat planes [] = { realPart, imPart };
merge(planes, 2, complexI);
the Mat_<float>(img)
constructor does an internal, automatic conversion to float (it's a template object, it's type is determined at compile time, so it obviously cannot hold any other data type). it's a shortcut, saving some lines of code, simply.
those template Mat's also have some other, interesting poroperties:
since the type is already handled in the constructor, you no more need at<type>
to access the elements, but can use a straightforward m(2,2)
then, it has an overloaded comma operator, so you can fill it like:
Mat_<float> T(3,3);
T << .2, .2, .4,
(which is quite useful for setting up transformation Matrices, or filter kernels)
5 | No.5 Revision |
it's just a clever trick (maybe too clever, if it's hard to understand ...)
i guess, the context here is some dft analysis, which requires complex, float input.
normally, you would have to do:
Mat srcImage = imread("1.jpg", 0); // read the grayscale image. it's still uchar.
Mat realPart;
srcImage.convertTo(realPart, CV_32F); // manual conversion
Mat imPart = Mat::zeros(srcImage.size(), CV_32F);
Mat planes [] = { realPart, imPart };
merge(planes, 2, complexI);
the Mat_<float>(img)
constructor does an internal, automatic conversion to float (it's a template object, it's type is determined at compile time, so it obviously cannot hold any other data type). it's a shortcut, saving some lines of code, simply.
those template Mat's also have some other, interesting poroperties:
since the type is already handled in the constructor, you no more need at<type>
to access the elements, but can use a straightforward m(2,2)
then, it has an overloaded comma operator, so you can fill it like:
Mat_<float> T(3,3);
T << .2, .2, .4,
.1, .2, .1,
.2, .1, .3;
(which is quite useful for setting up transformation Matrices, or filter kernels)
6 | No.6 Revision |
it's just a clever trick (maybe too clever, if it's hard to understand ...)
i guess, the context here is some dft analysis, which requires complex, float input.
normally, you would have to do:
Mat srcImage = imread("1.jpg", 0); // read the grayscale image. it's still uchar.
Mat realPart;
srcImage.convertTo(realPart, CV_32F); // manual conversion
Mat imPart = Mat::zeros(srcImage.size(), CV_32F);
Mat planes [] = { realPart, imPart };
merge(planes, 2, complexI);
the Mat_<float>(img)
constructor does an internal, automatic conversion to float (it's a template object, it's type is determined at compile time, so it obviously cannot hold any other data type). it's a shortcut, saving some lines of code, simply.
those template Mat's also have some other, interesting poroperties:
since the type is already handled in the constructor, you no more need at<type>
to access the elements, but can use a straightforward m(2,2)
then, it has an overloaded comma operator, so you can fill it like:
Mat_<float> T(3,3);
T << .2, .2, .4,
.1, .2, .1,
.2, .1, .3;
(which is quite useful for quickly setting up transformation Matrices, or filter kernels)
7 | No.7 Revision |
it's just a clever trick (maybe too clever, if it's hard to understand ...)
i guess, the context here is some dft analysis, which requires complex, float input.
normally, you would have to do:
Mat srcImage = imread("1.jpg", 0); // read the grayscale image. it's still uchar.
Mat realPart;
srcImage.convertTo(realPart, CV_32F); // manual conversion
Mat imPart = Mat::zeros(srcImage.size(), CV_32F);
Mat planes [] = { realPart, imPart };
merge(planes, 2, complexI);
the Mat_<float>(img)
constructor does an internal, automatic conversion to float (it's a template object, it's type is determined at compile time, so it obviously cannot hold any other data type). it's a shortcut, saving some lines of code, simply.
those template Mat's Mat_
's also have some other, interesting poroperties:properties:
since the type is already handled in the constructor, you no more need at<type>
to access the elements, but can use a straightforward m(2,2)
then, it has an overloaded comma operator, so you can fill it like:
Mat_<float> T(3,3);
T << .2, .2, .4,
.1, .2, .1,
.2, .1, .3;
(which is quite useful for quickly setting up transformation Matrices, or filter kernels)