ocvMxArrayToImage_{DataType}
Convert column major mxArray
to
row major cv::Mat
for image
C++ Syntax
#include "opencvmex.hpp"
void ocvMxArrayToImage_double(const
mxArray *in, cv::Mat &out);
void ocvMxArrayToImage_single(const
mxArray *in, cv::Mat &out);
void ocvMxArrayToImage_uint8(const
mxArray *in, cv::Mat &out);
void ocvMxArrayToImage_uint16(const
mxArray *in, cv::Mat &out);
void ocvMxArrayToImage_uint32(const
mxArray *in, cv::Mat &out);
void ocvMxArrayToImage_int8(const
mxArray *in, cv::Mat &out);
void ocvMxArrayToImage_int16(const
mxArray *in, cv::Mat &out);
void ocvMxArrayToImage_int32(const
mxArray *in, cv::Mat &out);
void ocvMxArrayToImage_bool(const
mxArray *in, cv::Mat &out);
cv::Ptr<cv::Mat>
ocvMxArrayToImage_double(const mxArray *in, const bool copyData =
true);
cv::Ptr<cv::Mat> ocvMxArrayToImage_single(const
mxArray *in, const bool copyData = true);
cv::Ptr<cv::Mat>
ocvMxArrayToImage_uint8(const mxArray *in, const bool copyData = true);
cv::Ptr<cv::Mat> ocvMxArrayToImage_uint16(const mxArray
*in, const bool copyData = true);
cv::Ptr<cv::Mat>
ocvMxArrayToImage_uint32(const mxArray *in, const bool copyData =
true);
cv::Ptr<cv::Mat> ocvMxArrayToImage_int8(const
mxArray *in, const bool copyData = true);
cv::Ptr<cv::Mat>
ocvMxArrayToImage_int16(const mxArray *in, const bool copyData = true);
cv::Ptr<cv::Mat> ocvMxArrayToImage_int32(const mxArray
*in, const bool copyData = true);
cv::Ptr<cv::Mat>
ocvMxArrayToImage_bool(const mxArray *in, const bool copyData = true);
Arguments
in
Pointer to a MATLAB® struct,
mxArray
, having column major data that represents a 2-D or 3-D image. Supported data types:real_T
(double
)uint8_T
(uint8
)uint32_T
(uint32
)int16_T
(int16
)real32_T
(single
)uint16_T
(uint16
)int8_T
(int8
)int32_T
(int32
)copyData
Boolean flag to copy data from
mxArray
to theMat
object.true
(default) — The function transposes and interleaves (for RGB images) column majormxArray
data into a row majorcv::Mat
object.false
— No data copies from themxArray
to theMat
object. The function creates a newMat
wrapper and uses it to point to themxArray
data. Because OpenCV is row-based and MATLAB is column-based, the columns of themxArray
become the rows of theMat
object. If the image is 2-D, thencopyData
isfalse
.
out
Reference to OpenCV
cv::Mat
with row major data.
Returns
The functions that set copyData
return
an OpenCV smart pointer (cv::Ptr
) to a cv::Mat
object.
Description
The ocvMxArrayToImage_{DataType}
function
applies to two C++ implementations. One set returns void
and
the other set returns an OpenCV smart pointer. The functions that
return void
reallocate memory for the cv::Mat
if
needed.
The ocvMxArrayToImage_{DataType}
transposes
and interleaves column major mxArray
data into row major cv::Mat
.
The ocvMxArrayToImage_{DataType}
function supports
2-D and 3-D images.
These functions are not a generic matrix conversion routine. For 3-D images, they take into account that the OpenCV format uses BGR ordering and manipulate the data to comply with that formatting.
See Also
mxArray
, ocvMxArrayToMat_{DataType}
, ocvMxArrayFromImage_{DataType}
, C Matrix API, Write C Functions Callable from MATLAB (MEX Files)