开发者

Convert All Images to RGB for Transfer

I am using JNA to access openCV, in my application I have one function that returns an array of RGB values to java for display which is fine if the image is actually uses rgb color space but if the image is hsv or a binary开发者_StackOverflow image it produces odd behavior artifacts how i can detect what color space it is using and convert everything to rgb before transfer and convert them to rgb if they arent?


You can't detect if an image is rgb or not by direct examination of the the three buffers. You need to know what format it's in before making it available to another process or app. I suggest you decide to use rgb for all your interprocess buffers and ensure that all the images are converted to rgb in each originating process.

in Opencv use "CvtColor" to get the native bgr into rgb. From other apps - if they don't support image conversion - then you can use cvconvert to get them all into rgb if you need to.

You can also use "Merge" and "Mixchannels" to make simple rgb to bgr without any fuss and in-place.

in 2.2 there is a better rgb to hsv fuinction which uses all 256 values for hue. it is better than the older one.

docs here: http://opencv.willowgarage.com/wiki/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜