Azzera filtri
Azzera filtri

Have I done something wrong with this code for edge detection on extreme gradient value

1 visualizzazione (ultimi 30 giorni)
I have first translated from RGB to HSV and separated to hue and saturation and intensity component h(i,j),s(i,j),v(i,j)
5*5 boundary detection operator window with original image f(i,j) and the central pixel of the window (i,j) is the boundary pixel to be detected,(x,y) is one of the eight neighborhood pixels of the central pixel
the central pixel's hue saturation and brightness in the direction of theta(0 to 315 with 45 degree spacing each) are defined as:
hθ(i, j)= h(x, y)-h(i, j)
sθ(i, j)= s(x, y-s (i, j)
vθ(i, j)=v(x, y)-v(i, j)
w=[1,1,1,1,1;1,1,1,1,1;1,1,-24,1,1;1,1,1,1,1;1,1,1,1,1];
gradient is
gθ(i, j)= hθ(x, y)+ sθ(i, j)+ vθ(x, y);
code
function g=exgradient(hsv)
hsv=rgb2hsv(rgb);
h=hsv(:,:,1);
s=hsv(:,:,2);
v=hsv(:,:,3);
theta=1:45:315
w=[1,1,1,1,1;1,1,1,1,1;1,1,-24,1,1;1,1,1,1,1;1,1,1,1,1];
for i=1:183
for j=1:276
h(theta)*(i,j)=h(x,y)-h(i,j);
s(theta)*(i,j)=s(x,y)-s(i,j);
v(theta)*(i,j)=v(x,y)-v(i.j);
end
end

Risposta accettata

Image Analyst
Image Analyst il 13 Feb 2013
Looks like 3x3 to me, not 5x5. Just have your kernel be
kernel = [-1 -1 -1;-1 8 -1;-1 -1 -1] / 9; % Average pixel difference.
edgeImage = conv2(double(grayImage), kernel, 'same'); % the filter.
  1 Commento
Poonam
Poonam il 21 Feb 2013
Thanks,I have edited and have posted some code related to the question please help me out whether i am correct with my code

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by