I would like to compute gradient of image I. I have two options that are
[Gx, Gy] = gradient(I);
g = sqrt(Gx.^2+Gy.^2);
and
[g,~] = imgradient(I, 'sobel');
My question are
What is gradient method using in first option?
What is befinet of finding gradient using sobel method ?
Thank all
This is what I tried
I=zeros([128 128]);
I(50:100,50:100)=100;
[Gx, Gy] = gradient(I);
g1 = sqrt(Gx.^2+Gy.^2);
[g2,~] = imgradient(I, 'sobel');
subplot(121);imshow(g1,[]);title('First option')
subplot(122);imshow(g2,[]);title('Second option')
When noisy is added to image, the different will be more clear
I=zeros([128 128]);
I(50:100,50:100)=100;
%% Add noise image;
noiseStd=5;
I_noise = I + (noiseStd * randn([128, 128]));
[Gx, Gy] = gradient(I_noise);
g1 = sqrt(Gx.^2+Gy.^2);
[g2,~] = imgradient(I_noise, 'sobel');
subplot(121);imshow(g1,[]);title('First option')
subplot(122);imshow(g2,[]);title('Second option')
As visualization, the second option provided more brightness value

