about use Mat to make binary image [closed]
I want make a binary image . the code is the following:
#include<opencv\cv.h>
#include<stdlib.h>
#include<opencv2\opencv.hpp>
#include<opencv\highgui.h>
using namespace cv;
int main()
{
int i=0,j=0;
Mat img = imread("hh.jpg");
if(img.empty())
{
printf("无法打开\n");
return 0;
}
for(i=0;i<img.rows;++i)
for(j=0;j<img.cols;++j)
{
if(img.at<uchar>(i,j)>=230)
img.at<uchar>(i,j)=255;
else
img.at<uchar>(i,j)=0;
}
imshow("图片浏览",img);
waitKey();
return 0;
}
thank you for you help!!!