Ask Your Question
0

Getting null value for image pixel

asked 2017-08-03 04:08:16 -0600

arqam gravatar image

updated 2017-08-03 04:09:42 -0600

berak gravatar image

I have an image and when I try to get the pixel value using

srcImage.get(x,y,buffer) and if the buffer is of a double data type I get null values in many cases and when the data type is changed to byte[] I don't get null.

My image is in YCrCb format. Any possible reason for this problem?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-08-03 04:15:05 -0600

berak gravatar image
  • YCrCb is unlikely to be double[], more like byte[]
  • img.get( y, x, buffer ); // NOT x,y
  • if you pass in a buffer, the type has to fit the image spec, you're not free to choose.
  • if you need a double[], use double[] pix = img.get(y,x);
  • try to avoid using get() and set(), it's slow & error-prone
edit flag offensive delete link more

Comments

but what is some values are more than 127, then we can't use byte right

arqam gravatar imagearqam ( 2017-08-03 04:20:06 -0600 )edit

no, byte is unsigned char, [0..255]

berak gravatar imageberak ( 2017-08-03 04:22:26 -0600 )edit

In Java its not. Just 127, here I need to find the highest Y value for the color space YcrCb.

arqam gravatar imagearqam ( 2017-08-03 04:28:02 -0600 )edit

And why should it be img.get(y,x) and not (x,y) as in the documentation it says (rows,columns)

arqam gravatar imagearqam ( 2017-08-03 04:36:10 -0600 )edit

y is row index (vertical), x is column index (horizontal)

berak gravatar imageberak ( 2017-08-03 04:42:56 -0600 )edit

Any way of getting the highest Y value of the pixel without parsing all the pixels?

arqam gravatar imagearqam ( 2017-08-03 04:59:04 -0600 )edit

use submat() to get a row, and minMaxLoc() on that to find the value

berak gravatar imageberak ( 2017-08-03 05:00:33 -0600 )edit

Is it possible to just get the row value using submat()?

arqam gravatar imagearqam ( 2017-08-03 05:51:56 -0600 )edit

what's "row value" ?

there's Mat.row(), too

berak gravatar imageberak ( 2017-08-03 06:09:11 -0600 )edit

For minMaxLoc it gives the error Assertion failed ((cn == 1 && (_mask.empty() || _mask.type() == CV_8U)) || (cn > 1 && _mask.empty() && !minIdx && !maxIdx)) in minMaxIdx, We just need to pass a submat right?

arqam gravatar imagearqam ( 2017-08-03 06:13:25 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-03 04:08:16 -0600

Seen: 421 times

Last updated: Aug 03 '17