How to apply Median filter to a image for fixed number of times using for loop

Hello all,
Simply I want to rewrite below code using for loop.
B = medfilt2( A );
C = medfilt2( B );
D = medfilt2( C );
E = medfilt2( D );
F = medfilt2( E );
Can't figure out how to store image in array or something to call inside for loop.
Thanks

 Accepted Answer

result{1} = A;
for K = 2 : 6
result{K} = medfilt(result{K-1});
end

2 Comments

It works.Is results array or matrix? can I store any thing on it?
Thank You for answer

Sign in to comment.

More Answers (1)

For other readers this is rewrite code using help of Walter Roberson
I = imread('Penguins.jpg');
J = rgb2gray(I);
result{1} = J;
for K = 2 : 6
result{K} = medfilt2(result{K-1});
end
imshow(result{5});

Tags

Community Treasure Hunt

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

Start Hunting!