IMDILATE - similar kind of loop need to be generated - HELP required
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to make a loop that should work Similar to IMDILATE - a step before it gives the result for each pixel. If you look into the sample code below, you could understand more clear way
a = [1 2 3 ; 4 5 6 ; 7 8 9 ] % input
b = ones(3,3) % say it to be struct element
nw = b;
for i = 1:3;
for j = 1:3;
if (i == 1 && j ==1)
for m = 1:2;
for n = 1:2;
nw (m+1,n+1) = a(m,n);
end
end
elseif (i == 1 && j == 2)
nw = b;
for m = 1:2;
for n = 1:3;
nw (m+1,n)= a(m,n);
end
end
elseif (i == 1 && j ==3)
nw =b;
for m = 1:2;
for n = 1:2;
nw (m+1,n) = a(m,n+1);
end
end
else
break;
end
display(nw);
end
end
Now variable nw displayed for the first row elements 1 2 3 .. in similar way I need your help to make it for 2 and 3 row too and also in a more generic way ... say my input and strel may vary on rows n columns (not fixed to (3,3))
Thanks in advance
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!