Edge Error

by

 

Usando detectores de borde como: canny, sobel... etc

edgeerrorthres.m
function [Mag_err]= edgeerrorthres(sourceimg, distimg)

%Imagen fuente
Xf=imread(sourceimg);
Yf=abs(rgb2gray(Xf));

[r c] =size(Yf);

%Bordes de la imagen fuente
[Edf,thresval] = edge(Yf,'sobel');
[Gradxf,Gradyf] = gradient(double(Yf));
x=find(Edf);

%Imagen distorsionada
Xd=imread(distimg);
Yd=abs(rgb2gray(Xd));

[n m] = size(Yd);


%Bordes de la imagen distorcionada
%  BW = edge(Yd,'sobel',0);
 
 

    
Edd = edge(Yd,'sobel',thresval);
[Gradxd,Gradyd] = gradient(double(Yd));
l=find(Edd);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Mag_err= sum(Edf(x)-Edd(l)) ;
Grad_errx = sum(Gradxf(x)-Gradxd(x))
Grad_erry = sum(Gradyf(x)-Gradyd(x));
E_err = Mag_err/sqrt(Grad_errx^(2)+Grad_erry^(2));



% E_err=0;
% 
% 
%         for r=1:n
%             for c=1:m
%                 
%                 E_err=E_err+((Edf(r,c)-Edd(r,c)).^(2));
%            
%             end
%         end
% %        Edge_err=mean(E_err);
% end
 
%  ECM=((double(BWf)-double(BW)).^2);
%  mse = sum(sum(ECM)) / (rows * columns);


%Clculo de bordes imagen distorcionada

   
% for (s = 0.04: -0.01: 0.01)
%     n=n+1
%     for n=n:6 
%    
%         BW = edge(Yd,'sobel',s);
%         %figure,imshow(BW)
%         subplot(2,2,n), imshow(BW)
%         break
%     end
% end

% subplot(1,2,1),imshow(BW)
% subplot(1,2,2),imshow(BWf)

Contact us