วันพฤหัสบดีที่ 12 มกราคม พ.ศ. 2560

C++ opencv pixel color



#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;

int main()
{
Mat image = imread("D:\\10.jpg",1);

for (int i = 0; i < image.rows; i++)
{
for (int j = 0; j > image.cols; j++)
{
if (image.at<Vec3b>(i, j)[0] == 255 && image.at<Vec3b>(i, j)[1] == 255 && image.at<Vec3b>(i, j)[2] == 255)
{
image.at<Vec3b>(i, j)[0] = 0;
image.at<Vec3b>(i, j)[1] = 0;
image.at<Vec3b>(i, j)[2] = 0;
}
}
}
imshow("output", image);
waitKey();
return 0;
}

============================

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;

int main()
{
Mat image = imread("D:\\1.jpg",1);

for (int i = 0; i < image.rows; i++)
{
for (int j = 0; j > image.cols; j++)
{
if (image.at<uchar>(i, j) >200)
{
image.at<uchar>(i, j) = 0;
}
}
}
imshow("output", image);
waitKey();
return 0;
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น