Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

first, please use correct flags for imread()

i guess, you wanted the following:

Mat image = imread(path, IMREAD_GRAYSCALE);
Mat float_img;
image.convertTo(float_img, CV_32F);

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;

first, please use correct flags for imread()

i guess, you wanted the following:

Mat image = imread(path, IMREAD_GRAYSCALE);
IMREAD_GRAYSCALE); //8bit uchar [0..255]
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;

first, please use correct flags for imread()

i guess, you wanted the following:

Mat image = imread(path, IMREAD_GRAYSCALE); //8bit uchar [0..255]
[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;