Ask Your Question

How to access pixel values of CV_32F/CV_64F Mat?

asked 2013-02-28 01:40:01 -0600

I was working on homography and whenever I try to check the values of H matrix (type CV_64F) using<float>(i, j) I get random numbers(sometimes garbage value). I want to access pixel values of float matrix. Is there any way to do it?

Mat A = Mat::eye(3, 3, CV_64F);
float B;
for(int i=0; i<A.rows; i++)
    for(int j=0; j<A.cols; j++)
        printf("%f\n",<float>(i, j));

imshow("identity", A);

This shows correct image of an identity matrix but while trying to access pixel values, I get

0.000000 1.875000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

Why is this so?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-02-28 01:52:05 -0600

AlexanderShishkov gravatar image

updated 2013-02-28 03:30:32 -0600

You should use double type for CV_64F type and float one for CV_32F type.

 printf("%f\n",<double>(i, j));
edit flag offensive delete link more

Question Tools


Asked: 2013-02-28 01:40:01 -0600

Seen: 8,485 times

Last updated: Feb 28 '13