我正在尝试使用 OpenCV,更具体地说是它的 HoughCircles 来检测和测量瞳孔和虹膜,目前我一直在使用函数中的一些变量,因为它要么返回 0 个圆圈,要么返回过多的圆圈。下面是我正在使用的代码和测试图像。
测量虹膜的代码:
eye1 = [self increaseIn:eye1 Contrast:2 andBrightness:0];
cv::cvtColor(eye1, eye1, CV_RGBA2RGB);
cv::bilateralFilter(eye1, eye2, 75, 100, 100);
cv::vector<cv::Vec3f> circles;
cv::cvtColor(eye2, eye1, CV_RGBA2GRAY);
cv::morphologyEx(eye1, eye1, 4, cv::getStructuringElement(cv::MORPH_RECT,cv::Size(3, 3)));
cv::threshold(eye1, eye1, 0, 255, cv::THRESH_OTSU);
eye1 = [self circleCutOut:eye1 Size:50];
cv::GaussianBlur(eye1, eye1, cv::Size(7, 7), 0);
cv::HoughCircles(eye1, circles, CV_HOUGH_GRADIENT, 2, eye1.rows/4);
测量瞳孔代码:
eye1 = [self increaseBlackPupil:eye1];
cv::Mat eye2 = cv::Mat::zeros(eye1.rows, eye1.cols, CV_8UC3);
eye1 = [self increaseIn:eye1 Contrast:2 andBrightness:0];
cv::cvtColor(eye1, eye1, CV_RGBA2RGB);
cv::bilateralFilter(eye1, eye2, 75, 100, 100);
cv::threshold(eye2, eye1, 25, 255, CV_THRESH_BINARY);
cv::SimpleBlobDetector::Params params;
params.minDistBetweenBlobs = 75.0f;
params.filterByInertia = false;
params.filterByConvexity = false;
params.filterByCircularity = false;
params.filterByArea = true;
params.minArea = 50;
params.maxArea = 500;
cv::Ptr<cv::FeatureDetector> blob_detector = new cv::SimpleBlobDetector(params);
blob_detector->create("SimpleBlob");
cv::vector<cv::KeyPoint> keypoints;
blob_detector->detect(eye1, keypoints);
我知道图像很粗糙,我也一直在尝试找到一种方法来清理它并使边缘更清晰。
所以我的问题说清楚了:我可以做些什么来调整函数 HoughCircles 中的参数或更改图像以检测到虹膜和瞳孔?
谢谢