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

📄 class.tex

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

\section{CLASSIFY : Contour Classification}
{\tt CLASSIFY} provides advance routines for detecting and classifying deformable contours directly from noisy image (Chapter 4 of \cite{kn:thesis}). It calculates the score of each competitive templates based on marginalization of the distribution ({\tt \_MARGIN\_PROB}), MAP probability ({\tt \_DEFORM\_PROB}), match of deformable template ({\tt \_DEFORM\_MATCH}) and match of rigid template ({\tt \_RIGID\_MATCH}). It has the following structure :

\begin{verbatim}
class CLASSIFY : public REGION {

    protected :
        int numClass ;	                /* number of class */
        EEXTTYPE Eexttype ;             /* type of external energy */
        CONTOUR **templates ;           /* reference templates */
        char **labels ;                 /* label of templates */
        double *Margin_Prob;            /* marginalized probability */
        double *Rigid_Match ;           /* rigid match score */
        double *Deform_Match ;          /* deform match score */
        double *Deform_Prob ;           /* deform match probability */
   
   /* these localization and minimization parameters are made public so
      that modifying them can be easy */
   public :
        int Qx, Qy ;                    /* GHT Image Cell Resolutions */
        int NR, Nrxy, Nt, Ndx, Ndy ;    /* GHT ranges */
        double QR, Qrxy, Qt, Qdx, Qdy;  /* GHT Resolutions */
        double R, THETA ;               /* GHT Constants */
        int numSearchSegment ;          /* number of search segments */
        int segmentSpacing ;            /* spacing between segments */
        int numLevel ;                  /* number of pyramid levels */
        int verbose ;                   /* verbose mode */
        int nhoodTangent, nhoodNormal;  /* neighborhood used in marginaliz-n */

 \end{verbatim}

It stores a list of competitive templates and their corresponding score. In addition, extra parameters such as GHT range and resolution are used for localizaing and minimizing these templates.


%
\subsection{CLASSIFY constructor}

\subsubsection*{Synopsis}
\begin{verbatim}
	CLASSIFY(EEXTTYPE _Eexttype = _EDGE);
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt \_Eexttype} & External energy type.
\te

\subsubsection*{Description}
The constructor sets the default parameters and initializes all pointer members to NULL. 

%
\subsection{CLASSIFY destructor}

\subsubsection*{Synopsis}
\begin{verbatim}
	~CLASSIFY(void);
\end{verbatim}

\subsubsection*{Description}
The destructor frees memory allocated to the pointer members.


%
\subsection{Loading a template into CLASSIFY}

\subsubsection*{Synopsis}
\begin{verbatim}
	int read( CONTOUR *contour );
	int read( char *filename );
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt contour} & Source {\tt CONTOUR}. \\
	{\tt filename} & Contour file. 
\te

\subsubsection*{Returns}
\tb
	{\tt NOERROR} & Template loaded successfully. \\
	{\tt MEMORYERROR} & Memory allocation failure or\\
			  & template initialization error
\te

\subsubsection*{Description}
These methods read in contour used for classification purpose. Once a contour is read, {\tt numContour} is incremented by one, reflecting the total number of contours read.


%
\subsection{Classifying templates}

\subsubsection*{Synopsis}
\begin{verbatim}
	int classify(IMAGE *testimg, CLASSTYPE ClassType = _MARGIN_PROB) ;
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt testimg} & Testing image. \\
	{\tt ClassType} & Type of classification : \\
			& {\tt \_MARGIN\_PROB},
	 {\tt \_DEFORM\_PROB}, {\tt \_DEFORM\_MATCH} or {\tt \_RIGID\_MATCH}.
\te	

\subsubsection*{Returns}
Classification score. 

\subsubsection*{Description}
{\tt classify} classify rigid and deformable templates directly from the testing image. For each template, it performs localization, minimization and marginalization to compute the classify score.


%
\subsection{Selecting the best matching contour}

\subsubsection*{Synopsis}
\begin{verbatim}
	int selectMax( ClassTYPE ClassType = _MARGIN_PROB )
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt ClassType} &  Type of classification : \\
			&{\tt \_MARGIN\_PROB},
	 {\tt \_DEFORM\_PROB}, {\tt \_DEFORM\_MATCH} or {\tt \_RIGID\_MATCH}.
\te

\subsubsection*{Returns}
Index to the template which consists of highest score.

\subsubsection*{Description}
{\tt selectMax} compares the classify score of templates of type interest and searches for the highest classify score.

%
\subsection{Getting the number of templates read}

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

\subsubsection*{Returns}
Number of templates read.

\subsubsection*{Description}
{\tt getNumClass} retrieves the number of templates read.


%
\subsection{Getting the matching score}

\subsubsection*{Synopsis}
\begin{verbatim}
	double getScore( int template_id, CLASSTYPE ClassType = _MARGIN_PROB)
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt template\_id} & Target template index. \\
	{\tt ClassType} & Type of classification : \\
			& {\tt \_MARGIN\_PROB},
	 {\tt \_DEFORM\_PROB}, {\tt \_DEFORM\_MATCH} or {\tt \_RIGID\_MATCH}.
\te

\subsubsection*{Returns}
Classify score of target template.

\subsubsection*{Description}
{\tt getScore} retrieves the score of template indexed by {\tt template\_id}.


%
\subsection{Printing templates score}

\subsubsection*{Synopsis}
\begin{verbatim}
	void dump(char *imgName, FILE *stream = stdout)
\end{verbatim}

\subsubsection*{Description}
{\tt dump} prints onto screen or file the score of each templates.

%
\subsection{Getting label of template}

\subsubsection*{Synopsis}
\begin{verbatim}
	char *getLabel(short class_id)
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt ClassType} & Type of classification : \\
			& {\tt \_MARGIN\_PROB},
	 {\tt \_DEFORM\_PROB}, {\tt \_DEFORM\_MATCH} or {\tt \_RIGID\_MATCH}.
\te

\subsubsection*{Returns}
Label of template of interest.

\subsubsection*{Description}
{getlabel} facilitates the retrieval of template label.


%
\subsection{Example : Classifying various templates}

\begin{verbatim}
void testmain( char **imgsamples ) /* image samples */
{
        register short i ;
        CLASSIFY shape(_EDGE) ;
 
        shape.Nrxy = 3 ;    /* allow some stretching in diagonal direction */         
        if( shape.read("ellip.con") != NOERROR ||
            shape.read("rect.con") != NOERROR  ) {
                printf("cannot find contour files\n") ;
                exit(-1) ;
        }

         
        for(i=0; *imgsamples; i++, imgsamples++) {
        
                IMAGE myImage ;
                if( myImage.read(*imgsamples) != NOERROR )
                        break ;

                int id = shape.classify(&myImage, _MARGIN_PROB) ;
                
                printf("%s : %s\n", *imgsamples, shape.getLabel(id) ) ;
                
                shape.dump(*imgsamples) ;
        }
        exit(0) ;
\end{verbatim}

This program read in two templates, namely {\tt ellip.con} and {\tt rect.con}. {\tt classify} maginalizes the distribution and returns the matched template. {\tt dump} will print on screen the classfy scores of the template.

⌨️ 快捷键说明

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