Cv2 color bgr2gray как работает

How to convert color image to grayscale in OpenCV
Welcome, In this tutorial we are going to see how to read a image as grayscale as well as we will convert a color image into a grayscale image using opencv and python, if you do not know how to read a image in opencv, do check out this post here.
So to convert a color image to a grayscale image in opencv, we can have two solution
- Convert image to grayscale with imread() function
- Convert image to grayscale using cvtColor() function
Let’s discover how to do it with above mentioned functions.
Method 1: Using imread() function
imread() function is used to read an image in OpenCV but there is one more parameter to be considerd, that is flag which decides the way image is read. There three flag defined in OpenCV..
- cv2.IMREAD_COLOR or 1
- cv2.IMREAD_GRAYSCALE or 0
- cv2.IMREAD_UNCHANGED or -1
So to convert the color image to grayscale we will be using cv2.imread(«image-name.png»,0) or you can also write cv2.IMREAD_GRAYSCALE in the place of 0 as it also denotes the same constant.
# Reading color image as grayscale
gray = cv2.imread(«color-img.png»,0)
# Showing grayscale image
cv2.imshow(«Grayscale Image», gray)
# waiting for key event
cv2.waitKey(0)
# destroying all windows
cv2.destroyAllWindows()
Method 2: Using cvtColor() function
cvtColor() function in OpenCV is very helpful in converting color channels from one to another such as BRG to HSV or BRG to RGB. The same method can be used to convert BRG to GRAY by using the cv2.cvtColor(img,cv2.BGR2GRAY)
# Reading color image
img = cv2.imread(«color-img.png»)
# Converting color image to grayscale image
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Showing the converted image
cv2.imshow(«Converted Image»,gray)
# waiting for key event
cv2.waitKey(0)
# destroying all windows
cv2.destroyAllWindows()
Output
Cv2 color bgr2gray как работает
Todo: document other conversion modes
RGB \(\leftrightarrow\) GRAY
Transformations within RGB space like adding/removing the alpha channel, reversing the channel order, conversion to/from 16-bit RGB color (R5:G6:B5 or R5:G5:B5), as well as conversion to/from grayscale using:
\[\text \quad Y \leftarrow 0.299 \cdot R + 0.587 \cdot G + 0.114 \cdot B\]
\[\text \quad R \leftarrow Y, G \leftarrow Y, B \leftarrow Y, A \leftarrow \max (ChannelRange)\]
The conversion from a RGB image to gray is done with:
cvtColor(src, bwsrc, cv::COLOR_RGB2GRAY);
More advanced channel reordering can also be done with cv::mixChannels.
RGB \(\leftrightarrow\) CIE XYZ.Rec 709 with D65 white point
\[\begin X \\ Y \\ Z \end \leftarrow \begin 0.412453 & 0.357580 & 0.180423 \\ 0.212671 & 0.715160 & 0.072169 \\ 0.019334 & 0.119193 & 0.950227 \end \cdot \begin R \\ G \\ B \end\]
\[\begin R \\ G \\ B \end \leftarrow \begin 3.240479 & -1.53715 & -0.498535 \\ -0.969256 & 1.875991 & 0.041556 \\ 0.055648 & -0.204043 & 1.057311 \end \cdot \begin X \\ Y \\ Z \end\]
\(X\), \(Y\) and \(Z\) cover the whole value range (in case of floating-point images, \(Z\) may exceed 1).
RGB \(\leftrightarrow\) YCrCb JPEG (or YCC)
\[Y \leftarrow 0.299 \cdot R + 0.587 \cdot G + 0.114 \cdot B\]
\[Cr \leftarrow (R-Y) \cdot 0.713 + delta\]
\[Cb \leftarrow (B-Y) \cdot 0.564 + delta\]
\[R \leftarrow Y + 1.403 \cdot (Cr — delta)\]
\[G \leftarrow Y — 0.714 \cdot (Cr — delta) — 0.344 \cdot (Cb — delta)\]
\[B \leftarrow Y + 1.773 \cdot (Cb — delta)\]
Y, Cr, and Cb cover the whole value range.
RGB \(\leftrightarrow\) HSV
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.
\[V \leftarrow max(R,G,B)\]
The values are then converted to the destination data type:
- 8-bit images: \(V \leftarrow 255 V, S \leftarrow 255 S, H \leftarrow H/2 \text<(to fit to 0 to 255)>\)
- 16-bit images: (currently not supported) \(V
- 32-bit images: H, S, and V are left as is
RGB \(\leftrightarrow\) HLS
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.
The values are then converted to the destination data type:
- 8-bit images: \(V \leftarrow 255 \cdot V, S \leftarrow 255 \cdot S, H \leftarrow H/2 \; \text<(to fit to 0 to 255)>\)
- 16-bit images: (currently not supported) \(V
- 32-bit images: H, S, V are left as is
RGB \(\leftrightarrow\) CIE L*a*b*
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.
\[X \leftarrow X/X_n, \text X_n = 0.950456\]
\[Z \leftarrow Z/Z_n, \text Z_n = 1.088754\]
\[a \leftarrow 500 (f(X)-f(Y)) + delta\]
\[b \leftarrow 200 (f(Y)-f(Z)) + delta\]
This outputs \(0 \leq L \leq 100\), \(-127 \leq a \leq 127\), \(-127 \leq b \leq 127\) . The values are then converted to the destination data type:
- 8-bit images: \(L \leftarrow L*255/100, \; a \leftarrow a + 128, \; b \leftarrow b + 128\)
- 16-bit images: (currently not supported)
- 32-bit images: L, a, and b are left as is
RGB \(\leftrightarrow\) CIE L*u*v*
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.
\[u’ \leftarrow 4*X/(X + 15*Y + 3 Z)\]
\[v’ \leftarrow 9*Y/(X + 15*Y + 3 Z)\]
\[u \leftarrow 13*L*(u’ — u_n) \quad \text \quad u_n=0.19793943\]
\[v \leftarrow 13*L*(v’ — v_n) \quad \text \quad v_n=0.46831096\]
This outputs \(0 \leq L \leq 100\), \(-134 \leq u \leq 220\), \(-140 \leq v \leq 122\) .
The values are then converted to the destination data type:
- 8-bit images: \(L \leftarrow 255/100 L, \; u \leftarrow 255/354 (u + 134), \; v \leftarrow 255/262 (v + 140)\)
- 16-bit images: (currently not supported)
- 32-bit images: L, u, and v are left as is
Note that when converting integer Luv images to RGB the intermediate X, Y and Z values are truncated to \( [0, 2] \) range to fit white point limitations. It may lead to incorrect representation of colors with odd XYZ values.
The above formulae for converting RGB to/from various color spaces have been taken from multiple sources on the web, primarily from the Charles Poynton site http://www.poynton.com/ColorFAQ.html
Bayer \(\rightarrow\) RGB
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 patterns (BGGR, GBRG, GRGB, RGGB)
The output RGB components of a pixel are interpolated from 1, 2, or 4 neighbors of the pixel having the same color.
Note See the following for information about correspondences between OpenCV Bayer pattern naming and classical Bayer pattern naming.

Bayer pattern
There are several modifications of the above pattern that can be achieved by shifting the pattern one pixel left and/or one pixel up. The two letters \(C_1\) and \(C_2\) in the conversion constants CV_Bayer \(C_1 C_2\) 2BGR and CV_Bayer \(C_1 C_2\) 2RGB indicate the particular pattern type. These are components from the second row, second and third columns, respectively. For example, the above pattern has a very popular «BG» type.

Generated on Sun Oct 29 2023 16:40:01 for OpenCV by 1.8.13
Convert RGB Image to Grayscale Image using OpenCV
![]()
During image processing, RGB images are often converted to grayscale images because smaller amount of data allows performing more complex image processing operations faster.
This tutorial provides example how to convert RGB image to grayscale image using OpenCV.
OpenCV provides the cvtColor function that allows to convert an image from one color space to another. This function accepts color conversion code. BGR2GRAY code is used to convert RGB image to grayscale image. Note that, OpenCV loads an image where the order of the color channels is Blue, Green, Red (BGR) instead of RGB.
OpenCV uses weighted method, also known as luminosity method, for RGB to grayscale conversion. The grayscale value is calculated as the weighted sum of the R, G, and B color components. The formula is:

import cv2 img = cv2.imread('test.jpg') grayImg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) cv2.imshow('RGB image', img) cv2.imshow('Grayscale image', grayImg) cv2.waitKey(0) cv2.destroyAllWindows()
#include using namespace cv; int main()
#include #include using namespace cv; int main()
package app; import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class Main < static < System.loadLibrary(Core.NATIVE_LIBRARY_NAME); >public static void main(String[] args) < Mat img = Imgcodecs.imread("test.jpg"); Mat grayImg = new Mat(); Imgproc.cvtColor(img, grayImg, Imgproc.COLOR_BGR2GRAY); HighGui.imshow("RGB image", img); HighGui.imshow("Grayscale image", grayImg); HighGui.waitKey(0); HighGui.destroyAllWindows(); System.exit(0); >>

Related
![]()
YOLO (You Only Look Once) is an object detection algorithm that allows to detect objects.
![]()
Displaying an image in a Qt application using OpenCV can help to create applications that.
![]()
Erosion is a morphological image processing operation that removes the boundaries of the foreground object.
Cv2 color bgr2gray как работает
the color conversion codes
Python: cv.COLOR_BGR2BGRA
add alpha channel to RGB or BGR image
Python: cv.COLOR_RGB2RGBA
Python: cv.COLOR_BGRA2BGR
remove alpha channel from RGB or BGR image
Python: cv.COLOR_RGBA2RGB
Python: cv.COLOR_BGR2RGBA
convert between RGB and BGR color spaces (with or without alpha channel)
Python: cv.COLOR_RGB2BGRA
Python: cv.COLOR_RGBA2BGR
Python: cv.COLOR_BGRA2RGB
Python: cv.COLOR_BGR2RGB
Python: cv.COLOR_RGB2BGR
Python: cv.COLOR_BGRA2RGBA
Python: cv.COLOR_RGBA2BGRA
Python: cv.COLOR_BGR2GRAY
convert between RGB/BGR and grayscale, color conversions
Python: cv.COLOR_RGB2GRAY
Python: cv.COLOR_GRAY2BGR
Python: cv.COLOR_GRAY2RGB
Python: cv.COLOR_GRAY2BGRA
Python: cv.COLOR_GRAY2RGBA
Python: cv.COLOR_BGRA2GRAY
Python: cv.COLOR_RGBA2GRAY
Python: cv.COLOR_BGR2BGR565
convert between RGB/BGR and BGR565 (16-bit images)
Python: cv.COLOR_RGB2BGR565
Python: cv.COLOR_BGR5652BGR
Python: cv.COLOR_BGR5652RGB
Python: cv.COLOR_BGRA2BGR565
Python: cv.COLOR_RGBA2BGR565
Python: cv.COLOR_BGR5652BGRA
Python: cv.COLOR_BGR5652RGBA
Python: cv.COLOR_GRAY2BGR565
convert between grayscale to BGR565 (16-bit images)
Python: cv.COLOR_BGR5652GRAY
Python: cv.COLOR_BGR2BGR555
convert between RGB/BGR and BGR555 (16-bit images)
Python: cv.COLOR_RGB2BGR555
Python: cv.COLOR_BGR5552BGR
Python: cv.COLOR_BGR5552RGB
Python: cv.COLOR_BGRA2BGR555
Python: cv.COLOR_RGBA2BGR555
Python: cv.COLOR_BGR5552BGRA
Python: cv.COLOR_BGR5552RGBA
Python: cv.COLOR_GRAY2BGR555
convert between grayscale and BGR555 (16-bit images)
Python: cv.COLOR_BGR5552GRAY
Python: cv.COLOR_BGR2XYZ
convert RGB/BGR to CIE XYZ, color conversions
Python: cv.COLOR_RGB2XYZ
Python: cv.COLOR_XYZ2BGR
Python: cv.COLOR_XYZ2RGB
Python: cv.COLOR_BGR2YCrCb
convert RGB/BGR to luma-chroma (aka YCC), color conversions
Python: cv.COLOR_RGB2YCrCb
Python: cv.COLOR_YCrCb2BGR
Python: cv.COLOR_YCrCb2RGB
Python: cv.COLOR_BGR2HSV
convert RGB/BGR to HSV (hue saturation value) with H range 0..180 if 8 bit image, color conversions
Python: cv.COLOR_RGB2HSV
Python: cv.COLOR_BGR2Lab
convert RGB/BGR to CIE Lab, color conversions
Python: cv.COLOR_RGB2Lab
Python: cv.COLOR_BGR2Luv
convert RGB/BGR to CIE Luv, color conversions
Python: cv.COLOR_RGB2Luv
Python: cv.COLOR_BGR2HLS
convert RGB/BGR to HLS (hue lightness saturation) with H range 0..180 if 8 bit image, color conversions
Python: cv.COLOR_RGB2HLS
Python: cv.COLOR_HSV2BGR
backward conversions HSV to RGB/BGR with H range 0..180 if 8 bit image
Python: cv.COLOR_HSV2RGB
Python: cv.COLOR_Lab2BGR
Python: cv.COLOR_Lab2RGB
Python: cv.COLOR_Luv2BGR
Python: cv.COLOR_Luv2RGB
Python: cv.COLOR_HLS2BGR
backward conversions HLS to RGB/BGR with H range 0..180 if 8 bit image
Python: cv.COLOR_HLS2RGB
Python: cv.COLOR_BGR2HSV_FULL
convert RGB/BGR to HSV (hue saturation value) with H range 0..255 if 8 bit image, color conversions
Python: cv.COLOR_RGB2HSV_FULL
Python: cv.COLOR_BGR2HLS_FULL
convert RGB/BGR to HLS (hue lightness saturation) with H range 0..255 if 8 bit image, color conversions
Python: cv.COLOR_RGB2HLS_FULL
Python: cv.COLOR_HSV2BGR_FULL
backward conversions HSV to RGB/BGR with H range 0..255 if 8 bit image
Python: cv.COLOR_HSV2RGB_FULL
Python: cv.COLOR_HLS2BGR_FULL
backward conversions HLS to RGB/BGR with H range 0..255 if 8 bit image
Python: cv.COLOR_HLS2RGB_FULL
Python: cv.COLOR_LBGR2Lab
Python: cv.COLOR_LRGB2Lab
Python: cv.COLOR_LBGR2Luv
Python: cv.COLOR_LRGB2Luv
Python: cv.COLOR_Lab2LBGR
Python: cv.COLOR_Lab2LRGB
Python: cv.COLOR_Luv2LBGR
Python: cv.COLOR_Luv2LRGB
Python: cv.COLOR_BGR2YUV
convert between RGB/BGR and YUV
Python: cv.COLOR_RGB2YUV
Python: cv.COLOR_YUV2BGR
Python: cv.COLOR_YUV2RGB
Python: cv.COLOR_YUV2RGB_NV12
YUV 4:2:0 family to RGB.
Python: cv.COLOR_YUV2BGR_NV12
Python: cv.COLOR_YUV2RGB_NV21
Python: cv.COLOR_YUV2BGR_NV21
Python: cv.COLOR_YUV420sp2RGB
Python: cv.COLOR_YUV420sp2BGR
Python: cv.COLOR_YUV2RGBA_NV12
Python: cv.COLOR_YUV2BGRA_NV12
Python: cv.COLOR_YUV2RGBA_NV21
Python: cv.COLOR_YUV2BGRA_NV21
Python: cv.COLOR_YUV420sp2RGBA
Python: cv.COLOR_YUV420sp2BGRA
Python: cv.COLOR_YUV2RGB_YV12
Python: cv.COLOR_YUV2BGR_YV12
Python: cv.COLOR_YUV2RGB_IYUV
Python: cv.COLOR_YUV2BGR_IYUV
Python: cv.COLOR_YUV2RGB_I420
Python: cv.COLOR_YUV2BGR_I420
Python: cv.COLOR_YUV420p2RGB
Python: cv.COLOR_YUV420p2BGR
Python: cv.COLOR_YUV2RGBA_YV12
Python: cv.COLOR_YUV2BGRA_YV12
Python: cv.COLOR_YUV2RGBA_IYUV
Python: cv.COLOR_YUV2BGRA_IYUV
Python: cv.COLOR_YUV2RGBA_I420
Python: cv.COLOR_YUV2BGRA_I420
Python: cv.COLOR_YUV420p2RGBA
Python: cv.COLOR_YUV420p2BGRA
Python: cv.COLOR_YUV2GRAY_420
Python: cv.COLOR_YUV2GRAY_NV21
Python: cv.COLOR_YUV2GRAY_NV12
Python: cv.COLOR_YUV2GRAY_YV12
Python: cv.COLOR_YUV2GRAY_IYUV
Python: cv.COLOR_YUV2GRAY_I420
Python: cv.COLOR_YUV420sp2GRAY
Python: cv.COLOR_YUV420p2GRAY
Python: cv.COLOR_YUV2RGB_UYVY
YUV 4:2:2 family to RGB.
Python: cv.COLOR_YUV2BGR_UYVY
Python: cv.COLOR_YUV2RGB_Y422
Python: cv.COLOR_YUV2BGR_Y422
Python: cv.COLOR_YUV2RGB_UYNV
Python: cv.COLOR_YUV2BGR_UYNV
Python: cv.COLOR_YUV2RGBA_UYVY
Python: cv.COLOR_YUV2BGRA_UYVY
Python: cv.COLOR_YUV2RGBA_Y422
Python: cv.COLOR_YUV2BGRA_Y422
Python: cv.COLOR_YUV2RGBA_UYNV
Python: cv.COLOR_YUV2BGRA_UYNV
Python: cv.COLOR_YUV2RGB_YUY2
Python: cv.COLOR_YUV2BGR_YUY2
Python: cv.COLOR_YUV2RGB_YVYU
Python: cv.COLOR_YUV2BGR_YVYU
Python: cv.COLOR_YUV2RGB_YUYV
Python: cv.COLOR_YUV2BGR_YUYV
Python: cv.COLOR_YUV2RGB_YUNV
Python: cv.COLOR_YUV2BGR_YUNV
Python: cv.COLOR_YUV2RGBA_YUY2
Python: cv.COLOR_YUV2BGRA_YUY2
Python: cv.COLOR_YUV2RGBA_YVYU
Python: cv.COLOR_YUV2BGRA_YVYU
Python: cv.COLOR_YUV2RGBA_YUYV
Python: cv.COLOR_YUV2BGRA_YUYV
Python: cv.COLOR_YUV2RGBA_YUNV
Python: cv.COLOR_YUV2BGRA_YUNV
Python: cv.COLOR_YUV2GRAY_UYVY
Python: cv.COLOR_YUV2GRAY_YUY2
Python: cv.COLOR_YUV2GRAY_Y422
Python: cv.COLOR_YUV2GRAY_UYNV
Python: cv.COLOR_YUV2GRAY_YVYU
Python: cv.COLOR_YUV2GRAY_YUYV
Python: cv.COLOR_YUV2GRAY_YUNV
Python: cv.COLOR_RGBA2mRGBA
Python: cv.COLOR_mRGBA2RGBA
Python: cv.COLOR_RGB2YUV_I420
RGB to YUV 4:2:0 family.
Python: cv.COLOR_BGR2YUV_I420
Python: cv.COLOR_RGB2YUV_IYUV
Python: cv.COLOR_BGR2YUV_IYUV
Python: cv.COLOR_RGBA2YUV_I420
Python: cv.COLOR_BGRA2YUV_I420
Python: cv.COLOR_RGBA2YUV_IYUV
Python: cv.COLOR_BGRA2YUV_IYUV
Python: cv.COLOR_RGB2YUV_YV12
Python: cv.COLOR_BGR2YUV_YV12
Python: cv.COLOR_RGBA2YUV_YV12
Python: cv.COLOR_BGRA2YUV_YV12
Python: cv.COLOR_BayerBG2BGR
Demosaicing, see color conversions for additional information.
equivalent to RGGB Bayer pattern
Python: cv.COLOR_BayerGB2BGR
equivalent to GRBG Bayer pattern
Python: cv.COLOR_BayerRG2BGR
equivalent to BGGR Bayer pattern
Python: cv.COLOR_BayerGR2BGR
equivalent to GBRG Bayer pattern
Python: cv.COLOR_BayerRGGB2BGR
Python: cv.COLOR_BayerGRBG2BGR
Python: cv.COLOR_BayerBGGR2BGR
Python: cv.COLOR_BayerGBRG2BGR
Python: cv.COLOR_BayerRGGB2RGB
Python: cv.COLOR_BayerGRBG2RGB
Python: cv.COLOR_BayerBGGR2RGB
Python: cv.COLOR_BayerGBRG2RGB
Python: cv.COLOR_BayerBG2RGB
equivalent to RGGB Bayer pattern
Python: cv.COLOR_BayerGB2RGB
equivalent to GRBG Bayer pattern
Python: cv.COLOR_BayerRG2RGB
equivalent to BGGR Bayer pattern
Python: cv.COLOR_BayerGR2RGB
equivalent to GBRG Bayer pattern
Python: cv.COLOR_BayerBG2GRAY
equivalent to RGGB Bayer pattern
Python: cv.COLOR_BayerGB2GRAY
equivalent to GRBG Bayer pattern
Python: cv.COLOR_BayerRG2GRAY
equivalent to BGGR Bayer pattern
Python: cv.COLOR_BayerGR2GRAY
equivalent to GBRG Bayer pattern
Python: cv.COLOR_BayerRGGB2GRAY
Python: cv.COLOR_BayerGRBG2GRAY
Python: cv.COLOR_BayerBGGR2GRAY
Python: cv.COLOR_BayerGBRG2GRAY
Python: cv.COLOR_BayerBG2BGR_VNG
Demosaicing using Variable Number of Gradients.
equivalent to RGGB Bayer pattern
Python: cv.COLOR_BayerGB2BGR_VNG
equivalent to GRBG Bayer pattern
Python: cv.COLOR_BayerRG2BGR_VNG
equivalent to BGGR Bayer pattern
Python: cv.COLOR_BayerGR2BGR_VNG
equivalent to GBRG Bayer pattern
Python: cv.COLOR_BayerRGGB2BGR_VNG
Python: cv.COLOR_BayerGRBG2BGR_VNG
Python: cv.COLOR_BayerBGGR2BGR_VNG
Python: cv.COLOR_BayerGBRG2BGR_VNG
Python: cv.COLOR_BayerRGGB2RGB_VNG
Python: cv.COLOR_BayerGRBG2RGB_VNG
Python: cv.COLOR_BayerBGGR2RGB_VNG
Python: cv.COLOR_BayerGBRG2RGB_VNG
Python: cv.COLOR_BayerBG2RGB_VNG
equivalent to RGGB Bayer pattern
Python: cv.COLOR_BayerGB2RGB_VNG
equivalent to GRBG Bayer pattern
Python: cv.COLOR_BayerRG2RGB_VNG
equivalent to BGGR Bayer pattern
Python: cv.COLOR_BayerGR2RGB_VNG
equivalent to GBRG Bayer pattern
Python: cv.COLOR_BayerBG2BGR_EA
equivalent to RGGB Bayer pattern
Python: cv.COLOR_BayerGB2BGR_EA
equivalent to GRBG Bayer pattern
Python: cv.COLOR_BayerRG2BGR_EA
equivalent to BGGR Bayer pattern
Python: cv.COLOR_BayerGR2BGR_EA
equivalent to GBRG Bayer pattern
Python: cv.COLOR_BayerRGGB2BGR_EA
Python: cv.COLOR_BayerGRBG2BGR_EA
Python: cv.COLOR_BayerBGGR2BGR_EA
Python: cv.COLOR_BayerGBRG2BGR_EA
Python: cv.COLOR_BayerRGGB2RGB_EA
Python: cv.COLOR_BayerGRBG2RGB_EA
Python: cv.COLOR_BayerBGGR2RGB_EA
Python: cv.COLOR_BayerGBRG2RGB_EA
Python: cv.COLOR_BayerBG2RGB_EA
equivalent to RGGB Bayer pattern
Python: cv.COLOR_BayerGB2RGB_EA
equivalent to GRBG Bayer pattern
Python: cv.COLOR_BayerRG2RGB_EA
equivalent to BGGR Bayer pattern
Python: cv.COLOR_BayerGR2RGB_EA
equivalent to GBRG Bayer pattern
Python: cv.COLOR_BayerBG2BGRA
Demosaicing with alpha channel.
equivalent to RGGB Bayer pattern
Python: cv.COLOR_BayerGB2BGRA
equivalent to GRBG Bayer pattern
Python: cv.COLOR_BayerRG2BGRA
equivalent to BGGR Bayer pattern
Python: cv.COLOR_BayerGR2BGRA
equivalent to GBRG Bayer pattern
Python: cv.COLOR_BayerRGGB2BGRA
Python: cv.COLOR_BayerGRBG2BGRA
Python: cv.COLOR_BayerBGGR2BGRA
Python: cv.COLOR_BayerGBRG2BGRA
Python: cv.COLOR_BayerRGGB2RGBA
Python: cv.COLOR_BayerGRBG2RGBA
Python: cv.COLOR_BayerBGGR2RGBA
Python: cv.COLOR_BayerGBRG2RGBA
Python: cv.COLOR_BayerBG2RGBA
equivalent to RGGB Bayer pattern
Python: cv.COLOR_BayerGB2RGBA
equivalent to GRBG Bayer pattern
Python: cv.COLOR_BayerRG2RGBA
equivalent to BGGR Bayer pattern
Python: cv.COLOR_BayerGR2RGBA
equivalent to GBRG Bayer pattern
Python: cv.COLOR_COLORCVT_MAX
Function Documentation
◆ cvtColor()
| void cv::cvtColor | ( | InputArray | src, |
| OutputArray | dst, | ||
| int | code, | ||
| int | dstCn = 0 | ||
| ) |
| Python: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cv.cvtColor( | src, code[, dst[, dstCn]] | ) -> | dst | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Converts an image from one color space to another.
The function converts an input image from one color space to another. In case of a transformation to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR). Note that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on.
The conventional ranges for R, G, and B channel values are:
- 0 to 255 for CV_8U images
- 0 to 65535 for CV_16U images
- 0 to 1 for CV_32F images
In case of linear transformations, the range does not matter. But in case of a non-linear transformation, an input RGB image should be normalized to the proper value range to get the correct results, for example, for RGB \(\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:
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.
If conversion adds the alpha channel, its value will set to the maximum of corresponding channel range: 255 for CV_8U, 65535 for CV_16U, 1 for CV_32F.
Parameters
| src | input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC. ), or single-precision floating-point. |
| dst | output image of the same size and depth as src. |
| code | color space conversion code (see ColorConversionCodes). |
| dstCn | number of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code. |
See also Color conversions Examples: samples/cpp/camshiftdemo.cpp, samples/cpp/edge.cpp, samples/cpp/facedetect.cpp, samples/cpp/ffilldemo.cpp, samples/cpp/lkdemo.cpp, samples/cpp/train_HOG.cpp, samples/cpp/tutorial_code/ImgTrans/houghcircles.cpp, samples/cpp/tutorial_code/ImgTrans/houghlines.cpp, samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp, samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp, samples/cpp/watershed.cpp, samples/dnn/colorization.cpp, samples/dnn/text_detection.cpp, and samples/tapi/hog.cpp.
◆ cvtColorTwoPlane()
| void cv::cvtColorTwoPlane | ( | InputArray | src1, |
| InputArray | src2, | ||
| OutputArray | dst, | ||
| int | code | ||
| ) |
| Python: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cv.cvtColorTwoPlane( | src1, src2, code[, dst] | ) -> | dst | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Converts an image from one color space to another where the source image is stored in two planes.
This function only supports YUV420 to RGB conversion as of now.
- COLOR_YUV2BGR_NV12
- COLOR_YUV2RGB_NV12
- COLOR_YUV2BGRA_NV12
- COLOR_YUV2RGBA_NV12
- COLOR_YUV2BGR_NV21
- COLOR_YUV2RGB_NV21
- COLOR_YUV2BGRA_NV21
- COLOR_YUV2RGBA_NV21
◆ demosaicing()
| void cv::demosaicing | ( | InputArray | src, |
| OutputArray | dst, | ||
| int | code, | ||
| int | dstCn = 0 | ||
| ) |
| Python: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cv.demosaicing( | src, code[, dst[, dstCn]] | ) -> | dst | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
main function for all demosaicing processes
Parameters
| src | input image: 8-bit unsigned or 16-bit unsigned. |
| dst | output image of the same size and depth as src. |
| code | Color space conversion code (see the description below). |
| dstCn | number of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code. |
The function can do the following transformations:
- Demosaicing using bilinear interpolation COLOR_BayerBG2BGR , COLOR_BayerGB2BGR , COLOR_BayerRG2BGR , COLOR_BayerGR2BGRCOLOR_BayerBG2GRAY , COLOR_BayerGB2GRAY , COLOR_BayerRG2GRAY , COLOR_BayerGR2GRAY
- Demosaicing using Variable Number of Gradients. COLOR_BayerBG2BGR_VNG , COLOR_BayerGB2BGR_VNG , COLOR_BayerRG2BGR_VNG , COLOR_BayerGR2BGR_VNG
- Edge-Aware Demosaicing. COLOR_BayerBG2BGR_EA , COLOR_BayerGB2BGR_EA , COLOR_BayerRG2BGR_EA , COLOR_BayerGR2BGR_EA
- Demosaicing with alpha channel COLOR_BayerBG2BGRA , COLOR_BayerGB2BGRA , COLOR_BayerRG2BGRA , COLOR_BayerGR2BGRA

Generated on Sun Oct 29 2023 16:40:06 for OpenCV by 1.8.13