Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

about use Mat to make binary image


I want make a binary image . the code flowling:

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&lt;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;

}

click to hide/show revision 2
No.2 Revision

updated 2013-10-23 02:37:24 -0600

berak gravatar image

about use Mat to make binary image


I want make a binary image . the code flowling:is the following:

include<opencv\cv.h>

include<stdlib.h>

include<opencv2\opencv.hpp>

include<opencv\highgui.h>

#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&lt;img.cols;++j)" {="" if(img.at<uchar="">(i,j)>=230)
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;
}

}