Bayer to HSV using openCV - opencv

does somebody know is there is a function somewhere available (based on OpenCV), to convert bayer images to HSV colourspace?
Or do I have to do the step via RGB?

Read about cvtColor and CV_BayerBG2BGR. More here.

Related

Lena grayscale image processing values

I am trying to get the grayscale image values 0-255 of the 512x512 image of lena. Some have suggested using Matlab, however I do not have Matlab. Has anyone used Gimp for this?
Just use ImageMagick. It is installed on most Linux distros and available for OSX and Windows:
convert lena.jpg -colorspace gray -depth 8 txt:-
The octave solution is to read the image using
im = imread("lena512.jpg");
The image im can then be shown using imshow (im).
Conversion to grayscale can be performed using
lenagy = 0.3*im(:,:,1) + 0.6*im(:,:,2) + 0.1*im(:,:,3);
The result is that lenagy consists of a 2-D array, which can be saved to a file using for example
save lenagy.org lenagy

Grayscale conversion algorithm of OpenCV's imread()

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.

Is there any function in OpenCV to quantize RGB values?

I need to quantize the RGB values to 29 uniform color dictionary. I used rgb2ind(image,29) in Matlab.
So, is there any function or efficient way to quantize the image color in OpenCV?
(I need to quantize the image color because i want to get a 29-sized histogram of color)
You will have to make your own. I can reccomend using HSV instead of RGB (you can convert RGB to HSV with opencv). Once the image is converted, you can then simply use 29 ranges for the H value.
EDIT: I saw this answer might be a bit vague for those who have little experience in computer vision. This question gives a lot more information about the difference between HSV and RGB and why this is usefull.

Convert from Vec3b to Mat3b

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.

SURF and OpenSURF to color image

I am using SURF features in OpenCV where the input images are converted to GRAY image.
cvtColor(object, object, CV_RGB2GRAY);
When I went through the documentation of OpenSURF I realised that its not in grayscale.
My confusion is that can we apply SURF to any image formats (YUV, HSV, RGB) or we have to change and modify the program to achieve that?
Most feature detectors work on greyscale because they analyse the patterns of edges in the image patch. You can run SURF on any single colour channel from the colour formats you mention i.e. You can run it on Y, U or V from YUV images, or on H, S or V from HSV images. Not sure how OpenSURF treats this, but they must be using the greyscale image internally.
Like OpenCV if you given an image to OpenSURF that is not single channel, it calls cvtColor(src, dst, CV_BGR2GRAY). If you pass either a 3 channel image in a YUV, HSV, Lab etc, things will go horribly wrong because the image will have an inappropriate color conversion applied..

Resources