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

📄 edge.tex

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

{\tt EDGE} is a class for operating image intensity to produce an edge map marking the location, strength and direction of edge points. The intensity gradient vectors are computed by fitting planes in 2x2 windows using the least squares method. For example, for a 2x2 image window as shown in Table 1.2, we have :

\begin{table}[thbp]
    \begin{center}
	\begin{tabular}{|c|c|} \hline
		$f_{11}$ & $f_{12}$ \\ \hline
		$f_{21}$ & $f_{22}$ \\ \hline
	\end{tabular}
     \end{center}
\caption{2 x 2 image window.}
\label{tbl:pe1}
\end{table}

\begin{eqnarray}
	d_{y} = \frac{1}{2}\left\{(f_{21}+f_{22}) - (f_{11}+f_{12})\right\} \\
	d_{x} = \frac{1}{2}\left\{(f_{12}+f_{22}) - (f_{11}+f_{21})\right\}
\end{eqnarray}

Thus the magnitude of intensity gradient at location $f_{11}$ is given by $({{d_{x}}^{2} + {d_{y}}^{2}})^{\frac{1}{2}}$, while the angle is given by ${tan}^{-1}\frac{dy}{dx}$.

{\tt EDGE} has the following defination :

\begin{verbatim}
            CLASS EDGE {
                  protected :
                      IMAGE *Mag;       /* magnitude */
                      IMAGE *Ang;       /* angle */
            }
\end{verbatim}

{\tt EDGE} object stores magnitude and direction of the edge gradient in the form of two images. This make them easy to experiment with various functions provided by {\tt IMAGE} class.

%
\subsection{EDGE constructor}

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

\subsubsection*{Description}
The constructor initializes the edge magnitude and angle image pointers to NULL.


%
\subsection{EDGE destructor}

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

\subsubsection*{Description}
The destructor frees memory allocated to the edge magnitude and angle image pointers. 


% 
\subsection{Resetting an {\tt EDGE} object}

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

\subsubsection*{Description}
{\tt reset} allows the reuse of {\tt EDGE} object. It frees memory allocated and set the edge magnitude and angle image pointers to NULL.


%
\subsection{Retrieving magnitude and angle of an edge point}

\subsubsection*{Synopsis}
\begin{verbatim}
	float getMag(int m, int n)
	float getAng(int m, int n)
\end{verbatim}

\subsubsection*{Arguments}
\begin{tabular} {ll}
	{\tt m, n} & Row and column coordinates of interest.
\end{tabular}

\subsubsection*{Returns}	
Edge magnitude or angle at location (m, n) of the edge matrix.

\subsubsection*{Description}
These methods allow accessing of the edge data. Attempts to get data from invalid coordinate will result in garbage data. 	


%
\subsection{Storing magnitude and angle of an edge point}

\subsubsection*{Synopsis}
\begin{verbatim}
	void putMag(int m, int n, float val)
	void putAng(int m, int n, float val)
\end{verbatim}

\subsubsection*{Arguments}
\begin{tabular} {ll}
	{\tt m, n} & Row and Column coordinates of interest.\\
	{\tt val}  & Data to be stored in location (m, n).
\end{tabular}

\subsubsection*{Description}
These methods store data in location (m, n) of edge magnitude or angle.


%
\subsection{Displaying edge map}

\subsubsection*{Synopsis}
\begin{verbatim}
	void show (unsigned char magnify = 1, int h_offset=0, int v_offset=0)
\end{verbatim}

\subsubsection*{Arguments}
\begin{tabular} {ll}
	{\tt magnify} & Magnification factor of the displayed image.\\
	{\tt h\_offset} & Horizontal offset of the image against the window
			 origin.\\
	{\tt v\_offset} & Vertical offset of the image against the window
			 origin.
\end{tabular}

\subsubsection*{Description}
{\tt show} generates and displays an X image for both the edge magnitude and angle images. {\tt show} will raise an X window for the display if the horizontal and vertical offsets are both 0. Otherwise, it will draw the specified X image without generating an X window. In this case, he user will have to ensure that an X window is up before displaying the image.



%
\subsection{Calculating the edge map}

\subsubsection*{Synopsis}
\begin{verbatim}
int compute(IMAGE *img, int verbose=1, double low_pct, double high_pct,
           double low_val, double high_val, double imm_pow)
\end{verbatim}

\subsubsection*{Arguments}
\begin{tabular}{ll}
	{\tt *img} & Input image in which the edge is to be computed.\\
	{\tt verbose} & Verbose Flag. On = 1 and off = 0.\\	
	{\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 of the mapping function.
\end{tabular}

\subsubsection*{Returns}
\begin{tabular} {ll}
	{\tt NOERROR}  &  No error. \\
	{\tt MEMORYERROR} & Memory allocation error.		
\end{tabular}

\subsubsection*{Description}
{\tt compute} generates the edge gradient magnitude and angle images by least square estimation. To increase robustness, we perform image conditioning for 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 good conditioning image. 


%
\subsection{Getting row and column of {\tt EDGE}}

\subsubsection*{Synopsis}
\begin{verbatim}
	int getRow(int MagData=1)
	int getCol(int MagData=1)
\end{verbatim}

\subsubsection*{Arguments}
\begin{tabular} {ll}
	{\tt MagData} & Indicates the choice of either magnitude (1) or angle
			(0) information. \\
\end{tabular}
			
\subsubsection*{Returns}
Row and column size of the magnitude or angle images.  
 
\subsubsection*{Description}
These methods provide a means of getting the row and column information.


%
\subsection{Example : Edge computation}

\begin{verbatim}
void testmain( char *imgfile,   /* image file */
               int mag )        /* magnification factor */
{
 
   IMAGE myimage;
   EDGE myedge;
 
   if (imgfile) myimage.read(imgfile);
   else {
         /* Create a sample image of 3 rows of different intensities */
 
         int i,j,row,col;
  
         row = 90;
         col = 90;
  
        printf("\nCreating demo image...\n");
         
        myimage.init(row,col);
    
        for(i=0;i<row;i++)
                for(j=0;j<col;j++)
                        myimage.put(i,j,20);
                 
        for(i=20;i<70;i++)
                for(j=20;j<70;j++)
                        myimage.put(i,j,70);
 
        for(i=30;i<60;i++)

                for(j=30;j<60;j++)
                        myimage.put(i,j,150);
   }

   myimage.show(mag);
   printf("\nShowing image. Press enter to see edge .");
   getchar();

   /* Computing and showing edge */
   /* Default parameters are used. Verbose mode */
   myedge.compute(&myimage, 1);
   myedge.show(mag);
   printf("\nPress enter to continue.");
   getchar();
   printf("End of test.\n");
}
\end{verbatim}
	
This program creates {\tt IMAGE} and {\tt EDGE} classes. If no image file is specified, a demo image will be generated. By calling {\tt compute} and {\tt show}, the edge gradient is calculated from the input or sampple image and then displayed on an X window.

⌨️ 快捷键说明

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