Ask Your Question
0

How to store negative float values in Mat object? [closed]

asked 2017-05-31 07:40:32 -0600

anomaly_ gravatar image

Why am I not able to do this?

Mat img = Mat(4,4, CV_32FC3);
img.at<Vec3b>(0,0)[0] = -1;
img.at<Vec3b>(0,1)[0] = -0.5;

When I display the Mat object, it shows 255 in place of -1. I want to have all of my pixel values in the range of -1 to 1. How can I achieve that?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by LBerger
close date 2017-05-31 07:49:40.375286

1 answer

Sort by » oldest newest most voted
0

answered 2017-05-31 07:43:07 -0600

LBerger gravatar image

updated 2017-05-31 07:43:45 -0600

it is not

   img.at<Vec3b>(0,0)[0] = -1;

but

   img.at<Vec3f>(0,0)[0] = -1;
edit flag offensive delete link more

Comments

Ohh! Got it, Thanks a lot :)

anomaly_ gravatar imageanomaly_ ( 2017-05-31 07:48:36 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-05-31 07:40:32 -0600

Seen: 1,142 times

Last updated: May 31 '17