48 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
56 for (
int i=2; i<nrhs; i+=2) {
57 string key(rhs[i].toString());
58 if (key ==
"JpegQuality") {
62 else if (key ==
"JpegProgressive") {
64 params.
push_back(rhs[i+1].toBool() ? 1 : 0);
66 else if (key ==
"JpegOptimize") {
68 params.
push_back(rhs[i+1].toBool() ? 1 : 0);
70 else if (key ==
"JpegResetInterval") {
74 else if (key ==
"JpegLumaQuality") {
78 else if (key ==
"JpegChromaQuality") {
82 else if (key ==
"PngCompression") {
86 else if (key ==
"PngStrategy") {
90 else if (key ==
"PngBilevel") {
92 params.
push_back(rhs[i+1].toBool() ? 1 : 0);
94 else if (key ==
"PxmBinary") {
96 params.
push_back(rhs[i+1].toBool() ? 1 : 0);
98 else if (key ==
"ExrType") {
102 else if (key ==
"WebpQuality") {
106 else if (key ==
"PamTupleType") {
110 else if (key ==
"Params") {
113 if ((pvec.
size()%2) != 0)
115 "Params vectors must contain pairs of id/value.");
118 else if (key ==
"FlipChannels")
119 flip = rhs[i+1].toBool();
122 "Unrecognized option %s", key.
c_str());
126 string filename(rhs[0].toString());
128 if (rhs[1].isNumeric()) {
136 success =
imwrite(filename, img, params);
138 else if (rhs[1].isCell()) {
144 Mat img(it->toMat(it->isFloat() ?
CV_32F :
146 if (
flip && (img.channels() == 3 || img.channels() == 4)) {
148 cvtColor(img, img, (img.channels()==3 ?
153 success =
imwrite(filename, img_vec, params);
const ConstMap< string, int > PngStrategyMap
PNG encoding strategies for option processing.
bool imwrite(const String &filename, InputArray img, const std::vector< int > ¶ms=std::vector< int >())
void cvtColor(InputArray src, OutputArray dst, int code, int dstCn=0)
IMWRITE_PNG_STRATEGY_FILTERED
const ConstMap< string, int > PamFormatMap
PAM tuple types for option processing.
IMWRITE_PNG_STRATEGY_FIXED
IMWRITE_PAM_FORMAT_RGB_ALPHA
struct mxArray_tag mxArray
Forward declaration for mxArray.
IMWRITE_JPEG_RST_INTERVAL
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY
IMWRITE_JPEG_LUMA_QUALITY
IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA
IMWRITE_PAM_FORMAT_GRAYSCALE
IMWRITE_PNG_STRATEGY_DEFAULT
Global constant definitions.
IMWRITE_PAM_FORMAT_BLACKANDWHITE
void flip(InputArray src, OutputArray dst, int flipCode)
std::map wrapper with one-line initialization and lookup method.
const ConstMap< string, int > ExrTypeMap
EXR storage types for option processing.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
IMWRITE_JPEG_CHROMA_QUALITY