⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idct2.cpp

📁 一篇有关数字水印的程序
💻 CPP
字号:
//
// MATLAB Compiler: 3.0
// Date: Wed Apr 25 16:38:48 2007
// 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" "idct2.m" 
//
#include "idct2.hpp"
#include "images_private_checknargin.hpp"
#include "images_private_idct.hpp"
#include "libmatlbm.hpp"
static mwArray _mxarray0_ = mclInitializeDouble(1.0);
static mwArray _mxarray1_ = mclInitializeDouble(3.0);
static mwArray _mxarray2_ = mclInitializeDouble(0.0);
static mwArray _mxarray3_ = mclInitializeDouble(2.0);

void InitializeModule_idct2() {
}

void TerminateModule_idct2() {
}

static mwArray Midct2(int nargout_, mwArray arg1, mwArray mrows, mwArray ncols);

_mexLocalFunctionTable _local_function_table_idct2
  = { 0, (mexFunctionTableEntry *)NULL };

//
// The function "idct2" contains the normal interface for the "idct2"
// M-function from file "d:\matlab6p5\toolbox\images\images\idct2.m" (lines
// 1-62). This function processes any input arguments and passes them to the
// implementation version of the function, appearing above.
//
mwArray idct2(mwArray arg1, mwArray mrows, mwArray ncols) {
    int nargout = 1;
    mwArray a = mwArray::UNDEFINED;
    a = Midct2(nargout, arg1, mrows, ncols);
    return a;
}

//
// The function "mlxIdct2" contains the feval interface for the "idct2"
// M-function from file "d:\matlab6p5\toolbox\images\images\idct2.m" (lines
// 1-62). The feval function calls the implementation version of idct2 through
// this function. This function processes any input arguments and passes them
// to the implementation version of the function, appearing above.
//
void mlxIdct2(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    MW_BEGIN_MLX();
    {
        mwArray mprhs[3];
        mwArray mplhs[1];
        int i;
        mclCppUndefineArrays(1, mplhs);
        if (nlhs > 1) {
            error(
              mwVarargin(
                mwArray(
                  "Run-time Error: File: idct2 Line: 1 Column: 1"
                  " The function \"idct2\" was called with more "
                  "than the declared number of outputs (1).")));
        }
        if (nrhs > 3) {
            error(
              mwVarargin(
                mwArray(
                  "Run-time Error: File: idct2 Line: 1 Column: 1"
                  " The function \"idct2\" was called with more "
                  "than the declared number of inputs (3).")));
        }
        for (i = 0; i < 3 && i < nrhs; ++i) {
            mprhs[i] = mwArray(prhs[i], 0);
        }
        for (; i < 3; ++i) {
            mprhs[i].MakeDIN();
        }
        mplhs[0] = Midct2(nlhs, mprhs[0], mprhs[1], mprhs[2]);
        plhs[0] = mplhs[0].FreezeData();
    }
    MW_END_MLX();
}

//
// The function "Midct2" is the implementation version of the "idct2"
// M-function from file "d:\matlab6p5\toolbox\images\images\idct2.m" (lines
// 1-62). 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 a = idct2(arg1,mrows,ncols)
//
static mwArray Midct2(int nargout_,
                      mwArray arg1,
                      mwArray mrows,
                      mwArray ncols) {
    mclMlineEnterFunction(
      "d:\\matlab6p5\\toolbox\\images\\images\\idct2.m", "idct2")
    mwLocalFunctionTable save_local_function_table_
      = &_local_function_table_idct2;
    int nargin_ = nargin(3, mwVarargin(arg1, mrows, ncols));
    mwArray a = mwArray::UNDEFINED;
    mwArray npad = mwArray::UNDEFINED;
    mwArray mpad = mwArray::UNDEFINED;
    mwArray b = mwArray::UNDEFINED;
    mwArray n = mwArray::UNDEFINED;
    mwArray m = mwArray::UNDEFINED;
    mwArray ans = mwArray::UNDEFINED;
    //
    // %IDCT2 Compute 2-D inverse discrete cosine transform.
    // %   B = IDCT2(A) returns the two-dimensional inverse discrete
    // %   cosine transform of A.
    // %
    // %   B = IDCT2(A,[M N]) or B = IDCT2(A,M,N) pads A with zeros (or
    // %   truncates A) to create a matrix of size M-by-N before
    // %   transforming. 
    // %
    // %   For any A, IDCT2(DCT2(A)) equals A to within roundoff error.
    // %
    // %   The discrete cosine transform is often used for image
    // %   compression applications.
    // %
    // %   Class Support
    // %   -------------
    // %   The input matrix A can be of class double or of any
    // %   numeric class. The output matrix B is of class double.
    // %
    // %   See also DCT2, DCTMTX, FFT2, IFFT2.
    // 
    // %   Copyright 1993-2002 The MathWorks, Inc.  
    // %   $Revision: 5.17 $  $Date: 2002/03/15 15:27:33 $
    // 
    // %   References: 
    // %   1) A. K. Jain, "Fundamentals of Digital Image
    // %      Processing", pp. 150-153.
    // %   2) Wallace, "The JPEG Still Picture Compression Standard",
    // %      Communications of the ACM, April 1991.
    // 
    // checknargin(1,3,nargin,mfilename);
    //
    mclMline(31);
    images_private_checknargin(_mxarray0_, _mxarray1_, nargin_, "idct2");
    //
    // 
    // [m, n] = size(arg1);
    //
    mclMline(33);
    size(mwVarargout(m, n), mwVa(arg1, "arg1"));
    //
    // % Basic algorithm.
    // if (nargin == 1),
    //
    mclMline(35);
    if (nargin_ == 1) {
        //
        // if (m > 1) & (n > 1),
        //
        mclMline(36);
        mwArray a_ = mwVv(m, "m") > _mxarray0_;
        if (tobool(a_) && tobool(a_ & mwVv(n, "n") > _mxarray0_)) {
            //
            // a = idct(idct(arg1).').';
            //
            mclMline(37);
            a
              = transpose(
                  images_private_idct(
                    transpose(images_private_idct(mwVa(arg1, "arg1")))));
            //
            // return;
            //
            mclMline(38);
            goto return_;
        //
        // else
        //
        } else {
            //
            // mrows = m;
            //
            mclMline(40);
            mrows = mwVv(m, "m");
            //
            // ncols = n;
            //
            mclMline(41);
            ncols = mwVv(n, "n");
        }
    //
    // end
    // end
    //
    mclMline(43);
    }
    //
    // 
    // % Padding for vector input.
    // 
    // b = arg1;
    //
    mclMline(47);
    b = mwVa(arg1, "arg1");
    //
    // if nargin==2, 
    //
    mclMline(48);
    if (nargin_ == 2) {
        //
        // ncols = mrows(2); 
        //
        mclMline(49);
        ncols = mclIntArrayRef(mwVa(mrows, "mrows"), 2);
        //
        // mrows = mrows(1); 
        //
        mclMline(50);
        mrows = mclIntArrayRef(mwVa(mrows, "mrows"), 1);
    //
    // end
    //
    mclMline(51);
    }
    //
    // 
    // mpad = mrows; npad = ncols;
    //
    mclMline(53);
    mpad = mwVa(mrows, "mrows");
    npad = mwVa(ncols, "ncols");
    //
    // if m == 1 & mpad > m, b(2, 1) = 0; m = 2; end
    //
    mclMline(54);
    {
        mwArray a_ = mwVv(m, "m") == _mxarray0_;
        if (tobool(a_) && tobool(a_ & mwVv(mpad, "mpad") > mwVv(m, "m"))) {
            mclIntArrayAssign(&b, _mxarray2_, 2, 1);
            m = _mxarray3_;
        } else {
        }
    }
    //
    // if n == 1 & npad > n, b(1, 2) = 0; n = 2; end
    //
    mclMline(55);
    {
        mwArray a_ = mwVv(n, "n") == _mxarray0_;
        if (tobool(a_) && tobool(a_ & mwVv(npad, "npad") > mwVv(n, "n"))) {
            mclIntArrayAssign(&b, _mxarray2_, 1, 2);
            n = _mxarray3_;
        } else {
        }
    }
    //
    // if m == 1, mpad = npad; npad = 1; end   % For row vector.
    //
    mclMline(56);
    if (mclEqBool(mwVv(m, "m"), _mxarray0_)) {
        mpad = mwVv(npad, "npad");
        npad = _mxarray0_;
    }
    //
    // 
    // % Transform.
    // 
    // a = idct(b, mpad);
    //
    mclMline(60);
    a = images_private_idct(mwVv(b, "b"), mwVv(mpad, "mpad"));
    //
    // if m > 1 & n > 1, a = idct(a.', npad).'; end
    //
    mclMline(61);
    {
        mwArray a_ = mwVv(m, "m") > _mxarray0_;
        if (tobool(a_) && tobool(a_ & mwVv(n, "n") > _mxarray0_)) {
            a
              = transpose(
                  images_private_idct(
                    transpose(mwVv(a, "a")), mwVv(npad, "npad")));
        } else {
        }
    }
    return_:
    mwValidateOutput(a, 1, nargout_, "a", "idct2");
    mclMlineFunctionReturn()
    return a;
    mclMlineExitFunctionReturn();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -