hi, im currently doing a iris recognition. im now in a segmentation process. ive already detect the the pupil region but how can i remove the background and leave only the pupil region?

댓글 수: 1

AKHILA P
AKHILA P 2018년 9월 2일
how you do the pupil region detection? please help me i am also doing iris recognition

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2018년 1월 8일

1 개 추천

This code shall work for you. When prompted/ figure opens, you need two click twice.
1. First click, click at the center of the circle, where you want to draw a circle.
2. Second click, click at any point which is at a distance of radius of circle you wanted to draw.
I = imread('Capture111.jpg');
[nx,ny,d] = size(I) ;
[X,Y] = meshgrid(1:ny,1:nx) ;
imshow(I) ;
hold on
[px,py] = getpts ; % click at the center and approximate Radius
r = sqrt(diff(px).^2+diff(py).^2) ;
th = linspace(0,2*pi) ;
xc = px(1)+r*cos(th) ;
yc = py(1)+r*sin(th) ;
plot(xc,yc,'r') ;
% Keep only points lying inside circle
idx = inpolygon(X(:),Y(:),xc',yc) ;
for i = 1:d
I1 = I(:,:,i) ;
I1(~idx) = 255 ;
I(:,:,i) = I1 ;
end
figure
imshow(I)
I am attaching the result, I got on running the above code:

댓글 수: 4

KSSV
KSSV 2018년 1월 8일
Then how do you think, I got the attached image?
Matthew Burges
Matthew Burges 2018년 1월 9일
how to do this without selecting the center and radius, meaning matlab should do this step on its own.
Sruthi Radhakrishnan
Sruthi Radhakrishnan 2018년 6월 29일
Thank you for the code, But how to eliminate the white background in the image ?
If I multiple circle I want to extract, and have a variable with the values of the centers and radii, how can I make a loop to extract all the circles?
for i_1 = 1:size(centers)
px = centers(i_1,1);
py = centers(i_1,2);
r = radii(i_1) ;
th = linspace(0,2*pi) ;
xc = px(i_1)+r(i_1)*cos(th) ;
yc = py(i_1)+r(i_1)*sin(th) ;
%plot(xc,yc,'r') ;
% Keep only points lying inside circle
idx = inpolygon(X(:),Y(:),xc',yc) ;
for j = 1:d
I1 = f_gray(:,:,j) ;
I1(~idx) = 255 ;
I(:,:,j) = I1 ;
end
end
I get this error: "Index exceeds the number of array elements (1)."

댓글을 달려면 로그인하십시오.

질문:

2016년 3월 1일

댓글:

2019년 12월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by