How to detect the edge of the photo
Mostrar comentarios más antiguos
I want to detect the photo edge and I turn the outside black color. However the thing is there are some dirty dots on the photo. So when I detect the edge, the dirty pot become the darkest and there is a line appear. I want to know how to remove it.
Below is my program can someone help me check what should I do. Thanks a lot.
I1=imread('C:\Users\Lenovo\Desktop\FYP_P055\Huijie1.jpg');
A=imread('C:\Users\Lenovo\Desktop\FYP_P055\Huijie1.jpg');
imtool(A);
hist(double(A));
I1(I1<40)=0;
A1=hist(double(I1));
hist(double(I1));
[row,col]=size(I1);
I11=I1(1:row/2,1:col/2);
I12=I1(1:row/2,col/2:end);
I21=I1(row/2+1:end,1:col/2);
I22=I1(row/2+1:end,col/2:end);
M11=min(I11,[],1);
M12=min(I12,[],1);
M21=min(I21,[],1);
M22=min(I22,[],1);
for c=1:col/2
for r=1:row/2
if I1(r,c)==M11(c)
min_val_col=c;
min_val_row=r;
for cc=1:min_val_row
I1(cc,min_val_col)=0;
end
end
end
for r=row/2+1:row
if I1(r,c)==M21(c)
min_val_col=c;
min_val_row=r;
for cc=min_val_row:row
I1(cc,min_val_col)=0;
end
end
end
end
for c2=round(col/2):col
c=c2-round(col/2)+1;
for r=1:row/2
if I1(r,c2)==M12(c)
min_val_col=c2;
min_val_row=r;
for cc=1:min_val_row
I1(cc,min_val_col)=0;
end
end
end
for r=row/2+1:row
if I1(r,c2)==M22(c)
min_val_col=c2;
min_val_row=r;
for cc=min_val_row:row
I1(cc,min_val_col)=0;
end
end
end
end
imtool(I1);


2 comentarios
Sivakumaran Chandrasekaran
el 18 de En. de 2016
check demos of image analyst in this website. you will get
Walter Roberson
el 18 de En. de 2016
imclearborder() ?
Respuesta aceptada
Más respuestas (1)
Thorsten
el 18 de En. de 2016
0 votos
You can use imfindcircles to detect the circle, and then set all points outside the circle to black. See http://stackoverflow.com/questions/29323640/circle-detection-via-hough-transform
Categorías
Más información sobre Region and Image Properties en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
