Ask Your Question

How to get data of Mat?

asked 2013-09-27 11:12:48 -0500

jecs89 gravatar image

updated 2013-09-27 11:46:08 -0500

berak gravatar image

I want to get data of Mat. I found many pages with info. But i still have questions.

I have it.

Mat lung_left( image_gray, Rect( 55, 100, 195, 290));
for( int i=0; i< lung_left.rows; i++){
    for( int j=0; j< lung_left.cols; j++){

In console, i got it: 26e+008 -1598.2 -5.2332e-06 ...

but if use it: "<float>(i,j) = 0; " in the cycle and print, i got it: 0 0 0 0 ...

It's strange, i can change values using .at<>(i,j) but i can't print the values rightly.

edit retag flag offensive close merge delete



you want<uchar>(i,j); here, not float

berak gravatar imageberak ( 2013-09-27 11:51:49 -0500 )edit

Thank you, i try it and worked. When i use uchar, i get char then i cast it in int.

I'm using it. unsigned char input = (unsigned char)(; and getting data in bucle with: (int)input[lung_left.step * j + i]

jecs89 gravatar imagejecs89 ( 2013-09-30 12:04:26 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-09-27 11:45:19 -0500

updated 2013-09-27 11:46:30 -0500

Your compiler is in debug mode.The issue is how to allocate the memory in debug mode that compiler fill it by specific pattern(magic debug values).If you build your code in the release mode probably the initial value is zero.Magic debug values are specific values written to memory during allocation or deallocation, so that it will later be possible to tell whether or not they have become corrupted, and to make it obvious when values taken from uninitialized memory are being used.

edit flag offensive delete link more


I got a bit. You can explain me more about how to make it. I'm using codeblocks. Thank you.

jecs89 gravatar imagejecs89 ( 2013-09-30 12:05:31 -0500 )edit

Question Tools


Asked: 2013-09-27 11:12:48 -0500

Seen: 1,223 times

Last updated: Sep 27 '13