📄 image.tex
字号:
function.
\end{tabular}
\subsubsection*{Description}
{\tt condition} performs image conditioning based on the histogram specification of an image. The transformation function is as following :
\eq
T_{k} = \left\{
\begin{array}{ll}
\frac{C_{k} low\_val}{low\_pct} & ;C_{k} < low\_val \\
(high\_val -low\_val)(\frac{C_{k} - low\_pct}{high\_pct -
low\_pct})^{imm\_pow} + low\_val &
;low\_val< C_{k} < high\_val\\
(1 - high\_val) (\frac{C_{k} - high\_pct}{1 -
high\_pct})^{imm\_pow}
+ high\_val & ;\mbox{Otherwise}
\end{array}
\right.
\en
where $C_{k}$ is the culmulative distribution function of histogram. Notice that histogram equalization can be achieved by setting {\tt low\_pct} $= 0$, {\tt high\_pct} $= 1$, {\tt low\_val} $= 0$, {\tt high\_val} $= 1$ and {\tt imm\_pow} $= 1$.
%
\subsection{Image correlation}
\subsubsection*{Synopsis}
\begin{verbatim}
IMAGE *correlate (IMAGE *InputImg, int RowStep, int ColStep,
char verbose=0)
\end{verbatim}
\subsubsection*{Arguments}
\begin{tabular}{ll}
{\tt *InputImg} & Pointer to the correlating image template. \\
{\tt RowStep,}
{\tt ColStep} & Pixel spacing where the correlating template will be shifted
each step.
\end{tabular}
\subsubsection*{Returns}
Pointer to a new correlated image. Returns NULL if memory allocation failed.
\subsubsection*{Description}
{\tt correlate} performs pixel-to-pixel correlation by calculating the inner product between the image template and data. The template will be shifted horizontally and vertically by {\tt ColStep} and {\tt Rowstep} each time.
%
\subsection{X window image generation}
\subsubsection*{Synopsis}
\begin{verbatim}
void generateX(unsigned char blowup=1)
\end{verbatim}
\subsubsection*{Arguments}
\begin{tabular}{ll}
{\tt blowup} & Image magnification factor.
\end{tabular}
\subsubsection*{Description}
{\tt generateX} creates an X image without displaying it on the screen.
%
\subsection{Cutting an image segment}
\subsubsection*{Synopsis}
\begin{verbatim}
IMAGE *IMAGE::cut(int sx, int sy, int height, int length)
\end{verbatim}
\subsubsection*{Arguments}
\begin{tabular}{ll}
{\tt sx, sy} & Top left corner of the new copied image.\\
{\tt height} & Height of the new copied image.\\
{\tt length} & Length of the new copied image.
\end{tabular}
\subsubsection*{Returns}
Pointer to a new copied image. Returns NULL if memory allocation fails.
\subsubsection*{Description}
{\tt cut} allows an image segment to be cut out from the image data. If the dimensions given are larger than the original image, {\tt cut} will select the maximun possible dimension which originated at ({\tt sx, sy}).
%
\subsection{Copying an image}
\subsubsection*{Synopsis}
\begin{verbatim}
IMAGE *IMAGE::copy()
\end{verbatim}
\subsubsection*{Returns}
Pointer to a new copied {\tt IMAGE} object. Returns NULL if memory allocation fails.
\subsubsection*{Description}
{\tt copy} duplicates the {\tt IMAGE} object.
%
\subsection{Filling of an area of image}
\subsubsection*{Synopsis}
\begin{verbatim}
int fill(float val, int sx=0, int sy=0, int length=0, int height=0)
\end{verbatim}
\subsubsection*{Arguments}
\tb
%\begin{tabular}{ll}
{\tt val } & Pixel value.\\
{\tt sx, sy} & Top left corner of the filled image segment.\\
{\tt height} & Height of the filled image segment.\\
{\tt length} & Length of the filled image segment.
\te
%\end{tabular}
\subsubsection*{Returns}
\tb
{\tt NOERROR} & Segment filled successfully. \\
{\tt PARAMERROR} & Illegal parameter values used.
\te
\subsubsection*{Description}
{\tt fill} initializes an image area to the given pixel value.
\subsection{Example : Reading, writing and correlation of images}
This program performs correlation between the input image and template. The correlated image will be displayed on an X window and written to an output file.
\begin{verbatim}
void testmain( char *imgfile, /* input image file */
char *tmpfile, /* image template */
char *outfile, /* output image file */
int mag ) /* magnification factor */
{
IMAGE test1,test2;
IMAGE *test3;
/* Read test images */
if (test1.read(imgfile)) exit(-1);
printf("Showing test image : %s",imgfile);
test1.show(mag);
/* If user did not specify template image, use a gaussian template */
if (tmpfile) {
if( test2.read(tmpfile) ) exit( -1 );
}
else
test2.initAsGauss();
test2.show(mag);
printf("\nCorrelating image..");
test3=test1.correlate(&test2,2,2,1);
/* Show all three images horizontally */
/* Allocate window space for three images */
test1.show(mag,3,0,0);
/* Show images with offsets */
test2.show(mag,1,test1.getCol());
test3->show(mag,1,test2.getCol()+test1.getCol());
printf("\nPress enter to continue ");
getchar();
/* write result to file */
if (outfile)
test3->write(outfile) ;
else
test3->write("out.bin");
printf("End of test.");
xwin_close();
}
\end{verbatim}
First, an input image will be read. If there is no template image, {\tt initAsGauss} will create a 3 by 3 Gausian kernal. The resulting image, {\tt test3}, is returned by {\tt correlate} and displayed together with the input image and template by {\tt show}.
\subsection{Example : Histogram specification of an image}
\begin{verbatim}
void testmain( char *imgfile, /* input image file */
int blowup, /* magnification factor */
float lp , float hp, /* percentage range */
float lv, float hv, /* intensity range */
float ep ) /* exponential power */
{
IMAGE myimage;
if ( !(myimage.read(imgfile)) ) {
printf("Displaying image .... \n\n");
printf("Histogram Specification parameters :\n");
printf("\n Low Percent:%f High Percent:%f",lp,hp);
printf("\n Low Value :%f High Value :%f",lv,hv);
printf("\n Exponent :%f Magnification:%d",ep,blowup);
myimage.show(blowup,2);
myimage.condition(lp,hp,lv,hv,ep);
printf("Displaying conditioned image ... Press enter to continue\n");
myimage.show(blowup,1,myimage.getCol()*blowup);
getchar();
xwin_close();
}
}
\end{verbatim}
Histogram specification is done by calling {\tt condition}. With appropriate input parameters, it can either perform noise reduction or image enhancement. In this program, the conditioned and input image will be displayed side by side on an X window.
\subsection{Example : Cutting and copying of image segments}
\begin{verbatim}
void testmain( char *imgfile, /* input image file */
char *outfile, /* output image file */
int mag ) /* magnification factor */
{
IMAGE test1;
IMAGE *test2,*test3;
int sx, sy, length, height;
/* Read image file */
if (test1.read(imgfile) ) exit(-1);
printf("Showing test1 : %s",imgfile);
test1.show(mag);
/* Using X windows to select an image segment */
xwin_SelRegion( &sx,&sy,&length,&height);
test2 = test1.cut(sx/mag ,sy/mag ,length/mag, height/mag);
/* Copy image*/
test3 = test2->copy();
/* Show images in line */
printf("\nShowing cut image and copied image ");
test2->show(mag,2);
test3->show(mag,1,test2->getCol());
printf("\nPress enter to continue...");
getchar();
if (outfile) {
printf("\nWriting to file %s",outfile);
test3->write(outfile);
}
printf("End of test..");
xwin_close();
}
\end{verbatim}
This program uses X window interface, {\tt xwin\_SelRegion}, to select an image segment and then cut it. This segment is finally copied to another image segment.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -