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

📄 model.tex

📁 图像中非刚性曲线的蛇形检测算法
💻 TEX
字号:
\rhead{class MODEL}

\section{MODEL : Shape Learning Class}
{\tt MODEL} provides shape matrix and local regularization parameters learning routines. It has the following structure:

\begin{verbatim}
class MODEL : public GSNAKE {

    protected :
        short deformSample;      /* number of deformed samples */
        short shapeSample;       /* number of learned samples */
};
\end{verbatim}

{\tt MODEL} inherits extra functions from {\tt GSNAKE}. With sufficient training samples, we can generate a robust contour model with specific prior knowledge.


%
\subsection{MODEL constructor}

\subsubsection*{Synopsis}
\begin{verbatim}
	MODEL(void)
\end{verbatim}

\subsubsection*{Description}
The constructor sets {\tt deformSample} and {\tt shapeSample} to 0.


%
\subsection{Learning shape matrix}
\subsubsection*{Synopsis}
\begin{verbatim}
	int LearnShape(GSNAKE *sample)
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt sample} & Gsnake sample.
\te

\subsubsection*{Returns}
\tb
	{\tt NOERROR} & Successfully operation. \\
	{\tt MEMORYERROR} & Memory allocation error.
\te 
	
\subsubsection*{Description}
{\tt LearnShape} performs learning of shape matrix from different samples. This is done by taking an initial estimate of shape matrix from the first sample. Using this shape matrix and {\em minmax} regularization, we minimize the second samples and average the shape matrix. By repeating this for the rest samples, we can derive a learned {\em model} to regenerate a new contour shape.

%
\subsection{Learning local deformation variances}

\subsubsection*{Synopsis}
\begin{verbatim}
	int LearnDeform(GSNAKE *sample)
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt *sample} & GSNAKE sample.
\te
 
\subsubsection*{Returns}
\tb
	{\tt NOERROR} & Successful operation. \\
	{\tt MEMORYERROR} & Memory allocation error. 
\te 

\subsubsection*{Description}
{\tt LearnDeform} learns the local regularization parameters $\lambda_{i}$ which control the {\tt GSNAKE} deformation. By computing deformation variance ($\sigma_{i}^{2}$) and noise varaince ($\sigma_{\eta}^{2}$), we have $\lambda_{i}$ as following,
\eq
	 \lambda_{i}=\frac{\sigma_{\eta}^{2}}{\sigma_{\eta}^{2}+\sigma_{i}^{2}}
\en


%
\subsection{Accessing the trained model}

\subsubsection*{Synopsis}
\begin{verbatim}
	GSNAKE *getModel(void) 
\end{verbatim}

\subsubsection*{Returns}
Learned contour model.

\subsubsection*{Description}
{\tt getModel} facilitates the retrieval of a learned contour model.


%
\subsection{Example : Learning of shape matrix from different samples}

\begin{verbatim}
void testmain( char **argv,
               unsigned char mag,
               short level,
               int magPos,
               int levelPos )
{
        MODEL model;            /* to store results of learning */
        GSNAKE sample(_EDGE);   /* sample will use _EDGE as external energy */
        char **imgsamples;      /* image samples */
        register short i;

        imgsamples = &argv[1] ;

        for( i=1; *imgsamples ; i++, imgsamples++) {

            if ( ( i == magPos ) || ( i == levelPos) )
                break;

            printf("Using Sample %s to Learn SHAPE\n\n", *imgsamples);

            sample.putRawImg(*imgsamples);

            if( i==1 ) {

                /* use manually selected feature points to
                   estimate the shape matrix */

                sample.CONTOUR::init( sample.rawImg, mag );
                model.LearnShape( &sample );
            }

            /* Using the initial shape matrix and minimiax regularization,
               the total energy of gsnake is minimize and then the shape
               matrix is updated */

            model.duplicate(&sample);
            sample.generate(level, 1);          /* generate pyramid */

            sample.localize(5, 5, 1, 0.25, 3);  /* localize the contour */
            sample.minimize(5, 5, 0, mag);      /* minimize energy */
            sample.deform( mag );               /* manually adjust */

            model.LearnShape( &sample );        /* average out the shape coef*/

            /* Using the shape matrix and the last two snaxels,
               a contour is regenerated to show invariance of shape matrix */

            if( i != 1 ) {

                printf("Regenerate the shape...\n");
                model.regenerate();     /* regenerate the shape based on mtx */
                model.CONTOUR::display( mag );
                printf("Press Enter to continue...\n");
                getchar();
             }
        }

        printf("\nResulting contour :\n");
        model.CONTOUR::print() ;
}
\end{verbatim}

This program reads in one sample at each interaction. An initial estimate of the shape matrix are computed from the first sample. {\tt localize} and {\tt minimize} will localize the second sample and minimize its energy, and then {\tt LearnShape} updates the new shape matrix. Since the shape matrix is regenerative, {\tt regenerate} will generate a new contour. By repeating this precedure for many samples, we can obtain a learned model. If we take several square images which undergo affine transformation to train the shape matrix, the program will show that the regenerative shape is still a square. This verify the invariance of a shape matrix.

⌨️ 快捷键说明

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