# Revision history [back]

### Imread returns a blank image for a certain file

version: 4.0.0-alpha

I try to display an image with this code:

cv::Mat image1 = cv::imread(path);
std::ifstream ifile(path);
if (!ifile.is_open()) {
std::cerr << "There was a problem opening the input file" << std::endl;
}
Mat prev = image1;
namedWindow("Display", WINDOW_AUTOSIZE);
imshow("Display", image1);
waitKey(0);


Where path is absolute path to a file. When I try to run with this file: C:\fakepath\5a2e6ac832420.png, i got only a black window without any image.

At the same time it works well with images from another dataset. Obviously the problem lays in file. But I just can't figure it out. It's a common png, what's wrong? I tried to use different flags in cv::imread, but it was useless.

Any ideas?

 2 retagged sturkmen 5881 ●3 ●41 ●68 https://github.com/stu...

### Imread returns a blank image for a certain file

version: 4.0.0-alpha

I try to display an image with this code:

cv::Mat image1 = cv::imread(path);
std::ifstream ifile(path);
if (!ifile.is_open()) {
std::cerr << "There was a problem opening the input file" << std::endl;
}
Mat prev = image1;
namedWindow("Display", WINDOW_AUTOSIZE);
imshow("Display", image1);
waitKey(0);


Where path is absolute path to a file. When I try to run with this file: C:\fakepath\5a2e6ac832420.png, i got only a black window without any image.

At the same time it works well with images from another dataset. Obviously the problem lays in file. But I just can't figure it out. It's a common png, what's wrong? I tried to use different flags in cv::imread, but it was useless.

Any ideas?