c++ - imwrite in OpenCV3.1 doesn't work -


when trying save image using imwrite following error:

files describe 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 online privacy statement not available, please read our privacy statement offline:   c:\windows\system32\en-us\erofflps.txt 

here's entire code (the code works --imshow shows blurred image):

#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 black , white image (grey)     image = 0.2126*channels[0] + 0.7152*channels[1] + 0.0722*channels[2]; //wikipedia formula      //colorimetric (luminance-preserving) conversion grayscale        if (image.empty())                      // check invalid input     {         cout << "could not open or find image" << std::endl;         return 0;     }      float neighbors[8];     float neighbors_mean = 0;     float neighbors_sum;      (int iter = 0; iter < 3; iter++){         (int = 0; < image.rows; i++) {             (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 window display.     //imshow("grey mona", image);                // show our image inside it.      //resizewindow("grey mona",800, 1000);      //waitkey(0); // wait keystroke in window     imwrite("10_iteration_blurring.jpg", image);     return 0; } 

but imwrite becomes unresponsive. how should fix this?

enter image description here

this worked me:

 imwrite("10_iteration_blurring.bmp", image); 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -