Iterating and printing all pixel values from a Mat image
Hello,
i would like to iterate and print out all pixel values of my
Mat image = imread(path, CV32F)
-Object.
Hello,
i would like to iterate and print out all pixel values of my
Mat image = imread(path, CV32F)
-Object.
first, please use correct flags for imread()
i guess, you wanted the following:
Mat image = imread(path, IMREAD_GRAYSCALE); //8bit uchar [0..255] (CV_8U)
Mat float_img;
image.convertTo(float_img, CV_32F);
//image.convertTo(float_img, CV_32F, 1.0/255); // if you want it in [0..1] range
then, iterating over pixels is an absolute anti-pattern in opencv, please try to avoid that by all means.
you can simply print a whole Mat by:
cout << image << endl;
Asked: 2017-03-09 04:01:05 -0600
Seen: 4,159 times
Last updated: Mar 09 '17
What is the most effective way to access cv::Mat elements in a loop?
How to operate on each pixel of a cv2.cv.Mat with a 3 x 3 matrix?
Basic matrix operations producing null pointer members
[C++] OpenCV2.4.3, cv::resize produces empty image
Access multiple channels in Mat