Ask Your Question
0

How to get one-pixel value from grayscaleImage(java,Android)

asked 2018-11-28 13:10:52 -0600

deveator gravatar image

After using code below

changedImg = new Mat();

    Imgproc.cvtColor(sampledImg, changedImg, Imgproc.COLOR_RGB2GRAY);

    changedImg.convertTo(changedImg,CvType.CV_8UC1);

    int rows = changedImg.rows();
    int clmns = changedImg.cols();
    int chn = changedImg.channels();

    double[] ft = changedImg.get(1560, 2080);

    infoTw.setText(rows + " | " + clmns + " | " + chn + " | " + ft );

Blockquote

I got " 3160 | 4160 | 1 | [D@cbe047b " What does "[D@cbe047b" mean? I consider that value is in range 0 - 255. A how could I get pixel value in range 0 - 255 ?

Thank in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-11-28 13:17:47 -0600

berak gravatar image

updated 2018-11-28 13:32:15 -0600

have another look at the docs

what you receive there is a []double (or the equivalent of a cv::Scalar)

in case of a grayscale (single channel) image, what you want is:

double[] ft = changedImg.get(1560, 2080)
double pixelvalue =  ft[0];

just to make it more obvious, in case of a bgr(3 channel) image it would be:

double[] ft = changedImg.get(1560, 2080)
double b =  ft[0];
double g =  ft[1];
double r =  ft[2];
edit flag offensive delete link more

Comments

1

Thank y With help of your answer I found right way. In my case I must add only

double b =  ft[0];

because of I convert image in grayScale

deveator gravatar imagedeveator ( 2018-11-29 00:38:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-11-28 13:10:52 -0600

Seen: 202 times

Last updated: Nov 28 '18