?? opencv 圖像處理和計算機視覺參考手冊.htm
字號:
<TR>
<TD><FONT color=#ff0000 size=5>
<P align=center>R</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#ff0000 size=5>
<P align=center>R</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#ff0000 size=5>
<P align=center>R</FONT></P></TD></TR>
<TR>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD bgColor=pink><FONT color=#0000ff size=5>
<P align=center>B</FONT></P></TD>
<TD bgColor=pink><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#0000ff size=5>
<P align=center>B</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD></TR>
<TR>
<TD><FONT color=#ff0000 size=5>
<P align=center>R</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#ff0000 size=5>
<P align=center>R</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#ff0000 size=5>
<P align=center>R</FONT></P></TD></TR>
<TR>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#0000ff size=5>
<P align=center>B</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#0000ff size=5>
<P align=center>B</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD></TR>
<TR>
<TD><FONT color=#ff0000 size=5>
<P align=center>R</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#ff0000 size=5>
<P align=center>R</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#ff0000 size=5>
<P align=center>R</FONT></P></TD></TR>
<TR>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#0000ff size=5>
<P align=center>B</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD>
<TD><FONT color=#0000ff size=5>
<P align=center>B</FONT></P></TD>
<TD><FONT color=#008000 size=5>
<P align=center>G</FONT></P></TD></TR></TBODY></TABLE>
<P>對象素輸出的RGB分量由該象素的1、2或者4鄰域中具有相同顏色的點插值得到。以上的模式可以通過向左或者向上平移一個像素點來作一些修改。轉換常量CV_BayerC1C22{RGB|RGB}中的兩個字母C1和C2表示特定的模式類型:顏色分量分別來自于第二行,第二和第三列。比如說,上述的模式具有很流行的"BG"類型。</P></LI></UL>
<HR>
<H3><A name=decl_cvThreshold>Threshold</A></H3>
<P class=Blurb>對數組元素進行固定閾值操作</P><PRE>void cvThreshold( const CvArr* src, CvArr* dst, double threshold,
double max_value, int threshold_type );
</PRE>
<P>
<DL>
<DT>src
<DD>原始數組 (單通道, 8-比特 of 32-比特 浮點數).
<DT>dst
<DD>輸出數組,必須與 <CODE>src</CODE> 的類型一致,或者為 8-比特.
<DT>threshold
<DD>閾值
<DT>max_value
<DD>使用 <CODE>CV_THRESH_BINARY</CODE> 和 <CODE>CV_THRESH_BINARY_INV</CODE> 的最大值.
<DT>threshold_type
<DD>閾值類型 (見討論) </DD></DL>
<P>函數 <A
href="http://fsa.ia.ac.cn/opencv-doc-cn/opencv-doc-cn-0.9.7/ref/opencvref_cv.cn.htm#decl_cvThreshold">cvThreshold</A>
對單通道數組應用固定閾值操作。該函數的典型應用是對灰度圖像進行閾值操作得到二值圖像。(<A
href="http://fsa.ia.ac.cn/opencv-doc-cn/opencv-doc-cn-0.9.7/ref/opencvref_cxcore.htm#decl_cvCmpS">cvCmpS</A>
也可以達到此目的) 或者是去掉噪聲,例如過濾很小或很大象素值的圖像點。本函數支持的對圖像取閾值的方法由 <CODE>threshold_type
確定</CODE>:</P><PRE>threshold_type=CV_THRESH_BINARY:
dst(x,y) = max_value, if src(x,y)>threshold
0, otherwise
threshold_type=CV_THRESH_BINARY_INV:
dst(x,y) = 0, if src(x,y)>threshold
max_value, otherwise
threshold_type=CV_THRESH_TRUNC:
dst(x,y) = threshold, if src(x,y)>threshold
src(x,y), otherwise
threshold_type=CV_THRESH_TOZERO:
dst(x,y) = src(x,y), if (x,y)>threshold
0, otherwise
threshold_type=CV_THRESH_TOZERO_INV:
dst(x,y) = 0, if src(x,y)>threshold
src(x,y), otherwise
</PRE>
<P>下面是圖形化的閾值描述:</P>
<P><IMG src="OpenCV 圖像處理和計算機視覺參考手冊.files/threshold.png" align=center> </P>
<HR>
<H3><A name=decl_cvAdaptiveThreshold>AdaptiveThreshold</A></H3>
<P class=Blurb>自適應閾值方法</P><PRE>void cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
int adaptive_method=CV_ADAPTIVE_THRESH_MEAN_C,
int threshold_type=CV_THRESH_BINARY,
int block_size=3, double param1=5 );
</PRE>
<P>
<DL>
<DT>src
<DD>輸入圖像.
<DT>dst
<DD>輸出圖像.
<DT>max_value
<DD>使用 <CODE>CV_THRESH_BINARY</CODE> 和 <CODE>CV_THRESH_BINARY_INV</CODE> 的最大值.
<DT>adaptive_method
<DD>自適應閾值算法使用:<CODE>CV_ADAPTIVE_THRESH_MEAN_C</CODE> 或
<CODE>CV_ADAPTIVE_THRESH_GAUSSIAN_C</CODE> (見討論).
<DT>threshold_type
<DD>取閾值類型:必須是下者之一
<UL>
<LI><CODE>CV_THRESH_BINARY,</CODE>
<LI><CODE>CV_THRESH_BINARY_INV</CODE> </LI></UL>
<DT>block_size
<DD>用來計算閾值的象素鄰域大小: 3, 5, 7, ...
<DT>param1
<DD>與方法有關的參數。對方法 <CODE>CV_ADAPTIVE_THRESH_MEAN_C</CODE> 和
<CODE>CV_ADAPTIVE_THRESH_GAUSSIAN_C</CODE>, 它是一個從均值或加權均值提取的常數(見討論), 盡管它可以是負數。
</DD></DL>
<P>函數 <A
href="http://fsa.ia.ac.cn/opencv-doc-cn/opencv-doc-cn-0.9.7/ref/opencvref_cv.cn.htm#decl_cvAdaptiveThreshold">cvAdaptiveThreshold</A>
將灰度圖像變換到二值圖像,采用下面公式:</P><PRE>threshold_type=<CODE>CV_THRESH_BINARY</CODE>:
dst(x,y) = max_value, if src(x,y)>T(x,y)
0, otherwise
threshold_type=<CODE>CV_THRESH_BINARY_INV</CODE>:
dst(x,y) = 0, if src(x,y)>T(x,y)
max_value, otherwise
</PRE>
<P>其中 T<SUB>I</SUB> 是為每一個象素點單獨計算的閾值</P>
<P>對方法 CV_ADAPTIVE_THRESH_MEAN_C,先求出塊中的均值,再減掉param1。</P>
<P>對方法 CV_ADAPTIVE_THRESH_GAUSSIAN_C ,先求出塊中的加權和(gaussian), 再減掉param1。</P>
<HR>
<H2><A name=cv_imgproc_pyramids>金字塔及其應用</A></H2>
<HR>
<H3><A name=decl_cvPyrDown>PyrDown</A></H3>
<P class=Blurb>圖像的下采樣</P><PRE>void cvPyrDown( const CvArr* src, CvArr* dst, int filter=CV_GAUSSIAN_5x5 );
</PRE>
<P>
<DL>
<DT>src
<DD>輸入圖像.
<DT>dst
<DD>輸出圖像, 寬度和高度應是輸入圖像的一半
<DT>filter
<DD>卷積濾波器的類型,目前僅支持 <CODE>CV_GAUSSIAN_5x5</CODE> </DD></DL>
<P>函數 <A
href="http://fsa.ia.ac.cn/opencv-doc-cn/opencv-doc-cn-0.9.7/ref/opencvref_cv.cn.htm#decl_cvPyrDown">cvPyrDown</A>
使用 Gaussian 金字塔分解對輸入圖像向下采樣。首先它對輸入圖像用指定濾波器進行卷積,然后通過拒絕偶數的行與列來下采樣圖像。</P>
<HR>
<H3><A name=decl_cvPyrUp>PyrUp</A></H3>
<P class=Blurb>圖像的上采樣</P><PRE>void cvPyrUp( const CvArr* src, CvArr* dst, int filter=CV_GAUSSIAN_5x5 );
</PRE>
<DL>
<DT>src
<DD>輸入圖像.
<DT>dst
<DD>輸出圖像, 寬度和高度應是輸入圖像的2倍
<DT>filter
<DD>卷積濾波器的類型,目前僅支持 <CODE>CV_GAUSSIAN_5x5</CODE> </DD></DL>
<P>函數 <A
href="http://fsa.ia.ac.cn/opencv-doc-cn/opencv-doc-cn-0.9.7/ref/opencvref_cv.cn.htm#decl_cvPyrUp">cvPyrUp</A>
使用Gaussian 金字塔分解對輸入圖像向上采樣。首先通過在圖像中插入 0
偶數行和偶數列,然后對得到的圖像用指定的濾波器進行高斯卷積,其中濾波器乘以4做差值。所以輸出圖像是輸入圖像的 4 倍大小。(<A
href="http://www.assuredigit.com/">hunnish</A>: 原理不清楚,尚待探討)</P>
<HR>
<H3><A name=decl_cvPyrSegmentation>PyrSegmentation</A></H3>
<P class=Blurb>用金字塔實現圖像分割</P><PRE>void cvPyrSegmentation( IplImage* src, IplImage* dst,
CvMemStorage* storage, CvSeq** comp,
int level, double threshold1, double threshold2 );
</PRE>
<P>
<DL>
<DT>src
<DD>輸入圖像.
<DT>dst
<DD>輸出圖像.
<DT>storage
<DD>Storage: 存儲連通部件的序列結果
<DT>comp
<DD>分割部件的輸出序列指針 components.
<DT>level
<DD>建立金字塔的最大層數
<DT>threshold1
<DD>建立連接的錯誤閾值
<DT>threshold2
<DD>分割簇的錯誤閾值 </DD></DL>
<P>函數 <A
href="http://fsa.ia.ac.cn/opencv-doc-cn/opencv-doc-cn-0.9.7/ref/opencvref_cv.cn.htm#decl_cvPyrSegmentation">cvPyrSegmentation</A>
實現了金字塔方法的圖像分割。金字塔建立到 <CODE>level</CODE> 指定的最大層數。如果
<CODE>p(c(a),c(b))<threshold1</CODE>,則在層 i 的象素點 a 和它的相鄰層的父親象素 b 之間的連接被建立起來,
<DIV>
<P>定義好連接部件后,它們被加入到某些簇中。如果<CODE>p(c(A),c(B))<threshold2</CODE><CODE>,</CODE>則任何兩個分割
A 和 B 屬于同一簇。</P>
<DIV>
<P>如果輸入圖像只有一個通道,那么</P>
<DIV><CODE> p(c¹,c²)=|c¹-c²|</CODE>.
<P>如果輸入圖像有單個通道(紅、綠、蘭),那么 </P>
<DIV><CODE>
p(c¹,c²)=0,3·(c¹<SUB>r</SUB>-c²<SUB>r</SUB>)+0,59·(c¹<SUB>g</SUB>-c²<SUB>g</SUB>)+0,11·(c¹<SUB>b</SUB>-c²<SUB>b</SUB>)
</CODE>.
<P>每一個簇可以有多個連接部件。</P>
<DIV>圖像 <CODE>src</CODE> 和 <CODE>dst</CODE> 應該是 8-比特、單通道 或 3-通道圖像,且大小一樣
<HR>
<H2><A name=cv_imgproc_ccomp>連接部件</A></H2>
<HR>
<H3><A name=decl_CvConnectedComp>CvConnectedComp</A></H3>
<P class=Blurb>連接部件</P><PRE> typedef struct CvConnectedComp
{
double area; /* 連通域的面積 */
float value; /* 分割域的灰度縮放值 */
CvRect rect; /* 分割域的 ROI */
} CvConnectedComp;
</PRE>
<HR>
<H3><A name=decl_cvFloodFill>FloodFill</A></H3>
<P class=Blurb>用指定顏色填充一個連接域</P><PRE>void cvFloodFill( CvArr* image, CvPoint seed_point, CvScalar new_val,
CvScalar lo_diff=cvScalarAll(0), CvScalar up_diff=cvScalarAll(0),
CvConnectedComp* comp=NULL, int flags=4, CvArr* mask=NULL );
#define CV_FLOODFILL_FIXED_RANGE (1 << 16)
#define CV_FLOODFILL_MASK_ONLY (1 << 17)
</PRE>
<P>
<DL>
<DT>image
<DD>輸入的 1- 或 3-通道, 8-比特或浮點數圖像。輸入的圖像將被函數的操作所改變,除非你選則 CV_FLOODFILL_MASK_ONLY 選項
(見
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -