I am finding the edge based on the triangle similarity In this it is assume that along with the change of the triangular shape, color is changing, the essential of triangular shape change is the value of h, s and v changed, it is the root cause of color changes.
The sides of triangle ABC
respectively is AB=h, AC=s, BC=v,
perimeter is L=h+s+v.
θ1=acos(( s^2 − h^2 − v^2)/2*h*v )θ2 =acos(( h^2 − s^2 − v^2)/2*s*v)θ3=acos(( v^2 − h^2 − s^2)/2*h*s)
So each pixel in the image will be plus one in edge detection processing in order to ensure that each pixel can construct triangle according to its r, g and b component, it will not make any effect to final detection results.
I=Lθ , r, g and b is the coordinate of that pointin HSV space.
Is this code right for this algorithm as I am getting right
Algorithm is given here
a) Each pixel value in the image will plus one;
b) Building corresponding triangle of all pixels and calculating triangular perimeter and three angles;
c) For each pixel, Sobel operator in four directions template and neighborhood pixel convolution, and calculate angle and perimeter difference;
d) Compared triangle perimeter corresponding with neighborhood to original triangle perimeter, if the difference is more big, so make the value of pixel is one, otherwise turn to e;
e) If the difference of triangle perimeter is not big, but the difference of corresponding angle is large, so make the value of pixel is one, otherwise turn to f;
f) If the difference of triangle perimeter and angle are both not very big, but they keep poor in threshold requirement range, so make the value of pixel is one, otherwise make it is zero to detect the image edges.
Because I=L calculate is larger, the actual implementation process is separately apply L and , if L is larger, then use L as the criterion of whether pixel is edge points; otherwise use .
function[e]=tedge(hsv)h=hsv(:,:,1);s=hsv(:,:,2);v=hsv(:,:,3); for i=1:183 for j=1:276 h(i,j)=h(i,j)+1; s(i,j)=s(i,j)+1; v(i,j)=v(i,j)+1; end endL=h+s+v;a1=acos((s.^2.-h.^2.-v.^2)./2.*h.*v);a2=acos((h.^2.-s.^2.-v.^2)./2.*s.*v);a3=acos((v.^2.-h.^2.-s.^2)./2.*h.*s);a=a1+a2+a3;I=L.*a;Th=0.4;w0=[-1,-2,-1;0,0,0;1,2,1];w90=[-1,0,1;-2,0,2;-1,0,1];w45=[-2,-1,0;-1,0,1;0,1,2];w135=[0,-1,-2;1,0,-1;2,1,0];for i=1:3g0=imfilter(a,w0(i));g90=imfilter(a,w90(i));g45=imfilter(a,w45(i));g135=imfilter(a,w135(i));endif L>=Ifor i=1:size(L,1) for j=1:size(L,2)L(1)=L(i-1,j+1)+2*L(i,j+1)+L(i+1,j+1)-L(i-1,j-1)-2*L(i,j-1)-L(i+1,i-1);L(2)=L(i+1,j-1)+2*L(i+1,j)+L(i+1,j+1)-L(i-1,j-1)-2*L(i-1,y)-L(i-1,j+1);L(3)=L(i,j+1)+2*L(i+1,j+1)+L(i+1,j)-L(i-1,j)-2*L(i-1,j-1)-L(i,j-1);L(4)=L(i,j+1)+2*L(i-1,j+1)+L(i-1,j)-L(i+1,j)-2*L(i+1,j)-L(i,j-1); endend if L(1)>Th e=L(1); else if L(2)>Th e=L(2); else if L(3)>Th e=L(3); else if L(4)>Th e=L(4); end end endendend x0=abs(g0); y90=abs(g90); x45=abs(g45); y135=abs(g135);for i=1:4 Ga1=sum(x0(i));endfor i=1:4 Ga2=sum(y90(i));endfor i=1:4 Ga3=sum(x45(i));endfor i=1:4 Ga4=sum(y135(i));endif a>=Iif Ga1>Th e=Ga1; else if Ga2>Th e=Ga2; else if Ga3>Th e=Ga3; else if Ga4>Th e=Ga4; end end end endend
Error
??? Output argument "e" (and maybe others) not assigned during call to"C:\Users\Poonam\Desktop\MATLAB\R2008a\tedge.m (tedge)".
Have i done something wrong in the code
Best Answer