【发布时间】:2021-07-12 06:43:05
【问题描述】:
所以我正在为我的论文工作,我必须使用霍夫变换从图像中检测瞳孔。到目前为止,我编写了一个代码来识别图像上的 2 个圆圈,但现在我必须让黑色圆圈远离瞳孔。
当我运行代码时,它会识别出我的瞳孔,还会在脸颊上随机出现一个圆圈。我的教授说我应该计算像素平均值,并且考虑到瞳孔是黑色的事实,只保留该区域的像素。我不知道该怎么做。
我会让我的代码在这里看看,如果有人知道我应该如何写这个并且只保留黑色像素会很棒。我还附上了最终图片,看看我得到了什么。
全部关闭 清除所有 path='C:\Users\Ioana PMEC\OneDrive\Ioana personal\Disertatie\test.jpg';
%Citire imagine initiala
xx = imread(path);
figure
imshow(xx)
title('Imagine initiala');% Binarizarea imaginii initiale
yy = rgb2gray(xx);
figure
imshow(yy);
title('Imagine binarizata');
e = edge(yy, 'canny');
imshow(e);
radii = 11:1:30;
h = circle_hough(e, radii, 'same', 'normalise');
peaks = circle_houghpeaks(h, radii, 'nhoodxy', 15, 'nhoodr', 21, 'npeaks', 2);
imshow(yy);
hold on;
for peak = peaks
[x, y]=circlepoints(peak(3));
plot(x+peak(1), y+peak(2), 'r-');
end
hold off
测试图像 最终图像
【问题讨论】:
标签: matlab geometry hough-transform