Clear Filters
Clear Filters

I am applying region growing on edge detected image,but not getting output,Is the code right

1 view (last 30 days)
function[g]=hueedge(f)
hsv=rgb2hsv(f);
H=hsv(:,:,1);
sh=fspecial('sobel');
sv=sh;
Gx=conv2(double(H(:,:,1)),sh);
Gy=conv2(double(H(:,:,1)),sv);
Gxy=sqrt(Gx.^2+Gy.^2);
w=[1,1,1;1,-8,1;1,1,1];
Gxy2=conv2(double(H),w);
g=Gxy-Gxy2;
%s=histeq(h);
%markerImage =imsubtract(s,2);
%g = imreconstruct(markerImage,h);
%w=ones(1);
%g=imsubtract(s,w);
This is my code edge detection on hsv image,now i have done REGION GROWING on this edge detected image, BUT NOT GETTING THE OUTPUT
here is the code for Region Growing on edge detected image
function pg=regiong(hsv)
h=hsv(:,:,1);
s=hsv(:,:,2);
v=hsv(:,:,3);
for i=1:size(hsv)
for j=1:size(hsv)
dh=h(x+i,y+j,1)-h(x,y,1).^2;
ds=s(x+i,y+j,1)-h(x,y,2).^2;
dv=v(x+i,y+j,1)-h(x,y,3).^2;
end
end
dist=sqrt(dh+ds+dv);
r=size(hsv);
c=size(hsv);
seed=[r./2,c./2];
rcount=1;
i=1;
j=1;
pg(i)=seed;
cases=input('choice');
switch cases
case 1
while pg(i)~=0
cp=pg(i);
i=i-1;
for k=1:8
if cp(k)~=0
dist=dist(seed,cp(k));
if(dist<thr)
cp(k)=rcount;
i=i+1;
pg(i)=cp(k);
else
j=j+1;
bp(j)=cp(k);
end
end
end
end
case 2
while bp~=0
seed=bp(j);
j=j-1;
rcount=rcount+1;
i=1;
pg(i)=seed;
end
case 1;
end
Is this code right, am I doing some mistake ,please give some specific answer with explaination

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!