OpenCV cvtColor function convert image from one colour space to another, such as from BGR to Gray, BGR to RGB, BGR to HSV, also by default OpenCV imread load image in BGR mode.
src ---> Input Image
dst ---> Output Image
conv_code --->conversion code(COLOR_BGR2GRAY,COLOR_BGR2HSV,COLOR_BGR2RGB etc..)
dstCn ---> Number of channel in desensitisation image.
C++ cvtColor function
void cvtColor(InputArray src, OutputArray dst, int conv_code, int dstCn=0 )
Where,src ---> Input Image
dst ---> Output Image
conv_code --->conversion code(COLOR_BGR2GRAY,COLOR_BGR2HSV,COLOR_BGR2RGB etc..)
dstCn ---> Number of channel in desensitisation image.
How to use cvtColor C++
Load Image from disk,
Mat src = imread("flower.jpg",IMREAD_COLOR);
if(! src.data ) {
std::cout << "Could not open or find the image" << std::endl ;
return -1;
}
imshow("src",src);
BGR To Gary
Mat dst;
cvtColor(src,dst,COLOR_BGR2GRAY);
BGR To HSV
cvtColor(src,dst,COLOR_BGR2HSV);
BGR To RGB
cvtColor(src,dst,COLOR_BGR2RGB);
No comments:
Post a Comment