SetDirectory[NotebookDirectory[]]
tmp1=ReadList["memb.pgm",Number];
tmp2=Partition[tmp1,100];
obr=tmp2/255.0;

gOriginal=ArrayPlot[obr,ColorFunction->GrayLevel,ColorFunctionScaling->False]

G[x_,y_,σ_]:=(1/((4π*σ)))*(E^(-((x^2+y^2)/(4σ))))

xxx=Integrate[G[x,y,σ],{x,-3h/2,3h/2},{y,-3h/2,3h/2}]/.σ->0.1//N

h=1;
wP=Integrate[G[x,y,σ1],{x,-h/2,h/2},{y,-h/2,h/2}]
wQ=Integrate[G[x,y,σ1],{x,h/2,3h/2},{y,-h/2,h/2}]
wR=Integrate[G[x,y,σ1],{x,h/2,3h/2},{y,h/2,3h/2}]

linDifGauss[array_]:=Module[
{vystup=Table[0,{i,1,Length[array]+2},{j,1,2+Length[array[[1]]]}],n1,n2},

n1=Length[array];
n2=Length[array[[1]]];

For[i=1,i<n1,i++,
{
For[j=1,j<n2,j++,
{
vystup[[i+1,j+1]]=array[[i,j]] ;

}];}];

n1=Length[vystup];
n2=Length[vystup[[1]]];

For[i=1,i<n1,i++,
{
For[j=1,j<n2,j++,
{
If[(i==1)&&(j!=1)&&(j≠n2),vystup[[i,j]]= vystup[[i+1,j]]];
If[(i==n1-1)&&(j!=1)&&(j≠n2),vystup[[i,j]]= vystup[[i-1,j]]];

If[(j==1)&&(i!=1)&&(i≠n1),vystup[[i,j]]= vystup[[i,j+1]]];
If[(j==n2-1)&&(i!=1)&&(i≠n1),vystup[[i,j]]= vystup[[i,j-1]]];


}];}];


Return[vystup]
]

ArrayPlot[linDifGauss[tmp2]]
ArrayPlot[tmp2]