from Spot Border Detection by Eduard Polityko
Spot on image ? get border as numeric array and a number of measurements of a spot and a border

cleanf1.m
%script cleanf1
if (~I(i,j))&(~I(i,j-1))...
    &I(i,j+1)&I(i-1,j)...
    &I(i-1,j+1)&(~I(i+1,j))...
    &I(i+1,j-1)&I(i+1,j+1)    
  I(i,j)=1;
end

Contact us at files@mathworks.com