Learn Opencv Representative To Convert Rgb To Greyness / Other Colouring Cloth Spaces
void cvtColor(InputArray src, OutputArray dst, int code, int dstCn=0 )
Parameters:
The conventional ranges for R, G, in addition to B channel values are:
RGB
GRAY ( CV_BGR2GRAY, CV_RGB2GRAY, CV_GRAY2BGR, CV_GRAY2RGB )
RGB
YCrCb JPEG (or YCC) ( CV_BGR2YCrCb,CV_RGB2YCrCb,CV_YCrCb2BGR,CV_YCrCb2RGB )
RGB
HSV ( CV_BGR2HSV, CV_RGB2HSV, CV_HSV2BGR, CV_HSV2RGB )
RGB
HLS ( CV_BGR2HLS, CV_RGB2HLS, CV_HLS2BGR, CV_HLS2RGB )
RGB
CIE L*a*b* ( CV_BGR2Lab, CV_RGB2Lab, CV_Lab2BGR, CV_Lab2RGB )
RGB
CIE L*u*v* ( CV_BGR2Luv, CV_RGB2Luv, CV_Luv2BGR, CV_Luv2RGB )
Bayer
RGB ( CV_BayerBG2BGR, CV_BayerGB2BGR, CV_BayerRG2BGR, CV_BayerGR2BGR, CV_BayerBG2RGB, CV_BayerGB2RGB, CV_BayerRG2RGB, CV_BayerGR2RGB )
RGB
CIE XYZ.Rec 709 amongst D65 white betoken ( CV_BGR2XYZ, CV_RGB2XYZ, CV_XYZ2BGR, CV_XYZ2RGB )
Parameters:
- src – input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC... ), or single-precision floating-point.
- dst – output icon of the same size in addition to depth equally src.
- code – color infinite conversion code (see the description below).
- dstCn – publish of channels inward the finish image; if the parameter is 0, the publish of the channels is derived automatically from src in addition to code .
Note that the default color format inward OpenCV is oft referred to equally RGB precisely it is genuinely BGR (the bytes are reversed).
The conventional ranges for R, G, in addition to 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
RGB
RGB
RGB
RGB
RGB
RGB
Bayer
RGB
Steps:
Load an image- Convert to grayness scale
- Show result
Functions:
Example:
-------------#include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "iostream" using namespace cv; using namespace std; int main( ) { Mat image; icon = imread("lena.jpg", CV_LOAD_IMAGE_COLOR); if(! image.data ) { cout << "Could non opened upward or notice the image" << std::endl ; supply -1; } // Create a novel matrix to concur the grayness icon Mat gray; // convert RGB icon to grayness cvtColor(image, gray, CV_BGR2GRAY); namedWindow( "Display window", CV_WINDOW_AUTOSIZE ); imshow( "Display window", icon ); namedWindow( "Result window", CV_WINDOW_AUTOSIZE ); imshow( "Result window", grayness ); waitKey(0); supply 0; } ------------- Sources:
Comments
Post a Comment