color space - OpenCV Display Colored Cb Cr Channels -
so understand how convert bgr image ycrcb format using cvtcolor() , seperate different channels using split() or mixchannels() in opencv. however, these channels displayed grayscale images cv_8uc1 mats.
i display cb , cr channels in color barns image on wikipedia. found solution in matlab, how do in opencv?
furthermore, mentioned solution displayed cb , cr channels "fills other channels constant value of 50%". question is:
is common way display cr cb channels? or there recommendations or specifications when displaying cr cb channels?
i made code scratch described in answer. looks it's need.
mat bgr_image = imread("lena.png"); mat ycrcb_image; cvtcolor(bgr_image, ycrcb_image, cv_bgr2ycrcb); mat ycrcbchannels[3]; split(ycrcb_image, ycrcbchannels); mat half(ycrcbchannels[0].size(), ycrcbchannels[0].type(), 127); vector<mat> ychannels = { ycrcbchannels[0], half, half }; mat yplot; merge(ychannels, yplot); cvtcolor(yplot, yplot, cv_ycrcb2bgr); imshow("y", yplot); vector<mat> crchannels = { half, ycrcbchannels[1], half }; mat crplot; merge(crchannels, crplot); cvtcolor(crplot, crplot, cv_ycrcb2bgr); imshow("cr", crplot); vector<mat> cbchannels = { half, half, ycrcbchannels[2] }; mat cbplot; merge(cbchannels, cbplot); cvtcolor(crplot, crplot, cv_ycrcb2bgr); imshow("cb", cbplot); waitkey(0);
as converting grayscale images color format, in such case color channels (b, g, r) set 1 grayscale value. in opencv cv_gray2bgr
mode implemented in manner.
as "fills other channels constant value of 50%" believe it's common way visualize such color spaces ycbcr , lab. did not find articles , descriptions of approach, think it's driven visualization purposes. indeed, if fill other channels zero, fundamentally nothing has changed: can see influence of each channel, picture not nice:
so, aim of approach make visualization more colorful.
Comments
Post a Comment