我怎么知道图像是RGB还是BGR格式? [英] how can i know if the image is in RGB or BGR format?

查看:6532
本文介绍了我怎么知道图像是RGB还是BGR格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法事先知道用作系统输入的图像是RGB还是BGR格式?

is there any way to know in advance if an image used as an input to a system is in RGB or BGR format?

我正在使用带有java API的opencv我想将输入图像转换为灰度或L a b *颜色空间,而在opencv中,您必须首先指定要转换的图像是RGB还是BGR。

I am using opencv with java API and i would like to convert an input image into grayscale or Lab* color space, and in opencv you have to specify first whether the image you want to convert is in RGB or BGR.

更新

我使用的图片类型是.jpg或png

the type of the image i am using is either .jpg or png

推荐答案

如果您的图片是 BufferedImage 那么您可以要求他键入 getType(),并针对几个常量进行测试(请参阅: BufferedImage )。

If your image is a BufferedImage then you can ask for his type with getType(), and test against the several constants (see: BufferedImage).

这篇关于我怎么知道图像是RGB还是BGR格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆