mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 05:29:54 +08:00
Merge pull request #956 from IanVS:COLOR_CODE
This commit is contained in:
commit
0a42a3eb06
@ -1475,7 +1475,7 @@ Such a scheme makes the memory management robust and efficient at the same time
|
||||
Mat color;
|
||||
...
|
||||
Mat gray(color.rows, color.cols, color.depth());
|
||||
cvtColor(color, gray, CV_BGR2GRAY);
|
||||
cvtColor(color, gray, COLOR_BGR2GRAY);
|
||||
|
||||
|
||||
you can simply write: ::
|
||||
@ -1483,7 +1483,7 @@ you can simply write: ::
|
||||
Mat color;
|
||||
...
|
||||
Mat gray;
|
||||
cvtColor(color, gray, CV_BGR2GRAY);
|
||||
cvtColor(color, gray, COLOR_BGR2GRAY);
|
||||
|
||||
|
||||
because ``cvtColor`` , as well as the most of OpenCV functions, calls ``Mat::create()`` for the output array internally.
|
||||
|
@ -128,7 +128,7 @@ Example: ::
|
||||
return 0;
|
||||
}
|
||||
|
||||
The array ``frame`` is automatically allocated by the ``>>`` operator since the video frame resolution and the bit-depth is known to the video capturing module. The array ``edges`` is automatically allocated by the ``cvtColor`` function. It has the same size and the bit-depth as the input array. The number of channels is 1 because the color conversion code ``CV_BGR2GRAY`` is passed, which means a color to grayscale conversion. Note that ``frame`` and ``edges`` are allocated only once during the first execution of the loop body since all the next video frames have the same resolution. If you somehow change the video resolution, the arrays are automatically reallocated.
|
||||
The array ``frame`` is automatically allocated by the ``>>`` operator since the video frame resolution and the bit-depth is known to the video capturing module. The array ``edges`` is automatically allocated by the ``cvtColor`` function. It has the same size and the bit-depth as the input array. The number of channels is 1 because the color conversion code ``COLOR_BGR2GRAY`` is passed, which means a color to grayscale conversion. Note that ``frame`` and ``edges`` are allocated only once during the first execution of the loop body since all the next video frames have the same resolution. If you somehow change the video resolution, the arrays are automatically reallocated.
|
||||
|
||||
The key component of this technology is the ``Mat::create`` method. It takes the desired array size and type. If the array already has the specified size and type, the method does nothing. Otherwise, it releases the previously allocated data, if any (this part involves decrementing the reference counter and comparing it with zero), and then allocates a new buffer of the required size. Most functions call the ``Mat::create`` method for each output array, and so the automatic output data allocation is implemented.
|
||||
|
||||
|
@ -3447,7 +3447,7 @@ function does not copy ``src`` itself but simply constructs the border, for exam
|
||||
// select the middle part of it w/o copying data
|
||||
Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));
|
||||
// convert image from RGB to grayscale
|
||||
cvtColor(rgb, gray, CV_RGB2GRAY);
|
||||
cvtColor(rgb, gray, COLOR_RGB2GRAY);
|
||||
// form a border in-place
|
||||
copyMakeBorder(gray, gray_buf, border, border,
|
||||
border, border, BORDER_REPLICATE);
|
||||
|
@ -210,7 +210,7 @@ The class provides C++ API for capturing video from cameras or for reading video
|
||||
{
|
||||
Mat frame;
|
||||
cap >> frame; // get a new frame from camera
|
||||
cvtColor(frame, edges, CV_BGR2GRAY);
|
||||
cvtColor(frame, edges, COLOR_BGR2GRAY);
|
||||
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
|
||||
Canny(edges, edges, 0, 30, 3);
|
||||
imshow("edges", edges);
|
||||
|
@ -106,7 +106,7 @@ But in case of a non-linear transformation, an input RGB image should be normali
|
||||
:math:`\rightarrow` L*u*v* transformation. For example, if you have a 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will have the 0..255 value range instead of 0..1 assumed by the function. So, before calling ``cvtColor`` , you need first to scale the image down: ::
|
||||
|
||||
img *= 1./255;
|
||||
cvtColor(img, img, CV_BGR2Luv);
|
||||
cvtColor(img, img, COLOR_BGR2Luv);
|
||||
|
||||
If you use ``cvtColor`` with 8-bit images, the conversion will have some information lost. For many applications, this will not be noticeable but it is recommended to use 32-bit images in applications that need the full range of colors or that convert an image before an operation and then convert back.
|
||||
|
||||
@ -129,7 +129,7 @@ The function can do the following transformations:
|
||||
|
||||
::
|
||||
|
||||
cvtColor(src, bwsrc, CV_RGB2GRAY);
|
||||
cvtColor(src, bwsrc, COLOR_RGB2GRAY);
|
||||
|
||||
..
|
||||
|
||||
@ -138,7 +138,7 @@ The function can do the following transformations:
|
||||
|
||||
*
|
||||
RGB
|
||||
:math:`\leftrightarrow` CIE XYZ.Rec 709 with D65 white point ( ``CV_BGR2XYZ, CV_RGB2XYZ, CV_XYZ2BGR, CV_XYZ2RGB`` ):
|
||||
:math:`\leftrightarrow` CIE XYZ.Rec 709 with D65 white point ( ``COLOR_BGR2XYZ, COLOR_RGB2XYZ, COLOR_XYZ2BGR, COLOR_XYZ2RGB`` ):
|
||||
|
||||
.. math::
|
||||
|
||||
@ -160,7 +160,7 @@ The function can do the following transformations:
|
||||
|
||||
*
|
||||
RGB
|
||||
:math:`\leftrightarrow` YCrCb JPEG (or YCC) ( ``CV_BGR2YCrCb, CV_RGB2YCrCb, CV_YCrCb2BGR, CV_YCrCb2RGB`` )
|
||||
:math:`\leftrightarrow` YCrCb JPEG (or YCC) ( ``COLOR_BGR2YCrCb, COLOR_RGB2YCrCb, COLOR_YCrCb2BGR, COLOR_YCrCb2RGB`` )
|
||||
|
||||
.. math::
|
||||
|
||||
@ -195,7 +195,7 @@ The function can do the following transformations:
|
||||
Y, Cr, and Cb cover the whole value range.
|
||||
|
||||
*
|
||||
RGB :math:`\leftrightarrow` HSV ( ``CV_BGR2HSV, CV_RGB2HSV, CV_HSV2BGR, CV_HSV2RGB`` )
|
||||
RGB :math:`\leftrightarrow` HSV ( ``COLOR_BGR2HSV, COLOR_RGB2HSV, COLOR_HSV2BGR, COLOR_HSV2RGB`` )
|
||||
In case of 8-bit and 16-bit images,
|
||||
R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.
|
||||
|
||||
@ -234,7 +234,7 @@ The function can do the following transformations:
|
||||
H, S, and V are left as is
|
||||
|
||||
*
|
||||
RGB :math:`\leftrightarrow` HLS ( ``CV_BGR2HLS, CV_RGB2HLS, CV_HLS2BGR, CV_HLS2RGB`` ).
|
||||
RGB :math:`\leftrightarrow` HLS ( ``COLOR_BGR2HLS, COLOR_RGB2HLS, COLOR_HLS2BGR, COLOR_HLS2RGB`` ).
|
||||
In case of 8-bit and 16-bit images,
|
||||
R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.
|
||||
|
||||
@ -284,7 +284,7 @@ The function can do the following transformations:
|
||||
H, S, V are left as is
|
||||
|
||||
*
|
||||
RGB :math:`\leftrightarrow` CIE L*a*b* ( ``CV_BGR2Lab, CV_RGB2Lab, CV_Lab2BGR, CV_Lab2RGB`` ).
|
||||
RGB :math:`\leftrightarrow` CIE L*a*b* ( ``COLOR_BGR2Lab, COLOR_RGB2Lab, COLOR_Lab2BGR, COLOR_Lab2RGB`` ).
|
||||
In case of 8-bit and 16-bit images,
|
||||
R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.
|
||||
|
||||
@ -340,7 +340,7 @@ The function can do the following transformations:
|
||||
L, a, and b are left as is
|
||||
|
||||
*
|
||||
RGB :math:`\leftrightarrow` CIE L*u*v* ( ``CV_BGR2Luv, CV_RGB2Luv, CV_Luv2BGR, CV_Luv2RGB`` ).
|
||||
RGB :math:`\leftrightarrow` CIE L*u*v* ( ``COLOR_BGR2Luv, COLOR_RGB2Luv, COLOR_Luv2BGR, COLOR_Luv2RGB`` ).
|
||||
In case of 8-bit and 16-bit images,
|
||||
R, G, and B are converted to the floating-point format and scaled to fit 0 to 1 range.
|
||||
|
||||
@ -389,7 +389,7 @@ The function can do the following transformations:
|
||||
http://www.poynton.com/ColorFAQ.html
|
||||
|
||||
*
|
||||
Bayer :math:`\rightarrow` RGB ( ``CV_BayerBG2BGR, CV_BayerGB2BGR, CV_BayerRG2BGR, CV_BayerGR2BGR, CV_BayerBG2RGB, CV_BayerGB2RGB, CV_BayerRG2RGB, CV_BayerGR2RGB`` ). The Bayer pattern is widely used in CCD and CMOS cameras. It enables you to get color pictures from a single plane where R,G, and B pixels (sensors of a particular component) are interleaved as follows:
|
||||
Bayer :math:`\rightarrow` RGB ( ``COLOR_BayerBG2BGR, COLOR_BayerGB2BGR, COLOR_BayerRG2BGR, COLOR_BayerGR2BGR, COLOR_BayerBG2RGB, COLOR_BayerGB2RGB, COLOR_BayerRG2RGB, COLOR_BayerGR2RGB`` ). The Bayer pattern is widely used in CCD and CMOS cameras. It enables you to get color pictures from a single plane where R,G, and B pixels (sensors of a particular component) are interleaved as follows:
|
||||
|
||||
.. image:: pics/bayer.png
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user