1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main()
{ int i=0,j,nbr=0,nbr1=0;
Mat image=imread("2_.png",CV_LOAD_IMAGE_GRAYSCALE);
Mat image2=imread("2_.png",CV_LOAD_IMAGE_GRAYSCALE);
for(i=0;i<image.rows;i++)
{
for( j=0;j<image.cols;j++)
{if (image.at<int>(i,j)!=0)
nbr++;
if (image2.at<int>(i,j)!=0)
nbr1++;
}
}
printf("%d\n %d\n",nbr,nbr1);
return 0;
} |
Partager