%�Canny edge detection,�
clc;
close all;
clear all;
img_name = input('Enter the image name :','s');
ima = imread(img_name);
ima=imread('boat.tif','tif');
ima=double(ima);
pima=mean(mean(ima.^2));
figure(1),clf;
imshow(ima,[0 255]);
n=length(ima);
v=10;
noi=v*randn(n,n);
iman=ima+noi;%%add noise to image
n=size(ima);
M=n(1);
N=n(2);
fprintf('\n Befor Edge Detection');
MSE = sum(sum((ima).^2))/(M*N);
PSNR = 10*log10(256*256/MSE);
fprintf('\nMSE: %7.2f ', MSE);
fprintf('\nPSNR: %9.7f \n', PSNR);
figure(2),clf;
imshow(iman,[0 255]);
sca=3;
th=getth2d(sca-1);th=th(sca-1);
[wr,wc,s,m]=wt2d(iman,sca);
[w1r,w2r,w1c,w2c,corr,corc]=compcorsca2d(wr,wc,m);
%%%%%%%%%%%%%%%%%%%%%%%
maskr=(corr>0);
maskc=(corc>0);
corr=corr.*maskr;
corc=corc.*maskc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%
k=2;
for con=16:2:26
[Mod,Ang]=compMA(w2r,w2c,corr,corc,th,v,con);%%get the edge map in different threshold
edmap=nmsupress2d(Mod,Ang);
k=k+1;figure(k);clf
imshow(edmap);
end
fprintf('\nAfter Edge Detection');
n=size(edmap);
M=n(1);
N=n(2);
MSE = sum(sum((edmap).^2))/(M*N);
PSNR = 10*log10(256*256/MSE);
fprintf('\nMSE: %7.2f ', MSE);
fprintf('\nPSNR: %9.7f \n', PSNR);