Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV color-value of a pixel by using mat.get() returns sometimes null

I try to get the RGB Values of a pixel using mat.get(inx, int y) on Android and OpenCV 2.4.4.

Mat img = Utils.loadResource(getBaseContext(), R.drawable.ex3);
double[] tmp = img.get(100, 100);
if(printLog) Log.v(tag, "Color: "+ tmp[0] +","+ tmp[1] +","+ tmp[2] +"");

Normaly I got the tmp-Array returned. But at some pixels, i got returned "null". (That points are in range of the picture!)

So why I get at some coordinates a array and on some others "null" and how to fix that?

like image 375
Paket2001 Avatar asked Apr 02 '13 12:04

Paket2001


1 Answers

At OpenCV by getting pixelinformations with Mat.get(row, col) the meaning of X and Y is changed: Use Y for the row and X for the col.

Mat.get(Y, X);

So in my case I was out of range but openCV did not return a Exception. It returns "null"

like image 75
Paket2001 Avatar answered Nov 16 '22 20:11

Paket2001