Excuse me, i wanna scan white pixel in this image and make border around whole contour that has white color . But I dont know how to code it. This is the result. :( I'm so confuse . C:\fakepath\1.JPG C:\fakepath\2.JPG
Mat grayi; //To store the thresholded image Mat ret; //convert the image to grayscale cvtColor(intpro,grayi,CV_BGR2GRAY); imshow("Gray Image",grayi); //threshold the image threshold(grayi,ret,0,255,CV_THRESH_OTSU); imshow("Thres",ret);
Mat grayi;
//To store the thresholded image
Mat ret;
//convert the image to grayscale
cvtColor(intpro,grayi,CV_BGR2GRAY);
imshow("Gray Image",grayi);
//threshold the image
threshold(grayi,ret,0,255,CV_THRESH_OTSU);
imshow("Thres",ret);Mat horizontal(ret.cols,2,CV_32S);//horizontal histogram
horizontal = Scalar::all(255);
Mat vertical(ret.rows,1,CV_32S);//vertical histogram
vertical = Scalar::all(255);
for(int i=0;i<ret.cols;i++)
{
int hor= horizontal.at<int>(i,0)=countNonZero(ret(Rect(i,0,1,ret.rows)));
cout<< hor;
rectangle(ret, Rect(0, i, hor, 1), Scalar(255,255,255), 2);
}
for(int i=0;i<ret.rows;i++)
{
int ver = vertical.at<int>(i,0)= countNonZero(ret(Rect(0,i,ret.cols,1)));
cout<< ver;
//= countNonZero(ret(Rect(0,i,ret.cols,1)));
rectangle(ret, Rect(0, i, ver, 1), Scalar(255,255,255), 2);
}
imshow("cc",ret);
} please anyone help me :(. Thank you