Date: Apr 7, 2013 3:55 AM
Author: Bruno Luong
Subject: Re: i want to simplify this code

Using convolution:

m = size(I,1);
P = 2.^(1:5);
a = [100 200 255 150 50];
for k = 1:length(P)
p = P(k);
b = conv2(double(S==p),ones(p)) > 0;
if size(b,1) < m
b(m,end) = false;
end
I(b) = a(k);
end

% Bruno