a=1;
b=80;
c=a;
d =b;
nr = b;
nc =b;
A0= ImageData[ColorConvert[Import["/Users/felix/fie_mac/Investigacion/BilateralFilter/Lena_origen_5.png"], "Grayscale"]];
A = A0[[a;;b,c;;d]];
B = A;
nk = 3;
For[i=1, i<=nr, i++,
For[j=1, j<=nc, j++,{
suma = 0;
For[k=i-nk, k≤i+nk, k++,
For[l=j-nk, l≤j+nk, l++,
 If[k>0 && k <nr && l >0 && l <nc, suma += A[[k,l]] ]
]
]
B[[i,j]]= suma;
}

];
]


{Image[A], Image[(B-Min[B])/(Max[B]-Min[B])]}

For[i=0, i<10, i++,
If[i >3 && i<5, Print[i] ]
]