"find number of 1s in a binary cv::mat image" Code Answer's
You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "find number of 1s in a binary cv::mat image" answered properly. Developers are finding an appropriate answer about find number of 1s in a binary cv::mat image related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like find number of 1s in a binary cv::mat image. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on find number of 1s in a binary cv::mat image.
find number of 1s in a binary cv::mat image
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <features2d.hpp>
using namespace cv;
using namespace std;
int main(int argc, char *argv[])
{
//load image
Mat img = imread("kayu.jpg", CV_LOAD_IMAGE_COLOR);
if(img.empty())
return -1;
//namedWindow( "kayu", CV_WINDOW_AUTOSIZE );
imshow("kayu", img);
//convert to b/w
Mat bw;
cvtColor(img, bw, CV_BGR2GRAY);
imshow("bw1", bw);
threshold(bw, bw, 40, 255, CV_THRESH_BINARY);
imshow("bw", bw);
//distance transform & normalisasi
Mat dist;
distanceTransform(bw, dist, CV_DIST_L2, 3);
normalize(dist, dist, 0, 2., NORM_MINMAX);
imshow("dist", dist);
//threshold to draw line
threshold(dist, dist, .5, 1., CV_THRESH_BINARY);
imshow("dist2", dist);
//dist = bw;
//dilasi
Mat dilation, erotion, element;
int dilation_type = MORPH_ELLIPSE;
int dilation_size = 17;
element = getStructuringElement(dilation_type, Size(2*dilation_size + 1, 2*dilation_size+1), Point(dilation_size, dilation_size ));
erode(dist, erotion, element);
int erotionCount = 0;
for(int i=0; i<erotionCount; i++){
erode(erotion, erotion, element);
}
imshow("erotion", erotion);
dilate(erotion, dilation, element);
imshow("dilation", dilation);
waitKey(0);
return 0;
}
Source: stackoverflow.com
All those coders who are working on the C++ based application and are stuck on find number of 1s in a binary cv::mat image can get a collection of related answers to their query. Programmers need to enter their query on find number of 1s in a binary cv::mat image related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about find number of 1s in a binary cv::mat image for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of find number of 1s in a binary cv::mat image while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "find number of 1s in a binary cv::mat image". Visit this developer's friendly online web community, CodeProZone, and get your queries like find number of 1s in a binary cv::mat image resolved professionally and stay updated to the latest C++ updates.