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

📄 opencv image processing and computer vision reference manual.mht

📁 比较齐全的OpenCV参考手册
💻 MHT
📖 第 1 页 / 共 5 页
字号:
single-channel,=20
  32-bit integer or double precision floating-point (64f).=20
  <DT>sqsum
  <DD>The integral image for squared pixel values,=20
  <CODE>W+1</CODE>=A1=C1<CODE>H+1</CODE>, single-channel, double =
precision=20
  floating-point (64f).=20
  <DT>tilted_sum
  <DD>The integral for the image rotated by 45 degrees,=20
  <CODE>W+1</CODE>=A1=C1<CODE>H+1</CODE>, single-channel, the same data =
type as=20
  <CODE>sum</CODE>. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvIntegral">cvIntegral</A>=20
calculates one or more integral images for the source image as =
following:</P><PRE>sum(X,Y)=3Dsum<SUB>x&lt;X,y&lt;Y</SUB>image(x,y)

sqsum(X,Y)=3Dsum<SUB>x&lt;X,y&lt;Y</SUB>image(x,y)<SUP>2</SUP>

tilted_sum(X,Y)=3Dsum<SUB>y&lt;Y,abs(x-X)&lt;y</SUB>image(x,y)
</PRE>
<P>Using these integral images, one may calculate sum, mean, standard =
deviation=20
over arbitrary pixel up-right or rotated rectangle in O(1), for =
example:</P><PRE>sum<SUB>x1&lt;=3Dx&lt;x2,y1&lt;=3Dy&lt;y2</SUB>image(x,y=
)=3Dsum(x2,y2)-sum(x1,y2)-sum(x2,y1)+sum(x1,x1)
</PRE>
<P>It makes possible to do a fast blurring or fast block correlation =
with=20
variable window size etc. </P>
<HR>

<H3><A name=3Ddecl_cvCvtColor>CvtColor</A></H3>
<P class=3DBlurb>Converts image from one color space to =
another</P><PRE>void cvCvtColor( const CvArr* src, CvArr* dst, int code =
);
</PRE>
<P>
<DL>
  <DT>src
  <DD>The source 8-bit or floating-point image.=20
  <DT>dst
  <DD>The destination 8-bit or floating-point image.=20
  <DT>code
  <DD>Color conversion operation that can be specifed using=20
  CV_&lt;src_color_space&gt;2&lt;dst_color_space&gt; constants (see =
below).=20
</DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvCvtColor">cvCvtColor</A>=20
converts input image from one color space to another. The function =
ignores=20
<CODE>colorModel</CODE> and <CODE>channelSeq</CODE> fields of=20
<CODE>IplImage</CODE> header, so the source image color space should be=20
specified correctly (including order of the channels in case of RGB =
space, e.g.=20
BGR means 24-bit format with B<SUB>0</SUB> G<SUB>0</SUB> R<SUB>0</SUB>=20
B<SUB>1</SUB> G<SUB>1</SUB> R<SUB>1</SUB> ... layout, whereas RGB means=20
24-format with R<SUB>0</SUB> G<SUB>0</SUB> B<SUB>0</SUB> R<SUB>1</SUB>=20
G<SUB>1</SUB> B<SUB>1</SUB> ... layout). The function can do the =
following=20
transformations:
<UL>
  <LI>Transformations within RGB space like adding/removing alpha =
channel,=20
  reversing the channel order, conversion to/from 16-bit RGB color =
(Rx5:Gx6:Rx5)=20
  color, 15-bit RGB color as well as conversion to/from grayscale using: =
<PRE>RGB[A]-&gt;Gray: Y=3D0.212671*R + 0.715160*G + 0.072169*B + 0*A
Gray-&gt;RGB[A]: R=3DY G=3DY B=3DY A=3D0
</PRE>All the possible combinations of input and output format are =
allowed=20
  here.=20
  <P></P>
  <LI>RGB&lt;=3D&gt;XYZ (CV_BGR2XYZ, CV_RGB2XYZ, CV_XYZ2BGR, =
CV_XYZ2RGB): <PRE>|X|   |0.412411  0.357585  0.180454| |R|
|Y| =3D |0.212649  0.715169  0.072182|*|G|
|Z|   |0.019332  0.119195  0.950390| |B|

|R|   | 3.240479  -1.53715  -0.498535| |X|
|G| =3D |-0.969256   1.875991  0.041556|*|Y|
|B|   | 0.055648  -0.204043  1.057311| |Z|
</PRE>
  <P></P>
  <LI>RGB&lt;=3D&gt;YCrCb (CV_BGR2YCrCb, CV_RGB2YCrCb, CV_YCrCb2BGR, =
CV_YCrCb2RGB)=20
<PRE>Y=3D0.299*R + 0.587*G + 0.114*B
Cr=3D(R-Y)*0.713 + 128
Cb=3D(B-Y)*0.564 + 128

R=3DY + 1.403*(Cr - 128)
G=3DY - 0.344*(Cr - 128) - 0.714*(Cb - 128)
B=3DY + 1.773*(Cb - 128)
</PRE>
  <P></P>
  <LI>RGB=3D&gt;HSV (CV_BGR2HSV,CV_RGB2HSV) <PRE>V=3Dmax(R,G,B)
S=3D(V-min(R,G,B))*255/V   if V!=3D0, 0 otherwise

       (G - B)*60/S,  if V=3DR
H=3D 180+(B - R)*60/S,  if V=3DG
   240+(R - G)*60/S,  if V=3DB

if H&lt;0 then H=3DH+360
</PRE>
  <P>The hue values calcualted using the above formulae vary from =
0=A1=E3 to 360=A1=E3 so=20
  they are divided by 2 to fit into 8 bits. </P>
  <P></P>
  <LI>RGB=3D&gt;Lab (CV_BGR2Lab, CV_RGB2Lab) <PRE>|X|   |0.433910  =
0.376220  0.189860| |R/255|
|Y| =3D |0.212649  0.715169  0.072182|*|G/255|
|Z|   |0.017756  0.109478  0.872915| |B/255|

L =3D 116*Y<SUP>1/3</SUP>      for Y&gt;0.008856
L =3D 903.3*Y      for Y&lt;=3D0.008856

a =3D 500*(f(X)-f(Y))
b =3D 200*(f(Y)-f(Z))
where f(t)=3Dt<SUP>1/3</SUP>              for t&gt;0.008856
      f(t)=3D7.787*t+16/116   for t&lt;=3D0.008856
</PRE>The above formulae have been taken from <A=20
  =
href=3D"http://www.cica.indiana.edu/cica/faq/color_spaces/color.spaces.ht=
ml">http://www.cica.indiana.edu/cica/faq/color_spaces/color.spaces.html</=
A>=20

  <P></P>
  <LI>Bayer=3D&gt;RGB (CV_BayerBG2BGR, CV_BayerGB2BGR, CV_BayerRG2BGR,=20
  CV_BayerGR2BGR,<BR>CV_BayerBG2RGB, CV_BayerRG2BGR, CV_BayerGB2RGB,=20
  CV_BayerGR2BGR,<BR>CV_BayerRG2RGB, CV_BayerBG2BGR, CV_BayerGR2RGB,=20
  CV_BayerGB2BGR)=20
  <P>Bayer pattern is widely used in CCD and CMOS cameras. It allows to =
get=20
  color picture out of a single plane where R,G and B pixels (sensors of =
a=20
  particular component) are interleaved like this:</P>
  <P>
  <TABLE width=3D400 border=3D0>
    <TBODY>
    <TR>
      <TD><FONT color=3D#ff0000 size=3D5>
        <P align=3Dcenter>R</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#ff0000 size=3D5>
        <P align=3Dcenter>R</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#ff0000 size=3D5>
        <P align=3Dcenter>R</FONT></P></TD></TR>
    <TR>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD bgColor=3Dpink><FONT color=3D#0000ff size=3D5>
        <P align=3Dcenter>B</FONT></P></TD>
      <TD bgColor=3Dpink><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#0000ff size=3D5>
        <P align=3Dcenter>B</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD></TR>
    <TR>
      <TD><FONT color=3D#ff0000 size=3D5>
        <P align=3Dcenter>R</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#ff0000 size=3D5>
        <P align=3Dcenter>R</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#ff0000 size=3D5>
        <P align=3Dcenter>R</FONT></P></TD></TR>
    <TR>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#0000ff size=3D5>
        <P align=3Dcenter>B</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#0000ff size=3D5>
        <P align=3Dcenter>B</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD></TR>
    <TR>
      <TD><FONT color=3D#ff0000 size=3D5>
        <P align=3Dcenter>R</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#ff0000 size=3D5>
        <P align=3Dcenter>R</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#ff0000 size=3D5>
        <P align=3Dcenter>R</FONT></P></TD></TR>
    <TR>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#0000ff size=3D5>
        <P align=3Dcenter>B</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD>
      <TD><FONT color=3D#0000ff size=3D5>
        <P align=3Dcenter>B</FONT></P></TD>
      <TD><FONT color=3D#008000 size=3D5>
        <P align=3Dcenter>G</FONT></P></TD></TR></TBODY></TABLE></P>
  <P>The output RGB components of a pixel are interpolated from 1, 2 or =
4=20
  neighbors of the pixel having the same color. There are several =
modifications=20
  of the above pattern that can be achieved by shifting the pattern one =
pixel=20
  left and/or one pixel up. The two letters C<SUB>1</SUB> and =
C<SUB>2</SUB> in=20
  the conversion constants CV_BayerC<SUB>1</SUB>C<SUB>2</SUB>2{BGR|RGB} =
indicate=20
  the particular pattern type - these are components from the second =
row, second=20
  and third columns, respectively. For example, the above pattern has =
very=20
  popular "BG" type.</P></LI></UL>
<P></P>
<HR>

<H3><A name=3Ddecl_cvThreshold>Threshold</A></H3>
<P class=3DBlurb>Applies fixed-level threshold to array =
elements</P><PRE>void cvThreshold( const CvArr* src, CvArr* dst, double =
threshold,
                  double max_value, int threshold_type );
</PRE>
<P>
<DL>
  <DT>src
  <DD>Source array (single-channel, 8-bit of 32-bit floating point).=20
  <DT>dst
  <DD>Destination array; must be either the same type as =
<CODE>src</CODE> or=20
  8-bit.=20
  <DT>threshold
  <DD>Threshold value.=20
  <DT>max_value
  <DD>Maximum value to use with <CODE>CV_THRESH_BINARY</CODE> and=20
  <CODE>CV_THRESH_BINARY_INV</CODE> thresholding types.=20
  <DT>threshold_type
  <DD>Thresholding type (see the discussion) </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvThreshold">cvThreshold</A>=20
applies fixed-level thresholding to single-channel array. The function =
is=20
typically used to get bi-level (binary) image out of grayscale image (<A =

href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvCmpS">cvCmpS</A>=20
could be also used for this purpose) or for removing a noise, i.e. =
filtering out=20
pixels with too small or too large values. There are several types of=20
thresholding the function supports that are determined by=20
<CODE>threshold_type</CODE>:</P><PRE>threshold_type=3DCV_THRESH_BINARY:
dst(x,y) =3D max_value, if src(x,y)&gt;threshold
           0, otherwise

threshold_type=3DCV_THRESH_BINARY_INV:
dst(x,y) =3D 0, if src(x,y)&gt;threshold
           max_value, otherwise

threshold_type=3DCV_THRESH_TRUNC:
dst(x,y) =3D threshold, if src(x,y)&gt;threshold
           src(x,y), otherwise

threshold_type=3DCV_THRESH_TOZERO:
dst(x,y) =3D src(x,y), if (x,y)&gt;threshold
           0, otherwise

threshold_type=3DCV_THRESH_TOZERO_INV:
dst(x,y) =3D 0, if src(x,y)&gt;threshold
           src(x,y), otherwise
</PRE>
<P>And this is the visual description of thresholding types:</P>
<P><IMG=20
src=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_docs=
/ref/pics/threshold.png"=20
align=3Dcenter> </P>
<P></P>
<HR>

<H3><A name=3Ddecl_cvAdaptiveThreshold>AdaptiveThreshold</A></H3>
<P class=3DBlurb>Applies adaptive threshold to array</P><PRE>void =
cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
                          int =
adaptive_method=3DCV_ADAPTIVE_THRESH_MEAN_C,
                          int threshold_type=3DCV_THRESH_BINARY,
                          int block_size=3D3, double param1=3D5 );
</PRE>
<P>
<DL>
  <DT>src
  <DD>Source image.=20
  <DT>dst
  <DD>Destination image.=20
  <DT>max_value
  <DD>Maximum value that is used with <CODE>CV_THRESH_BINARY</CODE> and=20
  <CODE>CV_THRESH_BINARY_INV</CODE>.=20
  <DT>adaptive_method
  <DD>Adaptive thresholding algorithm to use:=20
  <CODE>CV_ADAPTIVE_THRESH_MEAN_C</CODE> or=20
  <CODE>CV_ADAPTIVE_THRESH_GAUSSIAN_C</CODE> (see the discussion).=20
  <DT>threshold_type
  <DD>Thresholding type; must be one of=20
  <UL>
    <LI><CODE>CV_THRESH_BINARY,</CODE>=20
    <LI><CODE>CV_THRESH_BINARY_INV</CODE> </LI></UL>
  <DT>block_size
  <DD>The size of a pixel neighborhood that is used to calculate a =
threshold=20
  value for the pixel: 3, 5, 7, ...=20
  <DT>param1
  <DD>The method-dependent parameter. For the methods=20
  <CODE>CV_ADAPTIVE_THRESH_MEAN_C</CODE> and=20
  <CODE>CV_ADAPTIVE_THRESH_GAUSSIAN_C</CODE> it is a constant subtracted =
from=20
  mean or weighted mean (see the discussion), though it may be negative. =

</DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvAdaptiveThreshold">cvAdaptiveThreshold</A> =

transforms grayscale image to binary image according to the =
formulae:</P><PRE>threshold_type=3D<CODE>CV_THRESH_BINARY</CODE>:
dst(x,y) =3D max_value, if src(x,y)&gt;T(x,y)
           0, otherwise

threshold_type=3D<CODE>CV_THRESH_BINARY_INV</CODE>:
dst(x,y) =3D 0, if src(x,y)&gt;T(x,y)
           max_value, otherwise
</PRE>
<P>where T<SUB>I</SUB> is a threshold calculated individually for each=20
pixel.</P>
<P>For the method <CODE>CV_ADAPTIVE_THRESH_MEAN_C</CODE> it is a mean of =

<CODE>block_size</CODE> =A1=C1 <CODE>block_size</CODE> pixel =
neighborhood, subtracted=20
by <CODE>param1</CODE>.</P>
<P>For the method <CODE>CV_ADAPTIVE_THRESH_GAUSSIAN_C</CODE> it is a =
weighted=20
sum (gaussian) of <CODE>block_si

⌨️ 快捷键说明

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