Changing Colorspaces | opencv cpp cvtcolor
GoalInthistutorial,youwilllearnhowtoconvertimagesfromonecolor-spacetoanother,likeRGB(leftrightarrow)Gray,RGB(leftrightarrow)HSVetc.Youwilllearnfollowingfunctions:cv.cvtColor()[1],cv.inRange()[2]etc.cvtColorTherearemorethan150color-spaceconversionmethodsavailableinOpenCV.Butwewilllookintothemostwidelyusedone:RGB(leftrightarrow)Gray.Weusethefunction:cv.cvtColor[3](src,dst,code,dstCn=0)Parameterssrcinputimage.dstoutputimageofthesamesizeanddepthassrccodecolorspaceconversioncode(seecv.ColorConver...
Goal In this tutorial, you will learn how to convert images from one color-space to another, like RGB (leftrightarrow) Gray, RGB (leftrightarrow) HSV etc. You will learn following functions : cv.cvtColor()[1], cv.inRange()[2] etc. cvtColorThere are more than 150 color-space conversion methods available in OpenCV. But we will look into the most widely used one: RGB (leftrightarrow) Gray.
We use the function: cv.cvtColor[3] (src, dst, code, dstCn = 0)
Parameters srcinput image. dstoutput image of the same size and depth as src codecolor space conversion code(see cv.ColorConversionCodes[4]). dstCnnumber of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code.For RGB ( ightarrow) Gray conversion we use the code cv.COLOR_RGBA2GRAY[5].
Try it inRangeChecks if array elements lie between the elements of two other arrays.
We use the function: cv.inRange[6] (src, lowerb...