Implementation of the Roberts operator in edge function
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alejandro Fernández
el 31 de Mayo de 2020
Editada: Alejandro Fernández
el 31 de Mayo de 2020
Hello, using the open edge command, and looking for the area in which Roberts would be implemented I have a series of questions to see if anyone knows why it is done this way.
elseif strcmp(method, 'roberts')
x_mask = [1 0; 0 -1]/2; % Roberts approximation to diagonal derivative
y_mask = [0 1;-1 0]/2;
scale = 6;
offset = [-1 1 1 -1];
% compute the gradient in x and y direction
bx = imfilter(a,x_mask,'replicate');
by = imfilter(a,y_mask,'replicate');
% compute the magnitude
b = kx*bx.*bx + ky*by.*by;
The first question is because it uses as filters in x and in y those that appear in all the manuals, as for example in [1] but divided by 2.
The second is why it uses the imfilter function with replicate instead of using conv
And finally, the third one is why this method computes the magnitude of the gradient using this expression insted of using this one:
Thank you for all.
For me, the correct edge function should be something like:
function [BW,G45,G135] = Roberts(I,T)
I = im2single(I);
% Roberts approximation to diagonal derivative
x_mask = [1 0; 0 -1];
y_mask = [0 1;-1 0];
% compute the gradient in x and y direction
G45 = imfilter(I,x_mask,'conv');
G135 = imfilter(I,y_mask,'conv');
% compute the magnitude
M = sqrt(G45.^2+G135.^2);
% Create BW image
BW = false(size(I));
BW(M(:)>T) = 1;
0 comentarios
Respuestas (1)
Image Analyst
el 31 de Mayo de 2020
What is the "open edge command"?
The first question is not even a question. Dividing by 2 merely changes the range from -255 to +255 to -128 to +127.
For the second question, you can use conv2() or imfilter(). I believe imfilter() does not flip the kernel like conv2() does.
For the third question, it was the programmers choice how to pick the angles of the edge. If there are lots of horizontal and vertical angles, you could get more signal with the standard kernel rather than the diagonal ones. If there are more angles at 45 and 135 then you'd get a stronger signal using the angled kernel. It's not like one if always better and one is always worse or wrong. You're free to do whatever gives you the best signal in your particular case.
1 comentario
Alejandro Fernández
el 31 de Mayo de 2020
Editada: Alejandro Fernández
el 31 de Mayo de 2020
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!