#include <iostream>
#include <fstream>
#include <iomanip>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include<opencv\cv.h>
#include<opencv\highgui.h>
using namespace cv;
using namespace std;
int c;
int main(int argc, char* argv[])
{
ofstream fout("output.txt");
Mat image = imread("toilet.jpg", CV_LOAD_IMAGE_GRAYSCALE);
Mat B = image;
if (image.empty()){
fout << "Image open fail" << endl;
exit(1);
}
for (int i = 0; i < 320; ++i){
for (int j = 0; j < 240; ++j){
//3)
if ((int)image.at<uchar>(i, j) > 120)
{c=c+1;}
fout << setw(3) << " " << (int)image.at<uchar>(i, j);
}
fout << endl;
}
if (c>3000)
printf("bright pixel : %d \n AAA", c);
else
printf("bright pixel : %d \n BBB", c);
//4)
imshow("ML", B);
//5)
waitKey(0);
image.release(); // isn't it releasing memory?
B.release(); //
return 0;
}
please give me some bright answers it's killing me :( because it worked right before a day The error is like figure under.