How to get data of Mat?
I want to get data of Mat. I found many pages with info. But i still have questions.
http://jayrambhia.wordpress.com/2012/06/23/get-data-from-mat-cvmat-in-opencv/ http://docs.opencv.org/trunk/doc/tutorials/core/how_to_scan_images/how_to_scan_images.html
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++){
cout<<lung_left.at<float>(i,j)<<"\t";
}
}
In console, i got it: 26e+008 -1598.2 -5.2332e-06 ...
but if use it: " lung_left.at<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.
you want lung_left.at<uchar>(i,j); here, not float
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)(lung_left.data); and getting data in bucle with: (int)input[lung_left.step * j + i]