www.pudn.com > vcmatlab20060426WaterMark.zip > im2double.cpp
//
// MATLAB Compiler: 2.2
// Date: Tue May 31 21:57:06 2005
// Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"
// "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"
// "array_indexing:on" "-O" "optimize_conditionals:on" "-B" "sglcpp" "-p" "-W"
// "main" "-L" "Cpp" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg"
// "libmwsglm.mlib" "-l" "-p" "-W" "main" "-L" "Cpp" "-t" "-T" "link:exe" "-h"
// "libmmfile.mlib" "-h" "C_imwrite"
//
#include "im2double.hpp"
#include "libmatlbm.hpp"
static mxChar _array1_[136] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
'l', 'e', ':', ' ', 'i', 'm', '2', 'd', 'o',
'u', 'b', 'l', 'e', ' ', 'L', 'i', 'n', 'e',
':', ' ', '1', ' ', 'C', 'o', 'l', 'u', 'm',
'n', ':', ' ', '1', ' ', 'T', 'h', 'e', ' ',
'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', ' ',
'"', 'i', 'm', '2', 'd', 'o', 'u', 'b', 'l',
'e', '"', ' ', 'w', 'a', 's', ' ', 'c', 'a',
'l', 'l', 'e', 'd', ' ', 'w', 'i', 't', 'h',
' ', 'm', 'o', 'r', 'e', ' ', 't', 'h', 'a',
'n', ' ', 't', 'h', 'e', ' ', 'd', 'e', 'c',
'l', 'a', 'r', 'e', 'd', ' ', 'n', 'u', 'm',
'b', 'e', 'r', ' ', 'o', 'f', ' ', 'o', 'u',
't', 'p', 'u', 't', 's', ' ', '(', '1', ')',
'.' };
static mwArray _mxarray0_ = mclInitializeString(136, _array1_);
static mxChar _array3_[135] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
'l', 'e', ':', ' ', 'i', 'm', '2', 'd', 'o',
'u', 'b', 'l', 'e', ' ', 'L', 'i', 'n', 'e',
':', ' ', '1', ' ', 'C', 'o', 'l', 'u', 'm',
'n', ':', ' ', '1', ' ', 'T', 'h', 'e', ' ',
'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', ' ',
'"', 'i', 'm', '2', 'd', 'o', 'u', 'b', 'l',
'e', '"', ' ', 'w', 'a', 's', ' ', 'c', 'a',
'l', 'l', 'e', 'd', ' ', 'w', 'i', 't', 'h',
' ', 'm', 'o', 'r', 'e', ' ', 't', 'h', 'a',
'n', ' ', 't', 'h', 'e', ' ', 'd', 'e', 'c',
'l', 'a', 'r', 'e', 'd', ' ', 'n', 'u', 'm',
'b', 'e', 'r', ' ', 'o', 'f', ' ', 'i', 'n',
'p', 'u', 't', 's', ' ', '(', '2', ')', '.' };
static mwArray _mxarray2_ = mclInitializeString(135, _array3_);
static mxChar _array5_[6] = { 'd', 'o', 'u', 'b', 'l', 'e' };
static mwArray _mxarray4_ = mclInitializeString(6, _array5_);
static mxChar _array7_[6] = { 'u', 'i', 'n', 't', '1', '6' };
static mwArray _mxarray6_ = mclInitializeString(6, _array7_);
static mxChar _array9_[5] = { 'u', 'i', 'n', 't', '8' };
static mwArray _mxarray8_ = mclInitializeString(5, _array9_);
static mwArray _mxarray10_ = mclInitializeDouble(255.0);
static mwArray _mxarray11_ = mclInitializeDouble(65535.0);
static mxChar _array13_[1] = { 'i' };
static mwArray _mxarray12_ = mclInitializeString(1, _array13_);
static mxChar _array15_[23] = { 'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ',
'i', 'n', 'p', 'u', 't', ' ', 'a', 'r',
'g', 'u', 'm', 'e', 'n', 't', 's' };
static mwArray _mxarray14_ = mclInitializeString(23, _array15_);
static mwArray _mxarray16_ = mclInitializeDouble(1.0);
static mxChar _array18_[24] = { 'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ',
'i', 'n', 'p', 'u', 't', ' ', 'a', 'r',
'g', 'u', 'm', 'e', 'n', 't', 's', '.' };
static mwArray _mxarray17_ = mclInitializeString(24, _array18_);
static mxChar _array20_[24] = { 'U', 'n', 's', 'u', 'p', 'p', 'o', 'r',
't', 'e', 'd', ' ', 'i', 'n', 'p', 'u',
't', ' ', 'c', 'l', 'a', 's', 's', '.' };
static mwArray _mxarray19_ = mclInitializeString(24, _array20_);
void InitializeModule_im2double() {
}
void TerminateModule_im2double() {
}
static mwArray Mim2double(int nargout_, mwArray img, mwArray typestr);
_mexLocalFunctionTable _local_function_table_im2double
= { 0, (mexFunctionTableEntry *)NULL };
//
// The function "im2double" contains the normal interface for the "im2double"
// M-function from file "D:\matlab\matlab\toolbox\images\images\im2double.m"
// (lines 1-53). This function processes any input arguments and passes them to
// the implementation version of the function, appearing above.
//
mwArray im2double(mwArray img, mwArray typestr) {
int nargout(1);
mwArray d(mclGetUninitializedArray());
d = Mim2double(nargout, img, typestr);
return d;
}
//
// The function "mlxIm2double" contains the feval interface for the "im2double"
// M-function from file "D:\matlab\matlab\toolbox\images\images\im2double.m"
// (lines 1-53). The feval function calls the implementation version of
// im2double through this function. This function processes any input arguments
// and passes them to the implementation version of the function, appearing
// above.
//
void mlxIm2double(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
MW_BEGIN_MLX();
{
mwArray mprhs[2];
mwArray mplhs[1];
int i;
mclCppUninitializeArrays(1, mplhs);
if (nlhs > 1) {
error(_mxarray0_);
}
if (nrhs > 2) {
error(_mxarray2_);
}
for (i = 0; i < 2 && i < nrhs; ++i) {
mprhs[i] = mwArray(prhs[i], 0);
}
for (; i < 2; ++i) {
mprhs[i].MakeDIN();
}
mplhs[0] = Mim2double(nlhs, mprhs[0], mprhs[1]);
plhs[0] = mplhs[0].FreezeData();
}
MW_END_MLX();
}
//
// The function "Mim2double" is the implementation version of the "im2double"
// M-function from file "D:\matlab\matlab\toolbox\images\images\im2double.m"
// (lines 1-53). It contains the actual compiled code for that M-function. It
// is a static function and must only be called from one of the interface
// functions, appearing below.
//
//
// function d = im2double(img, typestr)
//
static mwArray Mim2double(int nargout_, mwArray img, mwArray typestr) {
mclMlineEnterFunction(
"D:\\matlab\\matlab\\toolbox\\images\\images\\im2double.m", "im2double")
mwLocalFunctionTable save_local_function_table_
(&_local_function_table_im2double);
int nargin_(nargin(2, mwVarargin(img, typestr)));
mwArray d(mclGetUninitializedArray());
mwArray ans(mclGetUninitializedArray());
//
// %IM2DOUBLE Convert image to double precision.
// % IM2DOUBLE takes an image as input, and returns an image of
// % class double. If the input image is of class double, the
// % output image is identical to it. If the input image is of
// % class uint8 or uint16, im2double returns the equivalent
// % image of class double, rescaling or offsetting the data
// % as necessary.
// %
// % I2 = IM2DOUBLE(I1) converts the intensity image I1 to double
// % precision, rescaling the data if necessary.
// %
// % RGB2 = IM2DOUBLE(RGB1) converts the truecolor image RGB1 to
// % double precision, rescaling the data if necessary.
// %
// % BW2 = IM2DOUBLE(BW1) converts the binary image BW1 to double
// % precision.
// %
// % X2 = IM2DOUBLE(X1,'indexed') converts the indexed image X1 to
// % double precision, offsetting the data if necessary.
// %
// % See also DOUBLE, IM2UINT8, UINT8.
//
// % Copyright 1993-2001 The MathWorks, Inc.
// % $Revision: 1.13 $ $Date: 2001/01/18 15:29:17 $
//
// if isa(img, 'double')
//
mclMline(27);
if (tobool(mwVe(isa(mwVa(img, "img"), _mxarray4_)))) {
//
// d = img;
//
mclMline(28);
d = mwVsa(img, "img");
//
// elseif isa(img, 'uint8') | isa(img, 'uint16')
//
mclMline(29);
} else {
mwArray a_(mwVe(isa(mwVa(img, "img"), _mxarray8_)));
if (tobool(a_)
|| tobool(a_ | mwVe(isa(mwVa(img, "img"), _mxarray6_)))) {
//
// if nargin==1
//
mclMline(30);
if (nargin_ == 1) {
//
// if islogical(img) % uint8 binary image
//
mclMline(31);
if (tobool(mwVe(islogical(mwVa(img, "img"))))) {
//
// d = double(img);
//
mclMline(32);
d = double_func(mwVa(img, "img"));
//
// else % uint8 or uint16 intensity image
//
mclMline(33);
} else {
//
// if isa(img, 'uint8')
//
mclMline(34);
if (tobool(mwVe(isa(mwVa(img, "img"), _mxarray8_)))) {
//
// d = double(img)/255;
//
mclMline(35);
d = mwVe(double_func(mwVa(img, "img"))) / _mxarray10_;
//
// else
//
mclMline(36);
} else {
//
// d = double(img)/65535;
//
mclMline(37);
d = mwVe(double_func(mwVa(img, "img"))) / _mxarray11_;
//
// end
//
mclMline(38);
}
//
// end
//
mclMline(39);
}
//
// elseif nargin==2
//
mclMline(40);
} else if (nargin_ == 2) {
//
// if ~ischar(typestr) | (typestr(1) ~= 'i')
//
mclMline(41);
mwArray a_0(~ mwVe(ischar(mwVa(typestr, "typestr"))));
if (tobool(a_0)
|| tobool(
a_0
| mwVe(mclIntArrayRef(mwVsa(typestr, "typestr"), 1))
!= _mxarray12_)) {
//
// error('Invalid input arguments');
//
mclMline(42);
error(_mxarray14_);
//
// else
//
mclMline(43);
} else {
//
// d = double(img)+1;
//
mclMline(44);
d = mwVe(double_func(mwVa(img, "img"))) + _mxarray16_;
}
//
// end
// else
//
mclMline(46);
} else {
//
// error('Invalid input arguments.');
//
mclMline(47);
error(_mxarray17_);
//
// end
//
mclMline(48);
}
//
// else
//
mclMline(49);
} else {
//
// error('Unsupported input class.');
//
mclMline(50);
error(_mxarray19_);
}
//
// end
//
mclMline(51);
}
mwValidateOutput(d, 1, nargout_, "d", "im2double");
mclMlineFunctionReturn()
return d;
//
//
//
mclMlineExitFunctionReturn();
}