YUV codes for cvtColor: descriptions added #25616
This PR contains descriptions for various RGB <-> YUV color conversion codes as well as detailed comments in the source code.
### Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
COLOR_YUV2RGB_NV12=90,//!< convert between 4:2:0-subsampled YUV NV12 and RGB, two planes (in one or separate arrays): Y and U/V interleaved, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGR_NV12=91,//!< convert between 4:2:0-subsampled YUV NV12 and BGR, two planes (in one or separate arrays): Y and U/V interleaved, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGB_NV21=92,//!< convert between 4:2:0-subsampled YUV NV21 and RGB, two planes (in one or separate arrays): Y and V/U interleaved, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGR_NV21=93,//!< convert between 4:2:0-subsampled YUV NV21 and BGR, two planes (in one or separate arrays): Y and V/U interleaved, see @ref color_convert_rgb_yuv_42x
COLOR_YUV420sp2RGB=COLOR_YUV2RGB_NV21,//!< synonym to NV21
COLOR_YUV420sp2BGR=COLOR_YUV2BGR_NV21,//!< synonym to NV21
COLOR_YUV2RGBA_NV12=94,//!< convert between 4:2:0-subsampled YUV NV12 and RGBA, two planes (in one or separate arrays): Y and U/V interleaved, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGRA_NV12=95,//!< convert between 4:2:0-subsampled YUV NV12 and BGRA, two planes (in one or separate arrays): Y and U/V interleaved, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGBA_NV21=96,//!< convert between 4:2:0-subsampled YUV NV21 and RGBA, two planes (in one or separate arrays): Y and V/U interleaved, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGRA_NV21=97,//!< convert between 4:2:0-subsampled YUV NV21 and BGRA, two planes (in one or separate arrays): Y and V/U interleaved, see @ref color_convert_rgb_yuv_42x
COLOR_YUV420sp2RGBA=COLOR_YUV2RGBA_NV21,//!< synonym to NV21
COLOR_YUV420sp2BGRA=COLOR_YUV2BGRA_NV21,//!< synonym to NV21
COLOR_YUV2RGB_YV12=98,//!< convert between 4:2:0-subsampled YUV YV12 and RGB, three planes in one array: Y, V and U, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGR_YV12=99,//!< convert between 4:2:0-subsampled YUV YV12 and BGR, three planes in one array: Y, V and U, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGB_IYUV=100,//!< convert between 4:2:0-subsampled YUV IYUV and RGB, three planes in one array: Y, U and V, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGR_IYUV=101,//!< convert between 4:2:0-subsampled YUV IYUV and BGR, three planes in one array: Y, U and V, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGB_I420=COLOR_YUV2RGB_IYUV,//!< synonym to IYUV
COLOR_YUV2BGR_I420=COLOR_YUV2BGR_IYUV,//!< synonym to IYUV
COLOR_YUV420p2RGB=COLOR_YUV2RGB_YV12,//!< synonym to YV12
COLOR_YUV420p2BGR=COLOR_YUV2BGR_YV12,//!< synonym to YV12
COLOR_YUV2RGBA_YV12=102,//!< convert between 4:2:0-subsampled YUV YV12 and RGBA, three planes in one array: Y, V and U, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGRA_YV12=103,//!< convert between 4:2:0-subsampled YUV YV12 and BGRA, three planes in one array: Y, V and U, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGBA_IYUV=104,//!< convert between 4:2:0-subsampled YUV YV12 and RGBA, three planes in one array: Y, U and V, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGRA_IYUV=105,//!< convert between 4:2:0-subsampled YUV YV12 and BGRA, three planes in one array: Y, U and V, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGBA_I420=COLOR_YUV2RGBA_IYUV,//!< synonym to IYUV
COLOR_YUV2BGRA_I420=COLOR_YUV2BGRA_IYUV,//!< synonym to IYUV
COLOR_YUV420p2RGBA=COLOR_YUV2RGBA_YV12,//!< synonym to YV12
COLOR_YUV420p2BGRA=COLOR_YUV2BGRA_YV12,//!< synonym to YV12
COLOR_YUV2GRAY_420=106,//!< extract Y channel from YUV 4:2:0 image
COLOR_YUV2GRAY_NV21=COLOR_YUV2GRAY_420,//!< synonym to COLOR_YUV2GRAY_420
COLOR_YUV2GRAY_NV12=COLOR_YUV2GRAY_420,//!< synonym to COLOR_YUV2GRAY_420
COLOR_YUV2GRAY_YV12=COLOR_YUV2GRAY_420,//!< synonym to COLOR_YUV2GRAY_420
COLOR_YUV2GRAY_IYUV=COLOR_YUV2GRAY_420,//!< synonym to COLOR_YUV2GRAY_420
COLOR_YUV2GRAY_I420=COLOR_YUV2GRAY_420,//!< synonym to COLOR_YUV2GRAY_420
COLOR_YUV420sp2GRAY=COLOR_YUV2GRAY_420,//!< synonym to COLOR_YUV2GRAY_420
COLOR_YUV420p2GRAY=COLOR_YUV2GRAY_420,//!< synonym to COLOR_YUV2GRAY_420
COLOR_YUV2RGB_UYVY=107,//!< convert between YUV UYVY and RGB, YUV is 4:2:2-subsampled and interleaved as U/Y1/V/Y2, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGR_UYVY=108,//!< convert between YUV UYVY and BGR, YUV is 4:2:2-subsampled and interleaved as U/Y1/V/Y2, see @ref color_convert_rgb_yuv_42x
//COLOR_YUV2RGB_VYUY = 109, //!< convert between YUV VYUY and RGB, YUV is 4:2:2-subsampled and interleaved as V/Y1/U/Y2, see @ref color_convert_rgb_yuv_42x
//COLOR_YUV2BGR_VYUY = 110, //!< convert between YUV VYUY and BGR, YUV is 4:2:2-subsampled and interleaved as V/Y1/U/Y2, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGB_Y422=COLOR_YUV2RGB_UYVY,//!< synonym to UYVY
COLOR_YUV2BGR_Y422=COLOR_YUV2BGR_UYVY,//!< synonym to UYVY
COLOR_YUV2RGB_UYNV=COLOR_YUV2RGB_UYVY,//!< synonym to UYVY
COLOR_YUV2BGR_UYNV=COLOR_YUV2BGR_UYVY,//!< synonym to UYVY
COLOR_YUV2RGBA_UYVY=111,//!< convert between YUV UYVY and RGBA, YUV is 4:2:2-subsampled and interleaved as U/Y1/V/Y2, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGRA_UYVY=112,//!< convert between YUV UYVY and BGRA, YUV is 4:2:2-subsampled and interleaved as U/Y1/V/Y2, see @ref color_convert_rgb_yuv_42x
//COLOR_YUV2RGBA_VYUY = 113, //!< convert between YUV VYUY and RGBA, YUV is 4:2:2-subsampled and interleaved as V/Y1/U/Y2, see @ref color_convert_rgb_yuv_42x
//COLOR_YUV2BGRA_VYUY = 114, //!< convert between YUV VYUY and BGRA, YUV is 4:2:2-subsampled and interleaved as V/Y1/U/Y2, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGBA_Y422=COLOR_YUV2RGBA_UYVY,//!< synonym to UYVY
COLOR_YUV2BGRA_Y422=COLOR_YUV2BGRA_UYVY,//!< synonym to UYVY
COLOR_YUV2RGBA_UYNV=COLOR_YUV2RGBA_UYVY,//!< synonym to UYVY
COLOR_YUV2BGRA_UYNV=COLOR_YUV2BGRA_UYVY,//!< synonym to UYVY
COLOR_YUV2RGB_YUY2=115,//!< convert between YUV YUY2 and RGB, YUV is 4:2:2-subsampled and interleaved as Y1/U/Y2/V, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGR_YUY2=116,//!< convert between YUV YUY2 and BGR, YUV is 4:2:2-subsampled and interleaved as Y1/U/Y2/V, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGB_YVYU=117,//!< convert between YUV YVYU and RGB, YUV is 4:2:2-subsampled and interleaved as Y1/V/Y2/U, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGR_YVYU=118,//!< convert between YUV YVYU and BGR, YUV is 4:2:2-subsampled and interleaved as Y1/V/Y2/U, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGB_YUYV=COLOR_YUV2RGB_YUY2,//!< synonym to YUY2
COLOR_YUV2BGR_YUYV=COLOR_YUV2BGR_YUY2,//!< synonym to YUY2
COLOR_YUV2RGB_YUNV=COLOR_YUV2RGB_YUY2,//!< synonym to YUY2
COLOR_YUV2BGR_YUNV=COLOR_YUV2BGR_YUY2,//!< synonym to YUY2
COLOR_YUV2RGBA_YUY2=119,//!< convert between YUV YUY2 and RGBA, YUV is 4:2:2-subsampled and interleaved as Y1/U/Y2/V, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGRA_YUY2=120,//!< convert between YUV YUY2 and BGRA, YUV is 4:2:2-subsampled and interleaved as Y1/U/Y2/V, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGBA_YVYU=121,//!< convert between YUV YVYU and RGBA, YUV is 4:2:2-subsampled and interleaved as Y1/V/Y2/U, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2BGRA_YVYU=122,//!< convert between YUV YVYU and BGRA, YUV is 4:2:2-subsampled and interleaved as Y1/V/Y2/U, see @ref color_convert_rgb_yuv_42x
COLOR_YUV2RGBA_YUYV=COLOR_YUV2RGBA_YUY2,//!< synonym to YUY2
COLOR_YUV2BGRA_YUYV=COLOR_YUV2BGRA_YUY2,//!< synonym to YUY2
COLOR_YUV2RGBA_YUNV=COLOR_YUV2RGBA_YUY2,//!< synonym to YUY2
COLOR_YUV2BGRA_YUNV=COLOR_YUV2BGRA_YUY2,//!< synonym to YUY2
COLOR_YUV2GRAY_UYVY=123,//!< extract Y channel from YUV 4:2:2 image
COLOR_YUV2GRAY_YUY2=124,//!< extract Y channel from YUV 4:2:2 image
//CV_YUV2GRAY_VYUY = CV_YUV2GRAY_UYVY, //!< synonym to COLOR_YUV2GRAY_UYVY
COLOR_YUV2GRAY_Y422=COLOR_YUV2GRAY_UYVY,//!< synonym to COLOR_YUV2GRAY_UYVY
COLOR_YUV2GRAY_UYNV=COLOR_YUV2GRAY_UYVY,//!< synonym to COLOR_YUV2GRAY_UYVY
COLOR_YUV2GRAY_YVYU=COLOR_YUV2GRAY_YUY2,//!< synonym to COLOR_YUV2GRAY_YUY2
COLOR_YUV2GRAY_YUYV=COLOR_YUV2GRAY_YUY2,//!< synonym to COLOR_YUV2GRAY_YUY2
COLOR_YUV2GRAY_YUNV=COLOR_YUV2GRAY_YUY2,//!< synonym to COLOR_YUV2GRAY_YUY2
//! alpha premultiplication
COLOR_RGBA2mRGBA=125,
COLOR_mRGBA2RGBA=126,
//! RGB to YUV 4:2:0 family
COLOR_RGB2YUV_I420=127,
COLOR_BGR2YUV_I420=128,
COLOR_RGB2YUV_IYUV=COLOR_RGB2YUV_I420,
COLOR_BGR2YUV_IYUV=COLOR_BGR2YUV_I420,
COLOR_RGBA2YUV_I420=129,
COLOR_BGRA2YUV_I420=130,
COLOR_RGBA2YUV_IYUV=COLOR_RGBA2YUV_I420,
COLOR_BGRA2YUV_IYUV=COLOR_BGRA2YUV_I420,
COLOR_RGB2YUV_YV12=131,
COLOR_BGR2YUV_YV12=132,
COLOR_RGBA2YUV_YV12=133,
COLOR_BGRA2YUV_YV12=134,
COLOR_RGB2YUV_I420=127,//!< convert between RGB and 4:2:0-subsampled YUV I420, three planes in one array: Y, U and V, see @ref color_convert_rgb_yuv_42x
COLOR_BGR2YUV_I420=128,//!< convert between BGR and 4:2:0-subsampled YUV I420, three planes in one array: Y, U and V, see @ref color_convert_rgb_yuv_42x
COLOR_RGB2YUV_IYUV=COLOR_RGB2YUV_I420,//!< synonym to I420
COLOR_BGR2YUV_IYUV=COLOR_BGR2YUV_I420,//!< synonym to I420
COLOR_RGBA2YUV_I420=129,//!< convert between RGBA and 4:2:0-subsampled YUV I420, three planes in one array: Y, U and V, see @ref color_convert_rgb_yuv_42x
COLOR_BGRA2YUV_I420=130,//!< convert between BGRA and 4:2:0-subsampled YUV I420, three planes in one array: Y, U and V, see @ref color_convert_rgb_yuv_42x
COLOR_RGBA2YUV_IYUV=COLOR_RGBA2YUV_I420,//!< synonym to I420
COLOR_BGRA2YUV_IYUV=COLOR_BGRA2YUV_I420,//!< synonym to I420
COLOR_RGB2YUV_YV12=131,//!< convert between RGB and 4:2:0-subsampled YUV YV12, three planes in one array: Y, V and U, see @ref color_convert_rgb_yuv_42x
COLOR_BGR2YUV_YV12=132,//!< convert between BGR and 4:2:0-subsampled YUV YV12, three planes in one array: Y, V and U, see @ref color_convert_rgb_yuv_42x
COLOR_RGBA2YUV_YV12=133,//!< convert between RGBA and 4:2:0-subsampled YUV YV12, three planes in one array: Y, V and U, see @ref color_convert_rgb_yuv_42x
COLOR_BGRA2YUV_YV12=134,//!< convert between BGRA and 4:2:0-subsampled YUV YV12, three planes in one array: Y, V and U, see @ref color_convert_rgb_yuv_42x
//! Demosaicing, see @ref color_convert_bayer "color conversions" for additional information
COLOR_BayerBG2BGR=46,//!< equivalent to RGGB Bayer pattern
@ -842,39 +839,37 @@ enum ColorConversionCodes {
COLOR_BayerRG2RGBA=COLOR_BayerBG2BGRA,//!< equivalent to BGGR Bayer pattern
COLOR_BayerGR2RGBA=COLOR_BayerGB2BGRA,//!< equivalent to GBRG Bayer pattern
//! RGB to YUV 4:2:2 family
COLOR_RGB2YUV_UYVY=143,
COLOR_BGR2YUV_UYVY=144,
COLOR_RGB2YUV_Y422=COLOR_RGB2YUV_UYVY,
COLOR_BGR2YUV_Y422=COLOR_BGR2YUV_UYVY,
COLOR_RGB2YUV_UYNV=COLOR_RGB2YUV_UYVY,
COLOR_BGR2YUV_UYNV=COLOR_BGR2YUV_UYVY,
COLOR_RGBA2YUV_UYVY=145,
COLOR_BGRA2YUV_UYVY=146,
COLOR_RGBA2YUV_Y422=COLOR_RGBA2YUV_UYVY,
COLOR_BGRA2YUV_Y422=COLOR_BGRA2YUV_UYVY,
COLOR_RGBA2YUV_UYNV=COLOR_RGBA2YUV_UYVY,
COLOR_BGRA2YUV_UYNV=COLOR_BGRA2YUV_UYVY,
COLOR_RGB2YUV_YUY2=147,
COLOR_BGR2YUV_YUY2=148,
COLOR_RGB2YUV_YVYU=149,
COLOR_BGR2YUV_YVYU=150,
COLOR_RGB2YUV_YUYV=COLOR_RGB2YUV_YUY2,
COLOR_BGR2YUV_YUYV=COLOR_BGR2YUV_YUY2,
COLOR_RGB2YUV_YUNV=COLOR_RGB2YUV_YUY2,
COLOR_BGR2YUV_YUNV=COLOR_BGR2YUV_YUY2,
COLOR_RGBA2YUV_YUY2=151,
COLOR_BGRA2YUV_YUY2=152,
COLOR_RGBA2YUV_YVYU=153,
COLOR_BGRA2YUV_YVYU=154,
COLOR_RGBA2YUV_YUYV=COLOR_RGBA2YUV_YUY2,
COLOR_BGRA2YUV_YUYV=COLOR_BGRA2YUV_YUY2,
COLOR_RGBA2YUV_YUNV=COLOR_RGBA2YUV_YUY2,
COLOR_BGRA2YUV_YUNV=COLOR_BGRA2YUV_YUY2,
COLOR_RGB2YUV_UYVY=143,//!< convert between RGB and YUV UYVU, YUV is 4:2:2 and interleaved as U/Y1/V/Y2, see @ref color_convert_rgb_yuv_42x
COLOR_BGR2YUV_UYVY=144,//!< convert between BGR and YUV UYVU, YUV is 4:2:2 and interleaved as U/Y1/V/Y2, see @ref color_convert_rgb_yuv_42x
COLOR_RGB2YUV_Y422=COLOR_RGB2YUV_UYVY,//!< synonym to UYVY
COLOR_BGR2YUV_Y422=COLOR_BGR2YUV_UYVY,//!< synonym to UYVY
COLOR_RGB2YUV_UYNV=COLOR_RGB2YUV_UYVY,//!< synonym to UYVY
COLOR_BGR2YUV_UYNV=COLOR_BGR2YUV_UYVY,//!< synonym to UYVY
COLOR_RGBA2YUV_UYVY=145,//!< convert between RGBA and YUV UYVU, YUV is 4:2:2 and interleaved as U/Y1/V/Y2, see @ref color_convert_rgb_yuv_42x
COLOR_BGRA2YUV_UYVY=146,//!< convert between BGRA and YUV UYVU, YUV is 4:2:2 and interleaved as U/Y1/V/Y2, see @ref color_convert_rgb_yuv_42x
COLOR_RGBA2YUV_Y422=COLOR_RGBA2YUV_UYVY,//!< synonym to UYVY
COLOR_BGRA2YUV_Y422=COLOR_BGRA2YUV_UYVY,//!< synonym to UYVY
COLOR_RGBA2YUV_UYNV=COLOR_RGBA2YUV_UYVY,//!< synonym to UYVY
COLOR_BGRA2YUV_UYNV=COLOR_BGRA2YUV_UYVY,//!< synonym to UYVY
COLOR_RGB2YUV_YUY2=147,//!< convert between RGB and YUV YUY2, YUV is 4:2:2 and interleaved as Y1/U/Y2/V, see @ref color_convert_rgb_yuv_42x
COLOR_BGR2YUV_YUY2=148,//!< convert between BGR and YUV YUY2, YUV is 4:2:2 and interleaved as Y1/U/Y2/V, see @ref color_convert_rgb_yuv_42x
COLOR_RGB2YUV_YVYU=149,//!< convert between RGB and YUV YVYU, YUV is 4:2:2 and interleaved as Y1/V/Y2/U, see @ref color_convert_rgb_yuv_42x
COLOR_BGR2YUV_YVYU=150,//!< convert between BGR and YUV YVYU, YUV is 4:2:2 and interleaved as Y1/V/Y2/U, see @ref color_convert_rgb_yuv_42x
COLOR_RGB2YUV_YUYV=COLOR_RGB2YUV_YUY2,//!< synonym to YUY2
COLOR_BGR2YUV_YUYV=COLOR_BGR2YUV_YUY2,//!< synonym to YUY2
COLOR_RGB2YUV_YUNV=COLOR_RGB2YUV_YUY2,//!< synonym to YUY2
COLOR_BGR2YUV_YUNV=COLOR_BGR2YUV_YUY2,//!< synonym to YUY2
COLOR_RGBA2YUV_YUY2=151,//!< convert between RGBA and YUV YUY2, YUV is 4:2:2 and interleaved as Y1/U/Y2/V, see @ref color_convert_rgb_yuv_42x
COLOR_BGRA2YUV_YUY2=152,//!< convert between BGRA and YUV YUY2, YUV is 4:2:2 and interleaved as Y1/U/Y2/V, see @ref color_convert_rgb_yuv_42x
COLOR_RGBA2YUV_YVYU=153,//!< convert between RGBA and YUV YVYU, YUV is 4:2:2 and interleaved as Y1/V/Y2/U, see @ref color_convert_rgb_yuv_42x
COLOR_BGRA2YUV_YVYU=154,//!< convert between BGRA and YUV YVYU, YUV is 4:2:2 and interleaved as Y1/V/Y2/U, see @ref color_convert_rgb_yuv_42x
COLOR_RGBA2YUV_YUYV=COLOR_RGBA2YUV_YUY2,//!< synonym to YUY2
COLOR_BGRA2YUV_YUYV=COLOR_BGRA2YUV_YUY2,//!< synonym to YUY2
COLOR_RGBA2YUV_YUNV=COLOR_RGBA2YUV_YUY2,//!< synonym to YUY2
COLOR_BGRA2YUV_YUNV=COLOR_BGRA2YUV_YUY2,//!< synonym to YUY2
// http://www.fourcc.org/yuv.php#NV21 == yuv420sp -> a plane of 8 bit Y samples followed by an interleaved V/U plane containing 8 bit 2x2 subsampled chroma samples
// http://www.fourcc.org/yuv.php#NV12 -> a plane of 8 bit Y samples followed by an interleaved U/V plane containing 8 bit 2x2 subsampled colour difference samples
// 4:2:0, two planes in one array: Y, UV interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
// see also: http://www.fourcc.org/yuv.php#NV21, http://www.fourcc.org/yuv.php#NV12