I want to get the bright area of my picture(opencv3 Blob Detection)
- I am using opencv3,
- and I want to "circle" the bright area of the picture I read by using
- Blob Detection
Be more specific, I want to "circle" the biggest red area.
- I checked this document
- But I really don't know how to write the code...
Thank you very much.
- this is my code
#include <opencv2\opencv.hpp> #include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat image = imread("reid.jpg");
namedWindow("img");
imshow("img", image);
Mat dstImage;
threshold(image, dstImage, 200, 255, 3);
Mat element = getStructuringElement(MORPH_RECT, Size(15, 15));
Mat out;
erode(dstImage, out, element);
Ptr<cv::SimpleBlobDetector> detector = cv::SimpleBlobDetector::create();
std::vector<KeyPoint> keyImg;
detector->detect(out, keyImg);
Mat result;
drawKeypoints(out, keyImg, result);
int i = 0;
for (vector<KeyPoint>::iterator k = keyImg.begin(); k != keyImg.end(); ++k, ++i)
circle(result, k->pt, (int)k->size, Scalar(0,0,0)[i % 65536]);
namedWindow("pic", WINDOW_AUTOSIZE);
imshow("pic", result);
waitKey(0);
}