I want to detect outer circle of iris in eye image.

11 次查看(过去 30 天)
how can we detect outer circle of iris. with my code, i can detect inner circle (blue), which is pupil effectively. but failed to detect outer circle (red) which is iris. sample image is attached. I am using a static value addition for outer circle radius.. which is 65 depending on some experimental data. I want to make it dynamic and automatic.
Any help will be highly appreciated.
Thank you
code:
files = dir(fullfile(folder_path, '*.bmp')); % Change the extension based on your image type
num_files = length(files);
% Read the input image
for i = 1:num_files
% Load the image
filename = fullfile(folder_path, files(i).name);
img = imread(filename);
% Convert the image to grayscale
gray = rgb2gray(img);
% Perform edge detection using Canny algorithm
edges = edge(gray,'canny');
[centers, radii, metric] = imfindcircles(edges,[10 200],'ObjectPolarity','dark');
% Select the circle with the maximum metric as the iris
[~, index] = max(metric);
iris_center = centers(index, :);
iris_radius = radii(index);
% Draw the detected iris on the original image
figure
imshow(img)
viscircles(iris_center, iris_radius+65, 'Color', 'r');
viscircles(iris_center, iris_radius, 'Color', 'b');
end
sample image

回答(1 个)

Sivsankar
Sivsankar 2023-6-7
To detect the outer circle of the iris automatically and dynamically, I feel that it can be done with these steps:
  1. Threshold the image: Convert the color image to grayscale and then apply a thresholding technique to separate the iris from the background and other structures like eyelashes, eyelids, etc.
  2. Detect the circles: Use the Hough circle transform to detect circles in the thresholded image. You can set the radius range to be between a minimum and maximum value. These values can be determined based on the size of the pupil, iris, and sclera in the image.
  3. Filter the circles: After detecting the circles, filter out the ones that are not part of the iris by checking their proximity to the previously detected pupil. You can also filter out very small or very large circles that are likely not part of the iris.
  4. Select the largest circle: Once you are left with the potential iris circles, select the one with the largest radius as the outer circle of the iris.
% Load the image and convert it to grayscale
img = imread('iris_image.jpg');
gray = rgb2gray(img);
% Apply thresholding to separate the iris from background
threshold = adaptthresh(gray);
bw = imbinarize(gray, threshold);
% Set the range of circle radii to search for
radii_range = [iris_radius+50 iris_radius+150];
% Use the Hough circle transform to detect circles
[centers, radii, ~] = imfindcircles(bw, radii_range, 'ObjectPolarity', 'dark', 'Sensitivity', 0.9);
% Filter out circles not part of the iris
dists = pdist2(centers, iris_center);
valid_circles = radii > (iris_radius + 40) & radii < (iris_radius + 160) & dists(:,2) < (iris_radius + 120);
iris_circles = [centers(valid_circles,: ) radii(valid_circles)];
% Select the largest iris circle
[~, index] = max(iris_circles(:,3));
iris_center_outer = iris_circles(index, 1:2);
iris_radius_outer = iris_circles(index, 3);
% Draw the detected iris on the original image
figure;
imshow(img);
viscircles(iris_center_outer, iris_radius_outer, 'Color', 'r');
viscircles(iris_center, iris_radius, 'Color', 'b');
This is the implementation of the above steps. In this code, I set the range of radii to search for as [iris_radius+50 iris_radius+150] to ensure that we only detect circles that are likely to be part of the iris. I think that this should be able to differentiate. Thanks!

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by