当我尝试使用imwrite保存图像时,我收到以下错误:
Files that help describe the problem:
C:\Users\jalal\AppData\Local\Temp\WER64CE.tmp.WERInternalMetadata.xml
C:\Users\jalal\AppData\Local\Temp\WER7092.tmp.appcompat.txt
C:\Users\jalal\AppData\Local\Temp\WER70C2.tmp.mdmp
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
这是我的整个代码(代码有效 - 显示模糊图像):
#include <opencv2/core/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
//void tintImageBlue(Mat& image);
int main()
{
Mat image;
Mat channels[3];
image = imread("mona1.jpg", IMREAD_GRAYSCALE);
split(image, channels);
//image = 0.2*channels[0] + 0.4*channels[1] + 0.4*channels[2]; //gives us a black and white image (grey)
image = 0.2126*channels[0] + 0.7152*channels[1] + 0.0722*channels[2]; //wikipedia formula
//Colorimetric (luminance-preserving) conversion to grayscale
if (image.empty()) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return 0;
}
float neighbors[8];
float neighbors_mean = 0;
float neighbors_sum;
for (int iter = 0; iter < 3; iter++){
for (int i = 0; i < image.rows; i++) {
for (int j = 0; j < image.cols; j++) {
neighbors[0] = (((i - 1) >= 0 && (j - 1) >= 0) ? image.at<uchar>(i - 1, j - 1) : 0.0f);
neighbors[1] = (((i - 1) >= 0) ? image.at<uchar>(i - 1, j) : 0.0f);
neighbors[2] = (((i - 1) >= 0 && (j + 1) < image.cols) ? image.at<uchar>(i - 1, j + 1) : 0.0f);
neighbors[3] = (((j + 1) < image.cols) ? image.at<uchar>(i, j + 1) : 0.0f);
neighbors[4] = (((i + 1) < image.rows && (j + 1) < image.cols) ? image.at<uchar>(i + 1, j + 1) : 0.0f);
neighbors[5] = (((i + 1) < image.rows && (j - 1) >= 0) ? image.at<uchar>(i + 1, j) : 0.0f);
neighbors[6] = (((i + 1) < image.rows && (j - 1) >= 0) ? image.at<uchar>(i + 1, j - 1) : 0.0f);
neighbors[7] = (((j - 1) >= 0) ? image.at<uchar>(i, j - 1) : 0.0f);
neighbors_sum = neighbors[0] + neighbors[1] + neighbors[2] + neighbors[3] +
neighbors[4] + neighbors[5] + neighbors[6] + neighbors[7];
neighbors_mean = neighbors_sum / 8.0f;
image.at<uchar>(i, j) = neighbors_mean;
neighbors_sum = 0;
neighbors_mean = 0;
}
}
}
//tintImageBlue(image);
//namedWindow("Grey Mona", WINDOW_AUTOSIZE); // Create a window for display.
//imshow("Grey Mona", image); // Show our image inside it.
//resizeWindow("Grey Mona",800, 1000);
//waitKey(0); // Wait for a keystroke in the window
imwrite("10_iteration_blurring.jpg", image);
return 0;
}
但是对于imwrite,它变得没有反应。我该如何解决这个问题?
答案 0 :(得分:1)
这对我有用:
||