Ask Your Question
0

Problem reading values from normalized Mat

asked 2013-12-18 16:35:50 -0500

Guru978 gravatar image

Hello everyone,

I have to come up again with a question.

My Problem: I subtract 2 Mat (each CV_16UC1 normalized to CV8_UC1) with the following code:

normalize(src1,dst1,0,255,NORM_MINMAX,CV_8UC1);
normalize(src2,dst2,0,255,NORM_MINMAX,CV_8UC1);
subtract(dst1,dst2,finaldestination);

now i want to access the values with:

finaldestination.at<uchar>(x,y)...

but every datatype I try brings a letter, a funny box but not the value...(the picture output with imshow is correct...) (I tried uchar, unsigned character, unsigned short, ushort...nothing works)

Any suggestions for me? Thx in advance!

edit retag flag offensive close merge delete

Comments

is that the 'cout thinks a uchar is a letter' problem ?

try a simple cast:

cout << (int) finaldestination.at<uchar>(y,x); // also note , y,x - not x,y

berak gravatar imageberak ( 2013-12-18 17:06:48 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-11-23 21:24:48 -0500

img gravatar image

try this:

normalize(src1,dst1,0,255,NORM_MINMAX,CV_8UC1);
normalize(src2,dst2,0,255,NORM_MINMAX,CV_8UC1);

dst1.convertTo(dst1, CV_32FC1);
dst2.convertTo(dst2, CV_32FC1);

subtract(dst1,dst2,finaldestination);
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-12-18 16:35:50 -0500

Seen: 5,654 times

Last updated: Dec 18 '13