0
我目前正在研究一段使用OpenCV将图像变成灰度的代码。我已经成功地把图像的黑色和白色,因为我想,用下面的代码:为什么我的get()方法失败了这个函数?
public static void Greyscale() {
Mat inputImage = Highgui.imread("files/lena.png");
Mat greyImage = new Mat();
Imshow ims4 = new Imshow("Grey Image");
Imgproc.cvtColor(inputImage, greyImage, Imgproc.COLOR_BGR2GRAY);
ims4.showImage(greyImage);
不过,我现在要运行一些特定的像素的get()方法,以确保所有的BGR值相等。然而,这不工作:
double[] bgr = greyImage.get(0, 0);
System.out.println("colour @ (0,0) = B: " + bgr[0] + " G: " + bgr[1] + " R: " + bgr[2]);
运行上述代码导致错误“在线程异常‘等的消息主要’java.lang.ArrayIndexOutOfBoundsException:1 在ColourQuery.Greyscale(ColourQuery.java:129) (ColourQuery.java:67)“ ”(ColourQuery.java:67)“
任何人都可以指出我在哪里出错了这段代码?它的工作的时候它不灰度图图像...
什么是'greyImage'的大小?你有什么事吗? – 2015-02-06 18:10:54
灰度图像中有多少个通道?再看一遍.. – berak 2015-02-06 18:11:20
它与input()代码工作的inputImage尺寸相同。 – Zetland 2015-02-06 18:11:36