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

📄 pyramid.tex

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

{\tt PYRAMID} is built up of a series of edge map and Gaussian images, which are generated from the raw image, in the form of EDGE and IMAGE objects. Construction of Gaussian pyramid images [7] is done by image correlation with Gaussian generating kernel. In this case, the higher level correlates image is a reduced version of the lower level image in that both resolution and sample density are decreased. For instance, a Gaussian image at level l, $g_{l}$, can be expressed as :
\eq
	g_{l}(i,j)=\sum_{m=-1}^{1}\sum_{n=-1}^{1}w(m, n)g_{l-1}(2i+m, 2j+n)
	\label{eqn:g_{l}}
\en
where w(m, n) is a 3 x 3 Gaussian generating kernel. An {\tt PYRAMID} object are defined as below :

\begin{verbatim}
class PYRAMID {

   protected :
        short numLevel ;		/* number of level */
        EDGE **edgemap ;		/* edge map at each level */
        IMAGE **gaussImg ;		/* gaussian smoothed image */
   	
      public :
        IMAGE *rawImg;			/* raw image */

};
\end{verbatim}

%
\subsection{PYRAMID Constructor}

\subsubsection*{Synopsis}
\begin{verbatim}
	PYRAMID()
\end{verbatim}
	
\subsubsection*{Description}
The constructor initializes the edge map, Gaussian pyramid and raw images to NULL, as well as sets the pyramid to level 0.

%
\subsection{PYRAMID Destructor}

\subsubsection*{Synopsis}
\begin{verbatim}
	~PYRAMID()
\end{verbatim}

\subsubsection*{Description}
The destructor frees the memory allocated to edge map, Gaussian pyramid and raw images.


%
\subsection{Resetting PYRAMID object}

\subsubsection*{Synopsis}
\begin{verbatim}
	reset()
\end{verbatim}
{\tt reset} allows the reuse of an {\tt PYRAMID} object. It frees the memory allocated to the edge map and Gaussian images for each level of the pyramid.

%
\subsection{Generating pyramid images}

\subsubsection*{Synopsis}
\begin{verbatim}
generate(short level, int verbose=0,double low_pct=0.9, 	
         double high_pct=0.95, double low_val=0.2,	
         double high_val=0.9, double imm_pow=1.0,
         EextTYPE = _EDGE)
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt level} & The number of Gaussian pyramid levels to be generated. \\
	{\tt verbose} & An option to enable verbose operation mode. \\		
	{\tt low\_pct, high\_pct} & Percentage range which the image pixels
			are to be mapped from. \\ 
	{\tt low\_val, high\_val} & Intensity range over which the pixels
			are to be mapped to. \\
	{\tt imm\_pow} & Exponential power for the mapping function.\\
	{\tt EextTYPE} & Type of external energy, includes intensity
			 (\_INTENSITY), edge \\
		       & magnitude only (\_EDGEMAG) and edge map (\_EDGE) image
			 energy.
\te

\subsubsection*{Returns}
\tb
	{\tt NOERROR} & Successful pyramid generation. \\
	{\tt MEMORYERROR} & Memory allocation failure. 
\te

\subsubsection*{Description}
{\tt generate} creates a pyramid of Gaussian images by correlating the 
raw image with a Gaussian kernel, and computes edge gradient based on the {\tt EextTYPE} specified. Edge direction map will not be generated if {\tt \_EDGE} is not used. To account for robustness, we use image conditioning, {\tt condition}, for the edge magnitude. The parameters ($high\_pct=0.95$, $low\_pct=0.9$, $ high\_val=0.9$, $low\_val=0.2$) were found empirically to produce a good conditioning image.


%
\subsection{Accessing edge map} 

\subsubsection*{Synopsis}
\begin{verbatim}
	EDGE *getEdge(short level_id)
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt level\_id} & Pyramid level of interest.
\te

\subsubsection*{Returns}
Pointer to an edge image of level specified. Returns {\tt NULL} if the level specified is invalid.

\subsubsection*{Description}
{\tt getEdge} allows accessing of an edge image of level specified, in which the level must be within the range of 0 to the highest possible pyramid level availble.


%
\subsection{Accessing Gaussian image}

\subsubsection*{Synopsis}
\begin{verbatim}
	IMAGE *getGauss(short level_id)
\end{verbatim}

\subsubsection*{Arguments}
\tb	
	{\tt level\_id} & Pyramid level of interest.
\te

\subsubsection*{Returns}
Pointer to a Gaussian image of level specified. Returns {\tt NULL} if the level specified is invalid.

\subsubsection*{Description}
{\tt getGauss} allows accessing of a Gaussian image of level specified, in which the level must be within the range of 0 to the highest possible pyramid level availble.

%
\subsection{Getting pyramid level}

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

\subsubsection*{Returns}
Number of levels of Gaussian pyramid. The highest level is given as level-1, since the lowest level is 0.


%
\subsection{Print Gaussian pyramid data}
 
\subsubsection*{Synopsis}
\begin{verbatim}
	void print(int level)
\end{verbatim}

\subsubsection*{Arguments}
\tb	
	{\tt level} & Pyramid level of interest.
\te

\subsubsection*{Description}
{\tt print} displays onto the screen all the data of an edge image of level specified.


%
\subsection{Displaying the pyramid of images}

\subsubsection*{Synopsis}
\begin{verbatim}
	void show(unsigned magnify,int level=1)
\end{verbatim}

\subsubsection*{Arguments} 
\tb
	{\tt magnify} & Image magnification factor. \\
	{\tt level} & Levels of the Gaussian pyramid required for display.
\te

\subsubsection*{Description}
{\tt show} displays pyramid of images, include edge and Gaussian images, from the lowest level to the level specified.  		
	
	
%
\subsection{Duplicating a pyramid}

\subsubsection*{Synopsis}
\begin{verbatim}
	duplicate(PYRAMID *pyramid)
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt *pyramid} & Pointer to a source pyramid.
\te

\subsubsection*{Returns}
\tb
	{\tt NOERROR} & Successful duplication. \\
	{\tt MEMORYERROR} & Memory allocation failure. 
\te

\subsubsection*{Description}
{\tt duplicate} copies the source pyramid into {\tt PYRAMID} itself.


%
\subsection{Putting root image into PYRAMID}

\subsubsection*{Synopsis}
\begin{verbatim}
	int putRawImg(char *filename)
	void putRawImg( IMAGE *img ) 
\end{verbatim}

\subsubsection*{Arguments}
\tb
	{\tt *filename} & Souce image filename. \\
	{\tt *img} & Pointer to a source {\tt IMAGE object}.
\te

\subsubsection*{Returns}
\tb
	{\tt NOERROR} & Successful read operation. \\
	{\tt MEMORYERROR} & Memory allocation failure. \\
	{\tt FILEIOERROR} & Unable to read from file.
\te

\subsubsection*{Description}
{\tt putRawImg} reads or copies the source image as its raw image. If a raw image has already existed, {\tt putRawImage} will destroy the current one and copies the source image as the new raw image.


%
\subsection{Example:Building of pyramid from image}
This program generates pyramid of images from an image file and shows them on an X window.
 
\begin{verbatim}
void testmain( char *imgfile,   /* image file */
               int level,       /* Gaussian pyramid level */
               int mag )         /* magnification factor */
{
        PYRAMID mypyramid;

        if ( mypyramid.putRawImg( imgfile ) ) {
 
                printf("Unable to read image file.");
                exit(-1);
        }
 
        else {     
                /* generating pyramid to default conditioning parameters */
                /* in verbose mode */
                mypyramid.generate( level, 1 );
                mypyramid.show( mag, level ); 
                getchar();
                xwin_close();
        }
}

\end{verbatim}
 
{\tt generate} uses default histogram conditioning paramters and verbose 'on' mode to compute and generate edge map and Gaussian images at each level of pyramid, while {\tt show} displays them in a hierarchical manner.

%
\subsection{Example:Accessing a particular level image}

\begin{verbatim}
void testmain( char *imgfile,   /* image file */
               int pymlevel,    /* pyramid levels */
               int i_level,     /* level of interest */
               int mag)         /* maginification factor */
{
        IMAGE myimage1,
              *myimage2;        /* IMAGE object */
        PYRAMID mypyramid;      /* PYRAMID object */
        EDGE *myedge;           /* EDGE object */
 
        if ( myimage1.read( imgfile ) ) {
                printf("\nUnable to get image.\n");
                exit(-1);
        }
         
        /* Placing image into pyramid object by using another image */
        mypyramid.putRawImg( &myimage1 );
         
        /* generating pyramid by default conditioning parameters */
        mypyramid.generate( pymlevel, 1 );
         
        if ( !i_level ) 
                i_level = mypyramid.getLevel() - 1;
 
        /* get edge map and Guassian images of interest */
        myimage2 = mypyramid.getGauss( i_level );
        myedge = mypyramid.getEdge( i_level );  
         
        /* Showing gaussian image at level */
        if ( myimage2 && myedge) {      
 
                printf("\nShowing level %d Gaussian image", i_level);
                myimage2->show( mag*i_level );
                printf("\nPress enter to continue .");
                getchar();

                printf("\nShowing level %d edge map", i_level);
                myedge->show( mag*i_level );
                printf("\nPress enter to continue.");
                getchar();
        }
        else
                printf("\nLevel specified is invalid.");

        printf("\nEnd of test\n");
}
\end{verbatim}

This example demonstrates how to access and display an edge map and Gaussian images of level of interest by {\tt getGauss} and {\tt getEdge}.

⌨️ 快捷键说明

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