I have downloaded a program, in which there are multiple classes. In that one of the function receives an image as parameter. How can I check the Image received by that function in is in YUV format or RGB format using opencv ??
You can't. Mat does not have such information. All you can get is depth and number of channels.
Related
i don't understand when opencv documentation mention the term "channel" . Does it mean the channel as in digital image ? or it is something else ?
So as OpenCV is an image processing Library, So A given image can be assumed as 2D matrix with each element as a pixel. Now since there are various types of image formats like Gray, RGB or RGBA, etc. each format is different as to how many colors it(pixel) can support. For example the pixels of Gray image take values in range 0-255 so to represent each gray pixel we need single uchar value, so it has single channel, similarly the pixels of RGB image can take values from 0-16777216 and to represent each RGB pixel, we need 3 uchar values, (256^3 = 16777216), hence it is 3 channels, similarly RGBA has 4 channels, the last channel is used for storing the alpha(transparency) value.
I am doing a computer vision based project in open cv.I want to plot the histograms each channel of a BGR image in the same window.I did it by splitting the image in 3 channels and then applying calcHist to each. Is there any way to do it by using the function only once and changing the parameters .Also I did not properly understand the const int* channels parameter in calcHist function.
take a look at the offical tutorial about plotting histogram of the image. here is the link for calcHist_Demo.cpp
What grayscale conversion algorithm does OpenCV's
cv::imread("image.jpg", cv::IMREAD_GRAYSCALE);
use?
In OpenCV 3.0:
cv::IMREAD_COLOR: the image is decompressed by cv::JpegDecoder as JCS_RGB (three channel image) and then the icvCvt_RGB2BGR_8u_C3R() function will swap the red and blue channels in order to get BGR format.
cv::IMREAD_GRAYSCALE: the image is decompressed by cv::JpegDecoder as JCS_GRAYSCALE (one channel image), all details of color conversion and other preprocessing/postprocessing is handled by the libjpeg. Finally, the decompressed data are copied into the internal buffer of the given cv::Mat.
Ergo no cv::cvtColor() is called after reading the image as cv::IMREAD_GRAYSCALE.
I am using BGR to HSV conversion of image using OpenCV. Since I am new to this field and software, I may sound incorrect so please let me know if I am wrong.
Now, in my school project i want to work with HSV image, which is easily converted using
cvtColor(src, dst, CV_BGR2HSV);
I suppose, that imread() function reads image in a uchar format which is 8bit unsigned image (i suppose). In that case imshow() is also uchar.
But to work with HSV image, I am not sure but I feel i need to convert use Mat3b perhaps for the distinctive H, S and V channels of the image.
Incase if I am wrong, that I want to work with H channel of the HSV image only so how can i print, or modify this channel information.
Many thanks
Perhaps you can use cv::split to devide the HSV to 3 one-channel Mat. I think this topic OpenCV:split HSV image and scan through H channel may solve your problem.
How convert one channel YUV image (first channel - Y are used) to 24 depth RGB image? I asks, because i must display it using gtk+ interface and gtk supports only 24 depth RGB image.
I'm not sure what you are actually starting from, a single-channel grayvalue image or a three-channel YUV image of which the second and third channel are full of zeros. If you have a single-channel 8-bit image to start with, you can use cvtColor(source_mat,destination_mat,CV_GRAY2RGB) to convert to 24-bit RGB. If you are starting from a 3-channel 24-bit YUV image with two channels full of zeros, you can use the split() function to get the Y channel out of it, then convert that as described above.